use batch api call for post-checkin backdating
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Oct 2009 08:12:16 +0000 (08:12 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Oct 2009 08:12:16 +0000 (08:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14513 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/circ/backdate_post_checkin.js
Open-ILS/xul/staff_client/server/circ/backdate_post_checkin.xul
Open-ILS/xul/staff_client/server/circ/checkin.js
Open-ILS/xul/staff_client/server/circ/util.js

index 8c5f85f..b7f7745 100644 (file)
@@ -191,6 +191,7 @@ const api = {
     'FM_CIRC_IMPROVED_COUNT_VIA_COPY' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.circbyyr.atomic' },
        'FM_CIRC_EDIT_DUE_DATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.due_date.update' },
     'FM_CIRC_BACKDATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.post_checkin_backdate' },
+    'FM_CIRC_BACKDATE_BATCH' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.post_checkin_backdate.batch.atomic' },
        'FM_CIT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.ident_types.retrieve', 'secure' : false },
        'FM_CITM_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.item_type_map.retrieve.all', 'secure' : false },
        'FM_CNAL_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.net_access_level.retrieve.all', 'secure' : false },
index aab214c..cf40bb1 100644 (file)
@@ -27,8 +27,16 @@ function backdate_post_checkin_init() {
 
         $('checkin_effective_datepicker').value = util.date.formatted_date(new Date(),'%F');
 
-        $('circ_brief').setAttribute('src', urls.XUL_CIRC_BRIEF);
-        get_contentWindow($('circ_brief')).xulG = { 'circ_id' : xul_param('circ_id',{'modal_xulG':true}) };
+        var x = $('circ_brief_area');
+        var circ_ids = xul_param('circ_ids',{'modal_xulG':true});
+        dojo.forEach(
+            circ_ids,
+            function(element,idx,list) {
+                var iframe = document.createElement('iframe'); x.appendChild(iframe);
+                iframe.setAttribute('src', urls.XUL_CIRC_BRIEF);
+                get_contentWindow(iframe).xulG = { 'circ_id' : element };
+            }
+        );
 
         /* set widget behavior */
         $('cancel_btn').addEventListener(
index ffed058..103dd22 100644 (file)
@@ -36,7 +36,7 @@
        <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
        <!-- CONTENT -->
     <dialogheader title="&staff.circ.backdate_post_checkin.header;" description="&staff.circ.backdate_post_checkin.description;" />
-    <iframe id="circ_brief" flex="1"/>
+    <vbox class="my_overflow" id="circ_brief_area" flex="1"/>
     <hbox>
         <label id="checkin_effective_date_label" value="&staff.circ.checkin_overlay.effective_date.label;" control="checkin_effective_datepicker" accesskey="&staff.circ.checkin_overlay.effective_date.accesskey;"/>
         <datepicker id="checkin_effective_datepicker" type="popup" context="clipboard"/>
index 0194557..6acee6d 100644 (file)
@@ -169,6 +169,7 @@ circ.checkin.prototype = {
                                                ['command'],
                                                function() {
                                                        JSAN.use('circ.util');
+                            var circ_ids = [];
                                                        for (var i = 0; i < obj.selection_list.length; i++) {
                                 var circ_id = obj.selection_list[i].circ_id; 
                                 var copy_id = obj.selection_list[i].copy_id; 
@@ -177,8 +178,9 @@ circ.checkin.prototype = {
                                     if (blob.circ) circ_id = blob.circ.id();
                                 }
                                 if (!circ_id) continue;
-                                                               circ.util.backdate_post_checkin( circ_id );
+                                circ_ids.push( circ_id );
                                                        }
+                            circ.util.backdate_post_checkin( circ_ids );
                                                }
                                        ],
                                        'sel_mark_items_damaged' : [
index b7d8f43..db5dd67 100644 (file)
@@ -84,7 +84,7 @@ circ.util.show_copy_details = function(copy_id) {
        }
 };
 
-circ.util.backdate_post_checkin = function(circ_id) {
+circ.util.backdate_post_checkin = function(circ_ids) {
        var obj = {};
        JSAN.use('util.error'); obj.error = new util.error();
        JSAN.use('util.window'); obj.win = new util.window();
@@ -94,29 +94,33 @@ circ.util.backdate_post_checkin = function(circ_id) {
 
     var circStrings = document.getElementById('circStrings');
 
-       if (typeof circ_id == 'object' && circ_id != null) circ_id = circ_id.id();
+    dojo.forEach(
+        circ_ids,
+        function(element,idx,list) {
+            if (typeof element == 'object' && element != null) list[idx] = element.id();
+        }
+    );
 
        try {
                var url = xulG.url_prefix( urls.XUL_BACKDATE );
-        obj.data.temp_circ_id = circ_id; obj.data.stash('temp_circ_id');
-               var my_xulG = obj.win.open( url, 'backdate_post_checkin', 'chrome,resizable,modal', {} );
+               var my_xulG = obj.win.open( url, 'backdate_post_checkin', 'chrome,resizable,modal', { 'circ_ids' : circ_ids } );
 
                if (typeof my_xulG.proceed == 'undefined') return;
 
-        var r = obj.network.simple_request( 'FM_CIRC_BACKDATE', [ ses(), circ_id, my_xulG.backdate ] );
+        var r = obj.network.simple_request( 'FM_CIRC_BACKDATE_BATCH', [ ses(), circ_ids, my_xulG.backdate ] );
         if (r == 1) {
             obj.sound.circ_good();
             var x = $('no_change_label');
             if (x) {
                 x.hidden = false;
-                x.setAttribute('value', circStrings.getFormattedString('staff.circ.backdate.success',[circ_id,my_xulG.backdate]));
+                x.setAttribute('value', circStrings.getFormattedString('staff.circ.backdate.success',[circ_ids.join(","),my_xulG.backdate]));
             }
         } else {
             obj.sound.circ_bad();
             var x = $('no_change_label');
             if (x) {
                 x.hidden = false;
-                x.setAttribute('value', circStrings.getFormattedString('staff.circ.backdate.failed',[circ_id,r.textcode]));
+                x.setAttribute('value', circStrings.getFormattedString('staff.circ.backdate.failed',[circ_ids.join(","),r.textcode]));
             }
         }