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');
406 function getString(s) { return data.entities[s]; }
410 'id' : 'acp_id', 'label' : getString('staff.acp_label_id'), 'flex' : 1,
411 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.id(); }, 'persist' : 'hidden width ordinal',
414 'id' : 'circ_id', 'label' : getString('staff.circ_label_id'), 'flex' : 1,
415 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
416 'persist' : 'hidden width ordinal',
419 'id' : 'mvr_doc_id', 'label' : getString('staff.mvr_label_doc_id'), 'flex' : 1,
420 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.doc_id(); },
421 'persist' : 'hidden width ordinal',
424 'id' : 'barcode', 'label' : getString('staff.acp_label_barcode'), 'flex' : 1,
425 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); },
426 'persist' : 'hidden width ordinal',
429 'id' : 'call_number', 'label' : getString('staff.acp_label_call_number'), 'flex' : 1,
430 '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(); } } },
431 'persist' : 'hidden width ordinal',
434 'id' : 'owning_lib', 'label' : 'Owning Lib', 'flex' : 1,
435 'primary' : false, 'hidden' : true,
436 '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(); } },
437 'persist' : 'hidden width ordinal',
440 'id' : 'copy_number', 'label' : getString('staff.acp_label_copy_number'), 'flex' : 1, 'sort_type' : 'number',
441 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.copy_number(); },
442 'persist' : 'hidden width ordinal',
445 'id' : 'location', 'label' : getString('staff.acp_label_location'), 'flex' : 1,
446 '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(); },
447 'persist' : 'hidden width ordinal',
450 'id' : 'loan_duration', 'label' : getString('staff.acp_label_loan_duration'), 'flex' : 1,
451 'primary' : false, 'hidden' : true,
452 'render' : function(my) { switch(my.acp.loan_duration()){ case 1: return "Short"; break; case 2: return "Normal"; break; case 3: return "Long"; break; }; },
453 'persist' : 'hidden width ordinal',
456 'id' : 'circ_lib', 'label' : getString('staff.acp_label_circ_lib'), 'flex' : 1,
457 '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(); },
458 'persist' : 'hidden width ordinal',
461 'id' : 'fine_level', 'label' : getString('staff.acp_label_fine_level'), 'flex' : 1,
462 'primary' : false, 'hidden' : true,
463 'render' : function(my) { switch(my.acp.fine_level()){ case 1: return "Low"; break; case 2: return "Normal"; break; case 3: return "High"; break; }; },
464 'persist' : 'hidden width ordinal',
467 'id' : 'circulate', 'label' : 'Circulate?', 'flex' : 1,
468 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.circulate() ) ? "Yes" : "No"; },
469 'persist' : 'hidden width ordinal',
472 'id' : 'deleted', 'label' : 'Deleted?', 'flex' : 1,
473 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deleted() ) ? "Yes" : "No"; },
474 'persist' : 'hidden width ordinal',
477 'id' : 'holdable', 'label' : 'Holdable?', 'flex' : 1,
478 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.holdable() ) ? "Yes" : "No"; },
479 'persist' : 'hidden width ordinal',
482 'id' : 'opac_visible', 'label' : 'OPAC Visible?', 'flex' : 1,
483 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.opac_visible() ) ? "Yes" : "No"; },
484 'persist' : 'hidden width ordinal',
487 'persist' : 'hidden width ordinal', 'id' : 'ref', 'label' : 'Reference?', 'flex' : 1,
488 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.ref() ) ? "Yes" : "No"; },
491 'persist' : 'hidden width ordinal', 'id' : 'deposit', 'label' : 'Deposit?', 'flex' : 1,
492 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deposit() ) ? "Yes" : "No"; },
495 'persist' : 'hidden width ordinal', 'id' : 'deposit_amount', 'label' : getString('staff.acp_label_deposit_amount'), 'flex' : 1,
496 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.deposit_amount()); }, 'sort_type' : 'money',
499 'persist' : 'hidden width ordinal', 'id' : 'price', 'label' : getString('staff.acp_label_price'), 'flex' : 1,
500 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.price() == null ? "<Unset>" : util.money.sanitize(my.acp.price()); }, 'sort_type' : 'money',
503 'persist' : 'hidden width ordinal', 'id' : 'circ_as_type', 'label' : getString('staff.acp_label_circ_as_type'), 'flex' : 1,
504 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_as_type(); },
507 'persist' : 'hidden width ordinal', 'id' : 'circ_modifier', 'label' : getString('staff.acp_label_circ_modifier'), 'flex' : 1,
508 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_modifier(); },
511 'persist' : 'hidden width ordinal', 'id' : 'checkout_lib', 'label' : 'Checkout Lib', 'flex' : 1,
512 '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() : ""); },
515 'persist' : 'hidden width ordinal', 'id' : 'xact_start_full', 'label' : 'Checkout Timestamp', 'flex' : 1,
516 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start() : (my.acp.circulations() ? my.acp.circulations()[0].xact_start() : ""); },
519 'persist' : 'hidden width ordinal', 'id' : 'checkin_time_full', 'label' : 'Checkin Timestamp', 'flex' : 1,
520 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time() : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time() : ""); },
523 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : 'Checkout Date', 'flex' : 1,
524 '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) : ""); },
527 'persist' : 'hidden width ordinal', 'id' : 'checkin_time', 'label' : 'Checkin Date', 'flex' : 1,
528 '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) : ""); },
532 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : 'Transaction Finished', 'flex' : 1,
533 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ.xact_finish(); },
536 'persist' : 'hidden width ordinal', 'id' : 'due_date', 'label' : getString('staff.circ_label_due_date'), 'flex' : 1,
537 '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) : ""); },
540 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : 'Date Created', 'flex' : 1,
541 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.create_date().substr(0,10); },
544 'persist' : 'hidden width ordinal', 'id' : 'edit_date', 'label' : 'Date Last Edited', 'flex' : 1,
545 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.edit_date().substr(0,10); },
548 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : getString('staff.mvr_label_title'), 'flex' : 2, 'sort_type' : 'title',
549 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } }
552 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : getString('staff.mvr_label_author'), 'flex' : 1,
553 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } }
556 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
557 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
560 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
561 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
564 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
565 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
568 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
569 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
572 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
573 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
576 'persist' : 'hidden width ordinal', 'id' : 'renewal_remaining', 'label' : getString('staff.circ_label_renewal_remaining'), 'flex' : 0,
577 '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',
580 'persist' : 'hidden width ordinal', 'id' : 'stop_fines', 'label' : 'Fines Stopped', 'flex' : 0,
581 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines() : ""); },
584 'persist' : 'hidden width ordinal', 'id' : 'stop_fines_time', 'label' : 'Fines Stopped Time', 'flex' : 0,
585 '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() : ""); },
588 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : getString('staff.acp_label_status'), 'flex' : 1,
589 '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(); },
592 'persist' : 'hidden width ordinal', 'id' : 'route_to', 'label' : 'Route To', 'flex' : 1,
593 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.route_to.toString(); },
596 'persist' : 'hidden width ordinal', 'id' : 'message', 'label' : 'Message', 'flex' : 1,
597 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.message.toString(); },
600 'persist' : 'hidden width ordinal', 'id' : 'uses', 'label' : '# of Uses', 'flex' : 1,
601 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.uses; }, 'sort_type' : 'number',
604 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : 'Alert Message', 'flex' : 1,
605 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.alert_message(); },
608 for (var i = 0; i < c.length; i++) {
609 if (modify[ c[i].id ]) {
610 for (var j in modify[ c[i].id ]) {
611 c[i][j] = modify[ c[i].id ][j];
616 if (params.just_these) {
617 JSAN.use('util.functional');
619 for (var i = 0; i < params.just_these.length; i++) {
620 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
621 new_c.push( function(y){ return y; }( x ) );
625 if (params.except_these) {
626 JSAN.use('util.functional');
628 for (var i = 0; i < c.length; i++) {
629 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
630 if (!x) new_c.push(c[i]);
635 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
638 circ.util.transit_columns = function(modify,params) {
640 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
642 function getString(s) { return data.entities[s]; }
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'});
722 function getString(s) { return data.entities[s]; }
726 'persist' : 'hidden width ordinal', 'id' : 'request_lib', 'label' : 'Request Lib (Full Name)', 'flex' : 1,
727 'primary' : false, 'hidden' : true,
728 '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(); },
731 'persist' : 'hidden width ordinal', 'id' : 'request_lib_shortname', 'label' : 'Request Lib', 'flex' : 0,
732 'primary' : false, 'hidden' : true,
733 '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(); },
737 'persist' : 'hidden width ordinal', 'id' : 'request_timestamp', 'label' : 'Request Timestamp', 'flex' : 0,
738 'primary' : false, 'hidden' : true,
739 'render' : function(my) { return my.ahr.request_time().toString(); },
742 'persist' : 'hidden width ordinal', 'id' : 'request_time', 'label' : 'Request Date', 'flex' : 0,
743 'primary' : false, 'hidden' : true,
744 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); },
747 'persist' : 'hidden width ordinal', 'id' : 'available_timestamp', 'label' : 'Available On (Timestamp)', 'flex' : 1,
748 '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() : "" ); },
751 'persist' : 'hidden width ordinal', 'id' : 'available_time', 'label' : 'Available On', 'flex' : 1,
752 '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) : "" ); },
755 'persist' : 'hidden width ordinal', 'id' : 'capture_timestamp', 'label' : 'Capture Timestamp', 'flex' : 1,
756 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; },
759 'persist' : 'hidden width ordinal', 'id' : 'capture_time', 'label' : 'Capture Date', 'flex' : 1,
760 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; },
763 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : getString('staff.ahr_status_label'), 'flex' : 1,
764 '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;}; },
767 'persist' : 'hidden width ordinal', 'id' : 'hold_type', 'label' : getString('staff.ahr_hold_type_label'), 'flex' : 0,
768 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.hold_type(); },
771 'persist' : 'hidden width ordinal', 'id' : 'frozen', 'label' : 'Frozen?', 'flex' : 0,
772 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.ahr.frozen() ) ? 'Yes' : 'No'; },
775 'persist' : 'hidden width ordinal', 'id' : 'thaw_date', 'label' : 'Thaw Date', 'flex' : 0,
776 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.thaw_date() == null ? 'No Date' : my.ahr.thaw_date().substr(0,10); },
779 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib', 'label' : 'Pickup Lib (Full Name)', 'flex' : 1,
780 'primary' : false, 'hidden' : true,
781 '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(); },
784 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib_shortname', 'label' : getString('staff.ahr_pickup_lib_label'), 'flex' : 0,
785 'primary' : false, 'hidden' : true,
786 '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(); },
789 'persist' : 'hidden width ordinal', 'id' : 'current_copy', 'label' : getString('staff.ahr_current_copy_label'), 'flex' : 1,
790 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp ? my.acp.barcode() : "No Copy"; },
793 'persist' : 'hidden width ordinal', 'id' : 'email_notify', 'label' : getString('staff.ahr_email_notify_label'), 'flex' : 1,
794 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool(my.ahr.email_notify()) ? "Yes" : "No"; },
797 'persist' : 'hidden width ordinal', 'id' : 'expire_time', 'label' : getString('staff.ahr_expire_time_label'), 'flex' : 1,
798 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.expire_time(); },
801 'persist' : 'hidden width ordinal', 'id' : 'fulfillment_time', 'label' : getString('staff.ahr_fulfillment_time_label'), 'flex' : 1,
802 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.fulfillment_time(); },
805 'persist' : 'hidden width ordinal', 'id' : 'holdable_formats', 'label' : getString('staff.ahr_holdable_formats_label'), 'flex' : 1,
806 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.holdable_formats(); },
809 'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : getString('staff.ahr_id_label'), 'flex' : 1,
810 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.id(); },
813 'persist' : 'hidden width ordinal', 'id' : 'phone_notify', 'label' : getString('staff.ahr_phone_notify_label'), 'flex' : 1,
814 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.phone_notify(); },
817 'persist' : 'hidden width ordinal', 'id' : 'prev_check_time', 'label' : getString('staff.ahr_prev_check_time_label'), 'flex' : 1,
818 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.prev_check_time(); },
821 'persist' : 'hidden width ordinal', 'id' : 'requestor', 'label' : getString('staff.ahr_requestor_label'), 'flex' : 1,
822 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.requestor(); },
825 'persist' : 'hidden width ordinal', 'id' : 'selection_depth', 'label' : getString('staff.ahr_selection_depth_label'), 'flex' : 1,
826 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.selection_depth(); },
829 'persist' : 'hidden width ordinal', 'id' : 'target', 'label' : getString('staff.ahr_target_label'), 'flex' : 1,
830 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.target(); },
833 'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : getString('staff.ahr_usr_label'), 'flex' : 1,
834 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.usr(); },
837 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : getString('staff.mvr_label_title'), 'flex' : 1, 'sort_type' : 'title',
838 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.title() : "No Title?"; },
841 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : getString('staff.mvr_label_author'), 'flex' : 1,
842 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.author() : "No Author?"; },
845 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1,
846 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); },
849 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1,
850 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); },
853 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1,
854 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); },
857 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1,
858 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); },
861 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1,
862 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); },
865 'persist' : 'hidden width ordinal', 'id' : 'notify_time', 'label' : 'Last Notify Time', 'flex' : 1,
866 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_time(); },
869 'persist' : 'hidden width ordinal', 'id' : 'notify_count', 'label' : 'Notices', 'flex' : 1,
870 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_count(); },
873 'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1,
874 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().source() ].shortname() : ""; },
877 'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1,
878 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; },
881 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1,
882 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; },
885 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1,
886 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; },
889 'persist' : 'hidden width ordinal', 'id' : 'patron_barcode', 'label' : 'Patron Barcode', 'flex' : 1,
890 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; },
893 'persist' : 'hidden width ordinal', 'id' : 'patron_family_name', 'label' : 'Patron Last Name', 'flex' : 1,
894 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; },
897 'persist' : 'hidden width ordinal', 'id' : 'patron_first_given_name', 'label' : 'Patron First Name', 'flex' : 1,
898 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; },
901 'persist' : 'hidden width ordinal', 'id' : 'callnumber', 'label' : 'Call Number', 'flex' : 1,
902 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); },
905 for (var i = 0; i < c.length; i++) {
906 if (modify[ c[i].id ]) {
907 for (var j in modify[ c[i].id ]) {
908 c[i][j] = modify[ c[i].id ][j];
913 if (params.just_these) {
914 JSAN.use('util.functional');
916 for (var i = 0; i < params.just_these.length; i++) {
917 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
918 new_c.push( function(y){ return y; }( x ) );
922 if (params.except_these) {
923 JSAN.use('util.functional');
925 for (var i = 0; i < c.length; i++) {
926 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
927 if (!x) new_c.push(c[i]);
933 return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
936 circ.util.std_map_row_to_column = function(error_value) {
937 return function(row,col) {
938 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
939 // col contains one of the objects listed above in columns
941 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
943 JSAN.use('util.error'); obj.error = new util.error();
944 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
945 JSAN.use('util.network'); obj.network = new util.network();
946 JSAN.use('util.money');
951 value = eval( col.render );
953 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
954 if (error_value) value = error_value; else value = ' ';
960 circ.util.std_map_row_to_columns = function(error_value) {
961 return function(row,cols) {
962 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
963 // cols contains all of the objects listed above in columns
966 JSAN.use('util.error'); obj.error = new util.error();
967 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
968 JSAN.use('util.network'); obj.network = new util.network();
969 JSAN.use('util.money');
975 for (var i = 0; i < cols.length; i++) {
976 switch (typeof cols[i].render) {
977 case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } break;
978 case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
979 default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
982 if (cmd) eval( cmd );
984 obj.error.sdump('D_WARN','map_row_to_column: ' + E);
985 if (error_value) { value = error_value; } else { value = ' ' };
991 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
993 JSAN.use('util.error'); var error = new util.error();
994 JSAN.use('util.network'); var network = new util.network();
995 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
996 JSAN.use('util.date');
998 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1000 //var params = { 'barcode' : barcode };
1001 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1003 if (typeof async == 'object') {
1004 try { async.disable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1006 var check = network.request(
1007 api.CHECKIN_VIA_BARCODE.app,
1008 api.CHECKIN_VIA_BARCODE.method,
1009 [ session, params ],
1010 async ? function(req) {
1012 var check = req.getResultObject();
1013 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1014 if (typeof async == 'object') {
1015 try { async.checkin_result(r); } catch(E) { error.sdump('D_ERROR','async.checkin_result() = ' + E); };
1018 JSAN.use('util.error'); var error = new util.error();
1019 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1020 if (typeof async == 'object') {
1021 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1027 'title' : 'Override Checkin Failure?',
1028 'overridable_events' : [
1029 1203 /* COPY_BAD_STATUS */,
1030 1213 /* PATRON_BARRED */,
1031 1217 /* PATRON_INACTIVE */,
1032 1224 /* PATRON_ACCOUNT_EXPIRED */,
1033 7009 /* CIRC_CLAIMS_RETURNED */,
1034 7010 /* COPY_ALERT_MESSAGE */,
1035 7011 /* COPY_STATUS_LOST */,
1036 7012 /* COPY_STATUS_MISSING */,
1037 7013 /* PATRON_EXCEEDS_FINES */,
1040 '1203' : function(r) {
1041 //return data.hash.ccs[ r.payload.status() ].name();
1042 return r.payload.status().name();
1044 '7010' : function(r) {
1051 return circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1056 JSAN.use('util.error'); var error = new util.error();
1057 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1058 if (typeof async == 'object') {
1059 try { async.enable_textbox(); } catch(E) { error.sdump('D_ERROR','async.disable_textbox() = ' + E); };
1065 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1067 JSAN.use('util.error'); var error = new util.error();
1068 JSAN.use('util.network'); var network = new util.network();
1069 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1070 JSAN.use('util.date');
1072 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1074 check.message = check.textcode;
1076 if (check.payload && check.payload.copy) check.copy = check.payload.copy;
1077 if (check.payload && check.payload.record) check.record = check.payload.record;
1078 if (check.payload && check.payload.circ) check.circ = check.payload.circ;
1080 if (!check.route_to) check.route_to = ' ';
1082 if (document.getElementById('no_change_label')) {
1083 document.getElementById('no_change_label').setAttribute('value','');
1084 document.getElementById('no_change_label').setAttribute('hidden','true');
1088 network.simple_request('FM_MBTS_RETRIEVE',[ses(),check.circ.id()], function(req) {
1089 JSAN.use('util.money');
1090 var bill = req.getResultObject();
1091 if (Number(bill.balance_owed()) == 0) return;
1092 if (document.getElementById('no_change_label')) {
1093 var m = document.getElementById('no_change_label').getAttribute('value');
1094 document.getElementById('no_change_label').setAttribute('value', m + 'Transaction for ' + params.barcode + ' billable $' + util.money.sanitize(bill.balance_owed()) + ' ');
1095 document.getElementById('no_change_label').setAttribute('hidden','false');
1102 if (check.payload && check.payload.cancelled_hold_transit) {
1103 msg += 'Original hold for transit cancelled.\n\n';
1106 /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
1107 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1108 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'; }
1109 if (check.ilsevent == 3 /* NO_CHANGE */) {
1110 //msg = 'This item is already checked in.\n';
1111 if (document.getElementById('no_change_label')) {
1112 var m = document.getElementById('no_change_label').getAttribute('value');
1113 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' was already checked in. ');
1114 document.getElementById('no_change_label').setAttribute('hidden','false');
1117 if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
1118 msg = 'Please inform your helpdesk/developers of this error:\nFIXME -- ITEM_NOT_CATALOGED event but copy status is '
1119 + (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() ) + '\n';
1121 switch(check.copy.status()) {
1122 case 0: /* AVAILABLE */
1123 case 7: /* RESHELVING */
1124 if (msg) msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1126 case 8: /* ON HOLDS SHELF */
1127 check.route_to = 'HOLDS SHELF';
1128 if (check.payload.hold) {
1129 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
1130 msg += 'Please inform your helpdesk/developers of this error:\nFIXME: We should have received a ROUTE_ITEM\n';
1132 msg += 'This item needs to be routed to ' + check.route_to + '.\n';
1135 msg += 'Please inform your helpdesk/developers of this error:\nFIXME: status of Holds Shelf, but no actual hold found.\n';
1137 JSAN.use('util.date');
1138 if (check.payload.hold) {
1139 JSAN.use('patron.util');
1140 msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1141 msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1142 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1143 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1144 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1145 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1146 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1147 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F') + '\n';
1150 msg += 'Slip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1151 if (!auto_print) rv = error.yns_alert_formatted(
1157 "Check here to confirm this message",
1158 '/xul/server/skin/media/images/turtle.gif'
1162 JSAN.use('util.print'); var print = new util.print();
1163 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
1164 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1166 dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1167 alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1171 if (document.getElementById('no_change_label')) {
1172 var m = document.getElementById('no_change_label').getAttribute('value');
1173 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' has been captured for a hold. ');
1174 document.getElementById('no_change_label').setAttribute('hidden','false');
1177 case 6: /* IN TRANSIT */
1178 check.route_to = 'TRANSIT SHELF??';
1179 msg += ("Please inform your helpdesk/developers of this error:\nFIXME -- I didn't think we could get here.\n");
1181 case 11: /* CATALOGING */
1182 check.route_to = 'CATALOGING';
1183 if (document.getElementById('do_not_alert_on_precat')) {
1184 var x = document.getElementById('do_not_alert_on_precat');
1185 if (! x.checked) msg += 'This item needs to be routed to ' + check.route_to + '.';
1187 msg += 'This item needs to be routed to ' + check.route_to + '.';
1189 if (document.getElementById('no_change_label')) {
1190 var m = document.getElementById('no_change_label').getAttribute('value');
1191 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' needs to be cataloged. ');
1192 document.getElementById('no_change_label').setAttribute('hidden','false');
1196 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');
1197 msg += 'This item needs to be routed to ' + check.route_to + '.';
1200 if (msg) error.yns_alert(msg,'Alert',null,'OK',null,"Check here to confirm this message");
1202 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
1204 var lib = data.hash.aou[ check.org ];
1205 check.route_to = lib.shortname();
1206 msg += 'Destination: ' + check.route_to + '.\n';
1207 msg += '\n' + lib.name() + '\n';
1209 if (lib.holds_address() ) {
1210 var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
1211 if (typeof a.ilsevent != 'undefined') throw(a);
1212 if (a.street1()) msg += a.street1() + '\n';
1213 if (a.street2()) msg += a.street2() + '\n';
1214 msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
1216 msg += "We do not have a holds address for this library.\n";
1219 msg += 'Unable to retrieve mailing address.\n';
1220 error.standard_unexpected_error_alert('Unable to retrieve mailing address.',E);
1222 msg += '\nBarcode: ' + check.payload.copy.barcode() + '\n';
1223 msg += 'Title: ' + (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() ) + '\n';
1224 msg += 'Author: ' + (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author() ) + '\n';
1225 JSAN.use('util.date');
1226 if (check.payload.hold) {
1227 JSAN.use('patron.util');
1228 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
1229 msg += '\nHold for patron ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + ' ' + au_obj.second_given_name() + '\n';
1230 msg += 'Barcode: ' + au_obj.card().barcode() + '\n';
1231 if (check.payload.hold.phone_notify()) msg += 'Notify by phone: ' + check.payload.hold.phone_notify() + '\n';
1232 if (check.payload.hold.email_notify()) msg += 'Notify by email: ' + (au_obj.email() ? au_obj.email() : '') + '\n';
1233 msg += '\nRequest Date: ' + util.date.formatted_date(check.payload.hold.request_time(),'%F');
1236 msg += '\nSlip Date: ' + util.date.formatted_date(new Date(),'%F') + '\n';
1237 if (!auto_print) rv = error.yns_alert_formatted(
1243 "Check here to confirm this message",
1244 '/xul/server/skin/media/images/turtle.gif'
1248 JSAN.use('util.print'); var print = new util.print();
1249 //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
1250 msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
1251 print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
1253 dump('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1254 alert('Please inform your helpdesk/developers of this error:\nFIXME: ' + E + '\n');
1257 if (document.getElementById('no_change_label')) {
1258 var m = document.getElementById('no_change_label').getAttribute('value');
1259 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is in transit. ');
1260 document.getElementById('no_change_label').setAttribute('hidden','false');
1263 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
1265 check.route_to = 'CATALOGING';
1267 'The barcode was either mis-scanned or the item needs to be cataloged.',
1272 "Check here to confirm this message"
1274 if (document.getElementById('no_change_label')) {
1275 var m = document.getElementById('no_change_label').getAttribute('value');
1276 document.getElementById('no_change_label').setAttribute('value',m + params.barcode + ' is mis-scanned or not cataloged. ');
1277 document.getElementById('no_change_label').setAttribute('hidden','false');
1280 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
1281 error.standard_network_error_alert('Check In Failed. If you wish to use the offline interface, in the top menubar select Circulation -> Offline Interface');
1284 switch (check.ilsevent) {
1285 case 1203 /* COPY_BAD_STATUS */ :
1286 case 1213 /* PATRON_BARRED */ :
1287 case 1217 /* PATRON_INACTIVE */ :
1288 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
1289 case 7009 /* CIRC_CLAIMS_RETURNED */ :
1290 case 7010 /* COPY_ALERT_MESSAGE */ :
1291 case 7011 /* COPY_STATUS_LOST */ :
1292 case 7012 /* COPY_STATUS_MISSING */ :
1293 case 7013 /* PATRON_EXCEEDS_FINES */ :
1294 return null; /* handled */
1304 JSAN.use('util.error'); var error = new util.error();
1305 error.standard_unexpected_error_alert('Check In Failed (in circ.util.checkin): ',E);
1310 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
1313 JSAN.use('util.network'); obj.network = new util.network();
1314 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
1316 var params = { barcode: barcode };
1317 if (patron_id) params.patron = patron_id;
1319 function renew_callback(req) {
1321 var renew = req.getResultObject();
1322 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
1323 for (var j = 0; j < renew.length; j++) {
1324 switch(renew[j].ilsevent) {
1325 case 0 /* SUCCESS */ : break;
1326 case 5000 /* PERM_FAILURE */: break;
1327 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
1328 case 1213 /* PATRON_BARRED */ : break;
1329 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
1330 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
1331 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
1332 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
1333 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
1334 case 7004 /* COPY_NOT_AVAILABLE */ : break;
1335 case 7006 /* COPY_IS_REFERENCE */ : break;
1336 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
1337 case 7008 /* MAX_RENEWALS_REACHED */ : break;
1338 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
1339 case 7010 /* COPY_ALERT_MESSAGE */ : break;
1340 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
1346 if (typeof async == 'function') async(renew);
1349 JSAN.use('util.error'); var error = new util.error();
1350 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1355 var renew = obj.network.simple_request(
1358 async ? renew_callback : null,
1360 'title' : 'Override Renew Failure?',
1361 'overridable_events' : [
1362 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
1363 1213 /* PATRON_BARRED */,
1364 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
1365 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
1366 7003 /* COPY_CIRC_NOT_ALLOWED */,
1367 7004 /* COPY_NOT_AVAILABLE */,
1368 7006 /* COPY_IS_REFERENCE */,
1369 7007 /* COPY_NEEDED_FOR_HOLD */,
1370 7008 /* MAX_RENEWALS_REACHED */,
1371 7009 /* CIRC_CLAIMS_RETURNED */,
1372 7010 /* COPY_ALERT_MESSAGE */,
1373 7013 /* PATRON_EXCEEDS_FINES */,
1376 '1212' : function(r) { return 'Barcode: ' + barcode; },
1377 '1213' : function(r) { return 'Barcode: ' + barcode; },
1378 '1215' : function(r) { return 'Barcode: ' + barcode; },
1379 '7002' : function(r) { return 'Barcode: ' + barcode; },
1380 '7003' : function(r) { return 'Barcode: ' + barcode; },
1381 '7004' : function(r) {
1382 return 'Barcode: ' + barcode + ' Status: ' + r.payload.status().name();
1384 '7006' : function(r) { return 'Barcode: ' + barcode; },
1385 '7007' : function(r) { return 'Barcode: ' + barcode; },
1386 '7008' : function(r) { return 'Barcode: ' + barcode; },
1387 '7009' : function(r) { return 'Barcode: ' + barcode; },
1388 '7010' : function(r) {
1389 return 'Barcode: ' + barcode + ' Message: ' + r.payload;
1391 '7013' : function(r) { return 'Barcode: ' + barcode; },
1395 if (! async ) return renew_callback( { 'getResultObject' : function() { return renew; } } );
1398 JSAN.use('util.error'); var error = new util.error();
1399 error.standard_unexpected_error_alert('Renew Failed for ' + barcode,E);
1406 dump('exiting circ/util.js\n');