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', 'renew_via_barcode'
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 var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
76 window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
78 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure'), E);
84 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
89 circ.util.show_last_few_circs = function(selection_list) {
91 JSAN.use('util.error'); obj.error = new util.error();
92 JSAN.use('util.window'); obj.win = new util.window();
93 JSAN.use('util.network'); obj.network = new util.network();
94 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
96 for (var i = 0; i < selection_list.length; i++) {
98 if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
99 var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
100 var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id } );
102 if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
103 var patrons = my_xulG.retrieve_these_patrons;
104 for (var j = 0; j < patrons.length; j++) {
105 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
107 var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
108 window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
110 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
116 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
121 circ.util.offline_checkout_columns = function(modify,params) {
126 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
130 'render' : function(my) { return my.timestamp; }
133 'id' : 'checkout_time',
134 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
138 'render' : function(my) { return my.checkout_time; }
142 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
146 'render' : function(my) { return my.type; }
150 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
154 'render' : function(my) { return my.noncat; }
157 'id' : 'noncat_type',
158 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
162 'render' : function(my) { return my.noncat_type; }
165 'id' : 'noncat_count',
166 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
167 'sort_type' : 'number',
171 'render' : function(my) { return my.noncat_count; }
174 'id' : 'patron_barcode',
175 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
179 'render' : function(my) { return my.patron_barcode; }
183 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
187 'render' : function(my) { return my.barcode; }
191 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
195 'render' : function(my) { return my.due_date; }
198 if (modify) for (var i = 0; i < c.length; i++) {
199 if (modify[ c[i].id ]) {
200 for (var j in modify[ c[i].id ]) {
201 c[i][j] = modify[ c[i].id ][j];
206 if (params.just_these) {
207 JSAN.use('util.functional');
209 for (var i = 0; i < params.just_these.length; i++) {
210 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
211 new_c.push( function(y){ return y; }( x ) );
215 if (params.except_these) {
216 JSAN.use('util.functional');
218 for (var i = 0; i < c.length; i++) {
219 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
220 if (!x) new_c.push(c[i]);
226 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
229 circ.util.offline_checkin_columns = function(modify,params) {
234 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
238 'render' : function(my) { return my.timestamp; }
242 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
246 'render' : function(my) { return my.backdate; }
250 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
254 'render' : function(my) { return my.type; }
258 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
262 'render' : function(my) { return my.barcode; }
265 if (modify) for (var i = 0; i < c.length; i++) {
266 if (modify[ c[i].id ]) {
267 for (var j in modify[ c[i].id ]) {
268 c[i][j] = modify[ c[i].id ][j];
273 if (params.just_these) {
274 JSAN.use('util.functional');
276 for (var i = 0; i < params.just_these.length; i++) {
277 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
278 new_c.push( function(y){ return y; }( x ) );
282 if (params.except_these) {
283 JSAN.use('util.functional');
285 for (var i = 0; i < c.length; i++) {
286 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
287 if (!x) new_c.push(c[i]);
293 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
296 circ.util.offline_renew_columns = function(modify,params) {
301 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
305 'render' : function(my) { return my.timestamp; }
308 'id' : 'checkout_time',
309 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
313 'render' : function(my) { return my.checkout_time; }
317 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
321 'render' : function(my) { return my.type; }
324 'id' : 'patron_barcode',
325 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
329 'render' : function(my) { return my.patron_barcode; }
333 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
337 'render' : function(my) { return my.barcode; }
341 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
345 'render' : function(my) { return my.due_date; }
348 if (modify) for (var i = 0; i < c.length; i++) {
349 if (modify[ c[i].id ]) {
350 for (var j in modify[ c[i].id ]) {
351 c[i][j] = modify[ c[i].id ][j];
356 if (params.just_these) {
357 JSAN.use('util.functional');
359 for (var i = 0; i < params.just_these.length; i++) {
360 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
361 new_c.push( function(y){ return y; }( x ) );
365 if (params.except_these) {
366 JSAN.use('util.functional');
368 for (var i = 0; i < c.length; i++) {
369 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
370 if (!x) new_c.push(c[i]);
376 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
379 circ.util.offline_inhouse_use_columns = function(modify,params) {
384 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
388 'render' : function(my) { return my.timestamp; }
392 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
396 'render' : function(my) { return my.use_time; }
400 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
404 'render' : function(my) { return my.type; }
408 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
409 'sort_type' : 'number',
413 'render' : function(my) { return my.count; }
417 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
421 'render' : function(my) { return my.barcode; }
424 if (modify) for (var i = 0; i < c.length; i++) {
425 if (modify[ c[i].id ]) {
426 for (var j in modify[ c[i].id ]) {
427 c[i][j] = modify[ c[i].id ][j];
432 if (params.just_these) {
433 JSAN.use('util.functional');
435 for (var i = 0; i < params.just_these.length; i++) {
436 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
437 new_c.push( function(y){ return y; }( x ) );
441 if (params.except_these) {
442 JSAN.use('util.functional');
444 for (var i = 0; i < c.length; i++) {
445 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
446 if (!x) new_c.push(c[i]);
452 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
455 circ.util.columns = function(modify,params) {
457 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
458 JSAN.use('util.network'); var network = new util.network();
459 JSAN.use('util.money');
464 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
468 'render' : function(my) { return my.acp.id(); },
469 'persist' : 'hidden width ordinal'
473 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
477 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
478 'persist' : 'hidden width ordinal'
482 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
486 'render' : function(my) { return my.mvr.doc_id(); },
487 'persist' : 'hidden width ordinal'
490 'persist' : 'hidden width ordinal',
496 'render' : function(my) { return my.service; }
500 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
504 'render' : function(my) { return my.acp.barcode(); },
505 'persist' : 'hidden width ordinal'
508 'id' : 'call_number',
509 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
513 'render' : function(my) {
514 if (my.acp && my.acp.call_number() == -1) {
515 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
516 } else if (my.acp && my.acp.call_number() == -2) {
517 return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
520 var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
522 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
524 my.acn = x; return x.label();
527 return my.acn.label();
531 'persist' : 'hidden width ordinal'
535 'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
539 'render' : function(my) {
540 if (Number(my.acn.owning_lib())>=0) {
541 return data.hash.aou[ my.acn.owning_lib() ].shortname();
543 return my.acn.owning_lib().shortname();
546 'persist' : 'hidden width ordinal'
549 'id' : 'copy_number',
550 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
552 'sort_type' : 'number',
555 'render' : function(my) { return my.acp.copy_number(); },
556 'persist' : 'hidden width ordinal'
560 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
564 'render' : function(my) {
565 if (Number(my.acp.location())>=0) {
566 return data.lookup("acpl", my.acp.location() ).name();
568 return my.acp.location().name();
571 'persist' : 'hidden width ordinal'
574 'id' : 'loan_duration',
575 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
579 'render' : function(my) {
580 switch(Number(my.acp.loan_duration())) {
582 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
585 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
588 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
592 'persist' : 'hidden width ordinal'
596 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
600 'render' : function(my) {
601 if (Number(my.acp.circ_lib())>=0) {
602 return data.hash.aou[ my.acp.circ_lib() ].shortname();
604 return my.acp.circ_lib().shortname();
607 'persist' : 'hidden width ordinal'
611 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
615 'render' : function(my) {
616 switch(Number(my.acp.fine_level())) {
618 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
621 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
624 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
628 'persist' : 'hidden width ordinal'
632 'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
636 'render' : function(my) {
637 if (get_bool( my.acp.circulate() )) {
638 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
640 return document.getElementById('circStrings').getString('staff.circ.utils.no');
643 'persist' : 'hidden width ordinal'
647 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
651 'render' : function(my) {
652 if (get_bool( my.acp.deleted() )) {
653 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
655 return document.getElementById('circStrings').getString('staff.circ.utils.no');
658 'persist' : 'hidden width ordinal'
662 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
666 'render' : function(my) {
667 if (get_bool( my.acp.holdable() )) {
668 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
670 return document.getElementById('circStrings').getString('staff.circ.utils.no');
673 'persist' : 'hidden width ordinal'
676 'id' : 'opac_visible',
677 'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
681 'render' : function(my) {
682 if (get_bool( my.acp.opac_visible() )) {
683 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
685 return document.getElementById('circStrings').getString('staff.circ.utils.no');
688 'persist' : 'hidden width ordinal'
691 'persist' : 'hidden width ordinal',
693 'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
697 'render' : function(my) {
698 if (get_bool( my.acp.ref() )) {
699 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
701 return document.getElementById('circStrings').getString('staff.circ.utils.no');
706 'persist' : 'hidden width ordinal',
708 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
712 'render' : function(my) {
713 if (get_bool( my.acp.deposit() )) {
714 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
716 return document.getElementById('circStrings').getString('staff.circ.utils.no');
721 'persist' : 'hidden width ordinal',
722 'id' : 'deposit_amount',
723 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
727 'render' : function(my) {
728 if (my.acp.price() == null) {
729 return document.getElementById('circStrings').getString('staff.circ.utils.unset');
731 return util.money.sanitize(my.acp.deposit_amount());
734 'sort_type' : 'money'
737 'persist' : 'hidden width ordinal',
739 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
743 'render' : function(my) {
744 if (my.acp.price() == null) {
745 return document.getElementById('circStrings').getString('staff.circ.utils.unset');
747 return util.money.sanitize(my.acp.price());
750 'sort_type' : 'money'
753 'persist' : 'hidden width ordinal',
754 'id' : 'circ_as_type',
755 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
759 'render' : function(my) { return my.acp.circ_as_type(); }
762 'persist' : 'hidden width ordinal',
763 'id' : 'circ_modifier',
764 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
768 'render' : function(my) { return my.acp.circ_modifier(); }
771 'persist' : 'hidden width ordinal',
772 'id' : 'checkout_lib',
773 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
777 'render' : function(my) {
779 return data.hash.aou[ my.circ.circ_lib() ].shortname();
781 if (my.acp.circulations()) {
782 return data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname();
790 'persist' : 'hidden width ordinal',
791 'id' : 'xact_start_full',
792 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_timestamp'),
796 'render' : function(my) {
798 return my.circ.xact_start();
800 if (my.acp.circulations()) {
801 return my.acp.circulations()[0].xact_start();
810 'persist' : 'hidden width ordinal',
811 'id' : 'checkin_time_full',
812 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_timestamp'),
816 'render' : function(my) {
818 return my.circ.checkin_time();
820 if (my.acp.circulations()) {
821 return my.acp.circulations()[0].checkin_time();
829 'persist' : 'hidden width ordinal',
831 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
835 'render' : function(my) {
837 return my.circ.xact_start().substr(0,10);
839 if (my.acp.circulations()) {
840 return my.acp.circulations()[0].xact_start().substr(0,10);
848 'persist' : 'hidden width ordinal',
849 'id' : 'checkin_time',
850 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
854 'render' : function(my) {
856 return my.circ.checkin_time().substr(0,10);
858 if (my.acp.circulations()) {
859 return my.acp.circulations()[0].checkin_time().substr(0,10);
867 'persist' : 'hidden width ordinal',
868 'id' : 'xact_finish',
869 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
873 'render' : function(my) { return my.circ.xact_finish(); }
876 'persist' : 'hidden width ordinal',
878 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
882 'render' : function(my) {
884 return my.circ.due_date().substr(0,10);
886 if (my.acp.circulations()) {
887 return my.acp.circulations()[0].due_date().substr(0,10);
895 'persist' : 'hidden width ordinal',
896 'id' : 'create_date',
897 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
901 'render' : function(my) { return my.acp.create_date().substr(0,10); }
904 'persist' : 'hidden width ordinal',
906 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
910 'render' : function(my) { return my.acp.edit_date().substr(0,10); }
913 'persist' : 'hidden width ordinal',
915 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
917 'sort_type' : 'title',
920 'render' : function(my) {
921 try { return my.mvr.title(); }
922 catch(E) { return my.acp.dummy_title(); }
926 'persist' : 'hidden width ordinal',
928 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
932 'render' : function(my) {
933 try { return my.mvr.author(); }
934 catch(E) { return my.acp.dummy_author(); }
938 'persist' : 'hidden width ordinal',
940 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
944 'render' : function(my) { return my.mvr.edition(); }
947 'persist' : 'hidden width ordinal',
949 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
953 'render' : function(my) { return my.mvr.isbn(); }
956 'persist' : 'hidden width ordinal',
958 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
962 'render' : function(my) { return my.mvr.pubdate(); }
965 'persist' : 'hidden width ordinal',
967 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
971 'render' : function(my) { return my.mvr.publisher(); }
974 'persist' : 'hidden width ordinal',
976 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
980 'render' : function(my) { return my.mvr.tcn(); }
983 'persist' : 'hidden width ordinal',
984 'id' : 'renewal_remaining',
985 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
989 'render' : function(my) {
991 return my.circ.renewal_remaining();
993 if (my.acp.circulations()) {
994 return my.acp.circulations()[0].renewal_remaining();
1000 'sort_type' : 'number'
1003 'persist' : 'hidden width ordinal',
1004 'id' : 'stop_fines',
1005 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1009 'render' : function(my) {
1011 return my.circ.stop_fines();
1013 if (my.acp.circulations()) {
1014 return my.acp.circulations()[0].stop_fines();
1022 'persist' : 'hidden width ordinal',
1023 'id' : 'stop_fines_time',
1024 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1028 'render' : function(my) {
1030 return my.circ.stop_fines_time();
1032 if (my.acp.circulations()) {
1033 return my.acp.circulations()[0].stop_fines_time();
1041 'persist' : 'hidden width ordinal',
1043 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1047 'render' : function(my) {
1048 if (Number(my.acp.status())>=0) {
1049 return data.hash.ccs[ my.acp.status() ].name();
1051 return my.acp.status().name();
1056 'persist' : 'hidden width ordinal',
1058 'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1062 'render' : function(my) { return my.route_to.toString(); }
1065 'persist' : 'hidden width ordinal',
1067 'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1071 'render' : function(my) { return my.message.toString(); }
1074 'persist' : 'hidden width ordinal',
1076 'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1080 'render' : function(my) { return my.uses; },
1081 'sort_type' : 'number'
1084 'persist' : 'hidden width ordinal',
1085 'id' : 'alert_message',
1086 'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1090 'render' : function(my) { return my.acp.alert_message(); }
1093 for (var i = 0; i < c.length; i++) {
1094 if (modify[ c[i].id ]) {
1095 for (var j in modify[ c[i].id ]) {
1096 c[i][j] = modify[ c[i].id ][j];
1101 if (params.just_these) {
1102 JSAN.use('util.functional');
1104 for (var i = 0; i < params.just_these.length; i++) {
1105 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1106 new_c.push( function(y){ return y; }( x ) );
1110 if (params.except_these) {
1111 JSAN.use('util.functional');
1113 for (var i = 0; i < c.length; i++) {
1114 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1115 if (!x) new_c.push(c[i]);
1120 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1123 circ.util.transit_columns = function(modify,params) {
1125 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1129 'persist' : 'hidden width ordinal',
1130 'id' : 'transit_item_barcode',
1131 'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1135 'render' : function(my) { return my.acp.barcode(); }
1138 'persist' : 'hidden width ordinal',
1139 'id' : 'transit_item_title',
1140 'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1144 'render' : function(my) {
1145 try { return my.mvr.title(); }
1146 catch(E) { return my.acp.dummy_title(); }
1150 'persist' : 'hidden width ordinal',
1151 'id' : 'transit_item_author',
1152 'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1156 'render' : function(my) {
1157 try { return my.mvr.author(); }
1158 catch(E) { return my.acp.dummy_author(); }
1162 'persist' : 'hidden width ordinal',
1163 'id' : 'transit_item_callnumber',
1164 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1168 'render' : function(my) { return my.acn.label(); }
1171 'persist' : 'hidden width ordinal',
1172 'id' : 'transit_id',
1173 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1177 'render' : function(my) { return my.atc.id(); }
1180 'persist' : 'hidden width ordinal',
1181 'id' : 'transit_source',
1182 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1186 'render' : function(my) {
1187 if (typeof my.atc.source() == "object") {
1188 return my.atc.source().shortname();
1190 return data.hash.aou[ my.atc.source() ].shortname();
1195 'persist' : 'hidden width ordinal',
1196 'id' : 'transit_source_send_time',
1197 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1201 'render' : function(my) { return my.atc.source_send_time(); }
1204 'persist' : 'hidden width ordinal',
1205 'id' : 'transit_dest_lib',
1206 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1210 'render' : function(my) {
1211 if (typeof my.atc.dest() == "object") {
1212 return my.atc.dest().shortname();
1214 return data.hash.aou[ my.atc.dest() ].shortname();
1219 'persist' : 'hidden width ordinal',
1220 'id' : 'transit_dest_recv_time',
1221 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1225 'render' : function(my) { return my.atc.dest_recv_time(); }
1228 'persist' : 'hidden width ordinal',
1229 'id' : 'transit_target_copy',
1230 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1234 'render' : function(my) { return my.atc.target_copy(); }
1237 for (var i = 0; i < c.length; i++) {
1238 if (modify[ c[i].id ]) {
1239 for (var j in modify[ c[i].id ]) {
1240 c[i][j] = modify[ c[i].id ][j];
1245 if (params.just_these) {
1246 JSAN.use('util.functional');
1248 for (var i = 0; i < params.just_these.length; i++) {
1249 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1250 new_c.push( function(y){ return y; }( x ) );
1254 if (params.except_these) {
1255 JSAN.use('util.functional');
1257 for (var i = 0; i < c.length; i++) {
1258 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1259 if (!x) new_c.push(c[i]);
1265 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1268 circ.util.hold_columns = function(modify,params) {
1270 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1274 'persist' : 'hidden width ordinal',
1275 'id' : 'request_lib',
1276 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1280 'render' : function(my) {
1281 if (Number(my.ahr.request_lib())>=0) {
1282 return data.hash.aou[ my.ahr.request_lib() ].name();
1284 return my.ahr.request_lib().name();
1289 'persist' : 'hidden width ordinal',
1290 'id' : 'request_lib_shortname',
1291 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1295 'render' : function(my) {
1296 if (Number(my.ahr.request_lib())>=0) {
1297 return data.hash.aou[ my.ahr.request_lib() ].shortname();
1299 return my.ahr.request_lib().shortname();
1305 'persist' : 'hidden width ordinal',
1306 'id' : 'request_timestamp',
1307 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1311 'render' : function(my) { return my.ahr.request_time().toString(); }
1314 'persist' : 'hidden width ordinal',
1315 'id' : 'request_time',
1316 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1320 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1323 'persist' : 'hidden width ordinal',
1324 'id' : 'available_timestamp',
1325 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1329 'render' : function(my) {
1330 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1331 return my.ahr.transit().dest_recv_time().toString();
1333 if (my.ahr.capture_time()) {
1334 return my.ahr.capture_time().toString();
1340 'persist' : 'hidden width ordinal',
1341 'id' : 'available_time',
1342 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1346 'render' : function(my) {
1347 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1348 return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1350 if (my.ahr.capture_time()) {
1351 return my.ahr.capture_time().toString().substr(0,10);
1357 'persist' : 'hidden width ordinal',
1358 'id' : 'capture_timestamp',
1359 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1363 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1366 'persist' : 'hidden width ordinal',
1367 'id' : 'capture_time',
1368 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1372 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1375 'persist' : 'hidden width ordinal',
1377 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1381 'render' : function(my) {
1382 switch (Number(my.status)) {
1384 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1387 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1390 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1393 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1402 'persist' : 'hidden width ordinal',
1404 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1408 'render' : function(my) { return my.ahr.hold_type(); }
1411 'persist' : 'hidden width ordinal',
1413 'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1417 'render' : function(my) {
1418 if (!get_bool( my.ahr.frozen() )) {
1419 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1421 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1426 'persist' : 'hidden width ordinal',
1428 'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1432 'render' : function(my) {
1433 if (my.ahr.thaw_date() == null) {
1434 return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1436 return my.ahr.thaw_date().substr(0,10);
1441 'persist' : 'hidden width ordinal',
1442 'id' : 'pickup_lib',
1443 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1447 'render' : function(my) {
1448 if (Number(my.ahr.pickup_lib())>=0) {
1449 return data.hash.aou[ my.ahr.pickup_lib() ].name();
1451 return my.ahr.pickup_lib().name();
1456 'persist' : 'hidden width ordinal',
1457 'id' : 'pickup_lib_shortname',
1458 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1462 'render' : function(my) {
1463 if (Number(my.ahr.pickup_lib())>=0) {
1464 return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1466 return my.ahr.pickup_lib().shortname();
1471 'persist' : 'hidden width ordinal',
1472 'id' : 'current_copy',
1473 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1477 'render' : function(my) {
1479 return my.acp.barcode();
1481 return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1486 'persist' : 'hidden width ordinal',
1487 'id' : 'current_copy_location',
1488 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1492 'render' : function(my) {
1493 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(); }
1497 'persist' : 'hidden width ordinal',
1498 'id' : 'email_notify',
1499 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1503 'render' : function(my) {
1504 if (get_bool(my.ahr.email_notify())) {
1505 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1507 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1512 'persist' : 'hidden width ordinal',
1513 'id' : 'expire_time',
1514 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1518 'render' : function(my) { return my.ahr.expire_time(); }
1521 'persist' : 'hidden width ordinal',
1522 'id' : 'expire_date',
1523 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1527 'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
1530 'persist' : 'hidden width ordinal',
1531 'id' : 'fulfillment_time',
1532 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1536 'render' : function(my) { return my.ahr.fulfillment_time(); }
1539 'persist' : 'hidden width ordinal',
1540 'id' : 'holdable_formats',
1541 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1545 'render' : function(my) { return my.ahr.holdable_formats(); }
1548 'persist' : 'hidden width ordinal',
1550 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1554 'render' : function(my) { return my.ahr.id(); }
1557 'persist' : 'hidden width ordinal',
1558 'id' : 'phone_notify',
1559 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1563 'render' : function(my) { return my.ahr.phone_notify(); }
1566 'persist' : 'hidden width ordinal',
1567 'id' : 'prev_check_time',
1568 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1572 'render' : function(my) { return my.ahr.prev_check_time(); }
1575 'persist' : 'hidden width ordinal',
1577 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1581 'render' : function(my) { return my.ahr.requestor(); }
1584 'persist' : 'hidden width ordinal',
1585 'id' : 'selection_depth',
1586 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1590 'render' : function(my) { return my.ahr.selection_depth(); }
1593 'persist' : 'hidden width ordinal',
1595 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1599 'render' : function(my) { return my.ahr.target(); }
1602 'persist' : 'hidden width ordinal',
1604 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1608 'render' : function(my) { return my.ahr.usr(); }
1611 'persist' : 'hidden width ordinal',
1613 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1615 'sort_type' : 'title',
1618 'render' : function(my) {
1620 return my.mvr.title();
1622 return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1627 'persist' : 'hidden width ordinal',
1629 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1633 'render' : function(my) {
1635 return my.mvr.author();
1637 return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1642 'persist' : 'hidden width ordinal',
1644 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1648 'render' : function(my) { return my.mvr.edition(); }
1651 'persist' : 'hidden width ordinal',
1653 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1657 'render' : function(my) { return my.mvr.isbn(); }
1660 'persist' : 'hidden width ordinal',
1662 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1666 'render' : function(my) { return my.mvr.pubdate(); }
1669 'persist' : 'hidden width ordinal',
1671 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1675 'render' : function(my) { return my.mvr.publisher(); }
1678 'persist' : 'hidden width ordinal',
1680 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1684 'render' : function(my) { return my.mvr.tcn(); }
1687 'persist' : 'hidden width ordinal',
1688 'id' : 'notify_time',
1689 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1693 'render' : function(my) { return my.ahr.notify_time(); }
1696 'persist' : 'hidden width ordinal',
1697 'id' : 'notify_count',
1698 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1702 'render' : function(my) { return my.ahr.notify_count(); }
1705 'persist' : 'hidden width ordinal',
1706 'id' : 'transit_source',
1707 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1711 'render' : function(my) {
1712 if (my.ahr.transit()) {
1713 return data.hash.aou[ my.ahr.transit().source() ].shortname();
1720 'persist' : 'hidden width ordinal',
1721 'id' : 'transit_source_send_time',
1722 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1726 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; }
1729 'persist' : 'hidden width ordinal',
1730 'id' : 'transit_dest_lib',
1731 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1735 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1738 'persist' : 'hidden width ordinal',
1739 'id' : 'transit_dest_recv_time',
1740 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1744 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; }
1747 'persist' : 'hidden width ordinal',
1748 'id' : 'patron_barcode',
1749 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1753 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1756 'persist' : 'hidden width ordinal',
1757 'id' : 'patron_family_name',
1758 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1762 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1765 'persist' : 'hidden width ordinal',
1766 'id' : 'patron_first_given_name',
1767 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1771 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1774 'persist' : 'hidden width ordinal',
1775 'id' : 'callnumber',
1776 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1780 'render' : function(my) { return my.acn.label(); }
1783 for (var i = 0; i < c.length; i++) {
1784 if (modify[ c[i].id ]) {
1785 for (var j in modify[ c[i].id ]) {
1786 c[i][j] = modify[ c[i].id ][j];
1791 if (params.just_these) {
1792 JSAN.use('util.functional');
1794 for (var i = 0; i < params.just_these.length; i++) {
1795 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1796 new_c.push( function(y){ return y; }( x ) );
1800 if (params.except_these) {
1801 JSAN.use('util.functional');
1803 for (var i = 0; i < c.length; i++) {
1804 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1805 if (!x) new_c.push(c[i]);
1811 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1814 circ.util.std_map_row_to_column = function(error_value) {
1815 return function(row,col) {
1816 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1817 // col contains one of the objects listed above in columns
1819 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
1821 JSAN.use('util.error'); obj.error = new util.error();
1822 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1823 JSAN.use('util.network'); obj.network = new util.network();
1824 JSAN.use('util.money');
1829 value = eval( col.render );
1831 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1832 if (error_value) value = error_value; else value = ' ';
1838 circ.util.std_map_row_to_columns = function(error_value) {
1839 return function(row,cols) {
1840 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1841 // cols contains all of the objects listed above in columns
1844 JSAN.use('util.error'); obj.error = new util.error();
1845 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1846 JSAN.use('util.network'); obj.network = new util.network();
1847 JSAN.use('util.money');
1853 for (var i = 0; i < cols.length; i++) {
1854 switch (typeof cols[i].render) {
1855 case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
1856 case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
1857 default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
1860 if (cmd) eval( cmd );
1862 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1863 if (error_value) { value = error_value; } else { value = ' ' };
1869 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
1871 JSAN.use('util.error'); var error = new util.error();
1872 JSAN.use('util.network'); var network = new util.network();
1873 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1874 JSAN.use('util.date');
1876 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1878 //var params = { 'barcode' : barcode };
1879 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1881 if (typeof async == 'object') {
1882 try { async.disable_textbox(); }
1883 catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1885 var check = network.request(
1886 api.CHECKIN_VIA_BARCODE.app,
1887 api.CHECKIN_VIA_BARCODE.method,
1888 [ session, params ],
1889 async ? function(req) {
1891 var check = req.getResultObject();
1892 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1893 if (typeof async == 'object') {
1894 try { async.checkin_result(r); }
1895 catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1898 JSAN.use('util.error'); var error = new util.error();
1899 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
1900 if (typeof async == 'object') {
1901 try { async.enable_textbox(); }
1902 catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1908 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
1909 'overridable_events' : [
1910 1203 /* COPY_BAD_STATUS */,
1911 1213 /* PATRON_BARRED */,
1912 1217 /* PATRON_INACTIVE */,
1913 1224 /* PATRON_ACCOUNT_EXPIRED */,
1914 7009 /* CIRC_CLAIMS_RETURNED */,
1915 7010 /* COPY_ALERT_MESSAGE */,
1916 7011 /* COPY_STATUS_LOST */,
1917 7012 /* COPY_STATUS_MISSING */,
1918 7013 /* PATRON_EXCEEDS_FINES */,
1921 '1203' : function(r) {
1922 //return data.hash.ccs[ r.payload.status() ].name();
1923 return r.payload.status().name();
1925 '7010' : function(r) {
1932 return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1937 JSAN.use('util.error'); var error = new util.error();
1938 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
1939 if (typeof async == 'object') {
1940 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1946 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1948 JSAN.use('util.error'); var error = new util.error();
1949 JSAN.use('util.network'); var network = new util.network();
1950 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1951 JSAN.use('util.date');
1953 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1955 check.message = check.textcode;
1957 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
1958 if (check.payload && check.payload.record) { check.record = check.payload.record; }
1959 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
1961 if (!check.route_to) { check.route_to = ' '; }
1963 if (document.getElementById('no_change_label')) {
1964 document.getElementById('no_change_label').setAttribute('value','');
1965 document.getElementById('no_change_label').setAttribute('hidden','true');
1969 network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
1970 JSAN.use('util.money');
1971 var bill = req.getResultObject();
1972 if (Number(bill.balance_owed()) == 0) { return; }
1973 if (document.getElementById('no_change_label')) {
1974 var m = document.getElementById('no_change_label').getAttribute('value');
1975 document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + ' ');
1976 document.getElementById('no_change_label').setAttribute('hidden','false');
1983 if (check.payload && check.payload.cancelled_hold_transit) {
1984 msg += document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
1988 /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
1989 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1990 try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
1992 msg += document.getElementById('commonStrings').getString('common.error');
1993 msg += '\nFIXME: ' + E + '\n';
1995 if (check.ilsevent == 3 /* NO_CHANGE */) {
1996 //msg = 'This item is already checked in.\n';
1997 if (document.getElementById('no_change_label')) {
1998 var m = document.getElementById('no_change_label').getAttribute('value');
1999 document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + ' ');
2000 document.getElementById('no_change_label').setAttribute('hidden','false');
2003 if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2004 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2005 msg = document.getElementById('commonStrings').getString('common.error');
2006 msg += '\nFIXME --';
2007 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2010 switch(Number(check.copy.status())) {
2011 case 0: /* AVAILABLE */
2012 case 7: /* RESHELVING */
2014 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2018 case 8: /* ON HOLDS SHELF */
2019 check.route_to = 'HOLDS SHELF';
2020 if (check.payload.hold) {
2021 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2022 msg += document.getElementById('commonStrings').getString('common.error');
2024 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2027 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2031 msg += document.getElementById('commonStrings').getString('common.error');
2033 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2036 JSAN.use('util.date');
2037 if (check.payload.hold) {
2038 JSAN.use('patron.util');
2040 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2042 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2043 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2045 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2047 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2049 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2051 if (check.payload.hold.phone_notify()) {
2052 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2055 if (check.payload.hold.email_notify()) {
2056 var payload_email = au_obj.email() ? au_obj.email() : '';
2057 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2061 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2065 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2068 rv = error.yns_alert_formatted(
2070 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2071 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2072 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2074 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2075 '/xul/server/skin/media/images/turtle.gif'
2080 JSAN.use('util.print'); var print = new util.print();
2081 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2082 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2084 var err_msg = document.getElementById('commonStrings').getString('common.error');
2085 err_msg += '\nFIXME: ' + E + '\n';
2091 if (document.getElementById('no_change_label')) {
2092 var m = document.getElementById('no_change_label').getAttribute('value');
2093 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2094 document.getElementById('no_change_label').setAttribute('value', m);
2095 document.getElementById('no_change_label').setAttribute('hidden','false');
2098 case 6: /* IN TRANSIT */
2099 check.route_to = 'TRANSIT SHELF??';
2100 msg += document.getElementById('commonStrings').getString('common.error');
2101 msg += "\nFIXME -- I didn't think we could get here.\n";
2103 case 11: /* CATALOGING */
2104 check.route_to = 'CATALOGING';
2105 if (document.getElementById('do_not_alert_on_precat')) {
2106 var x = document.getElementById('do_not_alert_on_precat');
2108 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2111 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2113 if (document.getElementById('no_change_label')) {
2114 var m = document.getElementById('no_change_label').getAttribute('value');
2115 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2116 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + ' ');
2117 document.getElementById('no_change_label').setAttribute('hidden','false');
2121 msg += document.getElementById('commonStrings').getString('common.error');
2122 var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2124 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2126 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2132 document.getElementById('circStrings').getString('staff.circ.alert'),
2134 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2136 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2139 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2141 var lib = data.hash.aou[ check.org ];
2142 check.route_to = lib.shortname();
2143 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2148 if (lib.holds_address() ) {
2149 var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2150 if (typeof a.ilsevent != 'undefined') throw(a);
2151 if (a.street1()) msg += a.street1() + '\n';
2152 if (a.street2()) msg += a.street2() + '\n';
2153 msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
2155 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2159 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2161 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2164 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2166 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2167 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2169 var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2170 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2172 JSAN.use('util.date');
2173 if (check.payload.hold) {
2174 JSAN.use('patron.util');
2175 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2177 document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2179 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2181 if (check.payload.hold.phone_notify()) {
2182 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2185 if (check.payload.hold.email_notify()) {
2186 var payload_email = au_obj.email() ? au_obj.email() : '';
2187 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2191 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2195 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2197 rv = error.yns_alert_formatted(
2199 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2200 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2201 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2203 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2204 '/xul/server/skin/media/images/turtle.gif'
2210 JSAN.use('util.print'); var print = new util.print();
2211 //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
2212 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2213 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2215 var err_msg = document.getElementById('commonStrings').getString('common.error');
2216 err_msg += '\nFIXME: ' + E + '\n';
2221 if (document.getElementById('no_change_label')) {
2222 var m = document.getElementById('no_change_label').getAttribute('value');
2223 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2224 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + ' ');
2225 document.getElementById('no_change_label').setAttribute('hidden','false');
2228 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2230 check.route_to = 'CATALOGING';
2231 var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2234 document.getElementById('circStrings').getString('staff.circ.alert'),
2236 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2238 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2240 if (document.getElementById('no_change_label')) {
2241 var m = document.getElementById('no_change_label').getAttribute('value');
2242 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' ');
2243 document.getElementById('no_change_label').setAttribute('hidden','false');
2246 } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
2249 msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
2250 rv = error.yns_alert_formatted(
2252 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
2253 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
2254 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
2256 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2257 '/xul/server/skin/media/images/stop_sign.png'
2259 params.capture = rv == 0 ? 'nocapture' : 'capture';
2261 return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
2263 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2264 error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2267 switch (Number(check.ilsevent)) {
2268 case 1203 /* COPY_BAD_STATUS */ :
2269 case 1213 /* PATRON_BARRED */ :
2270 case 1217 /* PATRON_INACTIVE */ :
2271 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2272 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2273 case 7010 /* COPY_ALERT_MESSAGE */ :
2274 case 7011 /* COPY_STATUS_LOST */ :
2275 case 7012 /* COPY_STATUS_MISSING */ :
2276 case 7013 /* PATRON_EXCEEDS_FINES */ :
2277 return null; /* handled */
2287 JSAN.use('util.error'); var error = new util.error();
2288 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
2293 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2296 JSAN.use('util.network'); obj.network = new util.network();
2297 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2299 var params = { barcode: barcode };
2300 if (patron_id) params.patron = patron_id;
2302 function renew_callback(req) {
2304 var renew = req.getResultObject();
2305 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2306 for (var j = 0; j < renew.length; j++) {
2307 switch(Number(renew[j].ilsevent)) {
2308 case 0 /* SUCCESS */ : break;
2309 case 5000 /* PERM_FAILURE */: break;
2310 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2311 case 1213 /* PATRON_BARRED */ : break;
2312 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2313 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2314 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2315 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2316 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2317 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2318 case 7006 /* COPY_IS_REFERENCE */ : break;
2319 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2320 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2321 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2322 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2323 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2329 if (typeof async == 'function') async(renew);
2332 JSAN.use('util.error'); var error = new util.error();
2333 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2338 var renew = obj.network.simple_request(
2341 async ? renew_callback : null,
2343 'title' : document.getElementById('circStrings').getMessage('staff.circ.checkin.renew_failed.override'),
2344 'overridable_events' : [
2345 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2346 1213 /* PATRON_BARRED */,
2347 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2348 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2349 7003 /* COPY_CIRC_NOT_ALLOWED */,
2350 7004 /* COPY_NOT_AVAILABLE */,
2351 7006 /* COPY_IS_REFERENCE */,
2352 7007 /* COPY_NEEDED_FOR_HOLD */,
2353 7008 /* MAX_RENEWALS_REACHED */,
2354 7009 /* CIRC_CLAIMS_RETURNED */,
2355 7010 /* COPY_ALERT_MESSAGE */,
2356 7013 /* PATRON_EXCEEDS_FINES */,
2359 '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2360 '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2361 '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2362 '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2363 '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2364 '7004' : function(r) {
2365 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [barcode, r.payload.status().name()]);
2367 '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2368 '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2369 '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2370 '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2371 '7010' : function(r) {
2372 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2374 '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2379 return renew_callback( { 'getResultObject' : function() { return renew; } } );
2383 JSAN.use('util.error'); var error = new util.error();
2384 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2389 dump('exiting circ/util.js\n');