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,count) {
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 if (!count) count = 4;
98 for (var i = 0; i < selection_list.length; i++) {
100 if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
101 var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
102 var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id, 'count' : count } );
104 if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
105 var patrons = my_xulG.retrieve_these_patrons;
106 for (var j = 0; j < patrons.length; j++) {
107 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
109 var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
110 window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
112 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
118 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
123 circ.util.offline_checkout_columns = function(modify,params) {
128 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
132 'render' : function(my) { return my.timestamp; }
135 'id' : 'checkout_time',
136 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
140 'render' : function(my) { return my.checkout_time; }
144 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
148 'render' : function(my) { return my.type; }
152 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
156 'render' : function(my) { return my.noncat; }
159 'id' : 'noncat_type',
160 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
164 'render' : function(my) { return my.noncat_type; }
167 'id' : 'noncat_count',
168 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
169 'sort_type' : 'number',
173 'render' : function(my) { return my.noncat_count; }
176 'id' : 'patron_barcode',
177 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
181 'render' : function(my) { return my.patron_barcode; }
185 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
189 'render' : function(my) { return my.barcode; }
193 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
197 'render' : function(my) { return my.due_date; }
200 if (modify) for (var i = 0; i < c.length; i++) {
201 if (modify[ c[i].id ]) {
202 for (var j in modify[ c[i].id ]) {
203 c[i][j] = modify[ c[i].id ][j];
208 if (params.just_these) {
209 JSAN.use('util.functional');
211 for (var i = 0; i < params.just_these.length; i++) {
212 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
213 new_c.push( function(y){ return y; }( x ) );
217 if (params.except_these) {
218 JSAN.use('util.functional');
220 for (var i = 0; i < c.length; i++) {
221 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
222 if (!x) new_c.push(c[i]);
228 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
231 circ.util.offline_checkin_columns = function(modify,params) {
236 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
240 'render' : function(my) { return my.timestamp; }
244 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
248 'render' : function(my) { return my.backdate; }
252 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
256 'render' : function(my) { return my.type; }
260 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
264 'render' : function(my) { return my.barcode; }
267 if (modify) for (var i = 0; i < c.length; i++) {
268 if (modify[ c[i].id ]) {
269 for (var j in modify[ c[i].id ]) {
270 c[i][j] = modify[ c[i].id ][j];
275 if (params.just_these) {
276 JSAN.use('util.functional');
278 for (var i = 0; i < params.just_these.length; i++) {
279 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
280 new_c.push( function(y){ return y; }( x ) );
284 if (params.except_these) {
285 JSAN.use('util.functional');
287 for (var i = 0; i < c.length; i++) {
288 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
289 if (!x) new_c.push(c[i]);
295 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
298 circ.util.offline_renew_columns = function(modify,params) {
303 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
307 'render' : function(my) { return my.timestamp; }
310 'id' : 'checkout_time',
311 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
315 'render' : function(my) { return my.checkout_time; }
319 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
323 'render' : function(my) { return my.type; }
326 'id' : 'patron_barcode',
327 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
331 'render' : function(my) { return my.patron_barcode; }
335 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
339 'render' : function(my) { return my.barcode; }
343 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
347 'render' : function(my) { return my.due_date; }
350 if (modify) for (var i = 0; i < c.length; i++) {
351 if (modify[ c[i].id ]) {
352 for (var j in modify[ c[i].id ]) {
353 c[i][j] = modify[ c[i].id ][j];
358 if (params.just_these) {
359 JSAN.use('util.functional');
361 for (var i = 0; i < params.just_these.length; i++) {
362 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
363 new_c.push( function(y){ return y; }( x ) );
367 if (params.except_these) {
368 JSAN.use('util.functional');
370 for (var i = 0; i < c.length; i++) {
371 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
372 if (!x) new_c.push(c[i]);
378 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
381 circ.util.offline_inhouse_use_columns = function(modify,params) {
386 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
390 'render' : function(my) { return my.timestamp; }
394 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
398 'render' : function(my) { return my.use_time; }
402 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
406 'render' : function(my) { return my.type; }
410 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
411 'sort_type' : 'number',
415 'render' : function(my) { return my.count; }
419 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
423 'render' : function(my) { return my.barcode; }
426 if (modify) for (var i = 0; i < c.length; i++) {
427 if (modify[ c[i].id ]) {
428 for (var j in modify[ c[i].id ]) {
429 c[i][j] = modify[ c[i].id ][j];
434 if (params.just_these) {
435 JSAN.use('util.functional');
437 for (var i = 0; i < params.just_these.length; i++) {
438 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
439 new_c.push( function(y){ return y; }( x ) );
443 if (params.except_these) {
444 JSAN.use('util.functional');
446 for (var i = 0; i < c.length; i++) {
447 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
448 if (!x) new_c.push(c[i]);
454 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
457 circ.util.columns = function(modify,params) {
459 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
460 JSAN.use('util.network'); var network = new util.network();
461 JSAN.use('util.money');
466 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
470 'render' : function(my) { return my.acp.id(); },
471 'persist' : 'hidden width ordinal'
475 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
479 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
480 'persist' : 'hidden width ordinal'
484 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
488 'render' : function(my) { return my.mvr.doc_id(); },
489 'persist' : 'hidden width ordinal'
492 'persist' : 'hidden width ordinal',
498 'render' : function(my) { return my.service; }
502 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
506 'render' : function(my) { return my.acp.barcode(); },
507 'persist' : 'hidden width ordinal'
510 'id' : 'call_number',
511 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
515 'render' : function(my) {
516 if (my.acp && my.acp.call_number() == -1) {
517 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
518 } else if (my.acp && my.acp.call_number() == -2) {
519 return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
522 var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
524 return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
526 my.acn = x; return x.label();
529 return my.acn.label();
533 'persist' : 'hidden width ordinal'
537 'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
541 'render' : function(my) {
542 if (Number(my.acn.owning_lib())>=0) {
543 return data.hash.aou[ my.acn.owning_lib() ].shortname();
545 return my.acn.owning_lib().shortname();
548 'persist' : 'hidden width ordinal'
551 'id' : 'copy_number',
552 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
554 'sort_type' : 'number',
557 'render' : function(my) { return my.acp.copy_number(); },
558 'persist' : 'hidden width ordinal'
562 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
566 'render' : function(my) {
567 if (Number(my.acp.location())>=0) {
568 return data.lookup("acpl", my.acp.location() ).name();
570 return my.acp.location().name();
573 'persist' : 'hidden width ordinal'
576 'id' : 'loan_duration',
577 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
581 'render' : function(my) {
582 switch(Number(my.acp.loan_duration())) {
584 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
587 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
590 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
594 'persist' : 'hidden width ordinal'
598 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
602 'render' : function(my) {
603 if (Number(my.acp.circ_lib())>=0) {
604 return data.hash.aou[ my.acp.circ_lib() ].shortname();
606 return my.acp.circ_lib().shortname();
609 'persist' : 'hidden width ordinal'
613 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
617 'render' : function(my) {
618 switch(Number(my.acp.fine_level())) {
620 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
623 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
626 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
630 'persist' : 'hidden width ordinal'
634 'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
638 'render' : function(my) {
639 if (get_bool( my.acp.circulate() )) {
640 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
642 return document.getElementById('circStrings').getString('staff.circ.utils.no');
645 'persist' : 'hidden width ordinal'
649 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
653 'render' : function(my) {
654 if (get_bool( my.acp.deleted() )) {
655 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
657 return document.getElementById('circStrings').getString('staff.circ.utils.no');
660 'persist' : 'hidden width ordinal'
664 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
668 'render' : function(my) {
669 if (get_bool( my.acp.holdable() )) {
670 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
672 return document.getElementById('circStrings').getString('staff.circ.utils.no');
675 'persist' : 'hidden width ordinal'
678 'id' : 'opac_visible',
679 'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
683 'render' : function(my) {
684 if (get_bool( my.acp.opac_visible() )) {
685 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
687 return document.getElementById('circStrings').getString('staff.circ.utils.no');
690 'persist' : 'hidden width ordinal'
693 'persist' : 'hidden width ordinal',
695 'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
699 'render' : function(my) {
700 if (get_bool( my.acp.ref() )) {
701 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
703 return document.getElementById('circStrings').getString('staff.circ.utils.no');
708 'persist' : 'hidden width ordinal',
710 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
714 'render' : function(my) {
715 if (get_bool( my.acp.deposit() )) {
716 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
718 return document.getElementById('circStrings').getString('staff.circ.utils.no');
723 'persist' : 'hidden width ordinal',
724 'id' : 'deposit_amount',
725 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
729 'render' : function(my) {
730 if (my.acp.price() == null) {
731 return document.getElementById('circStrings').getString('staff.circ.utils.unset');
733 return util.money.sanitize(my.acp.deposit_amount());
736 'sort_type' : 'money'
739 'persist' : 'hidden width ordinal',
741 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
745 'render' : function(my) {
746 if (my.acp.price() == null) {
747 return document.getElementById('circStrings').getString('staff.circ.utils.unset');
749 return util.money.sanitize(my.acp.price());
752 'sort_type' : 'money'
755 'persist' : 'hidden width ordinal',
756 'id' : 'circ_as_type',
757 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
761 'render' : function(my) { return my.acp.circ_as_type(); }
764 'persist' : 'hidden width ordinal',
765 'id' : 'circ_modifier',
766 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
770 'render' : function(my) { return my.acp.circ_modifier(); }
773 'persist' : 'hidden width ordinal',
774 'id' : 'checkout_lib',
775 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
779 'render' : function(my) {
781 return data.hash.aou[ my.circ.circ_lib() ].shortname();
783 if (my.acp.circulations()) {
784 return data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname();
792 'persist' : 'hidden width ordinal',
793 'id' : 'xact_start_full',
794 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_timestamp'),
798 'render' : function(my) {
800 return my.circ.xact_start();
802 if (my.acp.circulations()) {
803 return my.acp.circulations()[0].xact_start();
812 'persist' : 'hidden width ordinal',
813 'id' : 'checkin_time_full',
814 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_timestamp'),
818 'render' : function(my) {
820 return my.circ.checkin_time();
822 if (my.acp.circulations()) {
823 return my.acp.circulations()[0].checkin_time();
831 'persist' : 'hidden width ordinal',
833 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
837 'render' : function(my) {
839 return my.circ.xact_start().substr(0,10);
841 if (my.acp.circulations()) {
842 return my.acp.circulations()[0].xact_start().substr(0,10);
850 'persist' : 'hidden width ordinal',
851 'id' : 'checkin_time',
852 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
856 'render' : function(my) {
858 return my.circ.checkin_time().substr(0,10);
860 if (my.acp.circulations()) {
861 return my.acp.circulations()[0].checkin_time().substr(0,10);
869 'persist' : 'hidden width ordinal',
870 'id' : 'xact_finish',
871 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
875 'render' : function(my) { return my.circ.xact_finish(); }
878 'persist' : 'hidden width ordinal',
880 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
884 'render' : function(my) {
886 return my.circ.due_date().substr(0,10);
888 if (my.acp.circulations()) {
889 return my.acp.circulations()[0].due_date().substr(0,10);
897 'persist' : 'hidden width ordinal',
898 'id' : 'create_date',
899 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
903 'render' : function(my) { return my.acp.create_date().substr(0,10); }
906 'persist' : 'hidden width ordinal',
908 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
912 'render' : function(my) { return my.acp.edit_date().substr(0,10); }
915 'persist' : 'hidden width ordinal',
917 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
919 'sort_type' : 'title',
922 'render' : function(my) {
923 try { return my.mvr.title(); }
924 catch(E) { return my.acp.dummy_title(); }
928 'persist' : 'hidden width ordinal',
930 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
934 'render' : function(my) {
935 try { return my.mvr.author(); }
936 catch(E) { return my.acp.dummy_author(); }
940 'persist' : 'hidden width ordinal',
942 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
946 'render' : function(my) { return my.mvr.edition(); }
949 'persist' : 'hidden width ordinal',
951 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
955 'render' : function(my) { return my.mvr.isbn(); }
958 'persist' : 'hidden width ordinal',
960 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
964 'render' : function(my) { return my.mvr.pubdate(); }
967 'persist' : 'hidden width ordinal',
969 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
973 'render' : function(my) { return my.mvr.publisher(); }
976 'persist' : 'hidden width ordinal',
978 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
982 'render' : function(my) { return my.mvr.tcn(); }
985 'persist' : 'hidden width ordinal',
986 'id' : 'renewal_remaining',
987 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
991 'render' : function(my) {
993 return my.circ.renewal_remaining();
995 if (my.acp.circulations()) {
996 return my.acp.circulations()[0].renewal_remaining();
1002 'sort_type' : 'number'
1005 'persist' : 'hidden width ordinal',
1006 'id' : 'stop_fines',
1007 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1011 'render' : function(my) {
1013 return my.circ.stop_fines();
1015 if (my.acp.circulations()) {
1016 return my.acp.circulations()[0].stop_fines();
1024 'persist' : 'hidden width ordinal',
1025 'id' : 'stop_fines_time',
1026 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1030 'render' : function(my) {
1032 return my.circ.stop_fines_time();
1034 if (my.acp.circulations()) {
1035 return my.acp.circulations()[0].stop_fines_time();
1043 'persist' : 'hidden width ordinal',
1045 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1049 'render' : function(my) {
1050 if (Number(my.acp.status())>=0) {
1051 return data.hash.ccs[ my.acp.status() ].name();
1053 return my.acp.status().name();
1058 'persist' : 'hidden width ordinal',
1060 'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1064 'render' : function(my) { return my.route_to.toString(); }
1067 'persist' : 'hidden width ordinal',
1069 'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1073 'render' : function(my) { return my.message.toString(); }
1076 'persist' : 'hidden width ordinal',
1078 'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1082 'render' : function(my) { return my.uses; },
1083 'sort_type' : 'number'
1086 'persist' : 'hidden width ordinal',
1087 'id' : 'alert_message',
1088 'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1092 'render' : function(my) { return my.acp.alert_message(); }
1095 for (var i = 0; i < c.length; i++) {
1096 if (modify[ c[i].id ]) {
1097 for (var j in modify[ c[i].id ]) {
1098 c[i][j] = modify[ c[i].id ][j];
1103 if (params.just_these) {
1104 JSAN.use('util.functional');
1106 for (var i = 0; i < params.just_these.length; i++) {
1107 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1108 new_c.push( function(y){ return y; }( x ) );
1112 if (params.except_these) {
1113 JSAN.use('util.functional');
1115 for (var i = 0; i < c.length; i++) {
1116 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1117 if (!x) new_c.push(c[i]);
1122 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1125 circ.util.transit_columns = function(modify,params) {
1127 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1131 'persist' : 'hidden width ordinal',
1132 'id' : 'transit_item_barcode',
1133 'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1137 'render' : function(my) { return my.acp.barcode(); }
1140 'persist' : 'hidden width ordinal',
1141 'id' : 'transit_item_title',
1142 'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1146 'render' : function(my) {
1147 try { return my.mvr.title(); }
1148 catch(E) { return my.acp.dummy_title(); }
1152 'persist' : 'hidden width ordinal',
1153 'id' : 'transit_item_author',
1154 'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1158 'render' : function(my) {
1159 try { return my.mvr.author(); }
1160 catch(E) { return my.acp.dummy_author(); }
1164 'persist' : 'hidden width ordinal',
1165 'id' : 'transit_item_callnumber',
1166 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1170 'render' : function(my) { return my.acn.label(); }
1173 'persist' : 'hidden width ordinal',
1174 'id' : 'transit_id',
1175 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1179 'render' : function(my) { return my.atc.id(); }
1182 'persist' : 'hidden width ordinal',
1183 'id' : 'transit_source',
1184 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1188 'render' : function(my) {
1189 if (typeof my.atc.source() == "object") {
1190 return my.atc.source().shortname();
1192 return data.hash.aou[ my.atc.source() ].shortname();
1197 'persist' : 'hidden width ordinal',
1198 'id' : 'transit_source_send_time',
1199 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1203 'render' : function(my) { return my.atc.source_send_time(); }
1206 'persist' : 'hidden width ordinal',
1207 'id' : 'transit_dest_lib',
1208 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1212 'render' : function(my) {
1213 if (typeof my.atc.dest() == "object") {
1214 return my.atc.dest().shortname();
1216 return data.hash.aou[ my.atc.dest() ].shortname();
1221 'persist' : 'hidden width ordinal',
1222 'id' : 'transit_dest_recv_time',
1223 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1227 'render' : function(my) { return my.atc.dest_recv_time(); }
1230 'persist' : 'hidden width ordinal',
1231 'id' : 'transit_target_copy',
1232 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1236 'render' : function(my) { return my.atc.target_copy(); }
1239 for (var i = 0; i < c.length; i++) {
1240 if (modify[ c[i].id ]) {
1241 for (var j in modify[ c[i].id ]) {
1242 c[i][j] = modify[ c[i].id ][j];
1247 if (params.just_these) {
1248 JSAN.use('util.functional');
1250 for (var i = 0; i < params.just_these.length; i++) {
1251 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1252 new_c.push( function(y){ return y; }( x ) );
1256 if (params.except_these) {
1257 JSAN.use('util.functional');
1259 for (var i = 0; i < c.length; i++) {
1260 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1261 if (!x) new_c.push(c[i]);
1267 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1270 circ.util.hold_columns = function(modify,params) {
1272 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1276 'persist' : 'hidden width ordinal',
1277 'id' : 'request_lib',
1278 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1282 'render' : function(my) {
1283 if (Number(my.ahr.request_lib())>=0) {
1284 return data.hash.aou[ my.ahr.request_lib() ].name();
1286 return my.ahr.request_lib().name();
1291 'persist' : 'hidden width ordinal',
1292 'id' : 'request_lib_shortname',
1293 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1297 'render' : function(my) {
1298 if (Number(my.ahr.request_lib())>=0) {
1299 return data.hash.aou[ my.ahr.request_lib() ].shortname();
1301 return my.ahr.request_lib().shortname();
1307 'persist' : 'hidden width ordinal',
1308 'id' : 'request_timestamp',
1309 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1313 'render' : function(my) { return my.ahr.request_time().toString(); }
1316 'persist' : 'hidden width ordinal',
1317 'id' : 'request_time',
1318 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1322 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1325 'persist' : 'hidden width ordinal',
1326 'id' : 'available_timestamp',
1327 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1331 'render' : function(my) {
1332 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1333 return my.ahr.transit().dest_recv_time().toString();
1335 if (my.ahr.capture_time()) {
1336 return my.ahr.capture_time().toString();
1342 'persist' : 'hidden width ordinal',
1343 'id' : 'available_time',
1344 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1348 'render' : function(my) {
1349 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1350 return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1352 if (my.ahr.capture_time()) {
1353 return my.ahr.capture_time().toString().substr(0,10);
1359 'persist' : 'hidden width ordinal',
1360 'id' : 'capture_timestamp',
1361 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1365 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1368 'persist' : 'hidden width ordinal',
1369 'id' : 'capture_time',
1370 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1374 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1377 'persist' : 'hidden width ordinal',
1379 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1383 'render' : function(my) {
1384 switch (Number(my.status)) {
1386 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1389 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1392 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1395 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1404 'persist' : 'hidden width ordinal',
1406 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1410 'render' : function(my) { return my.ahr.hold_type(); }
1413 'persist' : 'hidden width ordinal',
1415 'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1419 'render' : function(my) {
1420 if (!get_bool( my.ahr.frozen() )) {
1421 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1423 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1428 'persist' : 'hidden width ordinal',
1430 'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1434 'render' : function(my) {
1435 if (my.ahr.thaw_date() == null) {
1436 return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1438 return my.ahr.thaw_date().substr(0,10);
1443 'persist' : 'hidden width ordinal',
1444 'id' : 'pickup_lib',
1445 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1449 'render' : function(my) {
1450 if (Number(my.ahr.pickup_lib())>=0) {
1451 return data.hash.aou[ my.ahr.pickup_lib() ].name();
1453 return my.ahr.pickup_lib().name();
1458 'persist' : 'hidden width ordinal',
1459 'id' : 'pickup_lib_shortname',
1460 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1464 'render' : function(my) {
1465 if (Number(my.ahr.pickup_lib())>=0) {
1466 return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1468 return my.ahr.pickup_lib().shortname();
1473 'persist' : 'hidden width ordinal',
1474 'id' : 'current_copy',
1475 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1479 'render' : function(my) {
1481 return my.acp.barcode();
1483 return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1488 'persist' : 'hidden width ordinal',
1489 'id' : 'current_copy_location',
1490 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1494 'render' : function(my) {
1495 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(); }
1499 'persist' : 'hidden width ordinal',
1500 'id' : 'email_notify',
1501 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1505 'render' : function(my) {
1506 if (get_bool(my.ahr.email_notify())) {
1507 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1509 return document.getElementById('circStrings').getString('staff.circ.utils.no');
1514 'persist' : 'hidden width ordinal',
1515 'id' : 'expire_time',
1516 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1520 'render' : function(my) { return my.ahr.expire_time(); }
1523 'persist' : 'hidden width ordinal',
1524 'id' : 'expire_date',
1525 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1529 'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
1532 'persist' : 'hidden width ordinal',
1533 'id' : 'fulfillment_time',
1534 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1538 'render' : function(my) { return my.ahr.fulfillment_time(); }
1541 'persist' : 'hidden width ordinal',
1542 'id' : 'holdable_formats',
1543 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1547 'render' : function(my) { return my.ahr.holdable_formats(); }
1550 'persist' : 'hidden width ordinal',
1552 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1556 'render' : function(my) { return my.ahr.id(); }
1559 'persist' : 'hidden width ordinal',
1560 'id' : 'phone_notify',
1561 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1565 'render' : function(my) { return my.ahr.phone_notify(); }
1568 'persist' : 'hidden width ordinal',
1569 'id' : 'prev_check_time',
1570 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1574 'render' : function(my) { return my.ahr.prev_check_time(); }
1577 'persist' : 'hidden width ordinal',
1579 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1583 'render' : function(my) { return my.ahr.requestor(); }
1586 'persist' : 'hidden width ordinal',
1587 'id' : 'selection_depth',
1588 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1592 'render' : function(my) { return my.ahr.selection_depth(); }
1595 'persist' : 'hidden width ordinal',
1597 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1601 'render' : function(my) { return my.ahr.target(); }
1604 'persist' : 'hidden width ordinal',
1606 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1610 'render' : function(my) { return my.ahr.usr(); }
1613 'persist' : 'hidden width ordinal',
1615 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1617 'sort_type' : 'title',
1620 'render' : function(my) {
1622 return my.mvr.title();
1624 return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1629 'persist' : 'hidden width ordinal',
1631 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1635 'render' : function(my) {
1637 return my.mvr.author();
1639 return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1644 'persist' : 'hidden width ordinal',
1646 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1650 'render' : function(my) { return my.mvr.edition(); }
1653 'persist' : 'hidden width ordinal',
1655 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1659 'render' : function(my) { return my.mvr.isbn(); }
1662 'persist' : 'hidden width ordinal',
1664 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1668 'render' : function(my) { return my.mvr.pubdate(); }
1671 'persist' : 'hidden width ordinal',
1673 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1677 'render' : function(my) { return my.mvr.publisher(); }
1680 'persist' : 'hidden width ordinal',
1682 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1686 'render' : function(my) { return my.mvr.tcn(); }
1689 'persist' : 'hidden width ordinal',
1690 'id' : 'notify_time',
1691 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1695 'render' : function(my) { return my.ahr.notify_time(); }
1698 'persist' : 'hidden width ordinal',
1699 'id' : 'notify_count',
1700 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1704 'render' : function(my) { return my.ahr.notify_count(); }
1707 'persist' : 'hidden width ordinal',
1708 'id' : 'transit_source',
1709 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1713 'render' : function(my) {
1714 if (my.ahr.transit()) {
1715 return data.hash.aou[ my.ahr.transit().source() ].shortname();
1722 'persist' : 'hidden width ordinal',
1723 'id' : 'transit_source_send_time',
1724 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1728 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; }
1731 'persist' : 'hidden width ordinal',
1732 'id' : 'transit_dest_lib',
1733 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1737 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1740 'persist' : 'hidden width ordinal',
1741 'id' : 'transit_dest_recv_time',
1742 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1746 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; }
1749 'persist' : 'hidden width ordinal',
1750 'id' : 'patron_barcode',
1751 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1755 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1758 'persist' : 'hidden width ordinal',
1759 'id' : 'patron_family_name',
1760 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1764 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1767 'persist' : 'hidden width ordinal',
1768 'id' : 'patron_first_given_name',
1769 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1773 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1776 'persist' : 'hidden width ordinal',
1777 'id' : 'callnumber',
1778 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1782 'render' : function(my) { return my.acn.label(); }
1785 for (var i = 0; i < c.length; i++) {
1786 if (modify[ c[i].id ]) {
1787 for (var j in modify[ c[i].id ]) {
1788 c[i][j] = modify[ c[i].id ][j];
1793 if (params.just_these) {
1794 JSAN.use('util.functional');
1796 for (var i = 0; i < params.just_these.length; i++) {
1797 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1798 new_c.push( function(y){ return y; }( x ) );
1802 if (params.except_these) {
1803 JSAN.use('util.functional');
1805 for (var i = 0; i < c.length; i++) {
1806 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1807 if (!x) new_c.push(c[i]);
1813 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1816 circ.util.std_map_row_to_column = function(error_value) {
1817 return function(row,col) {
1818 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1819 // col contains one of the objects listed above in columns
1821 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
1823 JSAN.use('util.error'); obj.error = new util.error();
1824 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1825 JSAN.use('util.network'); obj.network = new util.network();
1826 JSAN.use('util.money');
1831 value = eval( col.render );
1833 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1834 if (error_value) value = error_value; else value = ' ';
1840 circ.util.std_map_row_to_columns = function(error_value) {
1841 return function(row,cols) {
1842 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1843 // cols contains all of the objects listed above in columns
1846 JSAN.use('util.error'); obj.error = new util.error();
1847 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1848 JSAN.use('util.network'); obj.network = new util.network();
1849 JSAN.use('util.money');
1855 for (var i = 0; i < cols.length; i++) {
1856 switch (typeof cols[i].render) {
1857 case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
1858 case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
1859 default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
1862 if (cmd) eval( cmd );
1864 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1865 if (error_value) { value = error_value; } else { value = ' ' };
1871 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
1873 JSAN.use('util.error'); var error = new util.error();
1874 JSAN.use('util.network'); var network = new util.network();
1875 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1876 JSAN.use('util.date');
1878 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1880 //var params = { 'barcode' : barcode };
1881 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1883 if (typeof async == 'object') {
1884 try { async.disable_textbox(); }
1885 catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1887 var check = network.request(
1888 api.CHECKIN_VIA_BARCODE.app,
1889 api.CHECKIN_VIA_BARCODE.method,
1890 [ session, params ],
1891 async ? function(req) {
1893 var check = req.getResultObject();
1894 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1895 if (typeof async == 'object') {
1896 try { async.checkin_result(r); }
1897 catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1900 JSAN.use('util.error'); var error = new util.error();
1901 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['1']), E);
1902 if (typeof async == 'object') {
1903 try { async.enable_textbox(); }
1904 catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1910 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
1911 'overridable_events' : [
1912 1203 /* COPY_BAD_STATUS */,
1913 1213 /* PATRON_BARRED */,
1914 1217 /* PATRON_INACTIVE */,
1915 1224 /* PATRON_ACCOUNT_EXPIRED */,
1916 7009 /* CIRC_CLAIMS_RETURNED */,
1917 7010 /* COPY_ALERT_MESSAGE */,
1918 7011 /* COPY_STATUS_LOST */,
1919 7012 /* COPY_STATUS_MISSING */,
1920 7013 /* PATRON_EXCEEDS_FINES */,
1923 '1203' : function(r) {
1924 //return data.hash.ccs[ r.payload.status() ].name();
1925 return r.payload.status().name();
1927 '7010' : function(r) {
1934 return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1939 JSAN.use('util.error'); var error = new util.error();
1940 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['2']), E);
1941 if (typeof async == 'object') {
1942 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1948 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1950 JSAN.use('util.error'); var error = new util.error();
1951 JSAN.use('util.network'); var network = new util.network();
1952 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1953 JSAN.use('util.date');
1955 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1957 check.message = check.textcode;
1959 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
1960 if (check.payload && check.payload.record) { check.record = check.payload.record; }
1961 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
1963 if (!check.route_to) { check.route_to = ' '; }
1965 if (document.getElementById('no_change_label')) {
1966 document.getElementById('no_change_label').setAttribute('value','');
1967 document.getElementById('no_change_label').setAttribute('hidden','true');
1971 network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
1972 JSAN.use('util.money');
1973 var bill = req.getResultObject();
1974 if (Number(bill.balance_owed()) == 0) { return; }
1975 if (document.getElementById('no_change_label')) {
1976 var m = document.getElementById('no_change_label').getAttribute('value');
1977 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())]) + ' ');
1978 document.getElementById('no_change_label').setAttribute('hidden','false');
1985 if (check.payload && check.payload.cancelled_hold_transit) {
1986 msg += document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
1990 /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
1991 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1992 try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
1994 msg += document.getElementById('commonStrings').getString('common.error');
1995 msg += '\nFIXME: ' + E + '\n';
1997 if (check.ilsevent == 3 /* NO_CHANGE */) {
1998 //msg = 'This item is already checked in.\n';
1999 if (document.getElementById('no_change_label')) {
2000 var m = document.getElementById('no_change_label').getAttribute('value');
2001 document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + ' ');
2002 document.getElementById('no_change_label').setAttribute('hidden','false');
2005 if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2006 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2007 msg = document.getElementById('commonStrings').getString('common.error');
2008 msg += '\nFIXME --';
2009 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2012 switch(Number(check.copy.status())) {
2013 case 0: /* AVAILABLE */
2014 case 7: /* RESHELVING */
2016 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2020 case 8: /* ON HOLDS SHELF */
2021 check.route_to = 'HOLDS SHELF';
2022 if (check.payload.hold) {
2023 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2024 msg += document.getElementById('commonStrings').getString('common.error');
2026 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2029 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2033 msg += document.getElementById('commonStrings').getString('common.error');
2035 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2038 JSAN.use('util.date');
2039 if (check.payload.hold) {
2040 JSAN.use('patron.util');
2042 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2044 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2045 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2047 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2049 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()]);
2051 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2053 if (check.payload.hold.phone_notify()) {
2054 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2057 if (check.payload.hold.email_notify()) {
2058 var payload_email = au_obj.email() ? au_obj.email() : '';
2059 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2063 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2067 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2070 rv = error.yns_alert_formatted(
2072 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2073 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2074 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2076 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2077 '/xul/server/skin/media/images/turtle.gif'
2082 JSAN.use('util.print'); var print = new util.print();
2083 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2084 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2086 var err_msg = document.getElementById('commonStrings').getString('common.error');
2087 err_msg += '\nFIXME: ' + E + '\n';
2093 if (document.getElementById('no_change_label')) {
2094 var m = document.getElementById('no_change_label').getAttribute('value');
2095 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2096 document.getElementById('no_change_label').setAttribute('value', m);
2097 document.getElementById('no_change_label').setAttribute('hidden','false');
2100 case 6: /* IN TRANSIT */
2101 check.route_to = 'TRANSIT SHELF??';
2102 msg += document.getElementById('commonStrings').getString('common.error');
2103 msg += "\nFIXME -- I didn't think we could get here.\n";
2105 case 11: /* CATALOGING */
2106 check.route_to = 'CATALOGING';
2107 if (document.getElementById('do_not_alert_on_precat')) {
2108 var x = document.getElementById('do_not_alert_on_precat');
2110 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2113 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2115 if (document.getElementById('no_change_label')) {
2116 var m = document.getElementById('no_change_label').getAttribute('value');
2117 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2118 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + ' ');
2119 document.getElementById('no_change_label').setAttribute('hidden','false');
2123 msg += document.getElementById('commonStrings').getString('common.error');
2124 var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2126 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2128 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2134 document.getElementById('circStrings').getString('staff.circ.alert'),
2136 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2138 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2141 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2143 var lib = data.hash.aou[ check.org ];
2144 check.route_to = lib.shortname();
2145 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2150 if (lib.holds_address() ) {
2151 var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2152 if (typeof a.ilsevent != 'undefined') throw(a);
2153 if (a.street1()) msg += a.street1() + '\n';
2154 if (a.street2()) msg += a.street2() + '\n';
2155 msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
2157 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2161 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2163 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2166 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2168 var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2169 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2171 var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2172 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2174 JSAN.use('util.date');
2175 if (check.payload.hold) {
2176 JSAN.use('patron.util');
2177 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2179 document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2181 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2183 if (check.payload.hold.phone_notify()) {
2184 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2187 if (check.payload.hold.email_notify()) {
2188 var payload_email = au_obj.email() ? au_obj.email() : '';
2189 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2193 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2197 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2199 rv = error.yns_alert_formatted(
2201 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2202 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2203 document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2205 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2206 '/xul/server/skin/media/images/turtle.gif'
2212 JSAN.use('util.print'); var print = new util.print();
2213 //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
2214 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
2215 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2217 var err_msg = document.getElementById('commonStrings').getString('common.error');
2218 err_msg += '\nFIXME: ' + E + '\n';
2223 if (document.getElementById('no_change_label')) {
2224 var m = document.getElementById('no_change_label').getAttribute('value');
2225 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2226 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + ' ');
2227 document.getElementById('no_change_label').setAttribute('hidden','false');
2230 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2232 check.route_to = 'CATALOGING';
2233 var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2236 document.getElementById('circStrings').getString('staff.circ.alert'),
2238 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2240 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2242 if (document.getElementById('no_change_label')) {
2243 var m = document.getElementById('no_change_label').getAttribute('value');
2244 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' ');
2245 document.getElementById('no_change_label').setAttribute('hidden','false');
2248 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2249 error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2252 switch (Number(check.ilsevent)) {
2253 case 1203 /* COPY_BAD_STATUS */ :
2254 case 1213 /* PATRON_BARRED */ :
2255 case 1217 /* PATRON_INACTIVE */ :
2256 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2257 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2258 case 7010 /* COPY_ALERT_MESSAGE */ :
2259 case 7011 /* COPY_STATUS_LOST */ :
2260 case 7012 /* COPY_STATUS_MISSING */ :
2261 case 7013 /* PATRON_EXCEEDS_FINES */ :
2262 return null; /* handled */
2272 JSAN.use('util.error'); var error = new util.error();
2273 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.error', ['3']), E);
2278 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2281 JSAN.use('util.network'); obj.network = new util.network();
2282 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2284 var params = { barcode: barcode };
2285 if (patron_id) params.patron = patron_id;
2287 function renew_callback(req) {
2289 var renew = req.getResultObject();
2290 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2291 for (var j = 0; j < renew.length; j++) {
2292 switch(Number(renew[j].ilsevent)) {
2293 case 0 /* SUCCESS */ : break;
2294 case 5000 /* PERM_FAILURE */: break;
2295 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2296 case 1213 /* PATRON_BARRED */ : break;
2297 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2298 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2299 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2300 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2301 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2302 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2303 case 7006 /* COPY_IS_REFERENCE */ : break;
2304 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2305 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2306 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2307 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2308 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2314 if (typeof async == 'function') async(renew);
2317 JSAN.use('util.error'); var error = new util.error();
2318 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedMessage('staff.circ.checkin.renew_failed.error', [barcode]), E);
2323 var renew = obj.network.simple_request(
2326 async ? renew_callback : null,
2328 'title' : document.getElementById('circStrings').getMessage('staff.circ.checkin.renew_failed.override'),
2329 'overridable_events' : [
2330 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2331 1213 /* PATRON_BARRED */,
2332 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2333 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2334 7003 /* COPY_CIRC_NOT_ALLOWED */,
2335 7004 /* COPY_NOT_AVAILABLE */,
2336 7006 /* COPY_IS_REFERENCE */,
2337 7007 /* COPY_NEEDED_FOR_HOLD */,
2338 7008 /* MAX_RENEWALS_REACHED */,
2339 7009 /* CIRC_CLAIMS_RETURNED */,
2340 7010 /* COPY_ALERT_MESSAGE */,
2341 7013 /* PATRON_EXCEEDS_FINES */,
2344 '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2345 '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2346 '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2347 '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2348 '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2349 '7004' : function(r) {
2350 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [barcode, r.payload.status().name()]);
2352 '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2353 '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2354 '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2355 '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2356 '7010' : function(r) {
2357 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2359 '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2364 return renew_callback( { 'getResultObject' : function() { return renew; } } );
2368 JSAN.use('util.error'); var error = new util.error();
2369 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2374 dump('exiting circ/util.js\n');