var cloneUserObj;
var stageUser;
var optInSettings;
+var allCardsTemplate;
if(!window.xulG) var xulG = null;
loadSurveys();
checkClaimsReturnCountPerm();
checkClaimsNoCheckoutCountPerm();
+
+ dojo.connect(replaceBarcode, 'onClick', replaceCardHandler);
+ dojo.connect(allCards, 'onClick', drawAllCards);
+ if(patron.cards().length > 1)
+ dojo.removeClass(dojo.byId('uedit-all-barcodes'), 'hidden');
+}
+
+
+function drawAllCards() {
+
+ var tbody = dojo.byId('uedit-all-cards-tbody');
+ if(!allCardsTemplate) {
+ allCardsTemplate = tbody.removeChild(dojo.byId('uedit-all-cards-tr-template'));
+ } else {
+ while(tbody.childNodes[0])
+ tbody.removeChild(tbody.childNodes[0]);
+ }
+
+ var first = true;
+ dojo.forEach(
+ [patron.card()].concat(patron.cards()), // grab the main card first
+ function(card) {
+ if(!first) {
+ if(card.id() == patron.card().id())
+ return;
+ }
+ var row = allCardsTemplate.cloneNode(true);
+ getByName(row, 'barcode').innerHTML = card.barcode();
+ getByName(row, 'active').appendChild(
+ openils.Util.isTrue(card.active()) ?
+ dojo.byId('true').cloneNode(true) :
+ dojo.byId('false').cloneNode(true)
+ );
+
+ tbody.appendChild(row);
+ first = false;
+ }
+ );
+
+ allCardsDialog.show();
+}
+
+/**
+ * Mark the current card inactive, create a new primary card
+ */
+function replaceCardHandler() {
+ var input = findWidget('ac', 'barcode');
+ input.widget.attr('value', null);
+
+ // pull old car off the cards list so we don't have a dupe sitting in there
+ var old = patron.cards().filter(function(c){return (c.id() == patron.card().id())})[0];
+ old.active('f');
+ old.ischanged(1);
+
+ var newc = new fieldmapper.ac();
+ newc.id(uEditCardVirtId--);
+ newc.isnew(1);
+ newc.active('t');
+ patron.card(newc);
+ patron.cards().push(newc);
}
patron.isnew(1);
patron.id(-1);
card = new ac();
- card.id(uEditCardVirtId);
+ card.id(uEditCardVirtId--);
card.isnew(1);
patron.active(1);
patron.card(card);
<div><a href='javascript:void(0);' id='uedit-dupe-address-link'></a></div>
</div>
+<div class='hidden'>
+ <span id='true' style='color:green;'>✓</span>
+ <span id='false' style='color:red;'>✗</span>
+ <div dojoType='dijit.Dialog' jsId='allCardsDialog'>
+ <table class='oils-generic-table' style='margin:10px;'>
+ <thead>
+ <tr>
+ <th>Barcode</th>
+ <th>Active</th>
+ </tr>
+ </thead>
+ <tbody id='uedit-all-cards-tbody'>
+ <tr id='uedit-all-cards-tr-template'>
+ <td><div name='barcode'></div></td>
+ <td><div name='active'></div></td>
+ </tr>
+ </tbody>
+ <tbody>
+ <tr>
+ <td colspan='2' style='text-align:center;'>
+ <button dojoType='dijit.form.Button' onClick='allCardsDialog.hide()'>Close</button>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</div>
+
+
[% END %]
<tbody id='uedit-tbody'>
- <tr fmclass='ac' fmfield='barcode' required='required'/>
+ <tr fmclass='ac' fmfield='barcode' required='required'>
+ <td/><td/><td/>
+ <td><button dojoType='dijit.form.Button' jsId='replaceBarcode'>Replace Barcode</button></td>
+ <td id='uedit-all-barcodes' class='hidden'>
+ <button dojoType='dijit.form.Button' jsId='allCards'>See All</button>
+ </td>
+ </tr>
<tr fmclass='au' fmfield='usrname' required='required'/>
<tr fmclass='au' fmfield='passwd' required='required'/>
<tr fmclass='au' fmfield='passwd2' required='required'><td/><td>Verify Password</td><td/></tr>