1 dump('entering circ/util.js\n');
3 if (typeof circ == 'undefined') var circ = {};
6 circ.util.EXPORT_OK = [
7 'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns',
8 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns',
9 'show_last_few_circs', 'abort_transits', 'transit_columns', 'renew_via_barcode',
11 circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK };
13 circ.util.abort_transits = function(selection_list) {
15 JSAN.use('util.error'); obj.error = new util.error();
16 JSAN.use('util.network'); obj.network = new util.network();
17 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
18 JSAN.use('util.functional');
19 var msg = 'Are you sure you would like to abort transits for copies:' + util.functional.map_list( selection_list, function(o){return o.copy_id;}).join(', ') + '?';
20 var r = obj.error.yns_alert(msg,'Aborting Transits','Yes','No',null,'Check here to confirm this action');
23 for (var i = 0; i < selection_list.length; i++) {
24 var copy_id = selection_list[i].copy_id;
25 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'copyid' : copy_id } ]);
26 if (typeof robj.ilsevent != 'undefined') {
27 switch(robj.ilsevent) {
28 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
29 alert('Copy Id = ' + copy_id + '\n' + robj.desc);
31 case 1504 /* ACTION_TRANSIT_COPY_NOT_FOUND */ :
32 alert('This item was no longer in transit at the time of the abort. Perhaps this happened from a stale display?');
34 case 5000 /* PERM_FAILURE */ :
43 obj.error.standard_unexpected_error_alert('Transit not likely aborted.',E);
48 circ.util.show_copy_details = function(copy_id) {
50 JSAN.use('util.error'); obj.error = new util.error();
51 JSAN.use('util.window'); obj.win = new util.window();
52 JSAN.use('util.network'); obj.network = new util.network();
53 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
55 if (typeof copy_id == 'object' && copy_id != null) copy_id = copy_id.id();
58 var url = xulG.url_prefix( urls.XUL_COPY_DETAILS ); // + '?copy_id=' + copy_id;
59 var my_xulG = obj.win.open( url, 'show_copy_details', 'chrome,resizable,modal', { 'copy_id' : copy_id } );
61 if (typeof my_xulG.retrieve_these_patrons == 'undefined') return;
62 var patrons = my_xulG.retrieve_these_patrons;
63 for (var j = 0; j < patrons.length; j++) {
64 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
66 var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
67 window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
69 obj.error.standard_unexpected_error_alert('Problem retrieving patron.',E);
75 obj.error.standard_unexpected_error_alert('Problem retrieving copy details.',E);
80 circ.util.show_last_few_circs = function(selection_list,count) {
82 JSAN.use('util.error'); obj.error = new util.error();
83 JSAN.use('util.window'); obj.win = new util.window();
84 JSAN.use('util.network'); obj.network = new util.network();
85 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
87 if (!count) count = 4;
89 for (var i = 0; i < selection_list.length; i++) {
91 if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
92 var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
93 var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id, 'count' : count } );
95 if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
96 var patrons = my_xulG.retrieve_these_patrons;
97 for (var j = 0; j < patrons.length; j++) {
98 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
100 var url = urls.XUL_PATRON_DISPLAY; // + '?id=' + window.escape( patrons[j] );
101 window.xulG.new_tab( url, {}, { 'id' : patrons[j] } );
103 obj.error.standard_unexpected_error_alert('Problem retrieving patron.',E);
109 obj.error.standard_unexpected_error_alert('Problem retrieving circulations.',E);
114 circ.util.offline_checkout_columns = function(modify,params) {
119 'label' : 'Timestamp',
120 'flex' : 1, 'primary' : false, 'hidden' : true,
121 'render' : function(my) { return my.timestamp; },
124 'id' : 'checkout_time',
125 'label' : 'Check Out Time',
126 'flex' : 1, 'primary' : false, 'hidden' : true,
127 'render' : function(my) { return my.checkout_time; },
131 'label' : 'Transaction Type',
132 'flex' : 1, 'primary' : false, 'hidden' : true,
133 'render' : function(my) { return my.type; },
137 'label' : 'Non-Cataloged?',
138 'flex' : 1, 'primary' : false, 'hidden' : true,
139 'render' : function(my) { return my.noncat; },
142 'id' : 'noncat_type',
143 'label' : 'Non-Cat Type ID',
144 'flex' : 1, 'primary' : false, 'hidden' : true,
145 'render' : function(my) { return my.noncat_type; },
148 'id' : 'noncat_count',
149 'label' : 'Count', 'sort_type' : 'number',
150 'flex' : 1, 'primary' : false, 'hidden' : false,
151 'render' : function(my) { return my.noncat_count; },
154 'id' : 'patron_barcode',
155 'label' : 'Patron Barcode',
156 'flex' : 1, 'primary' : false, 'hidden' : true,
157 'render' : function(my) { return my.patron_barcode; },
161 'label' : 'Item Barcode',
162 'flex' : 2, 'primary' : true, 'hidden' : false,
163 'render' : function(my) { return my.barcode; },
167 'label' : 'Due Date',
168 'flex' : 1, 'primary' : false, 'hidden' : false,
169 'render' : function(my) { return my.due_date; },
172 if (modify) for (var i = 0; i < c.length; i++) {
173 if (modify[ c[i].id ]) {
174 for (var j in modify[ c[i].id ]) {
175 c[i][j] = modify[ c[i].id ][j];
180 if (params.just_these) {
181 JSAN.use('util.functional');
183 for (var i = 0; i < params.just_these.length; i++) {
184 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
185 new_c.push( function(y){ return y; }( x ) );
189 if (params.except_these) {
190 JSAN.use('util.functional');
192 for (var i = 0; i < c.length; i++) {
193 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
194 if (!x) new_c.push(c[i]);
200 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
203 circ.util.offline_checkin_columns = function(modify,params) {
208 'label' : 'Timestamp',
209 'flex' : 1, 'primary' : false, 'hidden' : true,
210 'render' : function(my) { return my.timestamp; },
214 'label' : 'Back Date',
215 'flex' : 1, 'primary' : false, 'hidden' : true,
216 'render' : function(my) { return my.backdate; },
220 'label' : 'Transaction Type',
221 'flex' : 1, 'primary' : false, 'hidden' : true,
222 'render' : function(my) { return my.type; },
226 'label' : 'Item Barcode',
227 'flex' : 2, 'primary' : true, 'hidden' : false,
228 'render' : function(my) { return my.barcode; },
231 if (modify) for (var i = 0; i < c.length; i++) {
232 if (modify[ c[i].id ]) {
233 for (var j in modify[ c[i].id ]) {
234 c[i][j] = modify[ c[i].id ][j];
239 if (params.just_these) {
240 JSAN.use('util.functional');
242 for (var i = 0; i < params.just_these.length; i++) {
243 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
244 new_c.push( function(y){ return y; }( x ) );
248 if (params.except_these) {
249 JSAN.use('util.functional');
251 for (var i = 0; i < c.length; i++) {
252 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
253 if (!x) new_c.push(c[i]);
259 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
262 circ.util.offline_renew_columns = function(modify,params) {
267 'label' : 'Timestamp',
268 'flex' : 1, 'primary' : false, 'hidden' : true,
269 'render' : function(my) { return my.timestamp; },
272 'id' : 'checkout_time',
273 'label' : 'Check Out Time',
274 'flex' : 1, 'primary' : false, 'hidden' : true,
275 'render' : function(my) { return my.checkout_time; },
279 'label' : 'Transaction Type',
280 'flex' : 1, 'primary' : false, 'hidden' : true,
281 'render' : function(my) { return my.type; },
284 'id' : 'patron_barcode',
285 'label' : 'Patron Barcode',
286 'flex' : 1, 'primary' : false, 'hidden' : true,
287 'render' : function(my) { return my.patron_barcode; },
291 'label' : 'Item Barcode',
292 'flex' : 2, 'primary' : true, 'hidden' : false,
293 'render' : function(my) { return my.barcode; },
297 'label' : 'Due Date',
298 'flex' : 1, 'primary' : false, 'hidden' : false,
299 'render' : function(my) { return my.due_date; },
302 if (modify) for (var i = 0; i < c.length; i++) {
303 if (modify[ c[i].id ]) {
304 for (var j in modify[ c[i].id ]) {
305 c[i][j] = modify[ c[i].id ][j];
310 if (params.just_these) {
311 JSAN.use('util.functional');
313 for (var i = 0; i < params.just_these.length; i++) {
314 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
315 new_c.push( function(y){ return y; }( x ) );
319 if (params.except_these) {
320 JSAN.use('util.functional');
322 for (var i = 0; i < c.length; i++) {
323 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
324 if (!x) new_c.push(c[i]);
330 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
333 circ.util.offline_inhouse_use_columns = function(modify,params) {
338 'label' : 'Timestamp',
339 'flex' : 1, 'primary' : false, 'hidden' : true,
340 'render' : function(my) { return my.timestamp; },
344 'label' : 'Use Time',
345 'flex' : 1, 'primary' : false, 'hidden' : true,
346 'render' : function(my) { return my.use_time; },
350 'label' : 'Transaction Type',
351 'flex' : 1, 'primary' : false, 'hidden' : true,
352 'render' : function(my) { return my.type; },
356 'label' : 'Count', 'sort_type' : 'number',
357 'flex' : 1, 'primary' : false, 'hidden' : false,
358 'render' : function(my) { return my.count; },
362 'label' : 'Item Barcode',
363 'flex' : 2, 'primary' : true, 'hidden' : false,
364 'render' : function(my) { return my.barcode; },
367 if (modify) for (var i = 0; i < c.length; i++) {
368 if (modify[ c[i].id ]) {
369 for (var j in modify[ c[i].id ]) {
370 c[i][j] = modify[ c[i].id ][j];
375 if (params.just_these) {
376 JSAN.use('util.functional');
378 for (var i = 0; i < params.just_these.length; i++) {
379 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
380 new_c.push( function(y){ return y; }( x ) );
384 if (params.except_these) {
385 JSAN.use('util.functional');
387 for (var i = 0; i < c.length; i++) {
388 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
389 if (!x) new_c.push(c[i]);
395 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
400 circ.util.columns = function(modify,params) {
402 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
403 JSAN.use('util.network'); var network = new util.network();
404 JSAN.use('util.money');
408 'id' : 'acp_id', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'), 'flex' : 1,
409 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.id(); }, 'persist' : 'hidden width ordinal',
412 'id' : 'circ_id', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'), 'flex' : 1,
413 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
414 'persist' : 'hidden width ordinal',
417 'id' : 'mvr_doc_id', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'), 'flex' : 1,
418 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.doc_id(); },
419 'persist' : 'hidden width ordinal',
422 'persist' : 'hidden width ordinal', 'id' : 'service', 'label' : 'Service', 'flex' : 1,
423 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.service; },
426 'id' : 'barcode', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'), 'flex' : 1,
427 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); },
428 'persist' : 'hidden width ordinal',
431 'id' : 'call_number', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'), 'flex' : 1,
432 'primary' : false, 'hidden' : true, 'render' : function(my) { if (my.acp && my.acp.call_number() == -1) { return "Not Cataloged"; } else { if (!my.acn) { var x = network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]); if (x.ilsevent) { return "Not Cataloged"; } else { my.acn = x; return x.label(); } } else { return my.acn.label(); } } },
433 'persist' : 'hidden width ordinal',
436 'id' : 'owning_lib', 'label' : 'Owning Lib', 'flex' : 1,
437 'primary' : false, 'hidden' : true,
438 'render' : function(my) { if (Number(my.acn.owning_lib())>=0) { return data.hash.aou[ my.acn.owning_lib() ].shortname(); } else { return my.acn.owning_lib().shortname(); } },
439 'persist' : 'hidden width ordinal',
442 'id' : 'copy_number', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'), 'flex' : 1, 'sort_type' : 'number',
443 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.copy_number(); },
444 'persist' : 'hidden width ordinal',
447 'id' : 'location', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'), 'flex' : 1,
448 'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); },
449 'persist' : 'hidden width ordinal',
452 'id' : 'loan_duration', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'), 'flex' : 1,
453 'primary' : false, 'hidden' : true,
454 'render' : function(my) { switch(my.acp.loan_duration()){ case 1: return "Short"; break; case 2: return "Normal"; break; case 3: return "Long"; break; }; },
455 'persist' : 'hidden width ordinal',
458 'id' : 'circ_lib', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'), 'flex' : 1,
459 'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.circ_lib())>=0) return data.hash.aou[ my.acp.circ_lib() ].shortname(); else return my.acp.circ_lib().shortname(); },
460 'persist' : 'hidden width ordinal',
463 'id' : 'fine_level', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'), 'flex' : 1,
464 'primary' : false, 'hidden' : true,
465 'render' : function(my) { switch(my.acp.fine_level()){ case 1: return "Low"; break; case 2: return "Normal"; break; case 3: return "High"; break; }; },
466 'persist' : 'hidden width ordinal',
469 'id' : 'circulate', 'label' : 'Circulate?', 'flex' : 1,
470 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.circulate() ) ? "Yes" : "No"; },
471 'persist' : 'hidden width ordinal',
474 'id' : 'deleted', 'label' : 'Deleted?', 'flex' : 1,
475 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deleted() ) ? "Yes" : "No"; },
476 'persist' : 'hidden width ordinal',
479 'id' : 'holdable', 'label' : 'Holdable?', 'flex' : 1,
480 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.holdable() ) ? "Yes" : "No"; },
481 'persist' : 'hidden width ordinal',
484 'id' : 'opac_visible', 'label' : 'OPAC Visible?', 'flex' : 1,
485 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.opac_visible() ) ? "Yes" : "No"; },
486 'persist' : 'hidden width ordinal',
489 'persist' : 'hidden width ordinal', 'id' : 'ref', 'label' : 'Reference?', 'flex' : 1,
490 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.ref() ) ? "Yes" : "No"; },
493 'persist' : 'hidden width ordinal', 'id' : 'deposit', 'label' : 'Deposit?', 'flex' : 1,
494 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deposit() ) ? "Yes" : "No"; },
497 'persist' : 'hidden width ordinal', 'id' : 'deposit_amount', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'), 'flex' : 1,
498 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.deposit_amount()); }, 'sort_type' : 'money',
501 'persist' : 'hidden width ordinal', 'id' : 'price', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'), 'flex' : 1,
502 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.price()); }, 'sort_type' : 'money',
505 'persist' : 'hidden width ordinal', 'id' : 'circ_as_type', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'), 'flex' : 1,
506 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_as_type(); },
509 'persist' : 'hidden width ordinal', 'id' : 'circ_modifier', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'), 'flex' : 1,
510 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_modifier(); },
513 'persist' : 'hidden width ordinal', 'id' : 'checkout_lib', 'label' : 'Checkout Lib', 'flex' : 1,
514 '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() : ""); },
517 'persist' : 'hidden width ordinal', 'id' : 'xact_start_full', 'label' : 'Checkout Timestamp', 'flex' : 1,
518 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start() : (my.acp.circulations() ? my.acp.circulations()[0].xact_start() : ""); },
521 'persist' : 'hidden width ordinal', 'id' : 'checkin_time_full', 'label' : 'Checkin Timestamp', 'flex' : 1,
522 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time() : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time() : ""); },
525 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : 'Checkout Date', 'flex' : 1,
526 '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) : ""); },
529 'persist' : 'hidden width ordinal', 'id' : 'checkin_time', 'label' : 'Checkin Date', 'flex' : 1,
530 '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) : ""); },
534 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : 'Transaction Finished', 'flex' : 1,
535 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ.xact_finish(); },
538 'persist' : 'hidden width ordinal', 'id' : 'due_date', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'), 'flex' : 1,
539 '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) : ""); },
542 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : 'Date Created', 'flex' : 1,
543 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.create_date().substr(0,10); },
546 'persist' : 'hidden width ordinal', 'id' : 'edit_date', 'label' : 'Date Last Edited', 'flex' : 1,
547 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.edit_date().substr(0,10); },
550 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'), 'flex' : 2, 'sort_type' : 'title',
551 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } }
554 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'), 'flex' : 1,
555 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } }
558 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
559 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
562 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
563 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
566 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
567 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
570 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
571 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
574 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
575 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
578 'persist' : 'hidden width ordinal', 'id' : 'renewal_remaining', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'), 'flex' : 0,
579 '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',
582 'persist' : 'hidden width ordinal', 'id' : 'stop_fines', 'label' : 'Fines Stopped', 'flex' : 0,
583 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines() : ""); },
586 'persist' : 'hidden width ordinal', 'id' : 'stop_fines_time', 'label' : 'Fines Stopped Time', 'flex' : 0,
587 '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() : ""); },
590 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'), 'flex' : 1,
591 '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(); },
594 'persist' : 'hidden width ordinal', 'id' : 'route_to', 'label' : 'Route To', 'flex' : 1,
595 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.route_to.toString(); },
598 'persist' : 'hidden width ordinal', 'id' : 'message', 'label' : 'Message', 'flex' : 1,
599 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.message.toString(); },
602 'persist' : 'hidden width ordinal', 'id' : 'uses', 'label' : '# of Uses', 'flex' : 1,
603 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.uses; }, 'sort_type' : 'number',
606 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : 'Alert Message', 'flex' : 1,
607 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.alert_message(); },
610 for (var i = 0; i < c.length; i++) {
611 if (modify[ c[i].id ]) {
612 for (var j in modify[ c[i].id ]) {
613 c[i][j] = modify[ c[i].id ][j];
618 if (params.just_these) {
619 JSAN.use('util.functional');
621 for (var i = 0; i < params.just_these.length; i++) {
622 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
623 new_c.push( function(y){ return y; }( x ) );
627 if (params.except_these) {
628 JSAN.use('util.functional');
630 for (var i = 0; i < c.length; i++) {
631 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
632 if (!x) new_c.push(c[i]);
637 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
640 circ.util.transit_columns = function(modify,params) {
642 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
646 'persist' : 'hidden width ordinal', 'id' : 'transit_item_barcode', 'label' : 'Barcode', 'flex' : 1,
647 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); },
650 'persist' : 'hidden width ordinal', 'id' : 'transit_item_title', 'label' : 'Title', 'flex' : 1,
651 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } },
654 'persist' : 'hidden width ordinal', 'id' : 'transit_item_author', 'label' : 'Author', 'flex' : 1,
655 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } },
658 'persist' : 'hidden width ordinal', 'id' : 'transit_item_callnumber', 'label' : 'Call Number', 'flex' : 1,
659 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); },
662 'persist' : 'hidden width ordinal', 'id' : 'transit_id', 'label' : 'Transit ID', 'flex' : 1,
663 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.atc.id(); },
666 'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1,
667 'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.source() == "object" ? my.atc.source().shortname() : data.hash.aou[ my.atc.source() ].shortname(); },
670 'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1,
671 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.source_send_time(); },
674 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1,
675 'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.dest() == "object" ? my.atc.dest().shortname() : data.hash.aou[ my.atc.dest() ].shortname(); },
678 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1,
679 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.dest_recv_time(); },
682 'persist' : 'hidden width ordinal', 'id' : 'transit_target_copy', 'label' : 'Transit Copy ID', 'flex' : 1,
683 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.atc.target_copy(); },
686 for (var i = 0; i < c.length; i++) {
687 if (modify[ c[i].id ]) {
688 for (var j in modify[ c[i].id ]) {
689 c[i][j] = modify[ c[i].id ][j];
694 if (params.just_these) {
695 JSAN.use('util.functional');
697 for (var i = 0; i < params.just_these.length; i++) {
698 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
699 new_c.push( function(y){ return y; }( x ) );
703 if (params.except_these) {
704 JSAN.use('util.functional');
706 for (var i = 0; i < c.length; i++) {
707 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
708 if (!x) new_c.push(c[i]);
714 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
718 circ.util.hold_columns = function(modify,params) {
720 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
724 'persist' : 'hidden width ordinal', 'id' : 'request_lib', 'label' : 'Request Lib (Full Name)', 'flex' : 1,
725 'primary' : false, 'hidden' : true,
726 '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(); },
729 'persist' : 'hidden width ordinal', 'id' : 'request_lib_shortname', 'label' : 'Request Lib', 'flex' : 0,
730 'primary' : false, 'hidden' : true,
731 '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(); },
735 'persist' : 'hidden width ordinal', 'id' : 'request_timestamp', 'label' : 'Request Timestamp', 'flex' : 0,
736 'primary' : false, 'hidden' : true,
737 'render' : function(my) { return my.ahr.request_time().toString(); },
740 'persist' : 'hidden width ordinal', 'id' : 'request_time', 'label' : 'Request Date', 'flex' : 0,
741 'primary' : false, 'hidden' : true,
742 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); },
745 'persist' : 'hidden width ordinal', 'id' : 'available_timestamp', 'label' : 'Available On (Timestamp)', 'flex' : 1,
746 '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() : "" ); },
749 'persist' : 'hidden width ordinal', 'id' : 'available_time', 'label' : 'Available On', 'flex' : 1,
750 '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) : "" ); },
753 'persist' : 'hidden width ordinal', 'id' : 'capture_timestamp', 'label' : 'Capture Timestamp', 'flex' : 1,
754 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; },
757 'persist' : 'hidden width ordinal', 'id' : 'capture_time', 'label' : 'Capture Date', 'flex' : 1,
758 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; },
761 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'), 'flex' : 1,
762 '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;}; },
765 'persist' : 'hidden width ordinal', 'id' : 'hold_type', 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'), 'flex' : 0,
766 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.hold_type(); },
769 'persist' : 'hidden width ordinal', 'id' : 'frozen', 'label' : 'Frozen?', 'flex' : 0,
770 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.ahr.frozen() ) ? 'Yes' : 'No'; },
773 'persist' : 'hidden width ordinal', 'id' : 'thaw_date', 'label' : 'Thaw Date', 'flex' : 0,
774 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.thaw_date() == null ? 'No Date' : my.ahr.thaw_date().substr(0,10); },
777 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib', 'label' : 'Pickup Lib (Full Name)', 'flex' : 1,
778 'primary' : false, 'hidden' : true,
779 '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(); },
782 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib_shortname', 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'), 'flex' : 0,
783 'primary' : false, 'hidden' : true,
784 '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(); },
787 'persist' : 'hidden width ordinal', 'id' : 'current_copy', 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'), 'flex' : 1,
788 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp ? my.acp.barcode() : "No Copy"; },
791 'persist' : 'hidden width ordinal', 'id' : 'email_notify', 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'), 'flex' : 1,
792 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool(my.ahr.email_notify()) ? "Yes" : "No"; },
795 'persist' : 'hidden width ordinal', 'id' : 'expire_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'), 'flex' : 1,
796 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.expire_time(); },
799 'persist' : 'hidden width ordinal', 'id' : 'fulfillment_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'), 'flex' : 1,
800 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.fulfillment_time(); },
803 'persist' : 'hidden width ordinal', 'id' : 'holdable_formats', 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'), 'flex' : 1,
804 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.holdable_formats(); },
807 'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'), 'flex' : 1,
808 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.id(); },
811 'persist' : 'hidden width ordinal', 'id' : 'phone_notify', 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'), 'flex' : 1,
812 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.phone_notify(); },
815 'persist' : 'hidden width ordinal', 'id' : 'prev_check_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'), 'flex' : 1,
816 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.prev_check_time(); },
819 'persist' : 'hidden width ordinal', 'id' : 'requestor', 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'), 'flex' : 1,
820 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.requestor(); },
823 'persist' : 'hidden width ordinal', 'id' : 'selection_depth', 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'), 'flex' : 1,
824 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.selection_depth(); },
827 'persist' : 'hidden width ordinal', 'id' : 'target', 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'), 'flex' : 1,
828 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.target(); },
831 'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'), 'flex' : 1,
832 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.usr(); },
835 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'), 'flex' : 1, 'sort_type' : 'title',
836 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.title() : "No Title?"; },
839 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'), 'flex' : 1,
840 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.author() : "No Author?"; },
843 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
844 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
847 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
848 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
851 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
852 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
855 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
856 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
859 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
860 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
863 'persist' : 'hidden width ordinal', 'id' : 'notify_time', 'label' : 'Last Notify Time', 'flex' : 1,
864 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_time(); },
867 'persist' : 'hidden width ordinal', 'id' : 'notify_count', 'label' : 'Notices', 'flex' : 1,
868 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_count(); },
871 'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1,
872 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().source() ].shortname() : ""; },
875 'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1,
876 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; },
879 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1,
880 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; },
883 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1,
884 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; },
887 'persist' : 'hidden width ordinal', 'id' : 'patron_barcode', 'label' : 'Patron Barcode', 'flex' : 1,
888 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; },
891 'persist' : 'hidden width ordinal', 'id' : 'patron_family_name', 'label' : 'Patron Last Name', 'flex' : 1,
892 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; },
895 'persist' : 'hidden width ordinal', 'id' : 'patron_first_given_name', 'label' : 'Patron First Name', 'flex' : 1,
896 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; },
899 'persist' : 'hidden width ordinal', 'id' : 'callnumber', 'label' : 'Call Number', 'flex' : 1,
900 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); },
903 for (var i = 0; i < c.length; i++) {
904 if (modify[ c[i].id ]) {
905 for (var j in modify[ c[i].id ]) {
906 c[i][j] = modify[ c[i].id ][j];
911 if (params.just_these) {
912 JSAN.use('util.functional');
914 for (var i = 0; i < params.just_these.length; i++) {
915 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
916 new_c.push( function(y){ return y; }( x ) );
920 if (params.except_these) {
921 JSAN.use('util.functional');
923 for (var i = 0; i < c.length; i++) {
924 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
925 if (!x) new_c.push(c[i]);
931 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
934 circ.util.std_map_row_to_column = function(error_value) {
935 return function(row,col) {
936 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
937 // col contains one of the objects listed above in columns
939 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
941 JSAN.use('util.error'); obj.error = new util.error();
942 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
943 JSAN.use('util.network'); obj.network = new util.network();
944 JSAN.use('util.money');
949 value = eval( col.render );
951 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
952 if (error_value) value = error_value; else value = ' ';
958 circ.util.std_map_row_to_columns = function(error_value) {
959 return function(row,cols) {
960 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
961 // cols contains all of the objects listed above in columns
964 JSAN.use('util.error'); obj.error = new util.error();
965 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
966 JSAN.use('util.network'); obj.network = new util.network();
967 JSAN.use('util.money');
973 for (var i = 0; i < cols.length; i++) {
974 switch (typeof cols[i].render) {
975 case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } break;
976 case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
977 default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
980 if (cmd) eval( cmd );
982 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
983 if (error_value) { value = error_value; } else { value = ' ' };
989 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
991 JSAN.use('util.error'); var error = new util.error();
992 JSAN.use('util.network'); var network = new util.network();
993 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
994 JSAN.use('util.date');
996 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
998 //var params = { 'barcode' : barcode };
999 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1001 if (typeof async == 'object') {
1002 try { async.disable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1004 var check = network.request(
1005 api.CHECKIN_VIA_BARCODE.app,
1006 api.CHECKIN_VIA_BARCODE.method,
1007 [ session, params ],
1008 async ? function(req) {
1010 var check = req.getResultObject();
1011 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1012 if (typeof async == 'object') {
1013 try { async.checkin_result(r); } catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1016 JSAN.use('util.error'); var error = new util.error();
1017 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1018 if (typeof async == 'object') {
1019 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1025 'title' : 'Override Checkin Failure?',
1026 'overridable_events' : [
1027 1203 /* COPY_BAD_STATUS */,
1028 1213 /* PATRON_BARRED */,
1029 1217 /* PATRON_INACTIVE */,
1030 1224 /* PATRON_ACCOUNT_EXPIRED */,
1031 7009 /* CIRC_CLAIMS_RETURNED */,
1032 7010 /* COPY_ALERT_MESSAGE */,
1033 7011 /* COPY_STATUS_LOST */,
1034 7012 /* COPY_STATUS_MISSING */,
1035 7013 /* PATRON_EXCEEDS_FINES */,
1038 '1203' : function(r) {
1039 //return data.hash.ccs[ r.payload.status() ].name();
1040 return r.payload.status().name();
1042 '7010' : function(r) {
1049 return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1054 JSAN.use('util.error'); var error = new util.error();
1055 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1056 if (typeof async == 'object') {
1057 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1063 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1065 JSAN.use('util.error'); var error = new util.error();
1066 JSAN.use('util.network'); var network = new util.network();
1067 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1068 JSAN.use('util.date');
1070 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1072 check.message = check.textcode;
1074 if (check.payload && check.payload.copy) check.copy = check.payload.copy;
1075 if (check.payload && check.payload.record) check.record = check.payload.record;
1076 if (check.payload && check.payload.circ) check.circ = check.payload.circ;
1078 if (!check.route_to) check.route_to = ' ';
1080 if (document.getElementById('no_change_label')) {
1081 document.getElementById('no_change_label').setAttribute('value','');
1082 document.getElementById('no_change_label').setAttribute('hidden','true');
1086 network.simple_request('FM_MBTS_RETRIEVE',[ses(),check.circ.id()], function(req) {
1087 JSAN.use('util.money');
1088 var bill = req.getResultObject();
1089 if (Number(bill.balance_owed()) == 0) return;
1090 if (document.getElementById('no_change_label')) {
1091 var m = document.getElementById('no_change_label').getAttribute('value');
1092 document.getElementById('no_change_label').setAttribute('value', m + 'Transaction for ' + params.barcode + ' billable $' + util.money.sanitize(bill.balance_owed()) + ' ');
1093 document.getElementById('no_change_label').setAttribute('hidden','false');
1100 if (check.payload && check.payload.cancelled_hold_transit) {
1101 msg += 'Original hold for transit cancelled.\n\n';
1104 /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
1105 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1106 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'; }
1107 if (check.ilsevent == 3 /* NO_CHANGE */) {
1108 //msg = 'This item is already checked in.\n';
1109 if (document.getElementById('no_change_label')) {
1110 var m = document.getElementById('no_change_label').getAttribute('value');
1111 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' was already checked in. ');
1112 document.getElementById('no_change_label').setAttribute('hidden','false');
1115 if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
1116 msg = 'Please inform your helpdesk/developers of this error:\nFIXME -- ITEM_NOT_CATALOGED event but copy status is '
1117 + (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() ) + '\n';
1119 switch(check.copy.status()) {
1120 case 0: /* AVAILABLE */
1121 case 7: /* RESHELVING */
1122 if (msg) msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1124 case 8: /* ON HOLDS SHELF */
1125 check.route_to = 'HOLDS SHELF';
1126 if (check.payload.hold) {
1127 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
1128 msg += 'Please inform your helpdesk/developers of this error:\nFIXME: We should have received a ROUTE_ITEM\n';
1130 msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1133 msg += 'Please inform your helpdesk/developers of this error:\nFIXME: status of Holds Shelf, but no actual hold found.\n';
1135 JSAN.use('util.date');
1136 if (check.payload.hold) {
1137 JSAN.use('patron.util');
1138 msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1139 msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1140 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1141 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1142 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1143 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1144 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1145 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F') + '\n';
1148 msg += 'Slip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1149 if (!auto_print) rv = error.yns_alert_formatted(
1155 "Check here to confirm this message",
1156 '/xul/server/skin/media/images/turtle.gif'
1160 JSAN.use('util.print'); var print = new util.print();
1161 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
1162 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1164 dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1165 alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1169 if (document.getElementById('no_change_label')) {
1170 var m = document.getElementById('no_change_label').getAttribute('value');
1171 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' has been captured for a hold. ');
1172 document.getElementById('no_change_label').setAttribute('hidden','false');
1175 case 6: /* IN TRANSIT */
1176 check.route_to = 'TRANSIT SHELF??';
1177 msg += ("Please inform your helpdesk/developers of this error:\nFIXME -- I didn't think we could get here.\n");
1179 case 11: /* CATALOGING */
1180 check.route_to = 'CATALOGING';
1181 if (document.getElementById('do_not_alert_on_precat')) {
1182 var x = document.getElementById('do_not_alert_on_precat');
1183 if (! x.checked) msg += 'This item needs to be routed to ' + check.route_to + '.';
1185 msg += 'This item needs to be routed to ' + check.route_to + '.';
1187 if (document.getElementById('no_change_label')) {
1188 var m = document.getElementById('no_change_label').getAttribute('value');
1189 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' needs to be cataloged. ');
1190 document.getElementById('no_change_label').setAttribute('hidden','false');
1194 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');
1195 msg += 'This item needs to be routed to ' + check.route_to + '.';
1198 if (msg) error.yns_alert(msg,'Alert',null,'OK',null,"Check here to confirm this message");
1200 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
1202 var lib = data.hash.aou[ check.org ];
1203 check.route_to = lib.shortname();
1204 msg += 'Destination: ' + check.route_to + '.\n';
1205 msg += '\n' + lib.name() + '\n';
1207 if (lib.holds_address() ) {
1208 var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
1209 if (typeof a.ilsevent != 'undefined') throw(a);
1210 if (a.street1()) msg += a.street1() + '\n';
1211 if (a.street2()) msg += a.street2() + '\n';
1212 msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
1214 msg += "We do not have a holds address for this library.\n";
1217 msg += 'Unable to retrieve mailing address.\n';
1218 error.standard_unexpected_error_alert('Unable to retrieve mailing address.',E);
1220 msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1221 msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1222 msg += 'Author: ' + (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author() ) + '\n';
1223 JSAN.use('util.date');
1224 if (check.payload.hold) {
1225 JSAN.use('patron.util');
1226 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1227 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1228 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1229 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1230 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1231 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F');
1234 msg += '\nSlip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1235 if (!auto_print) rv = error.yns_alert_formatted(
1241 "Check here to confirm this message",
1242 '/xul/server/skin/media/images/turtle.gif'
1246 JSAN.use('util.print'); var print = new util.print();
1247 //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
1248 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
1249 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1251 dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1252 alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1255 if (document.getElementById('no_change_label')) {
1256 var m = document.getElementById('no_change_label').getAttribute('value');
1257 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is in transit. ');
1258 document.getElementById('no_change_label').setAttribute('hidden','false');
1261 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
1263 check.route_to = 'CATALOGING';
1265 'The barcode was either mis-scanned or the item needs to be cataloged.',
1270 "Check here to confirm this message"
1272 if (document.getElementById('no_change_label')) {
1273 var m = document.getElementById('no_change_label').getAttribute('value');
1274 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is mis-scanned or not cataloged. ');
1275 document.getElementById('no_change_label').setAttribute('hidden','false');
1278 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
1279 error.standard_network_error_alert('Check In Failed. If you wish to use the offline interface, in the top menubar select Circulation -> Offline Interface');
1282 switch (check.ilsevent) {
1283 case 1203 /* COPY_BAD_STATUS */ :
1284 case 1213 /* PATRON_BARRED */ :
1285 case 1217 /* PATRON_INACTIVE */ :
1286 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
1287 case 7009 /* CIRC_CLAIMS_RETURNED */ :
1288 case 7010 /* COPY_ALERT_MESSAGE */ :
1289 case 7011 /* COPY_STATUS_LOST */ :
1290 case 7012 /* COPY_STATUS_MISSING */ :
1291 case 7013 /* PATRON_EXCEEDS_FINES */ :
1292 return null; /* handled */
1302 JSAN.use('util.error'); var error = new util.error();
1303 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1308 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
1311 JSAN.use('util.network'); obj.network = new util.network();
1312 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
1314 var params = { barcode: barcode };
1315 if (patron_id) params.patron = patron_id;
1317 function renew_callback(req) {
1319 var renew = req.getResultObject();
1320 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
1321 for (var j = 0; j < renew.length; j++) {
1322 switch(renew[j].ilsevent) {
1323 case 0 /* SUCCESS */ : break;
1324 case 5000 /* PERM_FAILURE */: break;
1325 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
1326 case 1213 /* PATRON_BARRED */ : break;
1327 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
1328 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
1329 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
1330 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
1331 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
1332 case 7004 /* COPY_NOT_AVAILABLE */ : break;
1333 case 7006 /* COPY_IS_REFERENCE */ : break;
1334 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
1335 case 7008 /* MAX_RENEWALS_REACHED */ : break;
1336 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
1337 case 7010 /* COPY_ALERT_MESSAGE */ : break;
1338 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
1344 if (typeof async == 'function') async(renew);
1347 JSAN.use('util.error'); var error = new util.error();
1348 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1353 var renew = obj.network.simple_request(
1356 async ? renew_callback : null,
1358 'title' : 'Override Renew Failure?',
1359 'overridable_events' : [
1360 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
1361 1213 /* PATRON_BARRED */,
1362 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
1363 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
1364 7003 /* COPY_CIRC_NOT_ALLOWED */,
1365 7004 /* COPY_NOT_AVAILABLE */,
1366 7006 /* COPY_IS_REFERENCE */,
1367 7007 /* COPY_NEEDED_FOR_HOLD */,
1368 7008 /* MAX_RENEWALS_REACHED */,
1369 7009 /* CIRC_CLAIMS_RETURNED */,
1370 7010 /* COPY_ALERT_MESSAGE */,
1371 7013 /* PATRON_EXCEEDS_FINES */,
1374 '1212' : function(r) { return 'Barcode: ' + barcode; },
1375 '1213' : function(r) { return 'Barcode: ' + barcode; },
1376 '1215' : function(r) { return 'Barcode: ' + barcode; },
1377 '7002' : function(r) { return 'Barcode: ' + barcode; },
1378 '7003' : function(r) { return 'Barcode: ' + barcode; },
1379 '7004' : function(r) {
1380 return 'Barcode: ' + barcode + ' Status: ' + r.payload.status().name();
1382 '7006' : function(r) { return 'Barcode: ' + barcode; },
1383 '7007' : function(r) { return 'Barcode: ' + barcode; },
1384 '7008' : function(r) { return 'Barcode: ' + barcode; },
1385 '7009' : function(r) { return 'Barcode: ' + barcode; },
1386 '7010' : function(r) {
1387 return 'Barcode: ' + barcode + ' Message: ' + r.payload;
1389 '7013' : function(r) { return 'Barcode: ' + barcode; },
1393 if (! async ) return renew_callback( { 'getResultObject' : function() { return renew; } } );
1396 JSAN.use('util.error'); var error = new util.error();
1397 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1404 dump('exiting circ/util.js\n');