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(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'),
129 'flex' : 1, 'primary' : false, 'hidden' : true,
130 'render' : function(my) { return my.timestamp; },
133 'id' : 'checkout_time',
134 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
135 'flex' : 1, 'primary' : false, 'hidden' : true,
136 'render' : function(my) { return my.checkout_time; },
140 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
141 'flex' : 1, 'primary' : false, 'hidden' : true,
142 'render' : function(my) { return my.type; },
146 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
147 'flex' : 1, 'primary' : false, 'hidden' : true,
148 'render' : function(my) { return my.noncat; },
151 'id' : 'noncat_type',
152 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
153 'flex' : 1, 'primary' : false, 'hidden' : true,
154 'render' : function(my) { return my.noncat_type; },
157 'id' : 'noncat_count',
158 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
159 'sort_type' : 'number',
160 'flex' : 1, 'primary' : false, 'hidden' : false,
161 'render' : function(my) { return my.noncat_count; },
164 'id' : 'patron_barcode',
165 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
166 'flex' : 1, 'primary' : false, 'hidden' : true,
167 'render' : function(my) { return my.patron_barcode; },
171 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
172 'flex' : 2, 'primary' : true, 'hidden' : false,
173 'render' : function(my) { return my.barcode; },
177 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
178 'flex' : 1, 'primary' : false, 'hidden' : false,
179 'render' : function(my) { return my.due_date; },
182 if (modify) for (var i = 0; i < c.length; i++) {
183 if (modify[ c[i].id ]) {
184 for (var j in modify[ c[i].id ]) {
185 c[i][j] = modify[ c[i].id ][j];
190 if (params.just_these) {
191 JSAN.use('util.functional');
193 for (var i = 0; i < params.just_these.length; i++) {
194 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
195 new_c.push( function(y){ return y; }( x ) );
199 if (params.except_these) {
200 JSAN.use('util.functional');
202 for (var i = 0; i < c.length; i++) {
203 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
204 if (!x) new_c.push(c[i]);
210 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
213 circ.util.offline_checkin_columns = function(modify,params) {
218 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
219 'flex' : 1, 'primary' : false, 'hidden' : true,
220 'render' : function(my) { return my.timestamp; },
224 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
225 'flex' : 1, 'primary' : false, 'hidden' : true,
226 'render' : function(my) { return my.backdate; },
230 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
231 'flex' : 1, 'primary' : false, 'hidden' : true,
232 'render' : function(my) { return my.type; },
236 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
237 'flex' : 2, 'primary' : true, 'hidden' : false,
238 'render' : function(my) { return my.barcode; },
241 if (modify) for (var i = 0; i < c.length; i++) {
242 if (modify[ c[i].id ]) {
243 for (var j in modify[ c[i].id ]) {
244 c[i][j] = modify[ c[i].id ][j];
249 if (params.just_these) {
250 JSAN.use('util.functional');
252 for (var i = 0; i < params.just_these.length; i++) {
253 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
254 new_c.push( function(y){ return y; }( x ) );
258 if (params.except_these) {
259 JSAN.use('util.functional');
261 for (var i = 0; i < c.length; i++) {
262 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
263 if (!x) new_c.push(c[i]);
269 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
272 circ.util.offline_renew_columns = function(modify,params) {
277 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
278 'flex' : 1, 'primary' : false, 'hidden' : true,
279 'render' : function(my) { return my.timestamp; },
282 'id' : 'checkout_time',
283 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
284 'flex' : 1, 'primary' : false, 'hidden' : true,
285 'render' : function(my) { return my.checkout_time; },
289 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
290 'flex' : 1, 'primary' : false, 'hidden' : true,
291 'render' : function(my) { return my.type; },
294 'id' : 'patron_barcode',
295 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
296 'flex' : 1, 'primary' : false, 'hidden' : true,
297 'render' : function(my) { return my.patron_barcode; },
301 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
302 'flex' : 2, 'primary' : true, 'hidden' : false,
303 'render' : function(my) { return my.barcode; },
307 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
308 'flex' : 1, 'primary' : false, 'hidden' : false,
309 'render' : function(my) { return my.due_date; },
312 if (modify) for (var i = 0; i < c.length; i++) {
313 if (modify[ c[i].id ]) {
314 for (var j in modify[ c[i].id ]) {
315 c[i][j] = modify[ c[i].id ][j];
320 if (params.just_these) {
321 JSAN.use('util.functional');
323 for (var i = 0; i < params.just_these.length; i++) {
324 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
325 new_c.push( function(y){ return y; }( x ) );
329 if (params.except_these) {
330 JSAN.use('util.functional');
332 for (var i = 0; i < c.length; i++) {
333 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
334 if (!x) new_c.push(c[i]);
340 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
343 circ.util.offline_inhouse_use_columns = function(modify,params) {
348 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
349 'flex' : 1, 'primary' : false, 'hidden' : true,
350 'render' : function(my) { return my.timestamp; },
354 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
355 'flex' : 1, 'primary' : false, 'hidden' : true,
356 'render' : function(my) { return my.use_time; },
360 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
361 'flex' : 1, 'primary' : false, 'hidden' : true,
362 'render' : function(my) { return my.type; },
366 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
367 'sort_type' : 'number',
368 'flex' : 1, 'primary' : false, 'hidden' : false,
369 'render' : function(my) { return my.count; },
373 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
374 'flex' : 2, 'primary' : true, 'hidden' : false,
375 'render' : function(my) { return my.barcode; },
378 if (modify) for (var i = 0; i < c.length; i++) {
379 if (modify[ c[i].id ]) {
380 for (var j in modify[ c[i].id ]) {
381 c[i][j] = modify[ c[i].id ][j];
386 if (params.just_these) {
387 JSAN.use('util.functional');
389 for (var i = 0; i < params.just_these.length; i++) {
390 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
391 new_c.push( function(y){ return y; }( x ) );
395 if (params.except_these) {
396 JSAN.use('util.functional');
398 for (var i = 0; i < c.length; i++) {
399 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
400 if (!x) new_c.push(c[i]);
406 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
411 circ.util.columns = function(modify,params) {
413 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
414 JSAN.use('util.network'); var network = new util.network();
415 JSAN.use('util.money');
419 'id' : 'acp_id', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'), 'flex' : 1,
420 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.id(); }, 'persist' : 'hidden width ordinal',
423 'id' : 'circ_id', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'), 'flex' : 1,
424 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
425 'persist' : 'hidden width ordinal',
428 'id' : 'mvr_doc_id', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'), 'flex' : 1,
429 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.doc_id(); },
430 'persist' : 'hidden width ordinal',
433 'persist' : 'hidden width ordinal', 'id' : 'service', 'label' : 'Service', 'flex' : 1,
434 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.service; },
437 'id' : 'barcode', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'), 'flex' : 1,
438 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); },
439 'persist' : 'hidden width ordinal',
442 'id' : 'call_number',
443 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
445 'primary' : false, 'hidden' : true,
446 'render' : function(my) {
447 if (my.acp && my.acp.call_number() == -1) {
448 return document.getElementById('commonStrings').getString('staff.circ.utils.not_cataloged');
451 var x = network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]);
453 return document.getElementById('commonStrings').getString('staff.circ.utils.not_cataloged');
455 my.acn = x; return x.label();
458 return my.acn.label();
462 'persist' : 'hidden width ordinal',
466 'label' : document.getElementById('commonStrings').getString('staff.circ.utils.owning_lib'),
468 'primary' : false, 'hidden' : true,
469 'render' : function(my) {
470 if (Number(my.acn.owning_lib())>=0) {
471 return data.hash.aou[ my.acn.owning_lib() ].shortname();
473 return my.acn.owning_lib().shortname();
476 'persist' : 'hidden width ordinal',
479 'id' : 'copy_number',
480 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
482 'sort_type' : 'number',
483 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.copy_number(); },
484 'persist' : 'hidden width ordinal',
488 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
490 'primary' : false, 'hidden' : true,
491 'render' : function(my) {
492 if (Number(my.acp.location())>=0) {
493 return data.lookup("acpl", my.acp.location() ).name();
495 return my.acp.location().name();
498 'persist' : 'hidden width ordinal',
501 'id' : 'loan_duration',
502 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
504 'primary' : false, 'hidden' : true,
505 'render' : function(my) {
506 switch(my.acp.loan_duration()) {
508 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
511 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
514 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
518 'persist' : 'hidden width ordinal',
522 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
524 'primary' : false, 'hidden' : true,
525 'render' : function(my) {
526 if (Number(my.acp.circ_lib())>=0) {
527 return data.hash.aou[ my.acp.circ_lib() ].shortname();
529 return my.acp.circ_lib().shortname();
532 'persist' : 'hidden width ordinal',
536 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'), 'flex' : 1,
537 'primary' : false, 'hidden' : true,
538 'render' : function(my) {
539 switch(my.acp.fine_level()) {
541 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
544 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
547 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
551 'persist' : 'hidden width ordinal',
555 'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
557 'primary' : false, 'hidden' : true,
558 'render' : function(my) {
559 if (get_bool( my.acp.circulate() )) {
560 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
562 return document.getElementById('circStrings').getString('staff.circ.utils.no');
565 'persist' : 'hidden width ordinal',
569 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
571 'primary' : false, 'hidden' : true,
572 'render' : function(my) {
573 if (get_bool( my.acp.deleted() )) {
574 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
576 return document.getElementById('circStrings').getString('staff.circ.utils.no');
579 'persist' : 'hidden width ordinal',
583 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
585 'primary' : false, 'hidden' : true,
586 'render' : function(my) {
587 if (get_bool( my.acp.holdable() )) {
588 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
590 return document.getElementById('circStrings').getString('staff.circ.utils.no');
593 'persist' : 'hidden width ordinal',
596 'id' : 'opac_visible',
597 'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
599 'primary' : false, 'hidden' : true,
600 'render' : function(my) {
601 if (get_bool( my.acp.opac_visible() )) {
602 return document.getElementById('circStrings').getString('staff.circ.utils.yes');
604 return document.getElementById('circStrings').getString('staff.circ.utils.no');
607 'persist' : 'hidden width ordinal',
610 'persist' : 'hidden width ordinal', 'id' : 'ref', 'label' : 'Reference?', 'flex' : 1,
611 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.ref() ) ? "Yes" : "No"; },
614 'persist' : 'hidden width ordinal', 'id' : 'deposit', 'label' : 'Deposit?', 'flex' : 1,
615 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deposit() ) ? "Yes" : "No"; },
618 'persist' : 'hidden width ordinal', 'id' : 'deposit_amount', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'), 'flex' : 1,
619 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.deposit_amount()); }, 'sort_type' : 'money',
622 'persist' : 'hidden width ordinal', 'id' : 'price', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'), 'flex' : 1,
623 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.price()); }, 'sort_type' : 'money',
626 'persist' : 'hidden width ordinal', 'id' : 'circ_as_type', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'), 'flex' : 1,
627 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_as_type(); },
630 'persist' : 'hidden width ordinal', 'id' : 'circ_modifier', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'), 'flex' : 1,
631 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_modifier(); },
634 'persist' : 'hidden width ordinal', 'id' : 'checkout_lib', 'label' : 'Checkout Lib', 'flex' : 1,
635 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? data.hash.aou[ my.circ.circ_lib() ].shortname() : ( my.acp.circulations() ? data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname() : ""); },
638 'persist' : 'hidden width ordinal', 'id' : 'xact_start_full', 'label' : 'Checkout Timestamp', 'flex' : 1,
639 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start() : (my.acp.circulations() ? my.acp.circulations()[0].xact_start() : ""); },
642 'persist' : 'hidden width ordinal', 'id' : 'checkin_time_full', 'label' : 'Checkin Timestamp', 'flex' : 1,
643 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time() : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time() : ""); },
646 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : 'Checkout Date', 'flex' : 1,
647 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].xact_start().substr(0,10) : ""); },
650 'persist' : 'hidden width ordinal', 'id' : 'checkin_time', 'label' : 'Checkin Date', 'flex' : 1,
651 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time().substr(0,10) : ""); },
655 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : 'Transaction Finished', 'flex' : 1,
656 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ.xact_finish(); },
659 'persist' : 'hidden width ordinal', 'id' : 'due_date', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'), 'flex' : 1,
660 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.due_date().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].due_date().substr(0,10) : ""); },
663 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : 'Date Created', 'flex' : 1,
664 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.create_date().substr(0,10); },
667 'persist' : 'hidden width ordinal', 'id' : 'edit_date', 'label' : 'Date Last Edited', 'flex' : 1,
668 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.edit_date().substr(0,10); },
671 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'), 'flex' : 2, 'sort_type' : 'title',
672 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } }
675 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'), 'flex' : 1,
676 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } }
679 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
680 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
683 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
684 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
687 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
688 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
691 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
692 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
695 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
696 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
699 'persist' : 'hidden width ordinal', 'id' : 'renewal_remaining', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'), 'flex' : 0,
700 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.renewal_remaining() : (my.acp.circulations() ? my.acp.circulations()[0].renewal_remaining() : ""); }, 'sort_type' : 'number',
703 'persist' : 'hidden width ordinal', 'id' : 'stop_fines', 'label' : 'Fines Stopped', 'flex' : 0,
704 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines() : ""); },
707 'persist' : 'hidden width ordinal', 'id' : 'stop_fines_time', 'label' : 'Fines Stopped Time', 'flex' : 0,
708 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines_time() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines_time() : ""); },
711 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'), 'flex' : 1,
712 'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.status())>=0) return data.hash.ccs[ my.acp.status() ].name(); else return my.acp.status().name(); },
715 'persist' : 'hidden width ordinal', 'id' : 'route_to', 'label' : 'Route To', 'flex' : 1,
716 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.route_to.toString(); },
719 'persist' : 'hidden width ordinal', 'id' : 'message', 'label' : 'Message', 'flex' : 1,
720 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.message.toString(); },
723 'persist' : 'hidden width ordinal', 'id' : 'uses', 'label' : '# of Uses', 'flex' : 1,
724 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.uses; }, 'sort_type' : 'number',
727 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : 'Alert Message', 'flex' : 1,
728 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.alert_message(); },
731 for (var i = 0; i < c.length; i++) {
732 if (modify[ c[i].id ]) {
733 for (var j in modify[ c[i].id ]) {
734 c[i][j] = modify[ c[i].id ][j];
739 if (params.just_these) {
740 JSAN.use('util.functional');
742 for (var i = 0; i < params.just_these.length; i++) {
743 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
744 new_c.push( function(y){ return y; }( x ) );
748 if (params.except_these) {
749 JSAN.use('util.functional');
751 for (var i = 0; i < c.length; i++) {
752 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
753 if (!x) new_c.push(c[i]);
758 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
761 circ.util.transit_columns = function(modify,params) {
763 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
767 'persist' : 'hidden width ordinal', 'id' : 'transit_item_barcode', 'label' : 'Barcode', 'flex' : 1,
768 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); },
771 'persist' : 'hidden width ordinal', 'id' : 'transit_item_title', 'label' : 'Title', 'flex' : 1,
772 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } },
775 'persist' : 'hidden width ordinal', 'id' : 'transit_item_author', 'label' : 'Author', 'flex' : 1,
776 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } },
779 'persist' : 'hidden width ordinal', 'id' : 'transit_item_callnumber', 'label' : 'Call Number', 'flex' : 1,
780 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); },
783 'persist' : 'hidden width ordinal', 'id' : 'transit_id', 'label' : 'Transit ID', 'flex' : 1,
784 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.atc.id(); },
787 'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1,
788 'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.source() == "object" ? my.atc.source().shortname() : data.hash.aou[ my.atc.source() ].shortname(); },
791 'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1,
792 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.source_send_time(); },
795 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1,
796 'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.dest() == "object" ? my.atc.dest().shortname() : data.hash.aou[ my.atc.dest() ].shortname(); },
799 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1,
800 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.dest_recv_time(); },
803 'persist' : 'hidden width ordinal', 'id' : 'transit_target_copy', 'label' : 'Transit Copy ID', 'flex' : 1,
804 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.atc.target_copy(); },
807 for (var i = 0; i < c.length; i++) {
808 if (modify[ c[i].id ]) {
809 for (var j in modify[ c[i].id ]) {
810 c[i][j] = modify[ c[i].id ][j];
815 if (params.just_these) {
816 JSAN.use('util.functional');
818 for (var i = 0; i < params.just_these.length; i++) {
819 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
820 new_c.push( function(y){ return y; }( x ) );
824 if (params.except_these) {
825 JSAN.use('util.functional');
827 for (var i = 0; i < c.length; i++) {
828 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
829 if (!x) new_c.push(c[i]);
835 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
839 circ.util.hold_columns = function(modify,params) {
841 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
845 'persist' : 'hidden width ordinal', 'id' : 'request_lib', 'label' : 'Request Lib (Full Name)', 'flex' : 1,
846 'primary' : false, 'hidden' : true,
847 'render' : function(my) { if (Number(my.ahr.request_lib())>=0) return data.hash.aou[ my.ahr.request_lib() ].name(); else return my.ahr.request_lib().name(); },
850 'persist' : 'hidden width ordinal', 'id' : 'request_lib_shortname', 'label' : 'Request Lib', 'flex' : 0,
851 'primary' : false, 'hidden' : true,
852 'render' : function(my) { if (Number(my.ahr.request_lib())>=0) return data.hash.aou[ my.ahr.request_lib() ].shortname(); else return my.ahr.request_lib().shortname(); },
856 'persist' : 'hidden width ordinal', 'id' : 'request_timestamp', 'label' : 'Request Timestamp', 'flex' : 0,
857 'primary' : false, 'hidden' : true,
858 'render' : function(my) { return my.ahr.request_time().toString(); },
861 'persist' : 'hidden width ordinal', 'id' : 'request_time', 'label' : 'Request Date', 'flex' : 0,
862 'primary' : false, 'hidden' : true,
863 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); },
866 'persist' : 'hidden width ordinal', 'id' : 'available_timestamp', 'label' : 'Available On (Timestamp)', 'flex' : 1,
867 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString() : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString() : "" ); },
870 'persist' : 'hidden width ordinal', 'id' : 'available_time', 'label' : 'Available On', 'flex' : 1,
871 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString().substr(0,10) : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : "" ); },
874 'persist' : 'hidden width ordinal', 'id' : 'capture_timestamp', 'label' : 'Capture Timestamp', 'flex' : 1,
875 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; },
878 'persist' : 'hidden width ordinal', 'id' : 'capture_time', 'label' : 'Capture Date', 'flex' : 1,
879 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; },
882 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'), 'flex' : 1,
883 'primary' : false, 'hidden' : false, 'render' : function(my) { switch(my.status) { case 1: case "1": return "Waiting for copy"; break; case 2: case "2": return "Waiting for capture"; break; case 3: case "3": return "In-Transit"; break; case 4: case "4" : return "Ready for pickup"; break; default: return my.status; break;}; },
886 'persist' : 'hidden width ordinal', 'id' : 'hold_type', 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'), 'flex' : 0,
887 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.hold_type(); },
890 'persist' : 'hidden width ordinal', 'id' : 'frozen', 'label' : 'Frozen?', 'flex' : 0,
891 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.ahr.frozen() ) ? 'Yes' : 'No'; },
894 'persist' : 'hidden width ordinal', 'id' : 'thaw_date', 'label' : 'Thaw Date', 'flex' : 0,
895 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.thaw_date() == null ? 'No Date' : my.ahr.thaw_date().substr(0,10); },
898 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib', 'label' : 'Pickup Lib (Full Name)', 'flex' : 1,
899 'primary' : false, 'hidden' : true,
900 'render' : function(my) { if (Number(my.ahr.pickup_lib())>=0) return data.hash.aou[ my.ahr.pickup_lib() ].name(); else return my.ahr.pickup_lib().name(); },
903 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib_shortname', 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'), 'flex' : 0,
904 'primary' : false, 'hidden' : true,
905 'render' : function(my) { if (Number(my.ahr.pickup_lib())>=0) return data.hash.aou[ my.ahr.pickup_lib() ].shortname(); else return my.ahr.pickup_lib().shortname(); },
908 'persist' : 'hidden width ordinal', 'id' : 'current_copy', 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'), 'flex' : 1,
909 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp ? my.acp.barcode() : "No Copy"; },
912 'persist' : 'hidden width ordinal', 'id' : 'email_notify', 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'), 'flex' : 1,
913 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool(my.ahr.email_notify()) ? "Yes" : "No"; },
916 'persist' : 'hidden width ordinal', 'id' : 'expire_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'), 'flex' : 1,
917 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.expire_time(); },
920 'persist' : 'hidden width ordinal', 'id' : 'fulfillment_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'), 'flex' : 1,
921 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.fulfillment_time(); },
924 'persist' : 'hidden width ordinal', 'id' : 'holdable_formats', 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'), 'flex' : 1,
925 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.holdable_formats(); },
928 'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'), 'flex' : 1,
929 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.id(); },
932 'persist' : 'hidden width ordinal', 'id' : 'phone_notify', 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'), 'flex' : 1,
933 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.phone_notify(); },
936 'persist' : 'hidden width ordinal', 'id' : 'prev_check_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'), 'flex' : 1,
937 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.prev_check_time(); },
940 'persist' : 'hidden width ordinal', 'id' : 'requestor', 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'), 'flex' : 1,
941 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.requestor(); },
944 'persist' : 'hidden width ordinal', 'id' : 'selection_depth', 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'), 'flex' : 1,
945 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.selection_depth(); },
948 'persist' : 'hidden width ordinal', 'id' : 'target', 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'), 'flex' : 1,
949 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.target(); },
952 'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'), 'flex' : 1,
953 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.usr(); },
956 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'), 'flex' : 1, 'sort_type' : 'title',
957 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.title() : "No Title?"; },
960 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'), 'flex' : 1,
961 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.author() : "No Author?"; },
964 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
965 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
968 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
969 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
972 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
973 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
976 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
977 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
980 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
981 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
984 'persist' : 'hidden width ordinal', 'id' : 'notify_time', 'label' : 'Last Notify Time', 'flex' : 1,
985 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_time(); },
988 'persist' : 'hidden width ordinal', 'id' : 'notify_count', 'label' : 'Notices', 'flex' : 1,
989 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_count(); },
992 'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1,
993 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().source() ].shortname() : ""; },
996 'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1,
997 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; },
1000 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1,
1001 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; },
1004 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1,
1005 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; },
1008 'persist' : 'hidden width ordinal', 'id' : 'patron_barcode', 'label' : 'Patron Barcode', 'flex' : 1,
1009 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; },
1012 'persist' : 'hidden width ordinal', 'id' : 'patron_family_name', 'label' : 'Patron Last Name', 'flex' : 1,
1013 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; },
1016 'persist' : 'hidden width ordinal', 'id' : 'patron_first_given_name', 'label' : 'Patron First Name', 'flex' : 1,
1017 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; },
1020 'persist' : 'hidden width ordinal', 'id' : 'callnumber', 'label' : 'Call Number', 'flex' : 1,
1021 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); },
1024 for (var i = 0; i < c.length; i++) {
1025 if (modify[ c[i].id ]) {
1026 for (var j in modify[ c[i].id ]) {
1027 c[i][j] = modify[ c[i].id ][j];
1032 if (params.just_these) {
1033 JSAN.use('util.functional');
1035 for (var i = 0; i < params.just_these.length; i++) {
1036 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1037 new_c.push( function(y){ return y; }( x ) );
1041 if (params.except_these) {
1042 JSAN.use('util.functional');
1044 for (var i = 0; i < c.length; i++) {
1045 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1046 if (!x) new_c.push(c[i]);
1052 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1055 circ.util.std_map_row_to_column = function(error_value) {
1056 return function(row,col) {
1057 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1058 // col contains one of the objects listed above in columns
1060 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
1062 JSAN.use('util.error'); obj.error = new util.error();
1063 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1064 JSAN.use('util.network'); obj.network = new util.network();
1065 JSAN.use('util.money');
1070 value = eval( col.render );
1072 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1073 if (error_value) value = error_value; else value = ' ';
1079 circ.util.std_map_row_to_columns = function(error_value) {
1080 return function(row,cols) {
1081 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1082 // cols contains all of the objects listed above in columns
1085 JSAN.use('util.error'); obj.error = new util.error();
1086 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1087 JSAN.use('util.network'); obj.network = new util.network();
1088 JSAN.use('util.money');
1094 for (var i = 0; i < cols.length; i++) {
1095 switch (typeof cols[i].render) {
1096 case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } break;
1097 case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
1098 default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
1101 if (cmd) eval( cmd );
1103 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1104 if (error_value) { value = error_value; } else { value = ' ' };
1110 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
1112 JSAN.use('util.error'); var error = new util.error();
1113 JSAN.use('util.network'); var network = new util.network();
1114 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1115 JSAN.use('util.date');
1117 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1119 //var params = { 'barcode' : barcode };
1120 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1122 if (typeof async == 'object') {
1123 try { async.disable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1125 var check = network.request(
1126 api.CHECKIN_VIA_BARCODE.app,
1127 api.CHECKIN_VIA_BARCODE.method,
1128 [ session, params ],
1129 async ? function(req) {
1131 var check = req.getResultObject();
1132 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1133 if (typeof async == 'object') {
1134 try { async.checkin_result(r); } catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1137 JSAN.use('util.error'); var error = new util.error();
1138 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin) (1): ',E);
1139 if (typeof async == 'object') {
1140 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1146 'title' : 'Override Checkin Failure?',
1147 'overridable_events' : [
1148 1203 /* COPY_BAD_STATUS */,
1149 1213 /* PATRON_BARRED */,
1150 1217 /* PATRON_INACTIVE */,
1151 1224 /* PATRON_ACCOUNT_EXPIRED */,
1152 7009 /* CIRC_CLAIMS_RETURNED */,
1153 7010 /* COPY_ALERT_MESSAGE */,
1154 7011 /* COPY_STATUS_LOST */,
1155 7012 /* COPY_STATUS_MISSING */,
1156 7013 /* PATRON_EXCEEDS_FINES */,
1159 '1203' : function(r) {
1160 //return data.hash.ccs[ r.payload.status() ].name();
1161 return r.payload.status().name();
1163 '7010' : function(r) {
1170 return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1175 JSAN.use('util.error'); var error = new util.error();
1176 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin) (2): ',E);
1177 if (typeof async == 'object') {
1178 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1184 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1186 JSAN.use('util.error'); var error = new util.error();
1187 JSAN.use('util.network'); var network = new util.network();
1188 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1189 JSAN.use('util.date');
1191 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1193 check.message = check.textcode;
1195 if (check.payload && check.payload.copy) check.copy = check.payload.copy;
1196 if (check.payload && check.payload.record) check.record = check.payload.record;
1197 if (check.payload && check.payload.circ) check.circ = check.payload.circ;
1199 if (!check.route_to) check.route_to = ' ';
1201 if (document.getElementById('no_change_label')) {
1202 document.getElementById('no_change_label').setAttribute('value','');
1203 document.getElementById('no_change_label').setAttribute('hidden','true');
1207 network.simple_request('FM_MBTS_RETRIEVE',[ses(),check.circ.id()], function(req) {
1208 JSAN.use('util.money');
1209 var bill = req.getResultObject();
1210 if (Number(bill.balance_owed()) == 0) return;
1211 if (document.getElementById('no_change_label')) {
1212 var m = document.getElementById('no_change_label').getAttribute('value');
1213 document.getElementById('no_change_label').setAttribute('value', m + 'Transaction for ' + params.barcode + ' billable $' + util.money.sanitize(bill.balance_owed()) + ' ');
1214 document.getElementById('no_change_label').setAttribute('hidden','false');
1221 if (check.payload && check.payload.cancelled_hold_transit) {
1222 msg += 'Original hold for transit cancelled.\n\n';
1225 /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
1226 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1227 try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); } catch(E) { msg += 'Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n'; }
1228 if (check.ilsevent == 3 /* NO_CHANGE */) {
1229 //msg = 'This item is already checked in.\n';
1230 if (document.getElementById('no_change_label')) {
1231 var m = document.getElementById('no_change_label').getAttribute('value');
1232 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' was already checked in. ');
1233 document.getElementById('no_change_label').setAttribute('hidden','false');
1236 if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
1237 msg = 'Please inform your helpdesk/developers of this error:\nFIXME -- ITEM_NOT_CATALOGED event but copy status is '
1238 + (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() ) + '\n';
1240 switch(check.copy.status()) {
1241 case 0: /* AVAILABLE */
1242 case 7: /* RESHELVING */
1243 if (msg) msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1245 case 8: /* ON HOLDS SHELF */
1246 check.route_to = 'HOLDS SHELF';
1247 if (check.payload.hold) {
1248 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
1249 msg += 'Please inform your helpdesk/developers of this error:\nFIXME: We should have received a ROUTE_ITEM\n';
1251 msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1254 msg += 'Please inform your helpdesk/developers of this error:\nFIXME: status of Holds Shelf, but no actual hold found.\n';
1256 JSAN.use('util.date');
1257 if (check.payload.hold) {
1258 JSAN.use('patron.util');
1259 msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1260 msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1261 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1262 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1263 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1264 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1265 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1266 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F') + '\n';
1269 msg += 'Slip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1270 if (!auto_print) rv = error.yns_alert_formatted(
1276 "Check here to confirm this message",
1277 '/xul/server/skin/media/images/turtle.gif'
1281 JSAN.use('util.print'); var print = new util.print();
1282 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
1283 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1285 dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1286 alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1290 if (document.getElementById('no_change_label')) {
1291 var m = document.getElementById('no_change_label').getAttribute('value');
1292 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' has been captured for a hold. ');
1293 document.getElementById('no_change_label').setAttribute('hidden','false');
1296 case 6: /* IN TRANSIT */
1297 check.route_to = 'TRANSIT SHELF??';
1298 msg += ("Please inform your helpdesk/developers of this error:\nFIXME -- I didn't think we could get here.\n");
1300 case 11: /* CATALOGING */
1301 check.route_to = 'CATALOGING';
1302 if (document.getElementById('do_not_alert_on_precat')) {
1303 var x = document.getElementById('do_not_alert_on_precat');
1304 if (! x.checked) msg += 'This item needs to be routed to ' + check.route_to + '.';
1306 msg += 'This item needs to be routed to ' + check.route_to + '.';
1308 if (document.getElementById('no_change_label')) {
1309 var m = document.getElementById('no_change_label').getAttribute('value');
1310 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' needs to be cataloged. ');
1311 document.getElementById('no_change_label').setAttribute('hidden','false');
1315 msg += ('Please inform your helpdesk/developers of this error:\nFIXME -- this case "' + (data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name()) + '" is unhandled.\n');
1316 msg += 'This item needs to be routed to ' + check.route_to + '.';
1319 if (msg) error.yns_alert(msg,'Alert',null,'OK',null,"Check here to confirm this message");
1321 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
1323 var lib = data.hash.aou[ check.org ];
1324 check.route_to = lib.shortname();
1325 msg += 'Destination: ' + check.route_to + '.\n';
1326 msg += '\n' + lib.name() + '\n';
1328 if (lib.holds_address() ) {
1329 var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
1330 if (typeof a.ilsevent != 'undefined') throw(a);
1331 if (a.street1()) msg += a.street1() + '\n';
1332 if (a.street2()) msg += a.street2() + '\n';
1333 msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
1335 msg += "We do not have a holds address for this library.\n";
1338 msg += 'Unable to retrieve mailing address.\n';
1339 error.standard_unexpected_error_alert('Unable to retrieve mailing address.',E);
1341 msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1342 msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1343 msg += 'Author: ' + (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author() ) + '\n';
1344 JSAN.use('util.date');
1345 if (check.payload.hold) {
1346 JSAN.use('patron.util');
1347 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1348 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1349 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1350 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1351 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1352 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F');
1355 msg += '\nSlip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1356 if (!auto_print) rv = error.yns_alert_formatted(
1362 "Check here to confirm this message",
1363 '/xul/server/skin/media/images/turtle.gif'
1367 JSAN.use('util.print'); var print = new util.print();
1368 //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
1369 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
1370 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1372 dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1373 alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1376 if (document.getElementById('no_change_label')) {
1377 var m = document.getElementById('no_change_label').getAttribute('value');
1378 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is in transit. ');
1379 document.getElementById('no_change_label').setAttribute('hidden','false');
1382 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
1384 check.route_to = 'CATALOGING';
1386 'The barcode was either mis-scanned or the item needs to be cataloged.',
1391 "Check here to confirm this message"
1393 if (document.getElementById('no_change_label')) {
1394 var m = document.getElementById('no_change_label').getAttribute('value');
1395 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is mis-scanned or not cataloged. ');
1396 document.getElementById('no_change_label').setAttribute('hidden','false');
1399 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
1400 error.standard_network_error_alert('Check In Failed. If you wish to use the offline interface, in the top menubar select Circulation -> Offline Interface');
1403 switch (check.ilsevent) {
1404 case 1203 /* COPY_BAD_STATUS */ :
1405 case 1213 /* PATRON_BARRED */ :
1406 case 1217 /* PATRON_INACTIVE */ :
1407 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
1408 case 7009 /* CIRC_CLAIMS_RETURNED */ :
1409 case 7010 /* COPY_ALERT_MESSAGE */ :
1410 case 7011 /* COPY_STATUS_LOST */ :
1411 case 7012 /* COPY_STATUS_MISSING */ :
1412 case 7013 /* PATRON_EXCEEDS_FINES */ :
1413 return null; /* handled */
1423 JSAN.use('util.error'); var error = new util.error();
1424 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin) (3): ',E);
1429 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
1432 JSAN.use('util.network'); obj.network = new util.network();
1433 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
1435 var params = { barcode: barcode };
1436 if (patron_id) params.patron = patron_id;
1438 function renew_callback(req) {
1440 var renew = req.getResultObject();
1441 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
1442 for (var j = 0; j < renew.length; j++) {
1443 switch(renew[j].ilsevent) {
1444 case 0 /* SUCCESS */ : break;
1445 case 5000 /* PERM_FAILURE */: break;
1446 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
1447 case 1213 /* PATRON_BARRED */ : break;
1448 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
1449 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
1450 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
1451 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
1452 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
1453 case 7004 /* COPY_NOT_AVAILABLE */ : break;
1454 case 7006 /* COPY_IS_REFERENCE */ : break;
1455 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
1456 case 7008 /* MAX_RENEWALS_REACHED */ : break;
1457 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
1458 case 7010 /* COPY_ALERT_MESSAGE */ : break;
1459 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
1465 if (typeof async == 'function') async(renew);
1468 JSAN.use('util.error'); var error = new util.error();
1469 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1474 var renew = obj.network.simple_request(
1477 async ? renew_callback : null,
1479 'title' : 'Override Renew Failure?',
1480 'overridable_events' : [
1481 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
1482 1213 /* PATRON_BARRED */,
1483 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
1484 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
1485 7003 /* COPY_CIRC_NOT_ALLOWED */,
1486 7004 /* COPY_NOT_AVAILABLE */,
1487 7006 /* COPY_IS_REFERENCE */,
1488 7007 /* COPY_NEEDED_FOR_HOLD */,
1489 7008 /* MAX_RENEWALS_REACHED */,
1490 7009 /* CIRC_CLAIMS_RETURNED */,
1491 7010 /* COPY_ALERT_MESSAGE */,
1492 7013 /* PATRON_EXCEEDS_FINES */,
1495 '1212' : function(r) { return 'Barcode: ' + barcode; },
1496 '1213' : function(r) { return 'Barcode: ' + barcode; },
1497 '1215' : function(r) { return 'Barcode: ' + barcode; },
1498 '7002' : function(r) { return 'Barcode: ' + barcode; },
1499 '7003' : function(r) { return 'Barcode: ' + barcode; },
1500 '7004' : function(r) {
1501 return 'Barcode: ' + barcode + ' Status: ' + r.payload.status().name();
1503 '7006' : function(r) { return 'Barcode: ' + barcode; },
1504 '7007' : function(r) { return 'Barcode: ' + barcode; },
1505 '7008' : function(r) { return 'Barcode: ' + barcode; },
1506 '7009' : function(r) { return 'Barcode: ' + barcode; },
1507 '7010' : function(r) {
1508 return 'Barcode: ' + barcode + ' Message: ' + r.payload;
1510 '7013' : function(r) { return 'Barcode: ' + barcode; },
1514 if (! async ) return renew_callback( { 'getResultObject' : function() { return renew; } } );
1517 JSAN.use('util.error'); var error = new util.error();
1518 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1525 dump('exiting circ/util.js\n');