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.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 for (var i = 0; i < c.length; i++) {
1172 if (modify[ c[i].id ]) {
1173 for (var j in modify[ c[i].id ]) {
1174 c[i][j] = modify[ c[i].id ][j];
1179 if (params.just_these) {
1180 JSAN.use('util.functional');
1182 for (var i = 0; i < params.just_these.length; i++) {
1183 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1184 new_c.push( function(y){ return y; }( x ) );
1188 if (params.except_these) {
1189 JSAN.use('util.functional');
1191 for (var i = 0; i < c.length; i++) {
1192 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1193 if (!x) new_c.push(c[i]);
1198 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1201 circ.util.work_log_columns = function(modify,params) {
1203 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1207 'persist' : 'hidden width ordinal',
1209 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.message'),
1213 'render' : function(my) { return my.message; }
1216 'persist' : 'hidden width ordinal',
1218 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.when'),
1222 'render' : function(my) { return String( my.when ); }
1226 for (var i = 0; i < c.length; i++) {
1227 if (modify[ c[i].id ]) {
1228 for (var j in modify[ c[i].id ]) {
1229 c[i][j] = modify[ c[i].id ][j];
1234 if (params.just_these) {
1235 JSAN.use('util.functional');
1237 for (var i = 0; i < params.just_these.length; i++) {
1238 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1239 new_c.push( function(y){ return y; }( x ) );
1243 if (params.except_these) {
1244 JSAN.use('util.functional');
1246 for (var i = 0; i < c.length; i++) {
1247 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1248 if (!x) new_c.push(c[i]);
1254 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1257 circ.util.transit_columns = function(modify,params) {
1259 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1263 'persist' : 'hidden width ordinal',
1264 'id' : 'transit_item_barcode',
1265 'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1269 'render' : function(my) { return my.acp.barcode(); }
1272 'persist' : 'hidden width ordinal',
1273 'id' : 'transit_item_title',
1274 'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1278 'render' : function(my) {
1279 try { return my.mvr.title(); }
1280 catch(E) { return my.acp.dummy_title(); }
1284 'persist' : 'hidden width ordinal',
1285 'id' : 'transit_item_author',
1286 'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1290 'render' : function(my) {
1291 try { return my.mvr.author(); }
1292 catch(E) { return my.acp.dummy_author(); }
1296 'persist' : 'hidden width ordinal',
1297 'id' : 'transit_item_callnumber',
1298 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1302 'render' : function(my) { return my.acn.label(); }
1305 'persist' : 'hidden width ordinal',
1306 'id' : 'transit_id',
1307 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1311 'render' : function(my) { return my.atc.id(); }
1314 'persist' : 'hidden width ordinal',
1315 'id' : 'transit_source',
1316 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1320 'render' : function(my) {
1321 if (typeof my.atc.source() == "object") {
1322 return my.atc.source().shortname();
1324 return data.hash.aou[ my.atc.source() ].shortname();
1329 'persist' : 'hidden width ordinal',
1330 'id' : 'transit_source_send_time',
1331 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1335 'render' : function(my) { return my.atc.source_send_time(); }
1338 'persist' : 'hidden width ordinal',
1339 'id' : 'transit_dest_lib',
1340 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1344 'render' : function(my) {
1345 if (typeof my.atc.dest() == "object") {
1346 return my.atc.dest().shortname();
1348 return data.hash.aou[ my.atc.dest() ].shortname();
1353 'persist' : 'hidden width ordinal',
1354 'id' : 'transit_dest_recv_time',
1355 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1359 'render' : function(my) { return my.atc.dest_recv_time(); }
1362 'persist' : 'hidden width ordinal',
1363 'id' : 'transit_target_copy',
1364 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1368 'render' : function(my) { return my.atc.target_copy(); }
1371 for (var i = 0; i < c.length; i++) {
1372 if (modify[ c[i].id ]) {
1373 for (var j in modify[ c[i].id ]) {
1374 c[i][j] = modify[ c[i].id ][j];
1379 if (params.just_these) {
1380 JSAN.use('util.functional');
1382 for (var i = 0; i < params.just_these.length; i++) {
1383 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1384 new_c.push( function(y){ return y; }( x ) );
1388 if (params.except_these) {
1389 JSAN.use('util.functional');
1391 for (var i = 0; i < c.length; i++) {
1392 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1393 if (!x) new_c.push(c[i]);
1399 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1402 circ.util.hold_columns = function(modify,params) {
1404 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1408 'persist' : 'hidden width ordinal',
1409 'id' : 'request_lib',
1410 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1414 'render' : function(my) {
1415 if (Number(my.ahr.request_lib())>=0) {
1416 return data.hash.aou[ my.ahr.request_lib() ].name();
1418 return my.ahr.request_lib().name();
1423 'persist' : 'hidden width ordinal',
1424 'id' : 'request_lib_shortname',
1425 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1429 'render' : function(my) {
1430 if (Number(my.ahr.request_lib())>=0) {
1431 return data.hash.aou[ my.ahr.request_lib() ].shortname();
1433 return my.ahr.request_lib().shortname();
1439 'persist' : 'hidden width ordinal',
1440 'id' : 'request_timestamp',
1441 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1445 'render' : function(my) { return my.ahr.request_time().toString(); }
1448 'persist' : 'hidden width ordinal',
1449 'id' : 'request_time',
1450 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1454 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1457 'persist' : 'hidden width ordinal',
1458 'id' : 'available_timestamp',
1459 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1463 'render' : function(my) {
1464 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1465 return my.ahr.transit().dest_recv_time().toString();
1467 if (!my.ahr.transit() && my.ahr.capture_time()) {
1468 return my.ahr.capture_time().toString();
1474 'persist' : 'hidden width ordinal',
1475 'id' : 'available_time',
1476 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1480 'render' : function(my) {
1481 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1482 return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1484 if (!my.ahr.transit() && my.ahr.capture_time()) {
1485 return my.ahr.capture_time().toString().substr(0,10);
1491 'persist' : 'hidden width ordinal',
1492 'id' : 'capture_timestamp',
1493 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1497 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1500 'persist' : 'hidden width ordinal',
1501 'id' : 'capture_time',
1502 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1506 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1509 'persist' : 'hidden width ordinal',
1511 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1515 'render' : function(my) {
1516 switch (Number(my.status)) {
1518 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1521 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1524 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1527 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1530 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.5');
1539 'persist' : 'hidden width ordinal',
1541 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1545 'render' : function(my) { return my.ahr.hold_type(); }
1548 'persist' : 'hidden width ordinal',
1550 'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1554 'render' : function(my) {
1555 if (!get_bool( my.ahr.frozen() )) {
1556 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1558 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1563 'persist' : 'hidden width ordinal',
1565 'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1569 'render' : function(my) {
1570 if (my.ahr.thaw_date() == null) {
1571 return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1573 return my.ahr.thaw_date().substr(0,10);
1578 'persist' : 'hidden width ordinal',
1579 'id' : 'pickup_lib',
1580 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1584 'render' : function(my) {
1585 if (Number(my.ahr.pickup_lib())>=0) {
1586 return data.hash.aou[ my.ahr.pickup_lib() ].name();
1588 return my.ahr.pickup_lib().name();
1593 'persist' : 'hidden width ordinal',
1594 'id' : 'pickup_lib_shortname',
1595 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1599 'render' : function(my) {
1600 if (Number(my.ahr.pickup_lib())>=0) {
1601 return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1603 return my.ahr.pickup_lib().shortname();
1608 'persist' : 'hidden width ordinal',
1609 'id' : 'current_copy',
1610 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1614 'render' : function(my) {
1616 return my.acp.barcode();
1618 return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1623 'persist' : 'hidden width ordinal',
1624 'id' : 'current_copy_location',
1625 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1629 'render' : function(my) {
1630 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(); }
1634 'persist' : 'hidden width ordinal',
1635 'id' : 'email_notify',
1636 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1640 'render' : function(my) {
1641 if (get_bool(my.ahr.email_notify())) {
1642 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1644 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1649 'persist' : 'hidden width ordinal',
1650 'id' : 'expire_time',
1651 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1655 'render' : function(my) { return my.ahr.expire_time(); }
1658 'persist' : 'hidden width ordinal',
1659 'id' : 'expire_date',
1660 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1664 'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
1667 'persist' : 'hidden width ordinal',
1668 'id' : 'fulfillment_time',
1669 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1673 'render' : function(my) { return my.ahr.fulfillment_time(); }
1676 'persist' : 'hidden width ordinal',
1677 'id' : 'holdable_formats',
1678 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1682 'render' : function(my) { return my.ahr.holdable_formats(); }
1685 'persist' : 'hidden width ordinal',
1687 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1691 'render' : function(my) { return my.ahr.id(); }
1694 'persist' : 'hidden width ordinal',
1695 'id' : 'phone_notify',
1696 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1700 'render' : function(my) { return my.ahr.phone_notify(); }
1703 'persist' : 'hidden width ordinal',
1704 'id' : 'prev_check_time',
1705 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1709 'render' : function(my) { return my.ahr.prev_check_time(); }
1712 'persist' : 'hidden width ordinal',
1714 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1718 'render' : function(my) { return my.ahr.requestor(); }
1721 'persist' : 'hidden width ordinal',
1722 'id' : 'selection_depth',
1723 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1727 'render' : function(my) { return my.ahr.selection_depth(); }
1730 'persist' : 'hidden width ordinal',
1732 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1736 'render' : function(my) { return my.ahr.target(); }
1739 'persist' : 'hidden width ordinal',
1741 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1745 'render' : function(my) { return my.ahr.usr(); }
1748 'persist' : 'hidden width ordinal',
1750 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1752 'sort_type' : 'title',
1755 'render' : function(my) {
1757 return my.mvr.title();
1759 return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1764 'persist' : 'hidden width ordinal',
1766 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1770 'render' : function(my) {
1772 return my.mvr.author();
1774 return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1779 'persist' : 'hidden width ordinal',
1781 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1785 'render' : function(my) { return my.mvr.edition(); }
1788 'persist' : 'hidden width ordinal',
1790 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1794 'render' : function(my) { return my.mvr.isbn(); }
1797 'persist' : 'hidden width ordinal',
1799 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1803 'render' : function(my) { return my.mvr.pubdate(); }
1806 'persist' : 'hidden width ordinal',
1808 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1812 'render' : function(my) { return my.mvr.publisher(); }
1815 'persist' : 'hidden width ordinal',
1817 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1821 'render' : function(my) { return my.mvr.tcn(); }
1824 'persist' : 'hidden width ordinal',
1825 'id' : 'notify_time',
1826 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1830 'render' : function(my) { return my.ahr.notify_time(); }
1833 'persist' : 'hidden width ordinal',
1834 'id' : 'notify_count',
1835 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1839 'render' : function(my) { return my.ahr.notify_count(); }
1842 'persist' : 'hidden width ordinal',
1843 'id' : 'transit_source',
1844 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1848 'render' : function(my) {
1849 if (my.ahr.transit()) {
1850 return data.hash.aou[ my.ahr.transit().source() ].shortname();
1857 'persist' : 'hidden width ordinal',
1858 'id' : 'transit_source_send_time',
1859 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1863 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; }
1866 'persist' : 'hidden width ordinal',
1867 'id' : 'transit_dest_lib',
1868 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1872 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1875 'persist' : 'hidden width ordinal',
1876 'id' : 'transit_dest_recv_time',
1877 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1881 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; }
1884 'persist' : 'hidden width ordinal',
1885 'id' : 'patron_barcode',
1886 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1890 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1893 'persist' : 'hidden width ordinal',
1894 'id' : 'patron_family_name',
1895 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1899 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1902 'persist' : 'hidden width ordinal',
1903 'id' : 'patron_first_given_name',
1904 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1908 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1911 'persist' : 'hidden width ordinal',
1912 'id' : 'callnumber',
1913 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1917 'render' : function(my) { return my.acn.label(); }
1920 'persist' : 'hidden width ordinal',
1921 'id' : 'total_holds',
1922 'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
1926 'render' : function(my) { return my.total_holds; }
1929 'persist' : 'hidden width ordinal',
1930 'id' : 'queue_position',
1931 'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
1935 'render' : function(my) { return my.queue_position; }
1938 'persist' : 'hidden width ordinal',
1939 'id' : 'potential_copies',
1940 'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
1944 'render' : function(my) { return my.potential_copies; }
1947 'persist' : 'hidden width ordinal',
1948 'id' : 'estimated_wait',
1949 'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
1953 'render' : function(my) { return my.estimated_wait; }
1956 'persist' : 'hidden width ordinal',
1958 'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
1962 'render' : function(my) { return my.ahrn_count; }
1965 'persist' : 'hidden width ordinal',
1966 'id' : 'staff_hold',
1967 'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
1971 'render' : function(my) {
1973 if (my.ahr.usr() != my.ahr.requestor()){
1974 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1976 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1981 for (var i = 0; i < c.length; i++) {
1982 if (modify[ c[i].id ]) {
1983 for (var j in modify[ c[i].id ]) {
1984 c[i][j] = modify[ c[i].id ][j];
1989 if (params.just_these) {
1990 JSAN.use('util.functional');
1992 for (var i = 0; i < params.just_these.length; i++) {
1993 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1994 new_c.push( function(y){ return y; }( x ) );
1998 if (params.except_these) {
1999 JSAN.use('util.functional');
2001 for (var i = 0; i < c.length; i++) {
2002 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
2003 if (!x) new_c.push(c[i]);
2009 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
2012 circ.util.std_map_row_to_column = function(error_value) {
2013 return function(row,col) {
2014 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2015 // col contains one of the objects listed above in columns
2017 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
2019 JSAN.use('util.error'); obj.error = new util.error();
2020 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2021 JSAN.use('util.network'); obj.network = new util.network();
2022 JSAN.use('util.money');
2027 value = eval( col.render );
2029 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2030 if (error_value) value = error_value; else value = ' ';
2036 circ.util.std_map_row_to_columns = function(error_value) {
2037 return function(row,cols) {
2038 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
2039 // cols contains all of the objects listed above in columns
2042 JSAN.use('util.error'); obj.error = new util.error();
2043 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
2044 JSAN.use('util.network'); obj.network = new util.network();
2045 JSAN.use('util.money');
2051 for (var i = 0; i < cols.length; i++) {
2052 switch (typeof cols[i].render) {
2053 case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
2054 case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
2055 default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
2058 if (cmd) eval( cmd );
2060 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
2061 if (error_value) { value = error_value; } else { value = ' ' };
2067 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
2069 JSAN.use('util.error'); var error = new util.error();
2070 JSAN.use('util.network'); var network = new util.network();
2071 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2072 JSAN.use('util.date'); JSAN.use('util.functional');
2074 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
2076 //var params = { 'barcode' : barcode };
2077 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
2079 if (typeof params.disable_textbox == 'function') {
2080 try { params.disable_textbox(); }
2081 catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2084 function checkin_callback(req) {
2086 var check = req.getResultObject();
2087 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
2088 if (typeof params.checkin_result == 'function') {
2089 try { params.checkin_result(r); }
2090 catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
2092 if (typeof async == 'function') async(check);
2095 JSAN.use('util.error'); var error = new util.error();
2096 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
2097 if (typeof params.enable_textbox == 'function') {
2098 try { params.enable_textbox(); }
2099 catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2105 var check = network.request(
2106 api.CHECKIN_VIA_BARCODE.app,
2107 api.CHECKIN_VIA_BARCODE.method,
2108 [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
2109 async ? checkin_callback : null,
2111 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
2112 'overridable_events' : [
2113 null /* custom event */,
2114 1203 /* COPY_BAD_STATUS */,
2115 1213 /* PATRON_BARRED */,
2116 1217 /* PATRON_INACTIVE */,
2117 1224 /* PATRON_ACCOUNT_EXPIRED */,
2118 1234 /* ITEM_DEPOSIT_PAID */,
2119 7009 /* CIRC_CLAIMS_RETURNED */,
2120 7010 /* COPY_ALERT_MESSAGE */,
2121 7011 /* COPY_STATUS_LOST */,
2122 7012 /* COPY_STATUS_MISSING */,
2123 7013 /* PATRON_EXCEEDS_FINES */,
2126 '1203' : function(r) {
2127 return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
2129 '1234' : function(r) {
2130 return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2132 '7010' : function(r) {
2139 return checkin_callback( { 'getResultObject' : function() { return check; } } );
2144 JSAN.use('util.error'); var error = new util.error();
2145 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
2146 if (typeof params.enable_textbox == 'function') {
2147 try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
2153 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
2155 JSAN.use('util.error'); var error = new util.error();
2156 JSAN.use('util.network'); var network = new util.network();
2157 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
2158 JSAN.use('util.date');
2160 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
2162 check.message = check.textcode;
2164 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
2165 if (check.payload && check.payload.record) { check.record = check.payload.record; }
2166 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
2168 if (!check.route_to) { check.route_to = ' '; }
2170 if (document.getElementById('no_change_label')) {
2171 document.getElementById('no_change_label').setAttribute('value','');
2172 document.getElementById('no_change_label').setAttribute('hidden','true');
2176 network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
2177 JSAN.use('util.money');
2178 var bill = req.getResultObject();
2179 if (Number(bill.balance_owed()) == 0) { return; }
2180 if (document.getElementById('no_change_label')) {
2181 var m = document.getElementById('no_change_label').getAttribute('value');
2182 document.getElementById('no_change_label').setAttribute(
2184 m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + ' '
2186 document.getElementById('no_change_label').setAttribute('hidden','false');
2188 if (document.getElementById('fine_tally')) {
2189 var amount = Number( document.getElementById('fine_tally').getAttribute('amount') ) + Number( bill.balance_owed() );
2190 document.getElementById('fine_tally').setAttribute('amount',amount);
2191 document.getElementById('fine_tally').setAttribute(
2193 document.getElementById('circStrings').getFormattedString('staff.circ.utils.fine_tally_text', [ util.money.sanitize( amount ) ])
2195 document.getElementById('fine_tally').setAttribute('hidden','false');
2201 var print_list = [];
2207 'route_to_msg' : '',
2208 'route_to_org_fullname' : '',
2211 'city_state_zip' : '',
2217 'item_barcode' : '',
2218 'item_barcode_msg' : '',
2220 'item_title_msg' : '',
2222 'item_author_msg' : '',
2223 'hold_for_msg' : '',
2224 'hold_for_alias' : '',
2225 'hold_for_family_name' : '',
2226 'hold_for_first_given_name' : '',
2227 'hold_for_second_given_name' : '',
2228 'user_barcode' : '',
2229 'user_barcode_msg' : '',
2230 'notify_by_phone' : '',
2231 'notify_by_phone_msg' : '',
2232 'notify_by_email' : '',
2233 'notify_by_email_msg' : '',
2234 'request_date' : '',
2235 'request_date_msg' : '',
2237 'slip_date_msg' : ''
2240 if (check.payload && check.payload.cancelled_hold_transit) {
2241 print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
2242 msg += print_data.cancelled;
2246 /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
2247 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
2248 try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
2250 print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
2251 print_data.error_msg += '\nFIXME: ' + E + '\n';
2252 msg += print_data.error_msg;
2254 if (check.ilsevent == 3 /* NO_CHANGE */) {
2255 //msg = 'This item is already checked in.\n';
2256 if (document.getElementById('no_change_label')) {
2257 var m = document.getElementById('no_change_label').getAttribute('value');
2258 document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + ' ');
2259 document.getElementById('no_change_label').setAttribute('hidden','false');
2262 if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2263 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2264 var err_msg = document.getElementById('commonStrings').getString('common.error');
2265 err_msg += '\nFIXME --';
2266 err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2269 print_data.error_msg += err_msg;
2271 switch(Number(check.copy.status())) {
2272 case 0: /* AVAILABLE */
2273 case 7: /* RESHELVING */
2275 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2276 print_data.route_to = check.route_to;
2277 msg += print_data.route_to_msg;
2281 case 8: /* ON HOLDS SHELF */
2282 check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
2283 if (check.payload.hold) {
2284 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2285 var err_msg = document.getElementById('commonStrings').getString('common.error');
2286 err_msg += '\nFIXME: ';
2287 err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2290 print_data.error_msg += err_msg;
2292 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2293 print_data.route_to = check.route_to;
2294 var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
2295 if (behind_the_desk_support) {
2296 var usr_settings = network.simple_request('FM_AUS_RETRIEVE',[ses(),check.payload.hold.usr()]);
2297 if (typeof usr_settings['circ.holds_behind_desk'] != 'undefined') {
2298 print_data.prefer_behind_holds_desk = true;
2299 check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.private_hold_shelf');
2300 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2301 print_data.route_to = check.route_to;
2303 check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.public_hold_shelf');
2304 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2305 print_data.route_to = check.route_to;
2308 msg += print_data.route_to_msg;
2312 var err_msg = document.getElementById('commonStrings').getString('common.error');
2313 err_msg += '\nFIXME: ';
2314 err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2317 print_data.error_msg += err_msg;
2319 JSAN.use('util.date');
2320 if (check.payload.hold) {
2321 JSAN.use('patron.util');
2323 print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2324 print_data.item_barcode = check.payload.copy.barcode();
2325 msg += print_data.item_barcode_msg;
2327 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2328 print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2329 print_data.item_title = payload_title;
2330 msg += print_data.item_title_msg;
2332 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2333 print_data.user = au_obj;
2335 if (au_obj.alias()) {
2336 print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias', [au_obj.alias()]);
2337 print_data.hold_for_alias = au_obj.alias();
2338 msg += print_data.hold_for_msg;
2340 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() : '']);
2341 msg += print_data.hold_for_msg;
2342 print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2343 print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2344 print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2347 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2348 print_data.user_barcode = au_obj.card().barcode();
2349 msg += print_data.user_barcode_msg;
2351 if (check.payload.hold.phone_notify()) {
2352 print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2353 print_data.notify_by_phone = check.payload.hold.phone_notify();
2354 msg += print_data.notify_by_phone_msg;
2357 if (get_bool(check.payload.hold.email_notify())) {
2358 var payload_email = au_obj.email() ? au_obj.email() : '';
2359 print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2360 print_data.notify_by_email = payload_email;
2361 msg += print_data.notify_by_email_msg;
2365 var notes = check.payload.hold.notes();
2366 print_data.notes_raw = notes;
2367 for (var i = 0; i < notes.length; i++) {
2368 if ( get_bool( notes[i].slip() ) ) {
2370 if ( get_bool( notes[i].staff() ) ) {
2371 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2373 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2375 msg += temp_msg + '\n';
2378 'formatted_note' : temp_msg,
2379 'note_title' : notes[i].title(),
2380 'note_body' : notes[i].body(),
2381 'note_public' : notes[i].pub(),
2382 'note_by_staff' : notes[i].staff()
2389 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2390 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2391 msg += print_data.request_date_msg;
2395 var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2396 if (no_print_prompting) {
2397 if (no_print_prompting.indexOf( "Hold Slip" ) > -1) {
2398 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2401 print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2402 print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2403 msg += print_data.slip_date_msg;
2405 print_data.payload = check.payload;
2408 rv = error.yns_alert_formatted(
2410 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2411 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2412 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2414 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2415 '/xul/server/skin/media/images/turtle.gif'
2420 JSAN.use('util.print'); var print = new util.print();
2421 var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2423 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2424 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2426 var template = 'hold_slip';
2428 'patron' : print_data.user,
2429 'lib' : data.hash.aou[ check.payload.hold.pickup_lib() ],
2430 'staff' : data.list.au[0],
2431 'header' : data.print_list_templates[ template ].header,
2432 'line_item' : data.print_list_templates[ template ].line_item,
2433 'footer' : data.print_list_templates[ template ].footer,
2434 'type' : data.print_list_templates[ template ].type,
2435 'list' : print_list,
2438 print.tree_list( params );
2441 var err_msg = document.getElementById('commonStrings').getString('common.error');
2442 err_msg += '\nFIXME: ' + E + '\n';
2448 if (document.getElementById('no_change_label')) {
2449 var m = document.getElementById('no_change_label').getAttribute('value');
2450 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2451 document.getElementById('no_change_label').setAttribute('value', m);
2452 document.getElementById('no_change_label').setAttribute('hidden','false');
2455 case 6: /* IN TRANSIT */
2456 check.route_to = 'TRANSIT SHELF??';
2457 print_data.route_to;
2458 var err_msg = document.getElementById('commonStrings').getString('common.error');
2459 err_msg += "\nFIXME -- I didn't think we could get here.\n";
2460 print_data.error_msg += err_msg;
2463 case 11: /* CATALOGING */
2464 check.route_to = 'CATALOGING';
2465 print_data.route_to;
2466 if (document.getElementById('do_not_alert_on_precat')) {
2467 var x = document.getElementById('do_not_alert_on_precat');
2469 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2470 msg += print_data.route_to_msg;
2473 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2474 msg += print_data.route_to_msg;
2476 if (document.getElementById('no_change_label')) {
2477 var m = document.getElementById('no_change_label').getAttribute('value');
2478 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2479 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + ' ');
2480 document.getElementById('no_change_label').setAttribute('hidden','false');
2484 msg += document.getElementById('commonStrings').getString('common.error');
2485 var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2487 var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2488 print_data.error_msg += error_msg;
2491 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2492 msg += print_data.route_to_msg;
2498 document.getElementById('circStrings').getString('staff.circ.alert'),
2500 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2502 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2505 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2507 var lib = data.hash.aou[ check.org ];
2508 check.route_to = lib.shortname();
2509 print_data.route_to = check.route_to;
2510 print_data.route_to_org = lib;
2511 print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2512 print_data.route_to_org_fullname = lib.name();
2513 msg += print_data.route_to_msg;
2518 if (lib.holds_address() ) {
2519 var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2520 if (typeof a.ilsevent != 'undefined') throw(a);
2521 if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
2522 if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
2523 print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
2524 print_data.city = a.city();
2525 print_data.state = a.state();
2526 print_data.county = a.county();
2527 print_data.country = a.country();
2528 print_data.post_code = a.post_code();
2529 msg += print_data.city_state_zip + '\n';
2531 print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2532 print_data.no_address = true;
2533 msg += print_data.street1;
2537 var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2538 print_data.error_msg += err_msg + '\n';
2539 msg += err_msg + '\n';
2540 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2543 print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2544 print_data.item_barcode = check.payload.copy.barcode();
2545 msg += print_data.item_barcode_msg;
2547 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2548 print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2549 print_data.item_title = payload_title;
2550 msg += print_data.item_title_msg;
2552 var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2553 print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2554 print_data.item_author = payload_author;
2555 msg += print_data.item_author_msg;
2557 JSAN.use('util.date');
2558 if (check.payload.hold) {
2559 JSAN.use('patron.util');
2560 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2561 print_data.user = au_obj;
2563 if (au_obj.alias()) {
2564 print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias', [au_obj.alias()]);
2565 print_data.hold_for_alias = au_obj.alias();
2566 msg += print_data.hold_for_msg;
2568 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() : '']);
2569 msg += print_data.hold_for_msg;
2570 print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
2571 print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
2572 print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
2575 print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2576 print_data.user_barcode = au_obj.card().barcode();
2577 msg += print_data.user_barcode_msg;
2579 if (check.payload.hold.phone_notify()) {
2580 print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2581 print_data.notify_by_phone = check.payload.hold.phone_notify();
2582 msg += print_data.notify_by_phone_msg;
2585 if (get_bool(check.payload.hold.email_notify())) {
2586 var payload_email = au_obj.email() ? au_obj.email() : '';
2587 print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2588 print_data.notify_by_email = payload_email;
2589 msg += print_data.notify_by_email_msg;
2593 var notes = check.payload.hold.notes();
2594 print_data.notes_raw = notes;
2595 for (var i = 0; i < notes.length; i++) {
2596 if ( get_bool( notes[i].slip() ) ) {
2598 if ( get_bool( notes[i].staff() ) ) {
2599 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.staff_note', [ notes[i].title(), notes[i].body() ]);
2601 temp_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.notes.patron_note', [ notes[i].title(), notes[i].body() ]);
2603 msg += temp_msg + '\n';
2606 'formatted_note' : temp_msg,
2607 'note_title' : notes[i].title(),
2608 'note_body' : notes[i].body(),
2609 'note_public' : notes[i].pub(),
2610 'note_by_staff' : notes[i].staff()
2617 print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
2618 print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
2619 msg += print_data.request_date_msg;
2623 var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
2624 if (no_print_prompting) {
2625 if (no_print_prompting.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) {
2626 rv = -1; auto_print = true; // DO NOT PRINT and skip dialog
2629 print_data.slip_date = util.date.formatted_date(new Date(),'%F');
2630 print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
2631 msg += print_data.slip_date_msg;
2632 print_data.payload = check.payload;
2635 rv = error.yns_alert_formatted(
2637 document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
2638 document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
2639 document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
2641 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2642 '/xul/server/skin/media/images/turtle.gif'
2647 JSAN.use('util.print'); var print = new util.print();
2648 var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
2650 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2651 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2653 var template = check.payload.hold ? 'hold_transit_slip' : 'transit_slip';
2655 'patron' : print_data.user,
2656 'lib' : data.hash.aou[ check.payload.hold ? check.payload.hold.pickup_lib() : check.payload.transit.source() ],
2657 'staff' : data.list.au[0],
2658 'header' : data.print_list_templates[ template ].header,
2659 'line_item' : data.print_list_templates[ template ].line_item,
2660 'footer' : data.print_list_templates[ template ].footer,
2661 'type' : data.print_list_templates[ template ].type,
2662 'list' : print_list,
2665 print.tree_list( params );
2668 var err_msg = document.getElementById('commonStrings').getString('common.error');
2669 err_msg += '\nFIXME: ' + E + '\n';
2674 if (document.getElementById('no_change_label')) {
2675 var m = document.getElementById('no_change_label').getAttribute('value');
2676 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2677 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + ' ');
2678 document.getElementById('no_change_label').setAttribute('hidden','false');
2681 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2683 check.route_to = 'CATALOGING';
2684 var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2687 document.getElementById('circStrings').getString('staff.circ.alert'),
2689 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2691 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2693 if (document.getElementById('no_change_label')) {
2694 var m = document.getElementById('no_change_label').getAttribute('value');
2695 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' ');
2696 document.getElementById('no_change_label').setAttribute('hidden','false');
2699 } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
2702 msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
2703 rv = error.yns_alert_formatted(
2705 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
2706 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
2707 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
2709 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2710 '/xul/server/skin/media/images/stop_sign.png'
2712 params.capture = rv == 0 ? 'nocapture' : 'capture';
2714 return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
2716 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2717 error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2720 if (check.ilsevent == null) { return null; /* handled */ }
2721 switch (Number(check.ilsevent)) {
2722 case 1203 /* COPY_BAD_STATUS */ :
2723 case 1213 /* PATRON_BARRED */ :
2724 case 1217 /* PATRON_INACTIVE */ :
2725 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2726 case 1234 /* ITEM_DEPOSIT_PAID */ :
2727 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2728 case 7010 /* COPY_ALERT_MESSAGE */ :
2729 case 7011 /* COPY_STATUS_LOST */ :
2730 case 7012 /* COPY_STATUS_MISSING */ :
2731 case 7013 /* PATRON_EXCEEDS_FINES */ :
2732 return null; /* handled */
2742 JSAN.use('util.error'); var error = new util.error();
2743 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
2748 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2751 JSAN.use('util.network'); obj.network = new util.network();
2752 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2754 var params = { barcode: barcode };
2755 if (patron_id) params.patron = patron_id;
2757 function renew_callback(req) {
2759 var renew = req.getResultObject();
2760 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2761 for (var j = 0; j < renew.length; j++) {
2762 switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
2763 case 0 /* SUCCESS */ : break;
2764 case null /* custom event */ : break;
2765 case 5000 /* PERM_FAILURE */: break;
2766 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2767 case 1213 /* PATRON_BARRED */ : break;
2768 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2769 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2770 case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
2771 case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
2772 case 1234 /* ITEM_DEPOSIT_PAID */ : break;
2773 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2774 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2775 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2776 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2777 case 7006 /* COPY_IS_REFERENCE */ : break;
2778 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2779 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2780 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2781 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2782 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2788 if (typeof async == 'function') async(renew);
2791 JSAN.use('util.error'); var error = new util.error();
2792 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2797 var renew = obj.network.simple_request(
2800 async ? renew_callback : null,
2802 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
2803 'overridable_events' : [
2804 null /* custom event */,
2805 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2806 1213 /* PATRON_BARRED */,
2807 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2808 1232 /* ITEM_DEPOSIT_REQUIRED */,
2809 1233 /* ITEM_RENTAL_FEE_REQUIRED */,
2810 1234 /* ITEM_DEPOSIT_PAID */,
2811 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2812 7003 /* COPY_CIRC_NOT_ALLOWED */,
2813 7004 /* COPY_NOT_AVAILABLE */,
2814 7006 /* COPY_IS_REFERENCE */,
2815 7007 /* COPY_NEEDED_FOR_HOLD */,
2816 7008 /* MAX_RENEWALS_REACHED */,
2817 7009 /* CIRC_CLAIMS_RETURNED */,
2818 7010 /* COPY_ALERT_MESSAGE */,
2819 7013 /* PATRON_EXCEEDS_FINES */,
2822 '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2823 '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2824 '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2825 '1232' : function(r) {
2826 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [barcode]);
2828 '1233' : function(r) {
2829 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [barcode]);
2831 '1234' : function(r) {
2832 return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2834 '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2835 '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2836 '7004' : function(r) {
2837 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()]);
2839 '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2840 '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2841 '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2842 '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2843 '7010' : function(r) {
2844 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2846 '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2851 return renew_callback( { 'getResultObject' : function() { return renew; } } );
2855 JSAN.use('util.error'); var error = new util.error();
2856 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2861 dump('exiting circ/util.js\n');