1 dump('entering patron.items.js\n');
3 if (typeof patron == 'undefined') patron = {};
4 patron.items = function (params) {
6 JSAN.use('util.error'); this.error = new util.error();
7 JSAN.use('util.network'); this.network = new util.network();
8 JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
11 patron.items.prototype = {
15 'init' : function( params ) {
19 obj.patron_id = params['patron_id'];
23 JSAN.use('util.controller'); obj.controller = new util.controller();
27 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
28 'save_columns2' : [ [ 'command' ], function() { obj.list2.save_columns(); } ],
29 'cmd_broken' : [ ['command'], function() { alert('Not Yet Implemented'); } ],
30 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ],
31 'sel_clip2' : [ ['command'], function() { obj.list2.clipboard(); } ],
32 'sel_patron' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids); } ],
37 cat.util.add_copies_to_bucket(util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
44 cat.util.add_copies_to_bucket(util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
47 'sel_mark_items_damaged' : [
50 JSAN.use('cat.util'); JSAN.use('util.functional');
51 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
54 'sel_mark_items_missing' : [
57 JSAN.use('cat.util'); JSAN.use('util.functional');
58 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
61 'sel_mark_items_damaged2' : [
64 JSAN.use('cat.util'); JSAN.use('util.functional');
65 cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
68 'sel_mark_items_missing2' : [
71 JSAN.use('cat.util'); JSAN.use('util.functional');
72 cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
75 'sel_copy_details' : [ ['command'],
77 JSAN.use('circ.util');
78 for (var i = 0; i < obj.retrieve_ids.length; i++) { circ.util.show_copy_details( obj.retrieve_ids[i].copy_id ); }
81 'sel_patron2' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids2); } ],
82 'sel_copy_details2' : [ ['command'],
84 JSAN.use('circ.util');
85 for (var i = 0; i < obj.retrieve_ids2.length; i++) { circ.util.show_copy_details( obj.retrieve_ids2[i].copy_id ); }
88 'cmd_items_print' : [ ['command'], function() { obj.items_print(1); } ],
89 'cmd_items_print2' : [ ['command'], function() { obj.items_print(2); } ],
90 'cmd_items_export' : [ ['command'], function() { obj.items_export(1); } ],
91 'cmd_items_export2' : [ ['command'], function() { obj.items_export(2); } ],
92 'cmd_items_renew' : [ ['command'], function() { obj.items_renew(1); /* obj.retrieve();*/ } ],
93 'cmd_items_renew_all' : [ ['command'], function() { obj.items_renew_all(); } ],
94 'cmd_items_renew2' : [ ['command'], function() { obj.items_renew(2); /* obj.retrieve();*/ } ],
95 'cmd_items_edit' : [ ['command'], function() { obj.items_edit(1); /*obj.retrieve();*/ } ],
96 'cmd_items_edit2' : [ ['command'], function() { obj.items_edit(2); /*obj.retrieve();*/ } ],
97 'cmd_items_mark_lost' : [ ['command'], function() { obj.items_mark_lost(1); /*obj.retrieve();*/ } ],
98 'cmd_items_mark_lost2' : [ ['command'], function() { obj.items_mark_lost(2); /*obj.retrieve();*/ } ],
99 'cmd_items_claimed_returned' : [ ['command'], function() { obj.items_claimed_returned(1); /*obj.retrieve();*/ } ],
100 'cmd_items_claimed_returned2' : [ ['command'], function() { obj.items_claimed_returned(2); /*obj.retrieve();*/ } ],
101 'cmd_items_checkin' : [ ['command'], function() { obj.items_checkin(1); /*obj.retrieve();*/ } ],
102 'cmd_items_checkin2' : [ ['command'], function() { obj.items_checkin(2); /*obj.retrieve();*/ } ],
103 'cmd_show_catalog' : [ ['command'], function() { obj.show_catalog(1); } ],
104 'cmd_show_catalog2' : [ ['command'], function() { obj.show_catalog(2); } ],
105 'cmd_add_billing' : [ ['command'], function() { obj.add_billing(1); /*obj.retrieve();*/ } ],
106 'cmd_add_billing2' : [ ['command'], function() { obj.add_billing(2); /*obj.retrieve();*/ } ],
107 'cmd_show_noncats' : [ ['command'], function() { obj.show_noncats(); } ],
114 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
115 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
116 obj.controller.view.sel_mark_items_damaged2.setAttribute('disabled','true');
117 obj.controller.view.sel_mark_items_missing2.setAttribute('disabled','true');
118 obj.controller.view.sel_clip.setAttribute('disabled','true');
119 obj.controller.view.sel_clip2.setAttribute('disabled','true');
120 obj.controller.view.sel_bucket.setAttribute('disabled','true');
121 obj.controller.view.sel_bucket2.setAttribute('disabled','true');
122 obj.controller.view.sel_copy_details.setAttribute('disabled','true');
123 obj.controller.view.sel_patron.setAttribute('disabled','true');
124 obj.controller.view.sel_copy_details2.setAttribute('disabled','true');
125 obj.controller.view.sel_patron2.setAttribute('disabled','true');
126 obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','true');
127 obj.controller.view.cmd_items_renew.setAttribute('disabled','true');
128 obj.controller.view.cmd_items_checkin.setAttribute('disabled','true');
129 obj.controller.view.cmd_items_edit.setAttribute('disabled','true');
130 obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','true');
131 obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
132 obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','true');
133 obj.controller.view.cmd_items_renew2.setAttribute('disabled','true');
134 obj.controller.view.cmd_items_checkin2.setAttribute('disabled','true');
135 obj.controller.view.cmd_items_edit2.setAttribute('disabled','true');
136 obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','true');
137 obj.controller.view.cmd_show_catalog2.setAttribute('disabled','true');
140 'show_noncats' : function() {
141 var obj = this; var checkout = {};
143 var robj = obj.network.simple_request('FM_ANCC_RETRIEVE_VIA_USER',[ ses(), obj.patron_id ]);
144 if (typeof robj.ilsevent != 'undefined') throw(robj);
146 for (var ii = 0; ii < robj.length; ii++) {
148 var nc_circ = obj.network.simple_request('FM_ANCC_RETRIEVE_VIA_ID',[ ses(), robj[ii] ]);
149 if (typeof nc_circ.ilsevent != 'undefined') throw(nc_circ);
150 var fake_circ = new aoc();
151 fake_circ.circ_lib( nc_circ.circ_lib() );
152 fake_circ.circ_staff( nc_circ.staff() );
153 fake_circ.usr( nc_circ.patron() );
154 fake_circ.xact_start( nc_circ.circ_time() );
155 fake_circ.renewal_remaining(0);
156 fake_circ.stop_fines('Non-Cataloged');
158 JSAN.use('util.date');
159 var c = nc_circ.circ_time();
160 var d = c == "now" ? new Date() : util.date.db_date2Date( c );
161 var t = obj.data.hash.cnct[ nc_circ.item_type() ];
163 var robj2 = obj.network.simple_request('FM_CNCT_RETRIEVE',[ nc_circ.circ_lib() ]);
164 if (typeof robj2.ilsevent != 'undefined') throw(robj);
165 obj.data.stash_retrieve();
166 for (var j = 0; j < robj2.length; j++) {
167 if (! obj.data.hash.cnct[ robj2[j].id() ] ) {
168 obj.data.hash.cnct[ robj2[j].id() ] = robj2[j];
169 obj.data.list.cnct.push( robj2[j] );
172 obj.data.stash('hash','list');
173 t = obj.data.hash.cnct[ nc_circ.item_type() ];
175 var cd = t.circ_duration() || "14 days";
176 var i = util.date.interval_to_seconds( cd ) * 1000;
177 d.setTime( Date.parse(d) + i );
178 fake_circ.due_date( util.date.formatted_date(d,'%F') );
180 var fake_record = new mvr();
181 fake_record.title( obj.data.hash.cnct[ nc_circ.item_type() ].name());
183 var fake_copy = new acp();
184 fake_copy.barcode( '' );
185 fake_copy.circ_lib( nc_circ.circ_lib() );
187 obj.list.append( { 'row' : { 'my' : { 'circ' : fake_circ, 'mvr' : fake_record, 'acp' : fake_copy } }, 'to_bottom' : true, 'no_auto_select' : true } );
190 obj.error.standard_unexpected_error_alert('Error showing NonCat #' + robj[ii].id(),F);
195 obj.error.standard_unexpected_error_alert('Error showing NonCat circulations',E);
199 'items_print' : function(which) {
202 var list = (which==2 ? obj.list2 : obj.list);
203 dump(js2JSON( list.dump_with_keys() ) + '\n');
204 function flesh_callback() {
206 JSAN.use('patron.util');
208 'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id),
209 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
210 'staff' : obj.data.list.au[0],
211 'header' : obj.data.print_list_templates.items_out.header,
212 'line_item' : obj.data.print_list_templates.items_out.line_item,
213 'footer' : obj.data.print_list_templates.items_out.footer,
214 'type' : obj.data.print_list_templates.items_out.type,
215 'list' : list.dump_with_keys(),
217 JSAN.use('util.print'); var print = new util.print();
218 print.tree_list( params );
219 setTimeout(function(){list.on_all_fleshed = null;},0);
221 obj.error.standard_unexpected_error_alert('printing 2',E);
224 list.on_all_fleshed = flesh_callback;
225 list.full_retrieve();
227 obj.error.standard_unexpected_error_alert('printing 1',E);
231 'items_export' : function(which) {
234 var list = (which==2 ? obj.list2 : obj.list);
235 function flesh_callback() {
237 dump( list.dump_csv() + '\n');
238 copy_to_clipboard(list.dump_csv());
239 setTimeout(function(){list.on_all_fleshed = null;},0);
241 obj.error.standard_unexpected_error_alert('export 2',E);
244 list.on_all_fleshed = flesh_callback;
245 list.full_retrieve();
247 obj.error.standard_unexpected_error_alert('export 1',E);
251 'items_renew_all' : function() {
253 var obj = this; var list = obj.list;
254 if (list.on_all_fleshed != null) {
255 var r = window.confirm('This is list is busy retrieving/rendering rows for a prior action. Abort the prior action and proceed?');
258 var r = window.confirm('Renew all the items in this list?');
260 function flesh_callback() {
262 obj.list.select_all();
263 obj.items_renew(1,true);
264 setTimeout(function(){list.on_all_fleshed = null; /* obj.retrieve();*/ },0);
266 obj.error.standard_unexpected_error_alert('2 All items were not likely renewed',E);
269 list.on_all_fleshed = flesh_callback;
270 list.full_retrieve();
272 this.error.standard_unexpected_error_alert('All items were not likely renewed',E);
276 'items_renew' : function(which,skip_prompt) {
279 JSAN.use('circ.util');
280 var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
281 if (!retrieve_ids || retrieve_ids.length == 0) return;
282 JSAN.use('util.functional');
284 var msg = 'Are you sure you would like to renew item' + ( retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ') + '?';
285 var r = window.confirm(msg);
291 function gen_renew(bc,circ_id) {
292 var x = document.getElementById('renew_msgs');
294 var l = document.createElement('label');
295 l.setAttribute('value','Renewing ' + bc);
298 var renew = circ.util.renew_via_barcode( barcode, obj.patron_id,
300 if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) {
301 l.setAttribute('value', bc + ' renewed.');
302 obj.list_circ_map[ circ_id ].row.my.circ = r[0].payload.circ;
303 obj.list_circ_map[ circ_id ].row.my.acp = r[0].payload.copy;
304 obj.list_circ_map[ circ_id ].row.my.mvr = r[0].payload.record;
306 l.setAttribute('value', bc + ' not renewed. ' + r[0].textcode + r[0].desc);
310 //if (window.confirm('Action completed. Refresh list?')) obj.retrieve();
311 JSAN.use('util.widgets'); util.widgets.remove_children(x);
313 obj.refresh(circ_id);
318 for (var i = 0; i < retrieve_ids.length; i++) {
321 var barcode = retrieve_ids[i].barcode;
322 var circ_id = retrieve_ids[i].circ_id;
323 gen_renew(barcode,circ_id);
325 obj.error.standard_unexpected_error_alert('Renew probably did not happen for barcode ' + barcode,E);
329 obj.error.standard_unexpected_error_alert('Renew probably did not happen.',E);
333 'items_edit' : function(which) {
336 var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
337 if (!retrieve_ids || retrieve_ids.length == 0) return;
338 function check_date(value) {
339 JSAN.use('util.date');
341 if (! util.date.check('YYYY-MM-DD',value) ) {
342 throw('Invalid Date');
344 if (util.date.check_past('YYYY-MM-DD',value) ) {
345 throw('Due date needs to be after today.');
348 if ( util.date.formatted_date(new Date(),'%F') == value) {
349 throw('Due date needs to be after today.');
359 JSAN.use('util.functional');
360 var title = 'Edit Due Date' + (retrieve_ids.length > 1 ? 's' : '');
361 var value = 'YYYY-MM-DD';
362 var text = 'Enter a new due date for these items: ' +
363 util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ');
364 var due_date; var invalid = true;
366 due_date = window.prompt(text,value,title);
368 invalid = ! check_date(due_date);
374 var circs = util.functional.map_list(retrieve_ids,function(o){return o.circ_id;});
375 for (var i = 0; i < circs.length; i++) {
376 var robj = obj.network.simple_request('FM_CIRC_EDIT_DUE_DATE',[ses(),circs[i],due_date]);
377 if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); }
380 for (var i = 0; i < obj.retrieve_ids.length; i++) {
381 obj.refresh(retrieve_ids[i].circ_id);
384 obj.error.standard_unexpected_error_alert('The due dates were not likely modified.',E);
388 'items_mark_lost' : function(which) {
391 var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
392 if (!retrieve_ids || retrieve_ids.length == 0) return;
393 for (var i = 0; i < retrieve_ids.length; i++) {
394 var barcode = retrieve_ids[i].barcode;
395 dump('Mark barcode lost = ' + barcode);
396 var robj = obj.network.simple_request( 'MARK_ITEM_LOST', [ ses(), { barcode: barcode } ]);
397 if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); }
398 obj.refresh(retrieve_ids[i].circ_id);
401 obj.error.standard_unexpected_error_alert('The items were not likely marked lost.',E);
405 'items_claimed_returned' : function(which) {
408 JSAN.use('util.date');
409 var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
410 if (!retrieve_ids || retrieve_ids.length == 0) return;
411 function check_date(value) {
413 if (! util.date.check('YYYY-MM-DD',value) ) {
414 throw('Invalid Date');
416 if ( util.date.formatted_date(new Date(),'%F') == value) {
419 if (! util.date.check_past('YYYY-MM-DD',value) ) {
420 throw('Claims Returned Date cannot be in the future.');
429 JSAN.use('util.functional');
430 var title = 'Claimed Returned';
431 var value = 'YYYY-MM-DD';
432 var text = 'Enter a claimed returned date for these items: ' +
433 util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ');
434 var backdate; var invalid = true;
436 backdate = window.prompt(text,value,title);
438 invalid = ! check_date(backdate);
443 //alert('backdate = ' + backdate);
445 backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
446 var barcodes = util.functional.map_list(retrieve_ids,function(o){return o.barcode;});
447 for (var i = 0; i < barcodes.length; i++) {
448 var robj = obj.network.simple_request(
449 'MARK_ITEM_CLAIM_RETURNED',
450 [ ses(), { barcode: barcodes[i], backdate: backdate } ]
452 if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); }
455 for (var i = 0; i < retrieve_ids.length; i++) obj.refresh(retrieve_ids[i].circ_id);
457 obj.error.standard_unexpected_error_alert('The items were not likely marked Claimed Returned.',E);
461 'items_checkin' : function(which) {
464 var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
465 if (!retrieve_ids || retrieve_ids.length == 0) return;
466 JSAN.use('util.functional');
467 var msg = 'Are you sure you would like to check in item' + ( retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ') + '?';
468 var r = window.confirm(msg);
470 JSAN.use('circ.util');
471 for (var i = 0; i < retrieve_ids.length; i++) {
472 var copy_id = retrieve_ids[i].copy_id;
473 dump('Check in copy_id = ' + copy_id + ' barcode = ' + retrieve_ids[i].barcode + '\n');
474 var robj = circ.util.checkin_via_barcode(
475 ses(), { 'copy_id' : copy_id }
477 /* circ.util.checkin_via_barcode handles errors currently */
478 obj.refresh(retrieve_ids[i].circ_id);
481 obj.error.standard_unexpected_error_alert('Checkin probably did not happen.',E);
485 'show_catalog' : function(which) {
488 var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
489 if (!retrieve_ids || retrieve_ids.length == 0) return;
490 for (var i = 0; i < retrieve_ids.length; i++) {
491 var doc_id = retrieve_ids[i].doc_id;
493 alert(retrieve_ids[i].barcode + ' is not cataloged');
496 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
497 var content_params = {
499 'authtime' : ses('authtime'),
500 'opac_url' : opac_url,
503 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
504 {'tab_name':'Retrieving title...'},
509 obj.error.standard_unexpected_error_alert('',E);
513 'add_billing' : function(which) {
516 var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
517 if (!retrieve_ids || retrieve_ids.length == 0) return;
518 JSAN.use('util.window'); var win = new util.window();
519 for (var i = 0; i < retrieve_ids.length; i++) {
520 var circ_id = retrieve_ids[i].circ_id;
521 var my_xulG = win.open(
522 urls.XUL_PATRON_BILL_WIZARD,
523 //+ '?patron_id=' + window.escape(obj.patron_id)
524 //+ '&xact_id=' + window.escape( circ_id ),
526 'chrome,resizable,modal',
527 { 'patron_id' : obj.patron_id, 'xact_id' : circ_id }
531 obj.error.standard_unexpected_error_alert('',E);
535 'init_lists' : function() {
538 JSAN.use('circ.util');
539 var columns = circ.util.columns(
541 'barcode' : { 'hidden' : false },
542 'checkout_lib' : { 'hidden' : false },
543 'circ_lib' : { 'hidden' : false },
544 'title' : { 'hidden' : false, 'flex' : '3' },
545 'due_date' : { 'hidden' : false },
546 'renewal_remaining' : { 'hidden' : false },
547 'stop_fines' : { 'hidden' : false },
550 var columns2 = circ.util.columns(
552 'barcode' : { 'hidden' : false },
553 'checkout_lib' : { 'hidden' : false },
554 'circ_lib' : { 'hidden' : false },
555 'title' : { 'hidden' : false, 'flex' : '3' },
556 'checkin_time' : { 'hidden' : false },
557 'stop_fines' : { 'hidden' : false },
561 function retrieve_row(params) {
563 var row = params.row;
565 if (!row.my.circ_id) {
566 if (typeof params.on_retrieve == 'function') {
567 params.on_retrieve(row);
573 obj.network.simple_request(
578 var robj = req.getResultObject();
579 if (typeof robj.ilsevent != 'undefined') throw(robj);
580 if (typeof robj.ilsevent == 'null') throw('null result');
581 row.my.circ = robj.circ;
582 row.my.acp = robj.copy;
583 row.my.mvr = robj.mvr;
584 row.my.acn = robj.volume;
585 row.my.record = robj.record;
587 var copy_id = row.my.circ.target_copy();
588 if (typeof copy_id == 'object') {
589 if (copy_id != null) {
590 copy_id = copy_id.id();
592 if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id();
595 if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id();
598 params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': ( row.my.record ? row.my.record.id() : null ) }) );
600 if (typeof params.on_retrieve == 'function') {
601 params.on_retrieve(row);
604 obj.error.standard_unexpected_error_alert('Error in callback for FM_CIRC_DETAILS in patron/items.js',E);
609 var copy_id = row.my.circ ? row.my.circ.target_copy() : null;
610 if (typeof copy_id == 'object') {
611 if (copy_id != null) {
612 copy_id = copy_id.id();
614 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
617 if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
620 params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':row.my.acp.id(),'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': (row.my.record ? row.my.record.id() : null) }) );
621 if (typeof params.on_retrieve == 'function') {
622 params.on_retrieve(row);
628 obj.error.standard_unexpected_error_alert('error in patron/items.js retrieve_row(): ',E);
633 JSAN.use('util.list'); obj.list = new util.list('items_list');
637 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
638 'retrieve_row' : retrieve_row,
639 'on_select' : function(ev) {
640 JSAN.use('util.functional');
641 var sel = obj.list.retrieve_selection();
642 obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
643 var list = util.functional.map_list(
645 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
647 if (typeof obj.on_select == 'function') {
650 if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
651 obj.error.sdump('D_PATRON','patron.items: Calling external .on_select()\n');
652 window.xulG.on_select(list);
654 obj.error.sdump('D_PATRON','patron.items: No external .on_select()\n');
660 obj.list2 = new util.list('items_list2');
663 'columns' : columns2,
664 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
665 'retrieve_row' : retrieve_row,
666 'on_select' : function(ev) {
667 JSAN.use('util.functional');
668 var sel = obj.list2.retrieve_selection();
669 obj.controller.view.sel_clip2.setAttribute('disabled',sel.length < 1);
670 var list = util.functional.map_list(
672 function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
674 if (typeof obj.on_select2 == 'function') {
675 obj.on_select2(list);
682 'refresh' : function(circ_id) {
685 var nparams = obj.list_circ_map[circ_id];
686 var which_list = nparams.which_list;
689 setTimeout(function(){try{obj.list2.refresh_row(nparams);}catch(E){obj.error.standard_unexpected_error_alert('2 Error refreshing row in list\ncirc_id = ' + circ_id + '\nnparams = ' + nparams,E);}},1000);
692 setTimeout(function(){try{obj.list.refresh_row(nparams);}catch(E){obj.error.standard_unexpected_error_alert('2 Error refreshing row in list\ncirc_id = ' + circ_id + '\nnparams = ' + nparams,E);}},1000);
696 obj.error.standard_unexpected_error_alert('Error refreshing row in list\ncirc_id = ' + circ_id + '\nnparams = ' + nparams,E);
700 'retrieve' : function(dont_show_me_the_list_change) {
702 if (window.xulG && window.xulG.checkouts) {
703 obj.checkouts = window.xulG.checkouts;
707 var robj = obj.network.simple_request(
708 'FM_CIRC_RETRIEVE_VIA_USER',
709 [ ses(), obj.patron_id ]
711 if (typeof robj.ilsevent!='undefined') {
712 obj.error.standard_unexpected_error_alert('Error retrieving circulations.',E);
714 obj.checkouts = obj.checkouts.concat( robj.overdue );
715 obj.checkouts = obj.checkouts.concat( robj.out );
716 obj.checkouts2 = obj.checkouts2.concat( robj.lost );
717 obj.checkouts2 = obj.checkouts2.concat( robj.claims_returned );
718 obj.checkouts2 = obj.checkouts2.concat( robj.long_overdue );
720 var robj = obj.network.simple_request(
721 'FM_CIRC_IN_WITH_FINES_VIA_USER',
722 [ ses(), obj.patron_id ]
724 if (typeof robj.ilsevent!='undefined') {
725 obj.error.standard_unexpected_error_alert('Error retrieving circulations.',E);
727 obj.checkouts2 = obj.checkouts2.concat( robj.lost );
728 obj.checkouts2 = obj.checkouts2.concat( robj.claims_returned );
729 obj.checkouts2 = obj.checkouts2.concat( robj.long_overdue );
733 function gen_list_append(circ_id,which_list) {
739 nparams = obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } );
742 nparams = obj.list.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } );
746 obj.list_circ_map[circ_id] = nparams; // unlike item status interface, each circ should be in this list only once
756 obj.list.clear(); obj.list2.clear();
758 JSAN.use('util.exec'); var exec = new util.exec();
760 for (var i in obj.checkouts) {
761 rows.push( gen_list_append(obj.checkouts[i],0) );
763 for (var i in obj.checkouts2) {
764 rows.push( gen_list_append(obj.checkouts2[i],1) );
767 if (!dont_show_me_the_list_change) {
768 if (window.xulG && typeof window.xulG.on_list_change == 'function') {
769 try { window.xulG.on_list_change(obj.checkouts); } catch(E) { this.error.sdump('D_ERROR',E); }
774 'on_select' : function(list) {
776 dump('patron.items.on_select list = ' + js2JSON(list) + '\n');
780 obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','false');
781 obj.controller.view.cmd_items_renew.setAttribute('disabled','false');
782 obj.controller.view.cmd_items_checkin.setAttribute('disabled','false');
783 obj.controller.view.cmd_items_edit.setAttribute('disabled','false');
784 obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','false');
785 obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
786 obj.controller.view.sel_copy_details.setAttribute('disabled','false');
787 obj.controller.view.sel_bucket.setAttribute('disabled','false');
788 obj.controller.view.sel_patron.setAttribute('disabled','false');
789 obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
790 obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
792 obj.retrieve_ids = list;
795 'on_select2' : function(list) {
797 dump('patron.items.on_select2 list = ' + js2JSON(list) + '\n');
801 obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','false');
802 obj.controller.view.cmd_items_renew2.setAttribute('disabled','false');
803 obj.controller.view.cmd_items_checkin2.setAttribute('disabled','false');
804 obj.controller.view.cmd_items_edit2.setAttribute('disabled','false');
805 obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','false');
806 obj.controller.view.cmd_show_catalog2.setAttribute('disabled','false');
807 obj.controller.view.sel_copy_details2.setAttribute('disabled','false');
808 obj.controller.view.sel_bucket2.setAttribute('disabled','false');
809 obj.controller.view.sel_patron2.setAttribute('disabled','false');
810 obj.controller.view.sel_mark_items_damaged2.setAttribute('disabled','false');
811 obj.controller.view.sel_mark_items_missing2.setAttribute('disabled','false');
813 this.retrieve_ids2 = list;
818 dump('exiting patron.items.js\n');