refactored renew and added it to copy status. Show the barcode with the override...
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 Sep 2006 06:39:12 +0000 (06:39 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 Sep 2006 06:39:12 +0000 (06:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5882 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/copy_status.xul
Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul
Open-ILS/xul/staff_client/server/circ/util.js
Open-ILS/xul/staff_client/server/patron/items.js

index 963d7b1..ee8efea 100644 (file)
@@ -61,6 +61,7 @@ circ.copy_status.prototype = {
                                                        obj.controller.view.sel_spine.setAttribute('disabled','true');
                                                        obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
                                                        obj.controller.view.sel_clip.setAttribute('disabled','true');
+                                                       obj.controller.view.sel_renew.setAttribute('disabled','true');
                                                } else {
                                                        obj.controller.view.sel_checkin.setAttribute('disabled','false');
                                                        obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
@@ -74,6 +75,7 @@ circ.copy_status.prototype = {
                                                        obj.controller.view.sel_spine.setAttribute('disabled','false');
                                                        obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
                                                        obj.controller.view.sel_clip.setAttribute('disabled','false');
+                                                       obj.controller.view.sel_renew.setAttribute('disabled','false');
                                                }
                                        } catch(E) {
                                                alert('FIXME: ' + E);
@@ -170,6 +172,22 @@ circ.copy_status.prototype = {
                                                        }
                                                }
                                        ],
+                                       'sel_renew' : [
+                                               ['command'],
+                                               function() {
+                                                       JSAN.use('circ.util');
+                                                       for (var i = 0; i < obj.selection_list.length; i++) {
+                                                               var test = obj.selection_list[i].renewable;
+                                                               var barcode = obj.selection_list[i].barcode;
+                                                               if (test == 't') {
+                                                                       circ.util.renew_via_barcode( barcode );
+                                                               } else {
+                                                                       alert('Item with barcode ' + barcode + ' is not circulating.');
+                                                               }
+                                                       }
+                                               }
+                                       ],
+
                                        'sel_mark_items_damaged' : [
                                                ['command'],
                                                function() {
@@ -288,7 +306,7 @@ circ.copy_status.prototype = {
                                var my_mvr = obj.network.simple_request('MODS_SLIM_RECORD_RETRIEVE_VIA_COPY', [ copy.id() ]);
                                obj.list.append(
                                        {
-                                               'retrieve_id' : js2JSON( { 'copy_id' : copy.id(), 'barcode' : barcode, 'doc_id' : (typeof my_mvr.ilsevent == 'undefined' ? my_mvr.doc_id() : null ) } ),
+                                               'retrieve_id' : js2JSON( { 'renewable' : copy.circulations() ? 't' : 'f', 'copy_id' : copy.id(), 'barcode' : barcode, 'doc_id' : (typeof my_mvr.ilsevent == 'undefined' ? my_mvr.doc_id() : null ) } ),
                                                'row' : {
                                                        'my' : {
                                                                'mvr' : my_mvr,
index 171aff1..9353744 100644 (file)
@@ -94,6 +94,7 @@
                <command id="cmd_replace_barcode" disabled="true"/>
                <command id="sel_patron" disabled="true"/>
                <command id="sel_checkin" disabled="true"/>
+               <command id="sel_renew" disabled="true"/>
                <command id="sel_edit" disabled="true"/>
                <command id="sel_opac" disabled="true"/>
                <command id="sel_bucket" disabled="true"/>
index 2679a66..b65f9ff 100644 (file)
@@ -25,6 +25,7 @@
                <menuseparator/>
                <menuitem command="sel_spine" label="Print Spine Label" accesskey="P"/>
                <menuitem command="sel_checkin" label="Check In Items" accesskey="N" />
+               <menuitem command="sel_renew" label="Renew Items" accesskey="R" />
                <menuseparator />
                <menuitem command="save_columns" label="Save Columns"/>
        </popup>
@@ -73,6 +74,7 @@
                        <menuseparator />
                        <menuitem command="sel_spine" label="Print Spine Label" accesskey="P"/>
                        <menuitem command="sel_checkin" label="Check In Items" accesskey="N" />
+                       <menuitem command="sel_renew" label="Renew Items" accesskey="R" />
                        <menuseparator />
                        <menuitem command="save_columns" label="Save Columns"/>
                </menupopup>
index c39df42..f8de568 100644 (file)
@@ -6,7 +6,7 @@ circ.util = {};
 circ.util.EXPORT_OK    = [ 
        'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns', 
        'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_column', 'hold_capture_via_copy_barcode',
-       'show_last_few_circs', 'abort_transits', 'transit_columns'
+       'show_last_few_circs', 'abort_transits', 'transit_columns', 'renew_via_barcode',
 ];
 circ.util.EXPORT_TAGS  = { ':all' : circ.util.EXPORT_OK };
 
@@ -1193,5 +1193,83 @@ circ.util.hold_capture_via_copy_barcode = function ( session, barcode, retrieve_
        }
 }
 
+circ.util.renew_via_barcode = function ( barcode, patron_id ) {
+       try {
+               var obj = {};
+               JSAN.use('util.network'); obj.network = new util.network();
+               JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
+
+               var params = { barcode: barcode };
+               if (patron_id) params.patron = patron_id;
+
+               var renew = obj.network.simple_request(
+                       'CHECKOUT_RENEW', 
+                       [ ses(), params ],
+                       null,
+                       {
+                               'title' : 'Override Renew Failure?',
+                               'overridable_events' : [ 
+                                       1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
+                                       1213 /* PATRON_BARRED */,
+                                       1215 /* CIRC_EXCEEDS_COPY_RANGE */,
+                                       7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
+                                       7003 /* COPY_CIRC_NOT_ALLOWED */,
+                                       7004 /* COPY_NOT_AVAILABLE */,
+                                       7006 /* COPY_IS_REFERENCE */,
+                                       7007 /* COPY_NEEDED_FOR_HOLD */,
+                                       7008 /* MAX_RENEWALS_REACHED */, 
+                                       7010 /* COPY_ALERT_MESSAGE */,
+                                       7013 /* PATRON_EXCEEDS_FINES */,
+                               ],
+                               'text' : {
+                                       '1212' : function(r) { return 'Barcode: ' + barcode; },
+                                       '1213' : function(r) { return 'Barcode: ' + barcode; },
+                                       '1215' : function(r) { return 'Barcode: ' + barcode; },
+                                       '7002' : function(r) { return 'Barcode: ' + barcode; },
+                                       '7003' : function(r) { return 'Barcode: ' + barcode; },
+                                       '7004' : function(r) {
+                                               return 'Barcode: ' + barcode + ' Status: ' + r.payload.status().name();
+                                       },
+                                       '7006' : function(r) { return 'Barcode: ' + barcode; },
+                                       '7007' : function(r) { return 'Barcode: ' + barcode; },
+                                       '7008' : function(r) { return 'Barcode: ' + barcode; },
+                                       '7010' : function(r) {
+                                               return 'Barcode: ' + barcode + ' Message: ' + r.payload;
+                                       },
+                                       '7013' : function(r) { return 'Barcode: ' + barcode; },
+                               }
+                       }
+               );
+               if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
+               for (var j = 0; j < renew.length; j++) { 
+                       switch(renew[j].ilsevent) {
+                               case 0 /* SUCCESS */ : break;
+                               case 5000 /* PERM_FAILURE */: break;
+                               case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
+                               case 1213 /* PATRON_BARRED */ : break;
+                               case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
+                               case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
+                               case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
+                               case 7004 /* COPY_NOT_AVAILABLE */ : break;
+                               case 7006 /* COPY_IS_REFERENCE */ : break;
+                               case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
+                               case 7008 /* MAX_RENEWALS_REACHED */ : break; 
+                               case 7010 /* COPY_ALERT_MESSAGE */ : break;
+                               case 7013 /* PATRON_EXCEEDS_FINES */ : break;
+                               default:
+                                       throw(renew);
+                               break;
+                       }
+               }
+               return renew;
+
+       } catch(E) {
+               JSAN.use('util.error'); var error = new util.error();
+               error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
+               return null;
+       }
+}
+
+
 
 dump('exiting circ/util.js\n');
index 1a85987..6850a08 100644 (file)
@@ -211,10 +211,16 @@ patron.items.prototype = {
        'items_renew_all' : function() {
                try {
                        var obj = this; var list = obj.list;
+                       if (list.on_all_fleshed != null) {
+                               var r = window.confirm('This is list is busy retrieving/rendering rows for a prior action.  Abort the prior action and proceed?');
+                               if (!r) return;
+                       }
+                       var r = window.confirm('Renew all the items in this list?');
+                       if (!r) return;
                        function flesh_callback() {
                                try {
                                        obj.list.select_all();
-                                       obj.items_renew(1);     
+                                       obj.items_renew(1,true);        
                                        setTimeout(function(){list.on_all_fleshed = null;},0);
                                } catch(E) {
                                        obj.error.standard_unexpected_error_alert('2 All items were not likely renewed',E);
@@ -227,71 +233,24 @@ patron.items.prototype = {
                }
        },
 
-       'items_renew' : function(which) {
+       'items_renew' : function(which,skip_prompt) {
                var obj = this;
                try{
+                       JSAN.use('circ.util');
                        var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
                        if (!retrieve_ids || retrieve_ids.length == 0) return;
                        JSAN.use('util.functional');
-                       var msg = 'Are you sure you would like to renew item' + ( retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ') + '?';
-                       var r = obj.error.yns_alert(msg,'Renewing Items','Yes','No',null,'Check here to confirm this message');
-                       if (r != 0) { return; }
+                       if (!skip_prompt) {
+                               var msg = 'Are you sure you would like to renew item' + ( retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ') + '?';
+                               var r = window.confirm(msg);
+                               if (!r) { return; }
+                       }
                        for (var i = 0; i < retrieve_ids.length; i++) {
                                try {
                                        var barcode = retrieve_ids[i].barcode;
                                        //alert('Renew barcode = ' + barcode);
-                                       var renew = obj.network.simple_request(
-                                               'CHECKOUT_RENEW', 
-                                               [ ses(), { barcode: barcode, patron: obj.patron_id } ],
-                                               null,
-                                               {
-                                                       'title' : 'Override Renew Failure?',
-                                                       'overridable_events' : [ 
-                                                               1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
-                                                               1213 /* PATRON_BARRED */,
-                                                               1215 /* CIRC_EXCEEDS_COPY_RANGE */,
-                                                               7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
-                                                               7003 /* COPY_CIRC_NOT_ALLOWED */,
-                                                               7004 /* COPY_NOT_AVAILABLE */,
-                                                               7006 /* COPY_IS_REFERENCE */,
-                                                               7007 /* COPY_NEEDED_FOR_HOLD */,
-                                                               7008 /* MAX_RENEWALS_REACHED */, 
-                                                               7010 /* COPY_ALERT_MESSAGE */,
-                                                               7013 /* PATRON_EXCEEDS_FINES */,
-                                                       ],
-                                                       'text' : {
-                                                               '7010' : function(r) {
-                                                                       return r.payload;
-                                                               },
-                                                               '7004' : function(r) {
-                                                                       //return obj.data.hash.ccs[ r.payload ].name();
-                                                                       return r.payload.status().name();
-                                                                       //return r.payload.name();
-                                                               },
-                                                       }
-                                               }
-                                       );
-                                       if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
-                                       for (var j = 0; j < renew.length; j++) { 
-                                               switch(renew[j].ilsevent) {
-                                                       case 0 /* SUCCESS */ : break;
-                                                       case 5000 /* PERM_FAILURE */: break;
-                                                       case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
-                                                       case 1213 /* PATRON_BARRED */ : break;
-                                                       case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
-                                                       case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
-                                                       case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
-                                                       case 7004 /* COPY_NOT_AVAILABLE */ : break;
-                                                       case 7006 /* COPY_IS_REFERENCE */ : break;
-                                                       case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
-                                                       case 7008 /* MAX_RENEWALS_REACHED */ : break; 
-                                                       case 7010 /* COPY_ALERT_MESSAGE */ : break;
-                                                       case 7013 /* PATRON_EXCEEDS_FINES */ : break;
-                                                       default:
-                                                               throw(renew);
-                                                       break;
-                                               }
-                                       }
+                                       var renew = circ.util.renew_via_barcode( barcode, obj.patron_id );
+
                                } catch(E) {
                                        obj.error.standard_unexpected_error_alert('Renew probably did not happen for barcode ' + barcode,E);
                                }
@@ -438,8 +397,8 @@ patron.items.prototype = {
                        if (!retrieve_ids || retrieve_ids.length == 0) return;
                        JSAN.use('util.functional');
                        var msg = 'Are you sure you would like to check in item' + ( retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ') + '?';
-                       var r = obj.error.yns_alert(msg,'Check In Items','Yes','No',null,'Check here to confirm this message');
-                       if (r != 0) { return; }
+                       var r = window.confirm(msg);
+                       if (!r) { return; }
                        JSAN.use('circ.util');
                        for (var i = 0; i < retrieve_ids.length; i++) {
                                var barcode = retrieve_ids[i].barcode;