added Replace Barcode option into new patron reg. interface. Also added a basic...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 27 May 2010 13:18:45 +0000 (13:18 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 27 May 2010 13:18:45 +0000 (13:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16516 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/actor/user/register.js
Open-ILS/web/templates/default/actor/user/register.tt2
Open-ILS/web/templates/default/actor/user/register_table.tt2

index 63428da..0ce7dec 100644 (file)
@@ -42,6 +42,7 @@ var cloneUser;
 var cloneUserObj;
 var stageUser;
 var optInSettings;
+var allCardsTemplate;
 
 
 if(!window.xulG) var xulG = null;
@@ -123,6 +124,66 @@ function load() {
     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);
 }
 
 
@@ -797,7 +858,7 @@ function uEditNewPatron() {
     patron.isnew(1);
     patron.id(-1);
     card = new ac();
-    card.id(uEditCardVirtId);
+    card.id(uEditCardVirtId--);
     card.isnew(1);
     patron.active(1);
     patron.card(card);
index b26d7a8..c5c3027 100644 (file)
     <div><a href='javascript:void(0);' id='uedit-dupe-address-link'></a></div>
 </div>
 
+<div class='hidden'>
+    <span id='true' style='color:green;'>&#x2713;</span>
+    <span id='false' style='color:red;'>&#x2717;</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 %]
 
index 69ca6a3..0acfb11 100644 (file)
@@ -1,5 +1,11 @@
 <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>