For backdating-already-returned-items prompt, don't display circ summaries for each...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 22 Oct 2009 06:41:29 +0000 (06:41 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 22 Oct 2009 06:41:29 +0000 (06:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14551 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/util.js
Open-ILS/xul/staff_client/server/locale/en-US/circ.properties

index b7f7745..aa34d76 100644 (file)
@@ -191,7 +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_CIRC_BACKDATE_BATCH' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.post_checkin_backdate.batch' },
        '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 cf40bb1..3c255f9 100644 (file)
@@ -1,4 +1,4 @@
-var data; var error; 
+var data; var error; var network; var sound;
 
 function $(id) { return document.getElementById(id); }
 
@@ -23,20 +23,19 @@ function backdate_post_checkin_init() {
 
         JSAN.use('util.error'); error = new util.error();
 
-        JSAN.use('util.date');
+        JSAN.use('util.network'); network = new util.network();
+
+        JSAN.use('util.sound'); sound = new util.sound();
+
+        JSAN.use('util.date'); 
+
+        dojo.require('openils.Util');
 
         $('checkin_effective_datepicker').value = util.date.formatted_date(new Date(),'%F');
 
         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 };
-            }
-        );
+        if (x) x.appendChild( document.createTextNode( $('circStrings').getFormattedString('staff.circ.backdate.circ_ids.prompt',[circ_ids.length,circ_ids.join(',')]) ) );
 
         /* set widget behavior */
         $('cancel_btn').addEventListener(
@@ -44,15 +43,7 @@ function backdate_post_checkin_init() {
         );
         $('apply_btn').addEventListener(
             'command', 
-            function() {
-                update_modal_xulG(
-                    {
-                        'backdate' : $('checkin_effective_datepicker').value,
-                        'proceed' : 1
-                    }
-                )
-                window.close();
-            }, 
+            gen_handle_apply(circ_ids),
             false
         );
 
@@ -87,3 +78,48 @@ function backdate_post_checkin_init() {
 
 }
 
+function gen_handle_apply(circ_ids) {
+    return function handle_apply(ev) {
+        try {
+            var backdate = $('checkin_effective_datepicker').value;
+            var progressmeter = $('progress');
+
+            var idx = -1;
+            var bad_circs = [];
+
+            fieldmapper.standardRequest(
+                [ api.FM_CIRC_BACKDATE_BATCH.app, api.FM_CIRC_BACKDATE_BATCH.method ],
+                {   async: true,
+                    params: [ses(), circ_ids, backdate],
+                    onresponse: function(r) {
+                        idx++; progressmeter.value = Number( progressmeter.value ) + 100/circ_ids.length;
+                        var result = r.recv().content();
+                        if (result != 1) {
+                            bad_circs.push( { 'circ_id' : circ_ids[ idx ], 'result' : result } );
+                        }
+                    },
+                    oncomplete: function() {
+                        if (bad_circs.length > 0) {
+                            sound.circ_bad(); 
+                            alert( $('circStrings').getFormattedString('staff.circ.backdate.circ_ids.failed',[ bad_circs.length, bad_circs.join(',') ]) );
+                        } else {
+                            sound.circ_good();
+                        }
+
+                        update_modal_xulG(
+                            {
+                                'backdate' : backdate,
+                                'bad_circs' : bad_circs,
+                                'complete' : 1
+                            }
+                        )
+                        window.close();
+                    }
+                }
+            );
+
+        } catch(E) {
+            alert('Error in backdate.js, handle_apply(): ' + E);
+        }
+    };
+}
index 103dd22..425f937 100644 (file)
@@ -20,7 +20,7 @@
 <window id="backdate_post_checkin_win" 
     onload="try { backdate_post_checkin_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-    height="250" width="800" oils_perist="height width"
+    oils_perist="height width"
     title="&staff.hold_list.cancel_hold_dialog.title;">
 
        <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
@@ -37,6 +37,7 @@
        <!-- CONTENT -->
     <dialogheader title="&staff.circ.backdate_post_checkin.header;" description="&staff.circ.backdate_post_checkin.description;" />
     <vbox class="my_overflow" id="circ_brief_area" flex="1"/>
+    <progressmeter type="determined" id="progress" />
     <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 deee41d..8ac1b8c 100644 (file)
@@ -105,33 +105,7 @@ circ.util.backdate_post_checkin = function(circ_ids) {
                var url = xulG.url_prefix( urls.XUL_BACKDATE );
                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_BATCH', [ ses(), circ_ids, my_xulG.backdate ] );
-        if (typeof r.ilsevent != 'undefined') throw(r);
-        var bad_sound = false;
-        dojo.forEach(
-            r,
-            function(element,idx,list) {
-                if (element == 1) {
-                    var x = $('no_change_label');
-                    if (x) {
-                        x.hidden = false;
-                        var m = x.getAttribute('value');
-                        x.setAttribute('value', (m ? m + ' : ' : '' ) + circStrings.getFormattedString('staff.circ.backdate.success',[circ_ids[idx],my_xulG.backdate]));
-                    }
-                } else {
-                    bad_sound = true;
-                    var x = $('no_change_label');
-                    if (x) {
-                        x.hidden = false;
-                        var m = x.getAttribute('value');
-                        x.setAttribute('value', (m ? m + ' : ' : '' ) + circStrings.getFormattedString('staff.circ.backdate.failure',[circ_ids[idx],r.textcode]));
-                    }
-                }
-            }
-        );
-        if (bad_sound) obj.sound.circ_bad(); else obj.sound.circ_good();
+        return my_xulG;
 
        } catch(E) {
                obj.error.standard_unexpected_error_alert(circStrings.getString('staff.circ.utils.retrieve_copy.failure'),E);
index c7801da..da51fb6 100644 (file)
@@ -23,6 +23,8 @@ staff.circ.util.checkin.exception.external=circ.util.checkin: Calling external .
 staff.circ.util.checkin.exception.no_external=circ.util.checkin: Calling external .on_checkin()
 staff.circ.backdate.success=Circ ID %1$s backdated to %2$s
 staff.circ.backdate.failure=Circ ID %1$s failed backdating due to %2$s
+staff.circ.backdate.circ_ids.prompt=Number of circulations selected: %1$s 
+staff.circ.backdate.circ_ids.failed=Number of circulations not backdated: %1$s 
 staff.circ.checkout.sorting.exception=error in sorting non-cataloged items: %1$s
 staff.circ.checkout.date.exception=Use this format: YYYY-MM-DD
 staff.circ.checkout.unimplemented=Not Yet Implemented