1 dump('entering circ/util.js\n');
4 if (typeof circ == 'undefined') { var circ = {}; }
7 circ.util.EXPORT_OK = [
8 'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns',
9 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns',
10 'show_last_few_circs', 'abort_transits', 'transit_columns', 'work_log_columns', 'renew_via_barcode', 'backdate_post_checkin'
12 circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK };
14 circ.util.abort_transits = function(selection_list) {
16 JSAN.use('util.error'); obj.error = new util.error();
17 JSAN.use('util.network'); obj.network = new util.network();
18 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
19 JSAN.use('util.functional');
20 var copies = util.functional.map_list( selection_list, function(o){return o.copy_id;}).join(', ');
21 var msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.abort_transits.confirm', [copies]);
22 var r = obj.error.yns_alert(
24 document.getElementById('circStrings').getString('staff.circ.utils.abort_transits.title'),
25 document.getElementById('circStrings').getString('staff.circ.utils.yes'),
26 document.getElementById('circStrings').getString('staff.circ.utils.no'),
28 document.getElementById('circStrings').getString('staff.circ.confirm')
32 for (var i = 0; i < selection_list.length; i++) {
33 var copy_id = selection_list[i].copy_id;
34 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'copyid' : copy_id } ]);
35 if (typeof robj.ilsevent != 'undefined') {
36 switch(Number(robj.ilsevent)) {
37 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
38 alert(document.getElementById('circString').getFormattedString('staff.circ.utils.abort_transits.not_allowed', [copy_id]) + '\n' + robj.desc);
40 case 1504 /* ACTION_TRANSIT_COPY_NOT_FOUND */ :
41 alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.not_found'));
43 case 5000 /* PERM_FAILURE */ :
52 obj.error.standard_unexpected_error_alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.unexpected_error'),E);
57 circ.util.show_copy_details = function(copy_id) {
59 JSAN.use('util.error'); obj.error = new util.error();
60 JSAN.use('util.window'); obj.win = new util.window();
61 JSAN.use('util.network'); obj.network = new util.network();
62 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
64 if (typeof copy_id == 'object' && copy_id != null) copy_id = copy_id.id();
67 var url = xulG.url_prefix( urls.XUL_COPY_DETAILS ); // + '?copy_id=' + copy_id;
68 var my_xulG = obj.win.open( url, 'show_copy_details', 'chrome,resizable,modal', { 'copy_id' : copy_id } );
70 if (typeof my_xulG.retrieve_these_patrons == 'undefined') return;
71 var patrons = my_xulG.retrieve_these_patrons;
72 for (var j = 0; j < patrons.length; j++) {
73 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
75 window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
77 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure'), E);
83 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
87 circ.util.backdate_post_checkin = function(circ_id) {
89 JSAN.use('util.error'); obj.error = new util.error();
90 JSAN.use('util.window'); obj.win = new util.window();
91 JSAN.use('util.network'); obj.network = new util.network();
92 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
93 JSAN.use('util.sound'); obj.sound = new util.sound();
95 var circStrings = document.getElementById('circStrings');
97 if (typeof circ_id == 'object' && circ_id != null) circ_id = circ_id.id();
100 var url = xulG.url_prefix( urls.XUL_BACKDATE );
101 obj.data.temp_circ_id = circ_id; obj.data.stash('temp_circ_id');
102 var my_xulG = obj.win.open( url, 'backdate_post_checkin', 'chrome,resizable,modal', {} );
104 if (typeof my_xulG.proceed == 'undefined') return;
106 var r = obj.network.simple_request( 'FM_CIRC_BACKDATE', [ ses(), circ_id, my_xulG.backdate ] );
108 obj.sound.circ_good();
109 var x = $('no_change_label');
112 x.setAttribute('value', circStrings.getFormattedString('staff.circ.backdate.success',[circ_id,my_xulG.backdate]));
115 obj.sound.circ_bad();
116 var x = $('no_change_label');
119 x.setAttribute('value', circStrings.getFormattedString('staff.circ.backdate.failed',[circ_id,r.textcode]));
124 obj.error.standard_unexpected_error_alert(circStrings.getString('staff.circ.utils.retrieve_copy.failure'),E);
129 circ.util.show_last_few_circs = function(selection_list) {
131 JSAN.use('util.error'); obj.error = new util.error();
132 JSAN.use('util.window'); obj.win = new util.window();
133 JSAN.use('util.network'); obj.network = new util.network();
134 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
136 for (var i = 0; i < selection_list.length; i++) {
138 if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
139 var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
140 var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id } );
142 if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
143 var patrons = my_xulG.retrieve_these_patrons;
144 for (var j = 0; j < patrons.length; j++) {
145 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
147 window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
149 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
155 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
160 circ.util.offline_checkout_columns = function(modify,params) {
165 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
169 'render' : function(my) { return my.timestamp; }
172 'id' : 'checkout_time',
173 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
177 'render' : function(my) { return my.checkout_time; }
181 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
185 'render' : function(my) { return my.type; }
189 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
193 'render' : function(my) { return my.noncat; }
196 'id' : 'noncat_type',
197 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
201 'render' : function(my) { return my.noncat_type; }
204 'id' : 'noncat_count',
205 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
206 'sort_type' : 'number',
210 'render' : function(my) { return my.noncat_count; }
213 'id' : 'patron_barcode',
214 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
218 'render' : function(my) { return my.patron_barcode; }
222 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
226 'render' : function(my) { return my.barcode; }
230 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
234 'render' : function(my) { return my.due_date; }
238 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
242 'render' : function(my) { return my.due_time; }
246 if (modify) for (var i = 0; i < c.length; i++) {
247 if (modify[ c[i].id ]) {
248 for (var j in modify[ c[i].id ]) {
249 c[i][j] = modify[ c[i].id ][j];
254 if (params.just_these) {
255 JSAN.use('util.functional');
257 for (var i = 0; i < params.just_these.length; i++) {
258 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
259 new_c.push( function(y){ return y; }( x ) );
263 if (params.except_these) {
264 JSAN.use('util.functional');
266 for (var i = 0; i < c.length; i++) {
267 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
268 if (!x) new_c.push(c[i]);
274 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
277 circ.util.offline_checkin_columns = function(modify,params) {
282 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
286 'render' : function(my) { return my.timestamp; }
290 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
294 'render' : function(my) { return my.backdate; }
298 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
302 'render' : function(my) { return my.type; }
306 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
310 'render' : function(my) { return my.barcode; }
313 if (modify) for (var i = 0; i < c.length; i++) {
314 if (modify[ c[i].id ]) {
315 for (var j in modify[ c[i].id ]) {
316 c[i][j] = modify[ c[i].id ][j];
321 if (params.just_these) {
322 JSAN.use('util.functional');
324 for (var i = 0; i < params.just_these.length; i++) {
325 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
326 new_c.push( function(y){ return y; }( x ) );
330 if (params.except_these) {
331 JSAN.use('util.functional');
333 for (var i = 0; i < c.length; i++) {
334 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
335 if (!x) new_c.push(c[i]);
341 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
344 circ.util.offline_renew_columns = function(modify,params) {
349 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
353 'render' : function(my) { return my.timestamp; }
356 'id' : 'checkout_time',
357 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
361 'render' : function(my) { return my.checkout_time; }
365 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
369 'render' : function(my) { return my.type; }
372 'id' : 'patron_barcode',
373 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
377 'render' : function(my) { return my.patron_barcode; }
381 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
385 'render' : function(my) { return my.barcode; }
389 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
393 'render' : function(my) { return my.due_date; }
397 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
401 'render' : function(my) { return my.due_time; }
404 if (modify) for (var i = 0; i < c.length; i++) {
405 if (modify[ c[i].id ]) {
406 for (var j in modify[ c[i].id ]) {
407 c[i][j] = modify[ c[i].id ][j];
412 if (params.just_these) {
413 JSAN.use('util.functional');
415 for (var i = 0; i < params.just_these.length; i++) {
416 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
417 new_c.push( function(y){ return y; }( x ) );
421 if (params.except_these) {
422 JSAN.use('util.functional');
424 for (var i = 0; i < c.length; i++) {
425 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
426 if (!x) new_c.push(c[i]);
432 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
435 circ.util.offline_inhouse_use_columns = function(modify,params) {
440 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
444 'render' : function(my) { return my.timestamp; }
448 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
452 'render' : function(my) { return my.use_time; }
456 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
460 'render' : function(my) { return my.type; }
464 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
465 'sort_type' : 'number',
469 'render' : function(my) { return my.count; }
473 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
477 'render' : function(my) { return my.barcode; }
480 if (modify) for (var i = 0; i < c.length; i++) {
481 if (modify[ c[i].id ]) {
482 for (var j in modify[ c[i].id ]) {
483 c[i][j] = modify[ c[i].id ][j];
488 if (params.just_these) {
489 JSAN.use('util.functional');
491 for (var i = 0; i < params.just_these.length; i++) {
492 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
493 new_c.push( function(y){ return y; }( x ) );
497 if (params.except_these) {
498 JSAN.use('util.functional');
500 for (var i = 0; i < c.length; i++) {
501 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
502 if (!x) new_c.push(c[i]);
508 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
511 circ.util.columns = function(modify,params) {
513 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
514 JSAN.use('util.network'); var network = new util.network();
515 JSAN.use('util.money');
520 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
524 'render' : function(my) { return my.acp.id(); },
525 'persist' : 'hidden width ordinal'
529 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
533 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
534 'persist' : 'hidden width ordinal'
538 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
542 'render' : function(my) { return my.mvr.doc_id(); },
543 'persist' : 'hidden width ordinal'
546 'persist' : 'hidden width ordinal',
552 'render' : function(my) { return my.service; }
556 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
560 'render' : function(my) { return my.acp.barcode(); },
561 'persist' : 'hidden width ordinal'
564 'id' : 'call_number',
565 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
569 'render' : function(my) {
570 if (my.acp && my.acp.call_number() == -1) {
571 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
572 } else if (my.acp && my.acp.call_number() == -2) {
573 return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
576 var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
578 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
580 my.acn = x; return x.label();
583 return my.acn.label();
587 'persist' : 'hidden width ordinal'
591 'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
595 'render' : function(my) {
596 if (Number(my.acn.owning_lib())>=0) {
597 return data.hash.aou[ my.acn.owning_lib() ].shortname();
599 return my.acn.owning_lib().shortname();
602 'persist' : 'hidden width ordinal'
605 'id' : 'copy_number',
606 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
608 'sort_type' : 'number',
611 'render' : function(my) { return my.acp.copy_number(); },
612 'persist' : 'hidden width ordinal'
616 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
620 'render' : function(my) {
621 if (Number(my.acp.location())>=0) {
622 return data.lookup("acpl", my.acp.location() ).name();
624 return my.acp.location().name();
627 'persist' : 'hidden width ordinal'
630 'id' : 'loan_duration',
631 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
635 'render' : function(my) {
636 switch(Number(my.acp.loan_duration())) {
638 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
641 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
644 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
648 'persist' : 'hidden width ordinal'
652 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
656 'render' : function(my) {
657 if (Number(my.acp.circ_lib())>=0) {
658 return data.hash.aou[ my.acp.circ_lib() ].shortname();
660 return my.acp.circ_lib().shortname();
663 'persist' : 'hidden width ordinal'
667 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
671 'render' : function(my) {
672 switch(Number(my.acp.fine_level())) {
674 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
677 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
680 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
684 'persist' : 'hidden width ordinal'
688 'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
692 'render' : function(my) {
693 if (get_bool( my.acp.circulate() )) {
694 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
696 return document.getElementById('circStrings').getString('staff.circ.utils.no');
699 'persist' : 'hidden width ordinal'
703 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
707 'render' : function(my) {
708 if (get_bool( my.acp.deleted() )) {
709 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
711 return document.getElementById('circStrings').getString('staff.circ.utils.no');
714 'persist' : 'hidden width ordinal'
718 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
722 'render' : function(my) {
723 if (get_bool( my.acp.holdable() )) {
724 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
726 return document.getElementById('circStrings').getString('staff.circ.utils.no');
729 'persist' : 'hidden width ordinal'
732 'id' : 'opac_visible',
733 'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
737 'render' : function(my) {
738 if (get_bool( my.acp.opac_visible() )) {
739 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
741 return document.getElementById('circStrings').getString('staff.circ.utils.no');
744 'persist' : 'hidden width ordinal'
747 'persist' : 'hidden width ordinal',
749 'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
753 'render' : function(my) {
754 if (get_bool( my.acp.ref() )) {
755 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
757 return document.getElementById('circStrings').getString('staff.circ.utils.no');
762 'persist' : 'hidden width ordinal',
764 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
768 'render' : function(my) {
769 if (get_bool( my.acp.deposit() )) {
770 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
772 return document.getElementById('circStrings').getString('staff.circ.utils.no');
777 'persist' : 'hidden width ordinal',
778 'id' : 'deposit_amount',
779 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
783 'render' : function(my) {
784 if (my.acp.price() == null) {
785 return document.getElementById('circStrings').getString('staff.circ.utils.unset');
787 return util.money.sanitize(my.acp.deposit_amount());
790 'sort_type' : 'money'
793 'persist' : 'hidden width ordinal',
795 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
799 'render' : function(my) {
800 if (my.acp.price() == null) {
801 return document.getElementById('circStrings').getString('staff.circ.utils.unset');
803 return util.money.sanitize(my.acp.price());
806 'sort_type' : 'money'
809 'persist' : 'hidden width ordinal',
810 'id' : 'circ_as_type',
811 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
815 'render' : function(my) { return my.acp.circ_as_type(); }
818 'persist' : 'hidden width ordinal',
819 'id' : 'circ_modifier',
820 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
824 'render' : function(my) { return my.acp.circ_modifier(); }
827 'persist' : 'hidden width ordinal',
828 'id' : 'checkout_lib',
829 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
833 'render' : function(my) {
835 return data.hash.aou[ my.circ.circ_lib() ].shortname();
837 if (my.acp.circulations()) {
838 return data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname();
846 'persist' : 'hidden width ordinal',
847 'id' : 'xact_start_full',
848 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_timestamp'),
852 'render' : function(my) {
854 return my.circ.xact_start();
856 if (my.acp.circulations()) {
857 return my.acp.circulations()[0].xact_start();
866 'persist' : 'hidden width ordinal',
867 'id' : 'checkin_time_full',
868 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_timestamp'),
872 'render' : function(my) {
874 return my.circ.checkin_time();
876 if (my.acp.circulations()) {
877 return my.acp.circulations()[0].checkin_time();
885 'persist' : 'hidden width ordinal',
887 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
891 'render' : function(my) {
893 return my.circ.xact_start().substr(0,10);
895 if (my.acp.circulations()) {
896 return my.acp.circulations()[0].xact_start().substr(0,10);
904 'persist' : 'hidden width ordinal',
905 'id' : 'checkin_time',
906 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
910 'render' : function(my) {
912 return my.circ.checkin_time().substr(0,10);
914 if (my.acp.circulations()) {
915 return my.acp.circulations()[0].checkin_time().substr(0,10);
923 'persist' : 'hidden width ordinal',
924 'id' : 'xact_finish',
925 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
929 'render' : function(my) { return my.circ ? my.circ.xact_finish() : ( my.acp.circulations() ? my.acp.circulations()[0].xact_finish() : ""); },
932 'persist' : 'hidden width ordinal',
934 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
938 'render' : function(my) {
940 return my.circ.due_date().substr(0,10);
942 if (my.acp.circulations()) {
943 return my.acp.circulations()[0].due_date().substr(0,10);
951 'persist' : 'hidden width ordinal',
953 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
957 'render' : function(my) {
959 return my.circ.due_date().substr(11,8);
961 if (my.acp.circulations()) {
962 return my.acp.circulations()[0].due_date().substr(11,8);
970 'persist' : 'hidden width ordinal',
971 'id' : 'create_date',
972 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
976 'render' : function(my) { return my.acp.create_date().substr(0,10); }
979 'persist' : 'hidden width ordinal',
981 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
985 'render' : function(my) { return my.acp.edit_date().substr(0,10); }
988 'persist' : 'hidden width ordinal',
990 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
992 'sort_type' : 'title',
995 'render' : function(my) {
996 try { return my.mvr.title(); }
997 catch(E) { return my.acp.dummy_title(); }
1001 'persist' : 'hidden width ordinal',
1003 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1007 'render' : function(my) {
1008 try { return my.mvr.author(); }
1009 catch(E) { return my.acp.dummy_author(); }
1013 'persist' : 'hidden width ordinal',
1015 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1019 'render' : function(my) { return my.mvr.edition(); }
1022 'persist' : 'hidden width ordinal',
1024 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1028 'render' : function(my) {
1029 try { return my.mvr.isbn(); }
1030 catch(E) { return my.acp.dummy_isbn(); }
1034 'persist' : 'hidden width ordinal',
1036 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1040 'render' : function(my) { return my.mvr.pubdate(); }
1043 'persist' : 'hidden width ordinal',
1045 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1049 'render' : function(my) { return my.mvr.publisher(); }
1052 'persist' : 'hidden width ordinal',
1054 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1058 'render' : function(my) { return my.mvr.tcn(); }
1061 'persist' : 'hidden width ordinal',
1062 'id' : 'renewal_remaining',
1063 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
1067 'render' : function(my) {
1069 return my.circ.renewal_remaining();
1071 if (my.acp.circulations()) {
1072 return my.acp.circulations()[0].renewal_remaining();
1078 'sort_type' : 'number'
1081 'persist' : 'hidden width ordinal',
1082 'id' : 'stop_fines',
1083 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1087 'render' : function(my) {
1089 return my.circ.stop_fines();
1091 if (my.acp.circulations()) {
1092 return my.acp.circulations()[0].stop_fines();
1100 'persist' : 'hidden width ordinal',
1101 'id' : 'stop_fines_time',
1102 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1106 'render' : function(my) {
1108 return my.circ.stop_fines_time();
1110 if (my.acp.circulations()) {
1111 return my.acp.circulations()[0].stop_fines_time();
1119 'persist' : 'hidden width ordinal',
1121 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1125 'render' : function(my) {
1126 if (Number(my.acp.status())>=0) {
1127 return data.hash.ccs[ my.acp.status() ].name();
1129 return my.acp.status().name();
1134 'persist' : 'hidden width ordinal',
1136 'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1140 'render' : function(my) { return my.route_to.toString(); }
1143 'persist' : 'hidden width ordinal',
1145 'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1149 'render' : function(my) { return my.message.toString(); }
1152 'persist' : 'hidden width ordinal',
1154 'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1158 'render' : function(my) { return my.uses; },
1159 'sort_type' : 'number'
1162 'persist' : 'hidden width ordinal',
1163 'id' : 'alert_message',
1164 'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1168 'render' : function(my) { return my.acp.alert_message(); }
1171 'persist' : 'hidden width ordinal',
1172 'id' : 'checkin_workstation',
1173 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_workstation'),
1177 'render' : function(my) { return my.circ ? ( typeof my.circ.checkin_workstation() == 'object' ? my.circ.checkin_workstation().name() : my.circ.checkin_workstation() ) : ( my.acp.circulations() ? ( typeof my.acp.circulations()[0].checkin_workstation() == 'object' ? my.acp.circulations().checkin_workstation().name() : my.acp.circulations().checkin_workstation() ) : ""); },
1180 'persist' : 'hidden width ordinal',
1181 'id' : 'checkin_scan_time',
1182 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_time'),
1186 'render' : function(my) { return my.circ ? my.circ.checkin_scan_time().substr(0,10) : ( my.acp.circulations() ? my.acp.circulations()[0].checkin_scan_time().substr(0,10) : ""); },
1189 'persist' : 'hidden width ordinal',
1190 'id' : 'checkin_scan_timestamp',
1191 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_timestamp'),
1195 'render' : function(my) { return my.circ ? my.circ.checkin_scan_time() : ( my.acp.circulations() ? my.acp.circulations()[0].checkin_scan_time() : ""); },
1199 for (var i = 0; i < c.length; i++) {
1200 if (modify[ c[i].id ]) {
1201 for (var j in modify[ c[i].id ]) {
1202 c[i][j] = modify[ c[i].id ][j];
1207 if (params.just_these) {
1208 JSAN.use('util.functional');
1210 for (var i = 0; i < params.just_these.length; i++) {
1211 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1212 new_c.push( function(y){ return y; }( x ) );
1216 if (params.except_these) {
1217 JSAN.use('util.functional');
1219 for (var i = 0; i < c.length; i++) {
1220 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1221 if (!x) new_c.push(c[i]);
1226 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1229 circ.util.work_log_columns = function(modify,params) {
1231 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1235 'persist' : 'hidden width ordinal',
1237 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.message'),
1241 'render' : function(my) { return my.message; }
1244 'persist' : 'hidden width ordinal',
1246 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.when'),
1250 'render' : function(my) { return String( my.when ); }
1254 for (var i = 0; i < c.length; i++) {
1255 if (modify[ c[i].id ]) {
1256 for (var j in modify[ c[i].id ]) {
1257 c[i][j] = modify[ c[i].id ][j];
1262 if (params.just_these) {
1263 JSAN.use('util.functional');
1265 for (var i = 0; i < params.just_these.length; i++) {
1266 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1267 new_c.push( function(y){ return y; }( x ) );
1271 if (params.except_these) {
1272 JSAN.use('util.functional');
1274 for (var i = 0; i < c.length; i++) {
1275 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1276 if (!x) new_c.push(c[i]);
1282 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1285 circ.util.transit_columns = function(modify,params) {
1287 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1291 'persist' : 'hidden width ordinal',
1292 'id' : 'transit_item_barcode',
1293 'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1297 'render' : function(my) { return my.acp.barcode(); }
1300 'persist' : 'hidden width ordinal',
1301 'id' : 'transit_item_title',
1302 'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1306 'render' : function(my) {
1307 try { return my.mvr.title(); }
1308 catch(E) { return my.acp.dummy_title(); }
1312 'persist' : 'hidden width ordinal',
1313 'id' : 'transit_item_author',
1314 'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1318 'render' : function(my) {
1319 try { return my.mvr.author(); }
1320 catch(E) { return my.acp.dummy_author(); }
1324 'persist' : 'hidden width ordinal',
1325 'id' : 'transit_item_callnumber',
1326 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1330 'render' : function(my) { return my.acn.label(); }
1333 'persist' : 'hidden width ordinal',
1334 'id' : 'transit_id',
1335 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1339 'render' : function(my) { return my.atc.id(); }
1342 'persist' : 'hidden width ordinal',
1343 'id' : 'transit_source',
1344 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1348 'render' : function(my) {
1349 if (typeof my.atc.source() == "object") {
1350 return my.atc.source().shortname();
1352 return data.hash.aou[ my.atc.source() ].shortname();
1357 'persist' : 'hidden width ordinal',
1358 'id' : 'transit_source_send_time',
1359 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1363 'render' : function(my) { return my.atc.source_send_time(); }
1366 'persist' : 'hidden width ordinal',
1367 'id' : 'transit_dest_lib',
1368 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1372 'render' : function(my) {
1373 if (typeof my.atc.dest() == "object") {
1374 return my.atc.dest().shortname();
1376 return data.hash.aou[ my.atc.dest() ].shortname();
1381 'persist' : 'hidden width ordinal',
1382 'id' : 'transit_dest_recv_time',
1383 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1387 'render' : function(my) { return my.atc.dest_recv_time(); }
1390 'persist' : 'hidden width ordinal',
1391 'id' : 'transit_target_copy',
1392 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1396 'render' : function(my) { return my.atc.target_copy(); }
1399 for (var i = 0; i < c.length; i++) {
1400 if (modify[ c[i].id ]) {
1401 for (var j in modify[ c[i].id ]) {
1402 c[i][j] = modify[ c[i].id ][j];
1407 if (params.just_these) {
1408 JSAN.use('util.functional');
1410 for (var i = 0; i < params.just_these.length; i++) {
1411 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1412 new_c.push( function(y){ return y; }( x ) );
1416 if (params.except_these) {
1417 JSAN.use('util.functional');
1419 for (var i = 0; i < c.length; i++) {
1420 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1421 if (!x) new_c.push(c[i]);
1427 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1430 circ.util.hold_columns = function(modify,params) {
1432 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1436 'persist' : 'hidden width ordinal',
1437 'id' : 'request_lib',
1438 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1442 'render' : function(my) {
1443 if (Number(my.ahr.request_lib())>=0) {
1444 return data.hash.aou[ my.ahr.request_lib() ].name();
1446 return my.ahr.request_lib().name();
1451 'persist' : 'hidden width ordinal',
1452 'id' : 'request_lib_shortname',
1453 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1457 'render' : function(my) {
1458 if (Number(my.ahr.request_lib())>=0) {
1459 return data.hash.aou[ my.ahr.request_lib() ].shortname();
1461 return my.ahr.request_lib().shortname();
1467 'persist' : 'hidden width ordinal',
1468 'id' : 'request_timestamp',
1469 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1473 'render' : function(my) { return my.ahr.request_time().toString(); }
1476 'persist' : 'hidden width ordinal',
1477 'id' : 'request_time',
1478 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1482 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1485 'persist' : 'hidden width ordinal',
1486 'id' : 'available_timestamp',
1487 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1491 'render' : function(my) {
1492 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1493 return my.ahr.transit().dest_recv_time().toString();
1495 if (!my.ahr.transit() && my.ahr.capture_time()) {
1496 return my.ahr.capture_time().toString();
1502 'persist' : 'hidden width ordinal',
1503 'id' : 'available_time',
1504 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1508 'render' : function(my) {
1509 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1510 return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1512 if (!my.ahr.transit() && my.ahr.capture_time()) {
1513 return my.ahr.capture_time().toString().substr(0,10);
1519 'persist' : 'hidden width ordinal',
1520 'id' : 'capture_timestamp',
1521 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1525 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1528 'persist' : 'hidden width ordinal',
1529 'id' : 'capture_time',
1530 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1534 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1537 'persist' : 'hidden width ordinal',
1539 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1543 'render' : function(my) {
1544 switch (Number(my.status)) {
1546 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1549 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1552 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1555 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1558 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.5');
1567 'persist' : 'hidden width ordinal',
1569 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1573 'render' : function(my) { return my.ahr.hold_type(); }
1576 'persist' : 'hidden width ordinal',
1578 'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1582 'render' : function(my) {
1583 if (!get_bool( my.ahr.frozen() )) {
1584 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1586 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1591 'persist' : 'hidden width ordinal',
1593 'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1597 'render' : function(my) {
1598 if (my.ahr.thaw_date() == null) {
1599 return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1601 return my.ahr.thaw_date().substr(0,10);
1606 'persist' : 'hidden width ordinal',
1607 'id' : 'pickup_lib',
1608 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1612 'render' : function(my) {
1613 if (Number(my.ahr.pickup_lib())>=0) {
1614 return data.hash.aou[ my.ahr.pickup_lib() ].name();
1616 return my.ahr.pickup_lib().name();
1621 'persist' : 'hidden width ordinal',
1622 'id' : 'pickup_lib_shortname',
1623 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1627 'render' : function(my) {
1628 if (Number(my.ahr.pickup_lib())>=0) {
1629 return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1631 return my.ahr.pickup_lib().shortname();
1636 'persist' : 'hidden width ordinal',
1637 'id' : 'current_copy',
1638 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1642 'render' : function(my) {
1644 return my.acp.barcode();
1646 return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1651 'persist' : 'hidden width ordinal',
1652 'id' : 'current_copy_location',
1653 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1657 'render' : function(my) {
1658 if (!my.acp) { return ""; } else { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); }
1662 'persist' : 'hidden width ordinal',
1663 'id' : 'email_notify',
1664 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1668 'render' : function(my) {
1669 if (get_bool(my.ahr.email_notify())) {
1670 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1672 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1677 'persist' : 'hidden width ordinal',
1678 'id' : 'expire_time',
1679 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1683 'render' : function(my) { return my.ahr.expire_time(); }
1686 'persist' : 'hidden width ordinal',
1687 'id' : 'expire_date',
1688 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1692 'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
1695 'persist' : 'hidden width ordinal',
1696 'id' : 'fulfillment_time',
1697 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1701 'render' : function(my) { return my.ahr.fulfillment_time(); }
1704 'persist' : 'hidden width ordinal',
1705 'id' : 'holdable_formats',
1706 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1710 'render' : function(my) { return my.ahr.holdable_formats(); }
1713 'persist' : 'hidden width ordinal',
1715 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1719 'render' : function(my) { return my.ahr.id(); }
1722 'persist' : 'hidden width ordinal',
1723 'id' : 'phone_notify',
1724 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1728 'render' : function(my) { return my.ahr.phone_notify(); }
1731 'persist' : 'hidden width ordinal',
1732 'id' : 'prev_check_time',
1733 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1737 'render' : function(my) { return my.ahr.prev_check_time(); }
1740 'persist' : 'hidden width ordinal',
1742 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1746 'render' : function(my) { return my.ahr.requestor(); }
1749 'persist' : 'hidden width ordinal',
1750 'id' : 'selection_depth',
1751 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1755 'render' : function(my) { return my.ahr.selection_depth(); }
1758 'persist' : 'hidden width ordinal',
1760 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1764 'render' : function(my) { return my.ahr.target(); }
1767 'persist' : 'hidden width ordinal',
1769 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1773 'render' : function(my) { return my.ahr.usr(); }
1776 'persist' : 'hidden width ordinal',
1778 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1780 'sort_type' : 'title',
1783 'render' : function(my) {
1785 return my.mvr.title();
1787 return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1792 'persist' : 'hidden width ordinal',
1794 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1798 'render' : function(my) {
1800 return my.mvr.author();
1802 return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1807 'persist' : 'hidden width ordinal',
1809 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1813 'render' : function(my) { return my.mvr.edition(); }
1816 'persist' : 'hidden width ordinal',
1818 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1822 'render' : function(my) { return my.mvr.isbn(); }
1825 'persist' : 'hidden width ordinal',
1827 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1831 'render' : function(my) { return my.mvr.pubdate(); }
1834 'persist' : 'hidden width ordinal',
1836 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1840 'render' : function(my) { return my.mvr.publisher(); }
1843 'persist' : 'hidden width ordinal',
1845 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1849 'render' : function(my) { return my.mvr.tcn(); }
1852 'persist' : 'hidden width ordinal',
1853 'id' : 'notify_time',
1854 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1858 'render' : function(my) { return my.ahr.notify_time(); }
1861 'persist' : 'hidden width ordinal',
1862 'id' : 'notify_count',
1863 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1867 'render' : function(my) { return my.ahr.notify_count(); }
1870 'persist' : 'hidden width ordinal',
1871 'id' : 'transit_source',
1872 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1876 'render' : function(my) {
1877 if (my.ahr.transit()) {
1878 return data.hash.aou[ my.ahr.transit().source() ].shortname();
1885 'persist' : 'hidden width ordinal',
1886 'id' : 'transit_source_send_time',
1887 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1891 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; }
1894 'persist' : 'hidden width ordinal',
1895 'id' : 'transit_dest_lib',
1896 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1900 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1903 'persist' : 'hidden width ordinal',
1904 'id' : 'transit_dest_recv_time',
1905 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1909 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; }
1912 'persist' : 'hidden width ordinal',
1913 'id' : 'patron_barcode',
1914 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1918 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1921 'persist' : 'hidden width ordinal',
1922 'id' : 'patron_family_name',
1923 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1927 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1930 'persist' : 'hidden width ordinal',
1931 'id' : 'patron_first_given_name',
1932 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1936 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1939 'persist' : 'hidden width ordinal',
1940 'id' : 'callnumber',
1941 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1945 'render' : function(my) { return my.acn.label(); }
1948 'persist' : 'hidden width ordinal',
1949 'id' : 'total_holds',
1950 'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
1954 'render' : function(my) { return my.total_holds; }
1957 'persist' : 'hidden width ordinal',
1958 'id' : 'queue_position',
1959 'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
1963 'render' : function(my) { return my.queue_position; }
1966 'persist' : 'hidden width ordinal',
1967 'id' : 'potential_copies',
1968 'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
1972 'render' : function(my) { return my.potential_copies; }
1975 'persist' : 'hidden width ordinal',
1976 'id' : 'estimated_wait',
1977 'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
1981 'render' : function(my) { return my.estimated_wait; }
1984 'persist' : 'hidden width ordinal',
1986 'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
1990 'render' : function(my) { return my.ahrn_count; }
1993 'persist' : 'hidden width ordinal',
1994 'id' : 'staff_hold',
1995 'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
1999 'render' : function(my) {
2001 if (my.ahr.usr() != my.ahr.requestor()){
2002 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
2004 return document.getElementById('circStrings').getString('staff.circ.utils.no');
2009 for (var i = 0; i < c.length; i++) {
2010 if (modify[ c[i].id ]) {
2011 for (var j in modify[ c[i].id ]) {
2012 c[i][j] = modify[ c[i].id ][j];
2017 if (params.just_these) {
2018 JSAN.use('util.functional');
2020 for (var i = 0; i < params.just_these.length; i++) {
2021 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
2022 new_c.push( function(y){ return y; }( x ) );
2026 if (params.except_these) {
2027 JSAN.use('util.functional');
2029 for (var i = 0; i < c.length; i++) {
2030 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
2031 if (!x) new_c.push(c[i]);
2037 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
2040 circ.util.std_map_row_to_column = function(error_value) {
2041 return function(row,col) {
2042 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2043 // col contains one of the objects listed above in columns
2045 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
2047 JSAN.use('util.error'); obj.error = new util.error();
2048 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2049 JSAN.use('util.network'); obj.network = new util.network();
2050 JSAN.use('util.money');
2055 value = eval( col.render );
2057 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2058 if (error_value) value = error_value; else value = ' ';
2064 circ.util.std_map_row_to_columns = function(error_value) {
2065 return function(row,cols) {
2066 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2067 // cols contains all of the objects listed above in columns
2070 JSAN.use('util.error'); obj.error = new util.error();
2071 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2072 JSAN.use('util.network'); obj.network = new util.network();
2073 JSAN.use('util.money');
2079 for (var i = 0; i < cols.length; i++) {
2080 switch (typeof cols[i].render) {
2081 case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
2082 case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
2083 default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
2086 if (cmd) eval( cmd );
2088 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2089 if (error_value) { value = error_value; } else { value = ' ' };
2095 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
2097 JSAN.use('util.error'); var error = new util.error();
2098 JSAN.use('util.network'); var network = new util.network();
2099 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2100 JSAN.use('util.date'); JSAN.use('util.functional');
2102 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
2104 //var params = { 'barcode' : barcode };
2105 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
2107 if (typeof params.disable_textbox == 'function') {
2108 try { params.disable_textbox(); }
2109 catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2112 function checkin_callback(req) {
2114 var check = req.getResultObject();
2115 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
2116 if (typeof params.checkin_result == 'function') {
2117 try { params.checkin_result(r); }
2118 catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
2120 if (typeof async == 'function') async(check);
2123 JSAN.use('util.error'); var error = new util.error();
2124 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
2125 if (typeof params.enable_textbox == 'function') {
2126 try { params.enable_textbox(); }
2127 catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2133 var check = network.request(
2134 api.CHECKIN_VIA_BARCODE.app,
2135 api.CHECKIN_VIA_BARCODE.method,
2136 [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
2137 async ? checkin_callback : null,
2139 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
2140 'overridable_events' : [
2141 null /* custom event */,
2142 1203 /* COPY_BAD_STATUS */,
2143 1213 /* PATRON_BARRED */,
2144 1217 /* PATRON_INACTIVE */,
2145 1224 /* PATRON_ACCOUNT_EXPIRED */,
2146 1234 /* ITEM_DEPOSIT_PAID */,
2147 7009 /* CIRC_CLAIMS_RETURNED */,
2148 7010 /* COPY_ALERT_MESSAGE */,
2149 7011 /* COPY_STATUS_LOST */,
2150 7012 /* COPY_STATUS_MISSING */,
2151 7013 /* PATRON_EXCEEDS_FINES */,
2154 '1203' : function(r) {
2155 return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2157 '1234' : function(r) {
2158 return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2160 '7010' : function(r) {
2167 return checkin_callback( { 'getResultObject' : function() { return check; } } );
2172 JSAN.use('util.error'); var error = new util.error();
2173 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2174 if (typeof params.enable_textbox == 'function') {
2175 try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2181 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2183 JSAN.use('util.error'); var error = new util.error();
2184 JSAN.use('util.network'); var network = new util.network();
2185 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2186 JSAN.use('util.date');
2188 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
2190 check.message = check.textcode;
2192 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2193 if (check.payload && check.payload.record) { check.record = check.payload.record; }
2194 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2196 if (!check.route_to) { check.route_to = ' '; }
2198 if (document.getElementById('no_change_label')) {
2199 document.getElementById('no_change_label').setAttribute('value','');
2200 document.getElementById('no_change_label').setAttribute('hidden','true');
2204 network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
2205 JSAN.use('util.money');
2206 var bill = req.getResultObject();
2207 if (Number(bill.balance_owed()) == 0) { return; }
2208 if (document.getElementById('no_change_label')) {
2209 var m = document.getElementById('no_change_label').getAttribute('value');
2210 document.getElementById('no_change_label').setAttribute(
2212 m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + ' '
2214 document.getElementById('no_change_label').setAttribute('hidden','false');
2216 if (document.getElementById('fine_tally')) {
2217 var amount = Number( document.getElementById('fine_tally').getAttribute('amount') ) + Number( bill.balance_owed() );
2218 document.getElementById('fine_tally').setAttribute('amount',amount);
2219 document.getElementById('fine_tally').setAttribute(
2221 document.getElementById('circStrings').getFormattedString('staff.circ.utils.fine_tally_text', [ util.money.sanitize( amount ) ])
2223 document.getElementById('fine_tally').setAttribute('hidden','false');
2229 var print_list = [];
2235 'route_to_msg' : '',
2236 'route_to_org_fullname' : '',
2239 'city_state_zip' : '',
2245 'item_barcode' : '',
2246 'item_barcode_msg' : '',
2248 'item_title_msg' : '',
2250 'item_author_msg' : '',
2251 'hold_for_msg' : '',
2252 'hold_for_alias' : '',
2253 'hold_for_family_name' : '',
2254 'hold_for_first_given_name' : '',
2255 'hold_for_second_given_name' : '',
2256 'user_barcode' : '',
2257 'user_barcode_msg' : '',
2258 'notify_by_phone' : '',
2259 'notify_by_phone_msg' : '',
2260 'notify_by_email' : '',
2261 'notify_by_email_msg' : '',
2262 'request_date' : '',
2263 'request_date_msg' : '',
2265 'slip_date_msg' : ''
2268 if (check.payload && check.payload.cancelled_hold_transit) {
2269 print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2270 msg += print_data.cancelled;
2274 /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
2275 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2276 try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
2278 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
2279 print_data.error_msg += '\nFIXME: ' + E + '\n';
2280 msg += print_data.error_msg;
2282 if (check.ilsevent == 3 /* NO_CHANGE */) {
2283 //msg = 'This item is already checked in.\n';
2284 if (document.getElementById('no_change_label')) {
2285 var m = document.getElementById('no_change_label').getAttribute('value');
2286 document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + ' ');
2287 document.getElementById('no_change_label').setAttribute('hidden','false');
2290 if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2291 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2292 var err_msg = document.getElementById('commonStrings').getString('common.error');
2293 err_msg += '\nFIXME --';
2294 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2297 print_data.error_msg += err_msg;
2299 switch(Number(check.copy.status())) {
2300 case 0: /* AVAILABLE */
2301 case 7: /* RESHELVING */
2303 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2304 print_data.route_to = check.route_to;
2305 msg += print_data.route_to_msg;
2309 case 8: /* ON HOLDS SHELF */
2310 check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
2311 if (check.payload.hold) {
2312 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2313 var err_msg = document.getElementById('commonStrings').getString('common.error');
2314 err_msg += '\nFIXME: ';
2315 err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2318 print_data.error_msg += err_msg;
2320 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2321 print_data.route_to = check.route_to;
2322 var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
2323 if (behind_the_desk_support) {
2324 var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]);
2325 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
2326 print_data.prefer_behind_holds_desk = true;
2327 check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
2328 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2329 print_data.route_to = check.route_to;
2331 check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2332 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2333 print_data.route_to = check.route_to;
2336 msg += print_data.route_to_msg;
2340 var err_msg = document.getElementById('commonStrings').getString('common.error');
2341 err_msg += '\nFIXME: ';
2342 err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2345 print_data.error_msg += err_msg;
2347 JSAN.use('util.date');
2348 if (check.payload.hold) {
2349 JSAN.use('patron.util');
2351 print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2352 print_data.item_barcode = check.payload.copy.barcode();
2353 msg += print_data.item_barcode_msg;
2355 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2356 print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2357 print_data.item_title = payload_title;
2358 msg += print_data.item_title_msg;
2360 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2361 print_data.user = au_obj;
2363 if (au_obj.alias()) {
2364 print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias', [au_obj.alias()]);
2365 print_data.hold_for_alias = au_obj.alias();
2366 msg += print_data.hold_for_msg;
2368 print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name() ? au_obj.family_name() : '', au_obj.first_given_name() ? au_obj.first_given_name() : '', au_obj.second_given_name() ? au_obj.second_given_name() : '']);
2369 msg += print_data.hold_for_msg;
2370 print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2371 print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2372 print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2375 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2376 print_data.user_barcode = au_obj.card().barcode();
2377 msg += print_data.user_barcode_msg;
2379 if (check.payload.hold.phone_notify()) {
2380 print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2381 print_data.notify_by_phone = check.payload.hold.phone_notify();
2382 msg += print_data.notify_by_phone_msg;
2385 if (get_bool(check.payload.hold.email_notify())) {
2386 var payload_email = au_obj.email() ? au_obj.email() : '';
2387 print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2388 print_data.notify_by_email = payload_email;
2389 msg += print_data.notify_by_email_msg;
2393 var notes = check.payload.hold.notes();
2394 print_data.notes_raw = notes;
2395 for (var i = 0; i < notes.length; i++) {
2396 if ( get_bool( notes[i].slip() ) ) {
2398 if ( get_bool( notes[i].staff() ) ) {
2399 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2401 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2403 msg += temp_msg + '\n';
2406 'formatted_note' : temp_msg,
2407 'note_title' : notes[i].title(),
2408 'note_body' : notes[i].body(),
2409 'note_public' : notes[i].pub(),
2410 'note_by_staff' : notes[i].staff()
2417 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2418 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2419 msg += print_data.request_date_msg;
2423 var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2424 if (no_print_prompting) {
2425 if (no_print_prompting.indexOf( "Hold Slip" ) > -1) {
2426 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2429 print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2430 print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2431 msg += print_data.slip_date_msg;
2433 print_data.payload = check.payload;
2436 rv = error.yns_alert_formatted(
2438 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2439 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2440 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2442 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2443 '/xul/server/skin/media/images/turtle.gif'
2448 JSAN.use('util.print'); var print = new util.print();
2449 var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2451 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2452 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2454 var template = 'hold_slip';
2456 'patron' : print_data.user,
2457 'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
2458 'staff' : data.list.au[0],
2459 'header' : data.print_list_templates[ template ].header,
2460 'line_item' : data.print_list_templates[ template ].line_item,
2461 'footer' : data.print_list_templates[ template ].footer,
2462 'type' : data.print_list_templates[ template ].type,
2463 'list' : print_list,
2466 print.tree_list( params );
2469 var err_msg = document.getElementById('commonStrings').getString('common.error');
2470 err_msg += '\nFIXME: ' + E + '\n';
2476 if (document.getElementById('no_change_label')) {
2477 var m = document.getElementById('no_change_label').getAttribute('value');
2478 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2479 document.getElementById('no_change_label').setAttribute('value', m);
2480 document.getElementById('no_change_label').setAttribute('hidden','false');
2483 case 6: /* IN TRANSIT */
2484 check.route_to = 'TRANSIT SHELF??';
2485 print_data.route_to;
2486 var err_msg = document.getElementById('commonStrings').getString('common.error');
2487 err_msg += "\nFIXME -- I didn't think we could get here.\n";
2488 print_data.error_msg += err_msg;
2491 case 11: /* CATALOGING */
2492 check.route_to = 'CATALOGING';
2493 print_data.route_to;
2494 if (document.getElementById('do_not_alert_on_precat')) {
2495 var x = document.getElementById('do_not_alert_on_precat');
2497 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2498 msg += print_data.route_to_msg;
2501 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2502 msg += print_data.route_to_msg;
2504 if (document.getElementById('no_change_label')) {
2505 var m = document.getElementById('no_change_label').getAttribute('value');
2506 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2507 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + ' ');
2508 document.getElementById('no_change_label').setAttribute('hidden','false');
2512 msg += document.getElementById('commonStrings').getString('common.error');
2513 var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2515 var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2516 print_data.error_msg += error_msg;
2519 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2520 msg += print_data.route_to_msg;
2526 document.getElementById('circStrings').getString('staff.circ.alert'),
2528 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2530 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2533 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2535 var lib = data.hash.aou[ check.org ];
2536 check.route_to = lib.shortname();
2537 print_data.route_to = check.route_to;
2538 print_data.route_to_org = lib;
2539 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2540 print_data.route_to_org_fullname = lib.name();
2541 msg += print_data.route_to_msg;
2546 if (lib.holds_address() ) {
2547 var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2548 if (typeof a.ilsevent != 'undefined') throw(a);
2549 if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
2550 if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
2551 print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
2552 print_data.city = a.city();
2553 print_data.state = a.state();
2554 print_data.county = a.county();
2555 print_data.country = a.country();
2556 print_data.post_code = a.post_code();
2557 msg += print_data.city_state_zip + '\n';
2559 print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2560 print_data.no_address = true;
2561 msg += print_data.street1;
2565 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2566 print_data.error_msg += err_msg + '\n';
2567 msg += err_msg + '\n';
2568 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2571 print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2572 print_data.item_barcode = check.payload.copy.barcode();
2573 msg += print_data.item_barcode_msg;
2575 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2576 print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2577 print_data.item_title = payload_title;
2578 msg += print_data.item_title_msg;
2580 var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2581 print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2582 print_data.item_author = payload_author;
2583 msg += print_data.item_author_msg;
2585 JSAN.use('util.date');
2586 if (check.payload.hold) {
2587 JSAN.use('patron.util');
2588 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2589 print_data.user = au_obj;
2591 if (au_obj.alias()) {
2592 print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias', [au_obj.alias()]);
2593 print_data.hold_for_alias = au_obj.alias();
2594 msg += print_data.hold_for_msg;
2596 print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name() ? au_obj.family_name() : '', au_obj.first_given_name() ? au_obj.first_given_name() : '', au_obj.second_given_name() ? au_obj.second_given_name() : '']);
2597 msg += print_data.hold_for_msg;
2598 print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2599 print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2600 print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2603 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2604 print_data.user_barcode = au_obj.card().barcode();
2605 msg += print_data.user_barcode_msg;
2607 if (check.payload.hold.phone_notify()) {
2608 print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2609 print_data.notify_by_phone = check.payload.hold.phone_notify();
2610 msg += print_data.notify_by_phone_msg;
2613 if (get_bool(check.payload.hold.email_notify())) {
2614 var payload_email = au_obj.email() ? au_obj.email() : '';
2615 print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2616 print_data.notify_by_email = payload_email;
2617 msg += print_data.notify_by_email_msg;
2621 var notes = check.payload.hold.notes();
2622 print_data.notes_raw = notes;
2623 for (var i = 0; i < notes.length; i++) {
2624 if ( get_bool( notes[i].slip() ) ) {
2626 if ( get_bool( notes[i].staff() ) ) {
2627 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2629 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2631 msg += temp_msg + '\n';
2634 'formatted_note' : temp_msg,
2635 'note_title' : notes[i].title(),
2636 'note_body' : notes[i].body(),
2637 'note_public' : notes[i].pub(),
2638 'note_by_staff' : notes[i].staff()
2645 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2646 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2647 msg += print_data.request_date_msg;
2651 var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2652 if (no_print_prompting) {
2653 if (no_print_prompting.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) {
2654 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2657 print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2658 print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2659 msg += print_data.slip_date_msg;
2660 print_data.payload = check.payload;
2663 rv = error.yns_alert_formatted(
2665 document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
2666 document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
2667 document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
2669 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2670 '/xul/server/skin/media/images/turtle.gif'
2675 JSAN.use('util.print'); var print = new util.print();
2676 var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2678 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2679 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2681 var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
2683 'patron' : print_data.user,
2684 'lib' : data.hash.aou[ check.payload.hold ? check.payload.hold.pickup_lib() : check.payload.transit.source() ],
2685 'staff' : data.list.au[0],
2686 'header' : data.print_list_templates[ template ].header,
2687 'line_item' : data.print_list_templates[ template ].line_item,
2688 'footer' : data.print_list_templates[ template ].footer,
2689 'type' : data.print_list_templates[ template ].type,
2690 'list' : print_list,
2693 print.tree_list( params );
2696 var err_msg = document.getElementById('commonStrings').getString('common.error');
2697 err_msg += '\nFIXME: ' + E + '\n';
2702 if (document.getElementById('no_change_label')) {
2703 var m = document.getElementById('no_change_label').getAttribute('value');
2704 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2705 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + ' ');
2706 document.getElementById('no_change_label').setAttribute('hidden','false');
2709 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2711 check.route_to = 'CATALOGING';
2712 var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2715 document.getElementById('circStrings').getString('staff.circ.alert'),
2717 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2719 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2721 if (document.getElementById('no_change_label')) {
2722 var m = document.getElementById('no_change_label').getAttribute('value');
2723 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' ');
2724 document.getElementById('no_change_label').setAttribute('hidden','false');
2727 } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
2730 msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
2731 rv = error.yns_alert_formatted(
2733 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
2734 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
2735 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
2737 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2738 '/xul/server/skin/media/images/stop_sign.png'
2740 params.capture = rv == 0 ? 'nocapture' : 'capture';
2742 return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
2744 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2745 error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2748 if (check.ilsevent == null) { return null; /* handled */ }
2749 switch (Number(check.ilsevent)) {
2750 case 1203 /* COPY_BAD_STATUS */ :
2751 case 1213 /* PATRON_BARRED */ :
2752 case 1217 /* PATRON_INACTIVE */ :
2753 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2754 case 1234 /* ITEM_DEPOSIT_PAID */ :
2755 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2756 case 7010 /* COPY_ALERT_MESSAGE */ :
2757 case 7011 /* COPY_STATUS_LOST */ :
2758 case 7012 /* COPY_STATUS_MISSING */ :
2759 case 7013 /* PATRON_EXCEEDS_FINES */ :
2760 return null; /* handled */
2770 JSAN.use('util.error'); var error = new util.error();
2771 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
2776 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2779 JSAN.use('util.network'); obj.network = new util.network();
2780 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2782 var params = { barcode: barcode };
2783 if (patron_id) params.patron = patron_id;
2785 function renew_callback(req) {
2787 var renew = req.getResultObject();
2788 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2789 for (var j = 0; j < renew.length; j++) {
2790 switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
2791 case 0 /* SUCCESS */ : break;
2792 case null /* custom event */ : break;
2793 case 5000 /* PERM_FAILURE */: break;
2794 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2795 case 1213 /* PATRON_BARRED */ : break;
2796 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2797 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2798 case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
2799 case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
2800 case 1234 /* ITEM_DEPOSIT_PAID */ : break;
2801 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2802 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2803 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2804 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2805 case 7006 /* COPY_IS_REFERENCE */ : break;
2806 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2807 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2808 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2809 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2810 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2816 if (typeof async == 'function') async(renew);
2819 JSAN.use('util.error'); var error = new util.error();
2820 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2825 var renew = obj.network.simple_request(
2828 async ? renew_callback : null,
2830 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
2831 'overridable_events' : [
2832 null /* custom event */,
2833 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2834 1213 /* PATRON_BARRED */,
2835 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2836 1232 /* ITEM_DEPOSIT_REQUIRED */,
2837 1233 /* ITEM_RENTAL_FEE_REQUIRED */,
2838 1234 /* ITEM_DEPOSIT_PAID */,
2839 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2840 7003 /* COPY_CIRC_NOT_ALLOWED */,
2841 7004 /* COPY_NOT_AVAILABLE */,
2842 7006 /* COPY_IS_REFERENCE */,
2843 7007 /* COPY_NEEDED_FOR_HOLD */,
2844 7008 /* MAX_RENEWALS_REACHED */,
2845 7009 /* CIRC_CLAIMS_RETURNED */,
2846 7010 /* COPY_ALERT_MESSAGE */,
2847 7013 /* PATRON_EXCEEDS_FINES */,
2850 '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2851 '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2852 '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2853 '1232' : function(r) {
2854 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [barcode]);
2856 '1233' : function(r) {
2857 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [barcode]);
2859 '1234' : function(r) {
2860 return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2862 '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2863 '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2864 '7004' : function(r) {
2865 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [barcode, typeof r.payload.status() == 'object' ? r.payload.status().name() : obj.data.hash.ccs[ r.payload.status() ].name()]);
2867 '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2868 '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2869 '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2870 '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2871 '7010' : function(r) {
2872 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2874 '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2879 return renew_callback( { 'getResultObject' : function() { return renew; } } );
2883 JSAN.use('util.error'); var error = new util.error();
2884 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2889 dump('exiting circ/util.js\n');