'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 },
-var data; var error;
+var data; var error; var network; var sound;
function $(id) { return document.getElementById(id); }
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(
);
$('apply_btn').addEventListener(
'command',
- function() {
- update_modal_xulG(
- {
- 'backdate' : $('checkin_effective_datepicker').value,
- 'proceed' : 1
- }
- )
- window.close();
- },
+ gen_handle_apply(circ_ids),
false
);
}
+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);
+ }
+ };
+}
<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;">
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<!-- 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"/>
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);
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