TPac: Load patron name when placing holds
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 12 Feb 2013 14:10:29 +0000 (09:10 -0500)
committerBen Shum <bshum@biblio.org>
Wed, 13 Feb 2013 18:23:07 +0000 (13:23 -0500)
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Signed-off-by: Michael Peters <mrpeters@library.in.gov>
Open-ILS/src/templates/opac/parts/place_hold.tt2
Open-ILS/web/js/ui/default/opac/staff.js
Open-ILS/xul/staff_client/chrome/content/main/menu.js

index 2066616..c22dee4 100644 (file)
@@ -22,7 +22,7 @@
             <label for="hold_usr_is_requestor_not">
                 [% l("Place hold for patron by barcode:") %]
             </label>
-            <input type="text" name="hold_usr" id="hold_usr_input" onchange="staff_hold_usr_barcode_changed();" onkeypress="return no_hold_submit(event)" /><br />
+            <input type="text" name="hold_usr" id="hold_usr_input" onchange="staff_hold_usr_barcode_changed();" onkeypress="return no_hold_submit(event)" /> <span id="patron_name"></span><br />
             <input type="hidden" id="staff_barcode" value="[% ctx.staff_recipient.card.barcode | html %]"/>
             <span>
                 <input type="radio" id="hold_usr_is_requestor"
@@ -99,7 +99,7 @@
                 [% END %]
             </blockquote>
         </p>
-        <input type="submit" name="submit" value="[% l('Submit') %]" title="[% l('Submit') %]"
+        <input id="place_hold_submit" type="submit" name="submit" value="[% l('Submit') %]" title="[% l('Submit') %]"
             alt="[% l('Submit') %]" class="opac-button" />
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <input type="reset" name="cancel" onclick="javascript:history.go(-1);"
index 6e2cbda..0e403ab 100644 (file)
@@ -40,11 +40,19 @@ function staff_hold_usr_barcode_changed(isload) {
             if(barcode && barcode != '' && !document.getElementById('hold_usr_is_requestor_not').checked)
                 document.getElementById('hold_usr_is_requestor_not').checked = 'checked';
         }
-        if(barcode == undefined || barcode == '' || barcode == cur_hold_barcode)
+        if(barcode == undefined || barcode == '') {
+            document.getElementById('patron_name').innerHTML = '';
             return;
+        }
+        if(barcode == cur_hold_barcode)
+            return;
+        // No submitting until we think the barcode is valid
+        document.getElementById('place_hold_submit').disabled = true;
         var load_info = xulG.get_barcode_and_settings(window, barcode, only_settings);
-        if(load_info == false || load_info == undefined)
+        if(load_info == false || load_info == undefined) {
+            document.getElementById('patron_name').innerHTML = '';
             return;
+        }
         cur_hold_barcode = load_info.barcode;
         if(!only_settings || (isload && isload !== true)) document.getElementById('hold_usr_input').value = load_info.barcode; // Safe at this point as we already set cur_hold_barcode
         if(load_info.settings['opac.default_pickup_location'])
@@ -76,6 +84,11 @@ function staff_hold_usr_barcode_changed(isload) {
         }
         update_elements = document.getElementsByName('email_address');
         for(var i in update_elements) update_elements[i].textContent = load_info.user_email;
+        if(!document.getElementById('hold_usr_is_requestor').checked && !only_settings) {
+            document.getElementById('patron_name').innerHTML = load_info.patron_name;
+        }
+        // Ok, now we can allow submitting again
+        document.getElementById('place_hold_submit').disabled = false;
     }
 }
 window.onload = function() {
index 9c5174f..54320d4 100644 (file)
@@ -2660,7 +2660,13 @@ commands:
         }
         if(!settings['opac.default_phone'] && user.day_phone()) settings['opac.default_phone'] = user.day_phone();
         if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') settings['opac.hold_notify'] = 'email:phone';
-        return {"barcode": barcode, "settings" : settings, "user_email" : user.email()};
+        // Taken from patron/util.js format_name
+        var patron_name = ( user.prefix() ? user.prefix() + ' ' : '') +
+            user.family_name() + ', ' +
+            user.first_given_name() + ' ' +
+            ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
+            ( user.suffix() ? user.suffix() : '');
+        return {"barcode": barcode, "settings" : settings, "user_email" : user.email(), "patron_name" : patron_name};
     },
 
     'sort_menu' : function(menu, recurse) {