]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
fixing logic error for the Available On column in various hold list interfaces. ...
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / circ / util.js
1 dump('entering circ/util.js\n');
2 // vim:noet:sw=4:ts=4:
3
4 if (typeof circ == 'undefined') { var circ = {}; }
5 circ.util = {};
6
7 circ.util.EXPORT_OK     = [
8         'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns',
9         'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns',
10         'show_last_few_circs', 'abort_transits', 'transit_columns', 'renew_via_barcode'
11 ];
12 circ.util.EXPORT_TAGS   = { ':all' : circ.util.EXPORT_OK };
13
14 circ.util.abort_transits = function(selection_list) {
15         var obj = {};
16         JSAN.use('util.error'); obj.error = new util.error();
17         JSAN.use('util.network'); obj.network = new util.network();
18         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
19         JSAN.use('util.functional');
20         var copies = util.functional.map_list( selection_list, function(o){return o.copy_id;}).join(', ');
21         var msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.abort_transits.confirm', [copies]);
22         var r = obj.error.yns_alert(
23                 msg,
24                 document.getElementById('circStrings').getString('staff.circ.utils.abort_transits.title'),
25                 document.getElementById('circStrings').getString('staff.circ.utils.yes'),
26                 document.getElementById('circStrings').getString('staff.circ.utils.no'),
27                 null,
28                 document.getElementById('circStrings').getString('staff.circ.confirm')
29         );
30         if (r == 0) {
31                 try {
32                         for (var i = 0; i < selection_list.length; i++) {
33                                 var copy_id = selection_list[i].copy_id;
34                                 var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'copyid' : copy_id } ]);
35                                 if (typeof robj.ilsevent != 'undefined') {
36                                         switch(Number(robj.ilsevent)) {
37                                                 case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
38                                                         alert(document.getElementById('circString').getFormattedString('staff.circ.utils.abort_transits.not_allowed', [copy_id]) + '\n' + robj.desc);
39                                                 break;
40                                                 case 1504 /* ACTION_TRANSIT_COPY_NOT_FOUND */ :
41                                                         alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.not_found'));
42                                                 break;
43                                                 case 5000 /* PERM_FAILURE */ :
44                                                 break;
45                                                 default:
46                                                         throw(robj);
47                                                 break;
48                                         }
49                                 }
50                         }
51                 } catch(E) {
52                         obj.error.standard_unexpected_error_alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.unexpected_error'),E);
53                 }
54         }
55 };
56
57 circ.util.show_copy_details = function(copy_id) {
58         var obj = {};
59         JSAN.use('util.error'); obj.error = new util.error();
60         JSAN.use('util.window'); obj.win = new util.window();
61         JSAN.use('util.network'); obj.network = new util.network();
62         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
63
64         if (typeof copy_id == 'object' && copy_id != null) copy_id = copy_id.id();
65
66         try {
67                 var url = xulG.url_prefix( urls.XUL_COPY_DETAILS ); // + '?copy_id=' + copy_id;
68                 var my_xulG = obj.win.open( url, 'show_copy_details', 'chrome,resizable,modal', { 'copy_id' : copy_id } );
69
70                 if (typeof my_xulG.retrieve_these_patrons == 'undefined') return;
71                 var patrons = my_xulG.retrieve_these_patrons;
72                 for (var j = 0; j < patrons.length; j++) {
73                         if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
74                                 try {
75                                         window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
76                                 } catch(E) {
77                                         obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure'), E);
78                                 }
79                         }
80                 }
81
82         } catch(E) {
83                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
84         }
85 };
86
87
88 circ.util.show_last_few_circs = function(selection_list) {
89         var obj = {};
90         JSAN.use('util.error'); obj.error = new util.error();
91         JSAN.use('util.window'); obj.win = new util.window();
92         JSAN.use('util.network'); obj.network = new util.network();
93         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
94
95         for (var i = 0; i < selection_list.length; i++) {
96                 try {
97                         if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
98                         var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
99                         var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id } );
100
101                         if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
102                         var patrons = my_xulG.retrieve_these_patrons;
103                         for (var j = 0; j < patrons.length; j++) {
104                                 if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
105                                         try {
106                                                 window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
107                                         } catch(E) {
108                                                 obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
109                                         }
110                                 }
111                         }
112
113                 } catch(E) {
114                         obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
115                 }
116         }
117 };
118
119 circ.util.offline_checkout_columns = function(modify,params) {
120         
121         var c = [
122                 {
123                         'id' : 'timestamp',
124                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
125                         'flex' : 1,
126                         'primary' : false,
127                         'hidden' : true,
128                         'render' : function(my) { return my.timestamp; }
129                 },
130                 {
131                         'id' : 'checkout_time',
132                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
133                         'flex' : 1,
134                         'primary' : false,
135                         'hidden' : true,
136                         'render' : function(my) { return my.checkout_time; }
137                 },
138                 {
139                         'id' : 'type',
140                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
141                         'flex' : 1,
142                         'primary' : false,
143                         'hidden' : true,
144                         'render' : function(my) { return my.type; }
145                 },
146                 {
147                         'id' : 'noncat',
148                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
149                         'flex' : 1,
150                         'primary' : false,
151                         'hidden' : true,
152                         'render' : function(my) { return my.noncat; }
153                 },
154                 {
155                         'id' : 'noncat_type',
156                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
157                         'flex' : 1,
158                         'primary' : false,
159                         'hidden' : true,
160                         'render' : function(my) { return my.noncat_type; }
161                 },
162                 {
163                         'id' : 'noncat_count',
164                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
165                         'sort_type' : 'number',
166                         'flex' : 1,
167                         'primary' : false,
168                         'hidden' : false,
169                         'render' : function(my) { return my.noncat_count; }
170                 },
171                 {
172                         'id' : 'patron_barcode',
173                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
174                         'flex' : 1,
175                         'primary' : false,
176                         'hidden' : true,
177                         'render' : function(my) { return my.patron_barcode; }
178                 },
179                 {
180                         'id' : 'barcode',
181                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
182                         'flex' : 2,
183                         'primary' : true,
184                         'hidden' : false,
185                         'render' : function(my) { return my.barcode; }
186                 },
187                 {
188                         'id' : 'due_date',
189                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
190                         'flex' : 1,
191                         'primary' : false,
192                         'hidden' : false,
193                         'render' : function(my) { return my.due_date; }
194                 }
195         ];
196         if (modify) for (var i = 0; i < c.length; i++) {
197                 if (modify[ c[i].id ]) {
198                         for (var j in modify[ c[i].id ]) {
199                                 c[i][j] = modify[ c[i].id ][j];
200                         }
201                 }
202         }
203         if (params) {
204                 if (params.just_these) {
205                         JSAN.use('util.functional');
206                         var new_c = [];
207                         for (var i = 0; i < params.just_these.length; i++) {
208                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
209                                 new_c.push( function(y){ return y; }( x ) );
210                         }
211                         c = new_c;
212                 }
213                 if (params.except_these) {
214                         JSAN.use('util.functional');
215                         var new_c = [];
216                         for (var i = 0; i < c.length; i++) {
217                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
218                                 if (!x) new_c.push(c[i]);
219                         }
220                         c = new_c;
221                 }
222
223         }
224         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
225 };
226
227 circ.util.offline_checkin_columns = function(modify,params) {
228         
229         var c = [
230                 {
231                         'id' : 'timestamp',
232                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
233                         'flex' : 1,
234                         'primary' : false,
235                         'hidden' : true,
236                         'render' : function(my) { return my.timestamp; }
237                 },
238                 {
239                         'id' : 'backdate',
240                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
241                         'flex' : 1,
242                         'primary' : false,
243                         'hidden' : true,
244                         'render' : function(my) { return my.backdate; }
245                 },
246                 {
247                         'id' : 'type',
248                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
249                         'flex' : 1,
250                         'primary' : false,
251                         'hidden' : true,
252                         'render' : function(my) { return my.type; }
253                 },
254                 {
255                         'id' : 'barcode',
256                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
257                         'flex' : 2,
258                         'primary' : true,
259                         'hidden' : false,
260                         'render' : function(my) { return my.barcode; }
261                 }
262         ];
263         if (modify) for (var i = 0; i < c.length; i++) {
264                 if (modify[ c[i].id ]) {
265                         for (var j in modify[ c[i].id ]) {
266                                 c[i][j] = modify[ c[i].id ][j];
267                         }
268                 }
269         }
270         if (params) {
271                 if (params.just_these) {
272                         JSAN.use('util.functional');
273                         var new_c = [];
274                         for (var i = 0; i < params.just_these.length; i++) {
275                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
276                                 new_c.push( function(y){ return y; }( x ) );
277                         }
278                         c = new_c;
279                 }
280                 if (params.except_these) {
281                         JSAN.use('util.functional');
282                         var new_c = [];
283                         for (var i = 0; i < c.length; i++) {
284                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
285                                 if (!x) new_c.push(c[i]);
286                         }
287                         c = new_c;
288                 }
289
290         }
291         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
292 };
293
294 circ.util.offline_renew_columns = function(modify,params) {
295         
296         var c = [
297                 {
298                         'id' : 'timestamp',
299                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
300                         'flex' : 1,
301                         'primary' : false,
302                         'hidden' : true,
303                         'render' : function(my) { return my.timestamp; }
304                 },
305                 {
306                         'id' : 'checkout_time',
307                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
308                         'flex' : 1,
309                         'primary' : false,
310                         'hidden' : true,
311                         'render' : function(my) { return my.checkout_time; }
312                 },
313                 {
314                         'id' : 'type',
315                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
316                         'flex' : 1,
317                         'primary' : false,
318                         'hidden' : true,
319                         'render' : function(my) { return my.type; }
320                 },
321                 {
322                         'id' : 'patron_barcode',
323                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
324                         'flex' : 1,
325                         'primary' : false,
326                         'hidden' : true,
327                         'render' : function(my) { return my.patron_barcode; }
328                 },
329                 {
330                         'id' : 'barcode',
331                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
332                         'flex' : 2,
333                         'primary' : true,
334                         'hidden' : false,
335                         'render' : function(my) { return my.barcode; }
336                 },
337                 {
338                         'id' : 'due_date',
339                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
340                         'flex' : 1,
341                         'primary' : false,
342                         'hidden' : false,
343                         'render' : function(my) { return my.due_date; }
344                 }
345         ];
346         if (modify) for (var i = 0; i < c.length; i++) {
347                 if (modify[ c[i].id ]) {
348                         for (var j in modify[ c[i].id ]) {
349                                 c[i][j] = modify[ c[i].id ][j];
350                         }
351                 }
352         }
353         if (params) {
354                 if (params.just_these) {
355                         JSAN.use('util.functional');
356                         var new_c = [];
357                         for (var i = 0; i < params.just_these.length; i++) {
358                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
359                                 new_c.push( function(y){ return y; }( x ) );
360                         }
361                         c = new_c;
362                 }
363                 if (params.except_these) {
364                         JSAN.use('util.functional');
365                         var new_c = [];
366                         for (var i = 0; i < c.length; i++) {
367                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
368                                 if (!x) new_c.push(c[i]);
369                         }
370                         c = new_c;
371                 }
372
373         }
374         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
375 };
376
377 circ.util.offline_inhouse_use_columns = function(modify,params) {
378         
379         var c = [
380                 {
381                         'id' : 'timestamp',
382                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
383                         'flex' : 1,
384                         'primary' : false,
385                         'hidden' : true,
386                         'render' : function(my) { return my.timestamp; }
387                 },
388                 {
389                         'id' : 'use_time',
390                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
391                         'flex' : 1,
392                         'primary' : false,
393                         'hidden' : true,
394                         'render' : function(my) { return my.use_time; }
395                 },
396                 {
397                         'id' : 'type',
398                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
399                         'flex' : 1,
400                         'primary' : false,
401                         'hidden' : true,
402                         'render' : function(my) { return my.type; }
403                 },
404                 {
405                         'id' : 'count',
406                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
407                         'sort_type' : 'number',
408                         'flex' : 1,
409                         'primary' : false,
410                         'hidden' : false,
411                         'render' : function(my) { return my.count; }
412                 },
413                 {
414                         'id' : 'barcode',
415                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
416                         'flex' : 2,
417                         'primary' : true,
418                         'hidden' : false,
419                         'render' : function(my) { return my.barcode; }
420                 }
421         ];
422         if (modify) for (var i = 0; i < c.length; i++) {
423                 if (modify[ c[i].id ]) {
424                         for (var j in modify[ c[i].id ]) {
425                                 c[i][j] = modify[ c[i].id ][j];
426                         }
427                 }
428         }
429         if (params) {
430                 if (params.just_these) {
431                         JSAN.use('util.functional');
432                         var new_c = [];
433                         for (var i = 0; i < params.just_these.length; i++) {
434                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
435                                 new_c.push( function(y){ return y; }( x ) );
436                         }
437                         c = new_c;
438                 }
439                 if (params.except_these) {
440                         JSAN.use('util.functional');
441                         var new_c = [];
442                         for (var i = 0; i < c.length; i++) {
443                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
444                                 if (!x) new_c.push(c[i]);
445                         }
446                         c = new_c;
447                 }
448
449         }
450         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
451 };
452
453 circ.util.columns = function(modify,params) {
454         
455         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
456         JSAN.use('util.network'); var network = new util.network();
457         JSAN.use('util.money');
458
459         var c = [
460                 {
461                         'id' : 'acp_id',
462                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
463                         'flex' : 1,
464                         'primary' : false,
465                         'hidden' : true,
466                         'render' : function(my) { return my.acp.id(); },
467                         'persist' : 'hidden width ordinal'
468                 },
469                 {
470                         'id' : 'circ_id',
471                         'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
472                         'flex' : 1,
473                         'primary' : false,
474                         'hidden' : true,
475                         'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
476                         'persist' : 'hidden width ordinal'
477                 },
478                 {
479                         'id' : 'mvr_doc_id',
480                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
481                         'flex' : 1,
482                         'primary' : false,
483                         'hidden' : true,
484                         'render' : function(my) { return my.mvr.doc_id(); },
485                         'persist' : 'hidden width ordinal'
486                 },
487         {
488                         'persist' : 'hidden width ordinal',
489                         'id' : 'service',
490                         'label' : 'Service',
491                         'flex' : 1,
492                         'primary' : false,
493                         'hidden' : true,
494                         'render' : function(my) { return my.service; }
495         },
496                 {
497                         'id' : 'barcode',
498                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
499                         'flex' : 1,
500                         'primary' : false,
501                         'hidden' : true,
502                         'render' : function(my) { return my.acp.barcode(); },
503                         'persist' : 'hidden width ordinal'
504                 },
505                 {
506                         'id' : 'call_number',
507                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
508                         'flex' : 1,
509                         'primary' : false,
510                         'hidden' : true,
511                         'render' : function(my) {
512                                 if (my.acp && my.acp.call_number() == -1) {
513                                         return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
514                                 } else if (my.acp && my.acp.call_number() == -2) {
515                                         return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
516                                 } else {
517                                         if (!my.acn) {
518                                                 var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
519                                                 if (x.ilsevent) {
520                                                         return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
521                                                 } else {
522                                                         my.acn = x; return x.label();
523                                                 }
524                                         } else {
525                                                 return my.acn.label();
526                                         }
527                                 }
528                         },
529                         'persist' : 'hidden width ordinal'
530                 },
531                 {
532                         'id' : 'owning_lib',
533                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
534                         'flex' : 1,
535                         'primary' : false,
536                         'hidden' : true,
537                         'render' : function(my) {
538                                 if (Number(my.acn.owning_lib())>=0) {
539                                         return data.hash.aou[ my.acn.owning_lib() ].shortname();
540                                 } else {
541                                         return my.acn.owning_lib().shortname();
542                                 }
543                         },
544                         'persist' : 'hidden width ordinal'
545                 },
546                 {
547                         'id' : 'copy_number',
548                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
549                         'flex' : 1,
550                         'sort_type' : 'number',
551                         'primary' : false,
552                         'hidden' : true,
553                         'render' : function(my) { return my.acp.copy_number(); },
554                         'persist' : 'hidden width ordinal'
555                 },
556                 {
557                         'id' : 'location',
558                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
559                         'flex' : 1,
560                         'primary' : false,
561                         'hidden' : true,
562                         'render' : function(my) {
563                                 if (Number(my.acp.location())>=0) {
564                                         return data.lookup("acpl", my.acp.location() ).name();
565                                 } else {
566                                         return my.acp.location().name();
567                                 }
568                         },
569                         'persist' : 'hidden width ordinal'
570                 },
571                 {
572                         'id' : 'loan_duration',
573                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
574                         'flex' : 1,
575                         'primary' : false,
576                         'hidden' : true,
577                         'render' : function(my) {
578                                 switch(Number(my.acp.loan_duration())) {
579                                         case 1:
580                                                 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
581                                                 break;
582                                         case 2:
583                                                 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
584                                                 break;
585                                         case 3:
586                                                 return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
587                                                 break;
588                                 };
589                         },
590                         'persist' : 'hidden width ordinal'
591                 },
592                 {
593                         'id' : 'circ_lib',
594                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
595                         'flex' : 1,
596                         'primary' : false,
597                         'hidden' : true,
598                         'render' : function(my) {
599                                 if (Number(my.acp.circ_lib())>=0) {
600                                         return data.hash.aou[ my.acp.circ_lib() ].shortname();
601                                 } else {
602                                         return my.acp.circ_lib().shortname();
603                                 }
604                         },
605                         'persist' : 'hidden width ordinal'
606                 },
607                 {
608                         'id' : 'fine_level',
609                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
610                         'flex' : 1,
611                         'primary' : false,
612                         'hidden' : true,
613                         'render' : function(my) {
614                                 switch(Number(my.acp.fine_level())) {
615                                         case 1:
616                                                 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
617                                                 break;
618                                         case 2:
619                                                 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
620                                                 break;
621                                         case 3:
622                                                 return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
623                                                 break;
624                                 };
625                         },
626                         'persist' : 'hidden width ordinal'
627                 },
628                 {
629                         'id' : 'circulate',
630                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
631                         'flex' : 1,
632                         'primary' : false,
633                         'hidden' : true,
634                         'render' : function(my) {
635                                 if (get_bool( my.acp.circulate() )) {
636                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
637                                 } else {
638                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
639                                 }
640                         },
641                         'persist' : 'hidden width ordinal'
642                 },
643                 {
644                         'id' : 'deleted',
645                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
646                         'flex' : 1,
647                         'primary' : false,
648                         'hidden' : true,
649                         'render' : function(my) {
650                                 if (get_bool( my.acp.deleted() )) {
651                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
652                                 } else {
653                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
654                                 }
655                         },
656                         'persist' : 'hidden width ordinal'
657                 },
658                 {
659                         'id' : 'holdable',
660                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
661                         'flex' : 1,
662                         'primary' : false,
663                         'hidden' : true,
664                         'render' : function(my) {
665                                 if (get_bool( my.acp.holdable() )) {
666                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
667                                 } else {
668                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
669                                 }
670                         },
671                         'persist' : 'hidden width ordinal'
672                 },
673                 {
674                         'id' : 'opac_visible',
675                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
676                         'flex' : 1,
677                         'primary' : false,
678                         'hidden' : true,
679                         'render' : function(my) {
680                                 if (get_bool( my.acp.opac_visible() )) {
681                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
682                                 } else {
683                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
684                                 }
685                         },
686                         'persist' : 'hidden width ordinal'
687                 },
688                 {
689                         'persist' : 'hidden width ordinal',
690                         'id' : 'ref',
691                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
692                         'flex' : 1,
693                         'primary' : false,
694                         'hidden' : true,
695                         'render' : function(my) {
696                                 if (get_bool( my.acp.ref() )) {
697                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
698                                 } else {
699                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
700                                 }
701                         }
702                 },
703                 {
704                         'persist' : 'hidden width ordinal',
705                         'id' : 'deposit',
706                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
707                         'flex' : 1,
708                         'primary' : false,
709                         'hidden' : true,
710                         'render' : function(my) {
711                                 if (get_bool( my.acp.deposit() )) {
712                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
713                                 } else {
714                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
715                                 }
716                         }
717                 },
718                 {
719                         'persist' : 'hidden width ordinal',
720                         'id' : 'deposit_amount',
721                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
722                         'flex' : 1,
723                         'primary' : false,
724                         'hidden' : true,
725                         'render' : function(my) {
726                                 if (my.acp.price() == null) {
727                                         return document.getElementById('circStrings').getString('staff.circ.utils.unset');
728                                 } else {
729                                         return util.money.sanitize(my.acp.deposit_amount());
730                                 }
731                         },
732                         'sort_type' : 'money'
733                 },
734                 {
735                         'persist' : 'hidden width ordinal',
736                         'id' : 'price',
737                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
738                         'flex' : 1,
739                         'primary' : false,
740                         'hidden' : true,
741                         'render' : function(my) {
742                                 if (my.acp.price() == null) {
743                                         return document.getElementById('circStrings').getString('staff.circ.utils.unset');
744                                 } else {
745                                         return util.money.sanitize(my.acp.price());
746                                 }
747                         },
748                         'sort_type' : 'money'
749                 },
750                 {
751                         'persist' : 'hidden width ordinal',
752                         'id' : 'circ_as_type',
753                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
754                         'flex' : 1,
755                         'primary' : false,
756                         'hidden' : true,
757                         'render' : function(my) { return my.acp.circ_as_type(); }
758                 },
759                 {
760                         'persist' : 'hidden width ordinal',
761                         'id' : 'circ_modifier',
762                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
763                         'flex' : 1,
764                         'primary' : false,
765                         'hidden' : true,
766                         'render' : function(my) { return my.acp.circ_modifier(); }
767                 },
768                 {
769                         'persist' : 'hidden width ordinal',
770                         'id' : 'checkout_lib',
771                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
772                         'flex' : 1,
773                         'primary' : false,
774                         'hidden' : true,
775                         'render' : function(my) {
776                                 if (my.circ) {
777                                         return data.hash.aou[ my.circ.circ_lib() ].shortname();
778                                 } else {
779                                         if (my.acp.circulations()) {
780                                                 return data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname();
781                                         } else {
782                                                 return "";
783                                         }
784                                 }
785                         }
786                 },
787                 {
788                         'persist' : 'hidden width ordinal',
789                         'id' : 'xact_start_full',
790                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_timestamp'),
791                         'flex' : 1,
792                         'primary' : false,
793                         'hidden' : true,
794                         'render' : function(my) {
795                                 if (my.circ) {
796                                         return my.circ.xact_start();
797                                 } else {
798                                         if (my.acp.circulations()) {
799                                                 return my.acp.circulations()[0].xact_start();
800                                         }
801                                         else {
802                                                 return  "";
803                                         }
804                                 }
805                         }
806                 },
807                 {
808                         'persist' : 'hidden width ordinal',
809                         'id' : 'checkin_time_full',
810                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_timestamp'),
811                         'flex' : 1,
812                         'primary' : false,
813                         'hidden' : true,
814                         'render' : function(my) {
815                                 if (my.circ) {
816                                         return my.circ.checkin_time();
817                                 } else {
818                                         if (my.acp.circulations()) {
819                                                 return my.acp.circulations()[0].checkin_time();
820                                         } else {
821                                                 return "";
822                                         }
823                                 }
824                         }
825                 },
826                 {
827                         'persist' : 'hidden width ordinal',
828                         'id' : 'xact_start',
829                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
830                         'flex' : 1,
831                         'primary' : false,
832                         'hidden' : true,
833                         'render' : function(my) {
834                                 if (my.circ) {
835                                         return my.circ.xact_start().substr(0,10);
836                                 } else {
837                                         if (my.acp.circulations()) {
838                                                 return my.acp.circulations()[0].xact_start().substr(0,10);
839                                         } else {
840                                                 return "";
841                                         }
842                                 }
843                         }
844                 },
845                 {
846                         'persist' : 'hidden width ordinal',
847                         'id' : 'checkin_time',
848                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
849                         'flex' : 1,
850                         'primary' : false,
851                         'hidden' : true,
852                         'render' : function(my) {
853                                 if (my.circ) {
854                                         return my.circ.checkin_time().substr(0,10);
855                                 } else {
856                                         if (my.acp.circulations()) {
857                                                 return my.acp.circulations()[0].checkin_time().substr(0,10);
858                                         } else {
859                                                 return "";
860                                         }
861                                 }
862                         }
863                 },
864                 {
865                         'persist' : 'hidden width ordinal',
866                         'id' : 'xact_finish',
867                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
868                         'flex' : 1,
869                         'primary' : false,
870                         'hidden' : true,
871                         'render' : function(my) { return my.circ.xact_finish(); }
872                 },
873                 {
874                         'persist' : 'hidden width ordinal',
875                         'id' : 'due_date',
876                         'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
877                         'flex' : 1,
878                         'primary' : false,
879                         'hidden' : true,
880                         'render' : function(my) {
881                                 if (my.circ) {
882                                         return my.circ.due_date().substr(0,10);
883                                 } else {
884                                         if (my.acp.circulations()) {
885                                                 return my.acp.circulations()[0].due_date().substr(0,10);
886                                         } else {
887                                                 return "";
888                                         }
889                                 }
890                         }
891                 },
892                 {
893                         'persist' : 'hidden width ordinal',
894                         'id' : 'create_date',
895                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
896                         'flex' : 1,
897                         'primary' : false,
898                         'hidden' : true,
899                         'render' : function(my) { return my.acp.create_date().substr(0,10); }
900                 },
901                 {
902                         'persist' : 'hidden width ordinal',
903                         'id' : 'edit_date',
904                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
905                         'flex' : 1,
906                         'primary' : false,
907                         'hidden' : true,
908                         'render' : function(my) { return my.acp.edit_date().substr(0,10); }
909                 },
910                 {
911                         'persist' : 'hidden width ordinal',
912                         'id' : 'title',
913                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
914                         'flex' : 2,
915                         'sort_type' : 'title',
916                         'primary' : false,
917                         'hidden' : true,
918                         'render' : function(my) {
919                                 try {  return my.mvr.title(); }
920                                 catch(E) { return my.acp.dummy_title(); }
921                         }
922                 },
923                 {
924                         'persist' : 'hidden width ordinal',
925                         'id' : 'author',
926                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
927                         'flex' : 1,
928                         'primary' : false,
929                         'hidden' : true,
930                         'render' : function(my) {
931                                 try { return my.mvr.author(); }
932                                 catch(E) { return my.acp.dummy_author(); }
933                         }
934                 },
935                 {
936                         'persist' : 'hidden width ordinal',
937                         'id' : 'edition',
938                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
939                         'flex' : 1,
940                         'primary' : false,
941                         'hidden' : true,
942                         'render' : function(my) { return my.mvr.edition(); }
943                 },
944                 {
945                         'persist' : 'hidden width ordinal',
946                         'id' : 'isbn',
947                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
948                         'flex' : 1,
949                         'primary' : false,
950                         'hidden' : true,
951                         'render' : function(my) { return my.mvr.isbn(); }
952                 },
953                 {
954                         'persist' : 'hidden width ordinal',
955                         'id' : 'pubdate',
956                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
957                         'flex' : 1,
958                         'primary' : false,
959                         'hidden' : true,
960                         'render' : function(my) { return my.mvr.pubdate(); }
961                 },
962                 {
963                         'persist' : 'hidden width ordinal',
964                         'id' : 'publisher',
965                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
966                         'flex' : 1,
967                         'primary' : false,
968                         'hidden' : true,
969                         'render' : function(my) { return my.mvr.publisher(); }
970                 },
971                 {
972                         'persist' : 'hidden width ordinal',
973                         'id' : 'tcn',
974                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
975                         'flex' : 1,
976                         'primary' : false,
977                         'hidden' : true,
978                         'render' : function(my) { return my.mvr.tcn(); }
979                 },
980                 {
981                         'persist' : 'hidden width ordinal',
982                         'id' : 'renewal_remaining',
983                         'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
984                         'flex' : 0,
985                         'primary' : false,
986                         'hidden' : true,
987                         'render' : function(my) {
988                                 if (my.circ) {
989                                         return my.circ.renewal_remaining();
990                                 } else {
991                                         if (my.acp.circulations()) {
992                                                 return my.acp.circulations()[0].renewal_remaining();
993                                         } else {
994                                                 return "";
995                                         }
996                                 }
997                         },
998                         'sort_type' : 'number'
999                 },
1000                 {
1001                         'persist' : 'hidden width ordinal',
1002                         'id' : 'stop_fines',
1003                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
1004                         'flex' : 0,
1005                         'primary' : false,
1006                         'hidden' : true,
1007                         'render' : function(my) {
1008                                 if (my.circ) {
1009                                         return my.circ.stop_fines();
1010                                 } else {
1011                                         if (my.acp.circulations()) {
1012                                                 return my.acp.circulations()[0].stop_fines();
1013                                         } else {
1014                                                 return "";
1015                                         }
1016                                 }
1017                         }
1018                 },
1019                 {
1020                         'persist' : 'hidden width ordinal',
1021                         'id' : 'stop_fines_time',
1022                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
1023                         'flex' : 0,
1024                         'primary' : false,
1025                         'hidden' : true,
1026                         'render' : function(my) {
1027                                 if (my.circ) {
1028                                         return my.circ.stop_fines_time();
1029                                 } else {
1030                                         if (my.acp.circulations()) {
1031                                                 return my.acp.circulations()[0].stop_fines_time();
1032                                         } else {
1033                                                 return "";
1034                                         }
1035                                 }
1036                         }
1037                 },
1038                 {
1039                         'persist' : 'hidden width ordinal',
1040                         'id' : 'status',
1041                         'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
1042                         'flex' : 1,
1043                         'primary' : false,
1044                         'hidden' : true,
1045                         'render' : function(my) {
1046                                 if (Number(my.acp.status())>=0) {
1047                                         return data.hash.ccs[ my.acp.status() ].name();
1048                                 } else {
1049                                         return my.acp.status().name();
1050                                 }
1051                         }
1052                 },
1053                 {
1054                         'persist' : 'hidden width ordinal',
1055                         'id' : 'route_to',
1056                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
1057                         'flex' : 1,
1058                         'primary' : false,
1059                         'hidden' : true,
1060                         'render' : function(my) { return my.route_to.toString(); }
1061                 },
1062                 {
1063                         'persist' : 'hidden width ordinal',
1064                         'id' : 'message',
1065                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
1066                         'flex' : 1,
1067                         'primary' : false,
1068                         'hidden' : true,
1069                         'render' : function(my) { return my.message.toString(); }
1070                 },
1071                 {
1072                         'persist' : 'hidden width ordinal',
1073                         'id' : 'uses',
1074                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
1075                         'flex' : 1,
1076                         'primary' : false,
1077                         'hidden' : true,
1078                         'render' : function(my) { return my.uses; },
1079                         'sort_type' : 'number'
1080                 },
1081                 {
1082                         'persist' : 'hidden width ordinal',
1083                         'id' : 'alert_message',
1084                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
1085                         'flex' : 1,
1086                         'primary' : false,
1087                         'hidden' : true,
1088                         'render' : function(my) { return my.acp.alert_message(); }
1089                 }
1090         ];
1091         for (var i = 0; i < c.length; i++) {
1092                 if (modify[ c[i].id ]) {
1093                         for (var j in modify[ c[i].id ]) {
1094                                 c[i][j] = modify[ c[i].id ][j];
1095                         }
1096                 }
1097         }
1098         if (params) {
1099                 if (params.just_these) {
1100                         JSAN.use('util.functional');
1101                         var new_c = [];
1102                         for (var i = 0; i < params.just_these.length; i++) {
1103                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1104                                 new_c.push( function(y){ return y; }( x ) );
1105                         }
1106                         c = new_c;
1107                 }
1108                 if (params.except_these) {
1109                         JSAN.use('util.functional');
1110                         var new_c = [];
1111                         for (var i = 0; i < c.length; i++) {
1112                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1113                                 if (!x) new_c.push(c[i]);
1114                         }
1115                         c = new_c;
1116                 }
1117         }
1118         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1119 };
1120
1121 circ.util.transit_columns = function(modify,params) {
1122         
1123         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1124
1125         var c = [
1126                 {
1127                         'persist' : 'hidden width ordinal',
1128                         'id' : 'transit_item_barcode',
1129                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
1130                         'flex' : 1,
1131                         'primary' : false,
1132                         'hidden' : true,
1133                         'render' : function(my) { return my.acp.barcode(); }
1134                 },
1135                 {
1136                         'persist' : 'hidden width ordinal',
1137                         'id' : 'transit_item_title',
1138                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
1139                         'flex' : 1,
1140                         'primary' : false,
1141                         'hidden' : true,
1142                         'render' : function(my) {
1143                                 try { return my.mvr.title(); }
1144                                 catch(E) { return my.acp.dummy_title(); }
1145                         }
1146                 },
1147                 {
1148                         'persist' : 'hidden width ordinal',
1149                         'id' : 'transit_item_author',
1150                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
1151                         'flex' : 1,
1152                         'primary' : false,
1153                         'hidden' : true,
1154                         'render' : function(my) {
1155                                 try { return my.mvr.author(); }
1156                                 catch(E) { return my.acp.dummy_author(); }
1157                         }
1158                 },
1159                 {
1160                         'persist' : 'hidden width ordinal',
1161                         'id' : 'transit_item_callnumber',
1162                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1163                         'flex' : 1,
1164                         'primary' : false,
1165                         'hidden' : true,
1166                         'render' : function(my) { return my.acn.label(); }
1167                 },
1168                 {
1169                         'persist' : 'hidden width ordinal',
1170                         'id' : 'transit_id',
1171                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
1172                         'flex' : 1,
1173                         'primary' : false,
1174                         'hidden' : true,
1175                         'render' : function(my) { return my.atc.id(); }
1176                 },
1177                 {
1178                         'persist' : 'hidden width ordinal',
1179                         'id' : 'transit_source',
1180                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1181                         'flex' : 1,
1182                         'primary' : false,
1183                         'hidden' : false,
1184                         'render' : function(my) {
1185                                 if (typeof my.atc.source() == "object") {
1186                                         return my.atc.source().shortname();
1187                                 } else {
1188                                         return data.hash.aou[ my.atc.source() ].shortname();
1189                                 }
1190                         }
1191                 },
1192                 {
1193                         'persist' : 'hidden width ordinal',
1194                         'id' : 'transit_source_send_time',
1195                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1196                         'flex' : 1,
1197                         'primary' : false,
1198                         'hidden' : false,
1199                         'render' : function(my) { return my.atc.source_send_time(); }
1200                 },
1201                 {
1202                         'persist' : 'hidden width ordinal',
1203                         'id' : 'transit_dest_lib',
1204                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1205                         'flex' : 1,
1206                         'primary' : false,
1207                         'hidden' : false,
1208                         'render' : function(my) {
1209                                 if (typeof my.atc.dest() == "object") {
1210                                         return my.atc.dest().shortname();
1211                                 } else {
1212                                         return data.hash.aou[ my.atc.dest() ].shortname();
1213                                 }
1214                         }
1215                 },
1216                 {
1217                         'persist' : 'hidden width ordinal',
1218                         'id' : 'transit_dest_recv_time',
1219                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1220                         'flex' : 1,
1221                         'primary' : false,
1222                         'hidden' : false,
1223                         'render' : function(my) { return my.atc.dest_recv_time(); }
1224                 },
1225                 {
1226                         'persist' : 'hidden width ordinal',
1227                         'id' : 'transit_target_copy',
1228                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
1229                         'flex' : 1,
1230                         'primary' : false,
1231                         'hidden' : true,
1232                         'render' : function(my) { return my.atc.target_copy(); }
1233                 },
1234         ];
1235         for (var i = 0; i < c.length; i++) {
1236                 if (modify[ c[i].id ]) {
1237                         for (var j in modify[ c[i].id ]) {
1238                                 c[i][j] = modify[ c[i].id ][j];
1239                         }
1240                 }
1241         }
1242         if (params) {
1243                 if (params.just_these) {
1244                         JSAN.use('util.functional');
1245                         var new_c = [];
1246                         for (var i = 0; i < params.just_these.length; i++) {
1247                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1248                                 new_c.push( function(y){ return y; }( x ) );
1249                         }
1250                         c = new_c;
1251                 }
1252                 if (params.except_these) {
1253                         JSAN.use('util.functional');
1254                         var new_c = [];
1255                         for (var i = 0; i < c.length; i++) {
1256                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1257                                 if (!x) new_c.push(c[i]);
1258                         }
1259                         c = new_c;
1260                 }
1261
1262         }
1263         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1264 };
1265
1266 circ.util.hold_columns = function(modify,params) {
1267         
1268         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1269
1270         var c = [
1271                 {
1272                         'persist' : 'hidden width ordinal',
1273                         'id' : 'request_lib',
1274                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
1275                         'flex' : 1,
1276                         'primary' : false,
1277                         'hidden' : true,
1278                         'render' : function(my) {
1279                                 if (Number(my.ahr.request_lib())>=0) {
1280                                         return data.hash.aou[ my.ahr.request_lib() ].name();
1281                                 } else {
1282                                         return my.ahr.request_lib().name();
1283                                 }
1284                         }
1285                 },
1286                 {
1287                         'persist' : 'hidden width ordinal',
1288                         'id' : 'request_lib_shortname',
1289                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
1290                         'flex' : 0,
1291                         'primary' : false,
1292                         'hidden' : true,
1293                         'render' : function(my) {
1294                                 if (Number(my.ahr.request_lib())>=0) {
1295                                         return data.hash.aou[ my.ahr.request_lib() ].shortname();
1296                                 } else {
1297                                         return my.ahr.request_lib().shortname();
1298                                 }
1299                         }
1300                 },
1301
1302                 {
1303                         'persist' : 'hidden width ordinal',
1304                         'id' : 'request_timestamp',
1305                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
1306                         'flex' : 0,
1307                         'primary' : false,
1308                         'hidden' : true,
1309                         'render' : function(my) { return my.ahr.request_time().toString(); }
1310                 },
1311                 {
1312                         'persist' : 'hidden width ordinal',
1313                         'id' : 'request_time',
1314                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
1315                         'flex' : 0,
1316                         'primary' : false,
1317                         'hidden' : true,
1318                         'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
1319                 },
1320                 {
1321                         'persist' : 'hidden width ordinal',
1322                         'id' : 'available_timestamp',
1323                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
1324                         'flex' : 1,
1325                         'primary' : false,
1326                         'hidden' : true,
1327                         'render' : function(my) {
1328                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1329                                         return my.ahr.transit().dest_recv_time().toString();
1330                                 }
1331                                 if (!my.ahr.transit() && my.ahr.capture_time()) {
1332                                         return my.ahr.capture_time().toString();
1333                                 }
1334                                 return "";
1335                         }
1336                 },
1337                 {
1338                         'persist' : 'hidden width ordinal',
1339                         'id' : 'available_time',
1340                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
1341                         'flex' : 1,
1342                         'primary' : false,
1343                         'hidden' : false,
1344                         'render' : function(my) {
1345                                 if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
1346                                         return my.ahr.transit().dest_recv_time().toString().substr(0,10);
1347                                 }
1348                                 if (my.ahr.capture_time()) {
1349                                         return my.ahr.capture_time().toString().substr(0,10);
1350                                 }
1351                                 return "";
1352                         }
1353                 },
1354                 {
1355                         'persist' : 'hidden width ordinal',
1356                         'id' : 'capture_timestamp',
1357                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
1358                         'flex' : 1,
1359                         'primary' : false,
1360                         'hidden' : true,
1361                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
1362                 },
1363                 {
1364                         'persist' : 'hidden width ordinal',
1365                         'id' : 'capture_time',
1366                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
1367                         'flex' : 1,
1368                         'primary' : false,
1369                         'hidden' : true,
1370                         'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
1371                 },
1372                 {
1373                         'persist' : 'hidden width ordinal',
1374                         'id' : 'status',
1375                         'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
1376                         'flex' : 1,
1377                         'primary' : false,
1378                         'hidden' : false,
1379                         'render' : function(my) {
1380                                 switch (Number(my.status)) {
1381                                         case 1:
1382                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
1383                                                 break;
1384                                         case 2:
1385                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
1386                                                 break;
1387                                         case 3:
1388                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
1389                                                 break;
1390                                         case 4:
1391                                                 return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
1392                                                 break;
1393                                         default:
1394                                                 return my.status;
1395                                                 break;
1396                                 };
1397                         }
1398                 },
1399                 {
1400                         'persist' : 'hidden width ordinal',
1401                         'id' : 'hold_type',
1402                         'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
1403                         'flex' : 0,
1404                         'primary' : false,
1405                         'hidden' : true,
1406                         'render' : function(my) { return my.ahr.hold_type(); }
1407                 },
1408         {
1409                         'persist' : 'hidden width ordinal',
1410                         'id' : 'frozen',
1411                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
1412                         'flex' : 0,
1413                         'primary' : false,
1414                         'hidden' : true,
1415                         'render' : function(my) {
1416                                 if (!get_bool( my.ahr.frozen() )) {
1417                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1418                                 } else {
1419                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1420                                 }
1421                         }
1422         },
1423         {
1424                         'persist' : 'hidden width ordinal',
1425                         'id' : 'thaw_date',
1426                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
1427                         'flex' : 0,
1428                         'primary' : false,
1429                         'hidden' : true,
1430                         'render' : function(my) {
1431                                 if (my.ahr.thaw_date() == null) {
1432                                         return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
1433                                 } else {
1434                                         return my.ahr.thaw_date().substr(0,10);
1435                                 }
1436                         }
1437         },
1438                 {
1439                         'persist' : 'hidden width ordinal',
1440                         'id' : 'pickup_lib',
1441                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
1442                         'flex' : 1,
1443                         'primary' : false,
1444                         'hidden' : true,
1445                         'render' : function(my) {
1446                                 if (Number(my.ahr.pickup_lib())>=0) {
1447                                         return data.hash.aou[ my.ahr.pickup_lib() ].name();
1448                                 } else {
1449                                         return my.ahr.pickup_lib().name();
1450                                 }
1451                         }
1452                 },
1453                 {
1454                         'persist' : 'hidden width ordinal',
1455                         'id' : 'pickup_lib_shortname',
1456                         'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
1457                         'flex' : 0,
1458                         'primary' : false,
1459                         'hidden' : true,
1460                         'render' : function(my) {
1461                                 if (Number(my.ahr.pickup_lib())>=0) {
1462                                         return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
1463                                 } else {
1464                                         return my.ahr.pickup_lib().shortname();
1465                                 }
1466                         }
1467                 },
1468                 {
1469                         'persist' : 'hidden width ordinal',
1470                         'id' : 'current_copy',
1471                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
1472                         'flex' : 1,
1473                         'primary' : false,
1474                         'hidden' : true,
1475                         'render' : function(my) {
1476                                 if (my.acp) {
1477                                         return my.acp.barcode();
1478                                 } else {
1479                                         return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
1480                                 }
1481                         }
1482                 },
1483                 {
1484                         'persist' : 'hidden width ordinal',
1485                         'id' : 'current_copy_location', 
1486                         'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
1487             'flex' : 1,
1488                         'primary' : false, 
1489             'hidden' : true, 
1490             'render' : function(my) { 
1491                 if (!my.acp) { return ""; } else { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); } 
1492             }
1493                 },
1494                 {
1495                         'persist' : 'hidden width ordinal',
1496                         'id' : 'email_notify',
1497                         'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
1498                         'flex' : 1,
1499                         'primary' : false,
1500                         'hidden' : true,
1501                         'render' : function(my) {
1502                                 if (get_bool(my.ahr.email_notify())) {
1503                                         return document.getElementById('circStrings').getString('staff.circ.utils.yes');
1504                                 } else {
1505                                         return document.getElementById('circStrings').getString('staff.circ.utils.no');
1506                                 }
1507                         }
1508                 },
1509                 {
1510                         'persist' : 'hidden width ordinal',
1511                         'id' : 'expire_time',
1512                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
1513                         'flex' : 1,
1514                         'primary' : false,
1515                         'hidden' : true,
1516                         'render' : function(my) { return my.ahr.expire_time(); }
1517                 },
1518                 {
1519                         'persist' : 'hidden width ordinal',
1520                         'id' : 'expire_date',
1521                         'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
1522                         'flex' : 1,
1523                         'primary' : false,
1524                         'hidden' : true,
1525                         'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
1526                 },
1527                 {
1528                         'persist' : 'hidden width ordinal',
1529                         'id' : 'fulfillment_time',
1530                         'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
1531                         'flex' : 1,
1532                         'primary' : false,
1533                         'hidden' : true,
1534                         'render' : function(my) { return my.ahr.fulfillment_time(); }
1535                 },
1536                 {
1537                         'persist' : 'hidden width ordinal',
1538                         'id' : 'holdable_formats',
1539                         'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
1540                         'flex' : 1,
1541                         'primary' : false,
1542                         'hidden' : true,
1543                         'render' : function(my) { return my.ahr.holdable_formats(); }
1544                 },
1545                 {
1546                         'persist' : 'hidden width ordinal',
1547                         'id' : 'id',
1548                         'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
1549                         'flex' : 1,
1550                         'primary' : false,
1551                         'hidden' : true,
1552                         'render' : function(my) { return my.ahr.id(); }
1553                 },
1554                 {
1555                         'persist' : 'hidden width ordinal',
1556                         'id' : 'phone_notify',
1557                         'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
1558                         'flex' : 1,
1559                         'primary' : false,
1560                         'hidden' : true,
1561                         'render' : function(my) { return my.ahr.phone_notify(); }
1562                 },
1563                 {
1564                         'persist' : 'hidden width ordinal',
1565                         'id' : 'prev_check_time',
1566                         'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
1567                         'flex' : 1,
1568                         'primary' : false,
1569                         'hidden' : true,
1570                         'render' : function(my) { return my.ahr.prev_check_time(); }
1571                 },
1572                 {
1573                         'persist' : 'hidden width ordinal',
1574                         'id' : 'requestor',
1575                         'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
1576                         'flex' : 1,
1577                         'primary' : false,
1578                         'hidden' : true,
1579                         'render' : function(my) { return my.ahr.requestor(); }
1580                 },
1581                 {
1582                         'persist' : 'hidden width ordinal',
1583                         'id' : 'selection_depth',
1584                         'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
1585                         'flex' : 1,
1586                         'primary' : false,
1587                         'hidden' : true,
1588                         'render' : function(my) { return my.ahr.selection_depth(); }
1589                 },
1590                 {
1591                         'persist' : 'hidden width ordinal',
1592                         'id' : 'target',
1593                         'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
1594                         'flex' : 1,
1595                         'primary' : false,
1596                         'hidden' : true,
1597                         'render' : function(my) { return my.ahr.target(); }
1598                 },
1599                 {
1600                         'persist' : 'hidden width ordinal',
1601                         'id' : 'usr',
1602                         'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
1603                         'flex' : 1,
1604                         'primary' : false,
1605                         'hidden' : true,
1606                         'render' : function(my) { return my.ahr.usr(); }
1607                 },
1608                 {
1609                         'persist' : 'hidden width ordinal',
1610                         'id' : 'title',
1611                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
1612                         'flex' : 1,
1613                         'sort_type' : 'title',
1614                         'primary' : false,
1615                         'hidden' : true,
1616                         'render' : function(my) {
1617                                 if (my.mvr) {
1618                                         return my.mvr.title();
1619                                 } else {
1620                                         return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
1621                                 }
1622                         }
1623                 },
1624                 {
1625                         'persist' : 'hidden width ordinal',
1626                         'id' : 'author',
1627                         'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
1628                         'flex' : 1,
1629                         'primary' : false,
1630                         'hidden' : true,
1631                         'render' : function(my) {
1632                                 if (my.mvr) {
1633                                         return my.mvr.author();
1634                                 } else {
1635                                         return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
1636                                 }
1637                         }
1638                 },
1639                 {
1640                         'persist' : 'hidden width ordinal',
1641                         'id' : 'edition',
1642                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
1643                         'flex' : 1,
1644                         'primary' : false,
1645                         'hidden' : true,
1646                         'render' : function(my) { return my.mvr.edition(); }
1647                 },
1648                 {
1649                         'persist' : 'hidden width ordinal',
1650                         'id' : 'isbn',
1651                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
1652                         'flex' : 1,
1653                         'primary' : false,
1654                         'hidden' : true,
1655                         'render' : function(my) { return my.mvr.isbn(); }
1656                 },
1657                 {
1658                         'persist' : 'hidden width ordinal',
1659                         'id' : 'pubdate',
1660                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
1661                         'flex' : 1,
1662                         'primary' : false,
1663                         'hidden' : true,
1664                         'render' : function(my) { return my.mvr.pubdate(); }
1665                 },
1666                 {
1667                         'persist' : 'hidden width ordinal',
1668                         'id' : 'publisher',
1669                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
1670                         'flex' : 1,
1671                         'primary' : false,
1672                         'hidden' : true,
1673                         'render' : function(my) { return my.mvr.publisher(); }
1674                 },
1675                 {
1676                         'persist' : 'hidden width ordinal',
1677                         'id' : 'tcn',
1678                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
1679                         'flex' : 1,
1680                         'primary' : false,
1681                         'hidden' : true,
1682                         'render' : function(my) { return my.mvr.tcn(); }
1683                 },
1684                 {
1685                         'persist' : 'hidden width ordinal',
1686                         'id' : 'notify_time',
1687                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
1688                         'flex' : 1,
1689                         'primary' : false,
1690                         'hidden' : true,
1691                         'render' : function(my) { return my.ahr.notify_time(); }
1692                 },
1693                 {
1694                         'persist' : 'hidden width ordinal',
1695                         'id' : 'notify_count',
1696                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
1697                         'flex' : 1,
1698                         'primary' : false,
1699                         'hidden' : true,
1700                         'render' : function(my) { return my.ahr.notify_count(); }
1701                 },
1702                 {
1703                         'persist' : 'hidden width ordinal',
1704                         'id' : 'transit_source',
1705                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
1706                         'flex' : 1,
1707                         'primary' : false,
1708                         'hidden' : true,
1709                         'render' : function(my) {
1710                                 if (my.ahr.transit()) {
1711                                         return data.hash.aou[ my.ahr.transit().source() ].shortname();
1712                                 } else {
1713                                         return "";
1714                                 }
1715                         }
1716                 },
1717                 {
1718                         'persist' : 'hidden width ordinal',
1719                         'id' : 'transit_source_send_time',
1720                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
1721                         'flex' : 1,
1722                         'primary' : false,
1723                         'hidden' : true,
1724                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().source_send_time() : ""; }
1725                 },
1726                 {
1727                         'persist' : 'hidden width ordinal',
1728                         'id' : 'transit_dest_lib',
1729                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
1730                         'flex' : 1,
1731                         'primary' : false,
1732                         'hidden' : true,
1733                         'render' : function(my) { return my.ahr.transit() ?  data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
1734                 },
1735                 {
1736                         'persist' : 'hidden width ordinal',
1737                         'id' : 'transit_dest_recv_time',
1738                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
1739                         'flex' : 1,
1740                         'primary' : false,
1741                         'hidden' : true,
1742                         'render' : function(my) { return my.ahr.transit() ?  my.ahr.transit().dest_recv_time() : ""; }
1743                 },
1744                 {
1745                         'persist' : 'hidden width ordinal',
1746                         'id' : 'patron_barcode',
1747                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
1748                         'flex' : 1,
1749                         'primary' : false,
1750                         'hidden' : true,
1751                         'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
1752                 },
1753                 {
1754                         'persist' : 'hidden width ordinal',
1755                         'id' : 'patron_family_name',
1756                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
1757                         'flex' : 1,
1758                         'primary' : false,
1759                         'hidden' : true,
1760                         'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
1761                 },
1762                 {
1763                         'persist' : 'hidden width ordinal',
1764                         'id' : 'patron_first_given_name',
1765                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
1766                         'flex' : 1,
1767                         'primary' : false,
1768                         'hidden' : true,
1769                         'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
1770                 },
1771                 {
1772                         'persist' : 'hidden width ordinal',
1773                         'id' : 'callnumber',
1774                         'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
1775                         'flex' : 1,
1776                         'primary' : false,
1777                         'hidden' : true,
1778                         'render' : function(my) { return my.acn.label(); }
1779                 },
1780         ];
1781         for (var i = 0; i < c.length; i++) {
1782                 if (modify[ c[i].id ]) {
1783                         for (var j in modify[ c[i].id ]) {
1784                                 c[i][j] = modify[ c[i].id ][j];
1785                         }
1786                 }
1787         }
1788         if (params) {
1789                 if (params.just_these) {
1790                         JSAN.use('util.functional');
1791                         var new_c = [];
1792                         for (var i = 0; i < params.just_these.length; i++) {
1793                                 var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
1794                                 new_c.push( function(y){ return y; }( x ) );
1795                         }
1796                         c = new_c;
1797                 }
1798                 if (params.except_these) {
1799                         JSAN.use('util.functional');
1800                         var new_c = [];
1801                         for (var i = 0; i < c.length; i++) {
1802                                 var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
1803                                 if (!x) new_c.push(c[i]);
1804                         }
1805                         c = new_c;
1806                 }
1807
1808         }
1809         return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
1810 };
1811 /*
1812 circ.util.std_map_row_to_column = function(error_value) {
1813         return function(row,col) {
1814                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1815                 // col contains one of the objects listed above in columns
1816                 
1817                 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
1818                 var obj = {};
1819                 JSAN.use('util.error'); obj.error = new util.error();
1820                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1821                 JSAN.use('util.network'); obj.network = new util.network();
1822                 JSAN.use('util.money');
1823
1824                 var my = row.my;
1825                 var value;
1826                 try {
1827                         value = eval( col.render );
1828                 } catch(E) {
1829                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1830                         if (error_value) value = error_value; else value = '   ';
1831                 }
1832                 return value;
1833         }
1834 };
1835 */
1836 circ.util.std_map_row_to_columns = function(error_value) {
1837         return function(row,cols) {
1838                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
1839                 // cols contains all of the objects listed above in columns
1840                 
1841                 var obj = {};
1842                 JSAN.use('util.error'); obj.error = new util.error();
1843                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
1844                 JSAN.use('util.network'); obj.network = new util.network();
1845                 JSAN.use('util.money');
1846
1847                 var my = row.my;
1848                 var values = [];
1849                 var cmd = '';
1850                 try {
1851                         for (var i = 0; i < cols.length; i++) {
1852                                 switch (typeof cols[i].render) {
1853                                         case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
1854                                         case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
1855                                         default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
1856                                 }
1857                         }
1858                         if (cmd) eval( cmd );
1859                 } catch(E) {
1860                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
1861                         if (error_value) { value = error_value; } else { value = '   ' };
1862                 }
1863                 return values;
1864         }
1865 };
1866
1867 circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
1868         try {
1869                 JSAN.use('util.error'); var error = new util.error();
1870                 JSAN.use('util.network'); var network = new util.network();
1871                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1872                 JSAN.use('util.date'); JSAN.use('util.functional');
1873
1874                 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
1875
1876                 //var params = { 'barcode' : barcode };
1877                 if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
1878
1879                 if (typeof params.disable_textbox == 'function') {
1880                         try { params.disable_textbox(); }
1881                         catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
1882                 }
1883
1884         function checkin_callback(req) {
1885             try {
1886                 var check = req.getResultObject();
1887                 var r = circ.util.checkin_via_barcode2(session,params,backdate,auto_print,check);
1888                 if (typeof params.checkin_result == 'function') {
1889                     try { params.checkin_result(r); }
1890                     catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
1891                 }
1892                                 if (typeof async == 'function') async(check);
1893                                 return check;
1894             } catch(E) {
1895                 JSAN.use('util.error'); var error = new util.error();
1896                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
1897                 if (typeof params.enable_textbox == 'function') {
1898                     try { params.enable_textbox(); }
1899                     catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
1900                 }
1901                 return null;
1902             }
1903         } 
1904
1905                 var check = network.request(
1906                         api.CHECKIN_VIA_BARCODE.app,
1907                         api.CHECKIN_VIA_BARCODE.method,
1908                         [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
1909                         async ? checkin_callback : null,
1910                         {
1911                                 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
1912                                 'overridable_events' : [
1913                     null /* custom event */,
1914                                         1203 /* COPY_BAD_STATUS */,
1915                                         1213 /* PATRON_BARRED */,
1916                                         1217 /* PATRON_INACTIVE */,
1917                                         1224 /* PATRON_ACCOUNT_EXPIRED */,
1918                                         1234 /* ITEM_DEPOSIT_PAID */,
1919                                         7009 /* CIRC_CLAIMS_RETURNED */,
1920                                         7010 /* COPY_ALERT_MESSAGE */,
1921                                         7011 /* COPY_STATUS_LOST */,
1922                                         7012 /* COPY_STATUS_MISSING */,
1923                                         7013 /* PATRON_EXCEEDS_FINES */,
1924                                 ],
1925                                 'text' : {
1926                                         '1203' : function(r) {
1927                                                 return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
1928                                         },
1929                                         '1234' : function(r) {
1930                                                 return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
1931                                         },
1932                                         '7010' : function(r) {
1933                                                 return r.payload;
1934                                         }
1935                                 }
1936                         }
1937                 );
1938                 if (! async ) {
1939                         return checkin_callback( { 'getResultObject' : function() { return check; } } );
1940                 }
1941
1942
1943         } catch(E) {
1944                 JSAN.use('util.error'); var error = new util.error();
1945                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
1946                 if (typeof params.enable_textbox == 'function') {
1947                         try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
1948                 }
1949                 return null;
1950         }
1951 };
1952
1953 circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
1954         try {
1955                 JSAN.use('util.error'); var error = new util.error();
1956                 JSAN.use('util.network'); var network = new util.network();
1957                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
1958                 JSAN.use('util.date');
1959
1960                 error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
1961
1962                 check.message = check.textcode;
1963
1964                 if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
1965                 if (check.payload && check.payload.record) { check.record = check.payload.record; }
1966                 if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
1967
1968                 if (!check.route_to) { check.route_to = '   '; }
1969
1970                 if (document.getElementById('no_change_label')) {
1971                         document.getElementById('no_change_label').setAttribute('value','');
1972                         document.getElementById('no_change_label').setAttribute('hidden','true');
1973                 }
1974
1975                 if (check.circ) {
1976                         network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),check.circ.id()], function(req) {
1977                                 JSAN.use('util.money');
1978                                 var bill = req.getResultObject();
1979                                 if (Number(bill.balance_owed()) == 0) { return; }
1980                                 if (document.getElementById('no_change_label')) {
1981                                         var m = document.getElementById('no_change_label').getAttribute('value');
1982                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.billable.amount', [params.barcode, util.money.sanitize(bill.balance_owed())]) + '  ');
1983                                         document.getElementById('no_change_label').setAttribute('hidden','false');
1984                                 }
1985                         });
1986                 }
1987
1988                 var msg = '';
1989
1990                 if (check.payload && check.payload.cancelled_hold_transit) {
1991                         msg += document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
1992                         msg += '\n\n';
1993                 }
1994
1995                 /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
1996                 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
1997                         try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
1998                         catch(E) {
1999                                 msg += document.getElementById('commonStrings').getString('common.error');
2000                                 msg += '\nFIXME: ' + E + '\n';
2001                         }
2002                         if (check.ilsevent == 3 /* NO_CHANGE */) {
2003                                 //msg = 'This item is already checked in.\n';
2004                                 if (document.getElementById('no_change_label')) {
2005                                         var m = document.getElementById('no_change_label').getAttribute('value');
2006                                         document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + '  ');
2007                                         document.getElementById('no_change_label').setAttribute('hidden','false');
2008                                 }
2009                         }
2010                         if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
2011                                 var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
2012                                 msg = document.getElementById('commonStrings').getString('common.error');
2013                                 msg += '\nFIXME --';
2014                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
2015                                 msg + '\n';
2016                         }
2017                         switch(Number(check.copy.status())) {
2018                                 case 0: /* AVAILABLE */
2019                                 case 7: /* RESHELVING */
2020                                         if (msg) {
2021                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2022                                                 msg += '\n';
2023                                         }
2024                                 break;
2025                                 case 8: /* ON HOLDS SHELF */
2026                                         check.route_to = 'HOLDS SHELF';
2027                                         if (check.payload.hold) {
2028                                                 if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
2029                                                         msg += document.getElementById('commonStrings').getString('common.error');
2030                                                         msg += '\nFIXME: ';
2031                                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
2032                                                         msg += '\n';
2033                                                 } else {
2034                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2035                                                         msg += '.\n';
2036                                                 }
2037                                         } else {
2038                                                 msg += document.getElementById('commonStrings').getString('common.error');
2039                                                 msg += '\nFIXME: ';
2040                                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
2041                                                 msg += '\n';
2042                                         }
2043                                         JSAN.use('util.date');
2044                                         if (check.payload.hold) {
2045                                                 JSAN.use('patron.util');
2046                                                 msg += '\n';
2047                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2048                                                 msg += '\n';
2049                                                 var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2050                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2051                                                 msg += '\n';
2052                                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2053                                                 msg += '\n';
2054                         if (au_obj.alias()) {
2055                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2056                         } else {
2057                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron',  [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2058                         }
2059                                                 msg += '\n';
2060                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2061                                                 msg += '\n';
2062                                                 if (check.payload.hold.phone_notify()) {
2063                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2064                                                         msg += '\n';
2065                                                 }
2066                                                 if (get_bool(check.payload.hold.email_notify())) {
2067                                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2068                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2069                                                         msg += '\n';
2070                                                 }
2071                                                 msg += '\n';
2072                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2073                                                 msg += '\n';
2074                                         }
2075                                         var rv = 0;
2076                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2077                                         msg += '\n';
2078                                         if (!auto_print) {
2079                                                 rv = error.yns_alert_formatted(
2080                                                         msg,
2081                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
2082                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
2083                                                         document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
2084                                                         null,
2085                                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2086                                                         '/xul/server/skin/media/images/turtle.gif'
2087                                                 );
2088                                         }
2089                                         if (rv == 0) {
2090                                                 try {
2091                                                         JSAN.use('util.print'); var print = new util.print();
2092                                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2093                                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2094                                                 } catch(E) {
2095                                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2096                                                         err_msg += '\nFIXME: ' + E + '\n';
2097                                                         dump(err_msg);
2098                                                         alert(err_msg);
2099                                                 }
2100                                         }
2101                                         msg = '';
2102                                         if (document.getElementById('no_change_label')) {
2103                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2104                                                 m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
2105                                                 document.getElementById('no_change_label').setAttribute('value', m);
2106                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2107                                         }
2108                                 break;
2109                                 case 6: /* IN TRANSIT */
2110                                         check.route_to = 'TRANSIT SHELF??';
2111                                         msg += document.getElementById('commonStrings').getString('common.error');
2112                                         msg += "\nFIXME -- I didn't think we could get here.\n";
2113                                 break;
2114                                 case 11: /* CATALOGING */
2115                                         check.route_to = 'CATALOGING';
2116                                         if (document.getElementById('do_not_alert_on_precat')) {
2117                                                 var x = document.getElementById('do_not_alert_on_precat');
2118                                                 if (! x.checked) {
2119                                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2120                                                 }
2121                                         } else {
2122                                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2123                                         }
2124                                         if (document.getElementById('no_change_label')) {
2125                                                 var m = document.getElementById('no_change_label').getAttribute('value');
2126                                                 var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
2127                                                 document.getElementById('no_change_label').setAttribute('value', m + needs_cat + '  ');
2128                                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2129                                         }
2130                                 break;
2131                                 default:
2132                                         msg += document.getElementById('commonStrings').getString('common.error');
2133                                         var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
2134                                         msg += '\n';
2135                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
2136                                         msg += '\n';
2137                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
2138                                 break;
2139                         }
2140                         if (msg) {
2141                                 error.yns_alert(
2142                                         msg,
2143                                         document.getElementById('circStrings').getString('staff.circ.alert'),
2144                                         null,
2145                                         document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2146                                         null,
2147                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2148                                 );
2149                         }
2150                 } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
2151
2152                         var lib = data.hash.aou[ check.org ];
2153                         check.route_to = lib.shortname();
2154                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
2155                         msg += '\n\n';
2156                         msg += lib.name();
2157                         msg += '\n';
2158                         try {
2159                                 if (lib.holds_address() ) {
2160                                         var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
2161                                         if (typeof a.ilsevent != 'undefined') throw(a);
2162                                         if (a.street1()) msg += a.street1() + '\n';
2163                                         if (a.street2()) msg += a.street2() + '\n';
2164                                         msg += (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '') + '\n';
2165                                 } else {
2166                                         msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
2167                                         msg += '\n';
2168                                 }
2169                         } catch(E) {
2170                                 msg += document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
2171                                 msg += '\n';
2172                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
2173                         }
2174                         msg += '\n';
2175                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
2176                         msg += '\n';
2177                         var payload_title  = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
2178                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
2179                         msg += '\n';
2180                         var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
2181                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
2182                         msg += '\n';
2183                         JSAN.use('util.date');
2184                         if (check.payload.hold) {
2185                                 JSAN.use('patron.util');
2186                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
2187                                 msg += '\n';
2188                 if (au_obj.alias()) {
2189                     msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias',  [au_obj.alias()]);
2190                 } else {
2191                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name(), au_obj.first_given_name(), au_obj.second_given_name()]);
2192                 }
2193                                 msg += '\n';
2194                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
2195                                 msg += '\n';
2196                                 if (check.payload.hold.phone_notify()) {
2197                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
2198                                         msg += '\n';
2199                                 }
2200                                 if (get_bool(check.payload.hold.email_notify())) {
2201                                         var payload_email = au_obj.email() ? au_obj.email() : '';
2202                                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
2203                                         msg += '\n';
2204                                 }
2205                                 msg += '\n';
2206                                 msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [util.date.formatted_date(check.payload.hold.request_time(),'%F')]);
2207                                 msg += '\n';
2208                         }
2209                         var rv = 0;
2210                         msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [util.date.formatted_date(new Date(),'%F')]);
2211                         if (!auto_print) {
2212                                 rv = error.yns_alert_formatted(
2213                                         msg,
2214                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
2215                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
2216                                         document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
2217                                         null,
2218                                         document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2219                                         '/xul/server/skin/media/images/turtle.gif'
2220                                 );
2221                         }
2222
2223                         if (rv == 0) {
2224                                 try {
2225                                         JSAN.use('util.print'); var print = new util.print();
2226                                         //print.simple( msg, { 'no_prompt' : true, 'content_type' : 'text/plain' } );
2227                                         msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g,'<br/>');
2228                                         print.simple( msg , { 'no_prompt' : true, 'content_type' : 'text/html' } );
2229                                 } catch(E) {
2230                                         var err_msg = document.getElementById('commonStrings').getString('common.error');
2231                                         err_msg += '\nFIXME: ' + E + '\n';
2232                                         dump(err_msg);
2233                                         alert(err_msg);
2234                                 }
2235                         }
2236                         if (document.getElementById('no_change_label')) {
2237                                 var m = document.getElementById('no_change_label').getAttribute('value');
2238                                 var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
2239                                 document.getElementById('no_change_label').setAttribute('value', m + trans_msg + '  ');
2240                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2241                         }
2242
2243                 } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
2244
2245                         check.route_to = 'CATALOGING';
2246                         var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
2247                         error.yns_alert(
2248                                 mis_scan_msg,
2249                                 document.getElementById('circStrings').getString('staff.circ.alert'),
2250                                 null,
2251                                 document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
2252                                 null,
2253                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg')
2254                         );
2255                         if (document.getElementById('no_change_label')) {
2256                                 var m = document.getElementById('no_change_label').getAttribute('value');
2257                                 document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + '  ');
2258                                 document.getElementById('no_change_label').setAttribute('hidden','false');
2259                         }
2260
2261                 } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
2262
2263                         var rv = 0;
2264                         msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
2265                         rv = error.yns_alert_formatted(
2266                                 msg,
2267                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
2268                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
2269                                 document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
2270                                 null,
2271                                 document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
2272                                 '/xul/server/skin/media/images/stop_sign.png'
2273                         );
2274                         params.capture = rv == 0 ? 'nocapture' : 'capture';
2275
2276                         return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false); 
2277
2278                 } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
2279                         error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
2280                 } else {
2281
2282             if (check.ilsevent == null) { return null; /* handled */ }
2283                         switch (Number(check.ilsevent)) {
2284                                 case 1203 /* COPY_BAD_STATUS */ :
2285                                 case 1213 /* PATRON_BARRED */ :
2286                                 case 1217 /* PATRON_INACTIVE */ :
2287                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
2288                                 case 1234 /* ITEM_DEPOSIT_PAID */ :
2289                                 case 7009 /* CIRC_CLAIMS_RETURNED */ :
2290                                 case 7010 /* COPY_ALERT_MESSAGE */ :
2291                                 case 7011 /* COPY_STATUS_LOST */ :
2292                                 case 7012 /* COPY_STATUS_MISSING */ :
2293                                 case 7013 /* PATRON_EXCEEDS_FINES */ :
2294                                         return null; /* handled */
2295                                 break;
2296                         }
2297
2298                         throw(check);
2299
2300                 }
2301
2302                 return check;
2303         } catch(E) {
2304                 JSAN.use('util.error'); var error = new util.error();
2305                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
2306                 return null;
2307         }
2308 };
2309
2310 circ.util.renew_via_barcode = function ( barcode, patron_id, async ) {
2311         try {
2312                 var obj = {};
2313                 JSAN.use('util.network'); obj.network = new util.network();
2314                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
2315
2316                 var params = { barcode: barcode };
2317                 if (patron_id) params.patron = patron_id;
2318
2319                 function renew_callback(req) {
2320                         try {
2321                                 var renew = req.getResultObject();
2322                                 if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
2323                                 for (var j = 0; j < renew.length; j++) {
2324                                         switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
2325                                                 case 0 /* SUCCESS */ : break;
2326                                                 case null /* custom event */ : break;
2327                                                 case 5000 /* PERM_FAILURE */: break;
2328                                                 case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
2329                                                 case 1213 /* PATRON_BARRED */ : break;
2330                                                 case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
2331                                                 case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
2332                         case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
2333                         case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
2334                                             case 1234 /* ITEM_DEPOSIT_PAID */ : break;
2335                                                 case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
2336                                                 case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
2337                                                 case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
2338                                                 case 7004 /* COPY_NOT_AVAILABLE */ : break;
2339                                                 case 7006 /* COPY_IS_REFERENCE */ : break;
2340                                                 case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
2341                                                 case 7008 /* MAX_RENEWALS_REACHED */ : break;
2342                                                 case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
2343                                                 case 7010 /* COPY_ALERT_MESSAGE */ : break;
2344                                                 case 7013 /* PATRON_EXCEEDS_FINES */ : break;
2345                                                 default:
2346                                                         throw(renew);
2347                                                 break;
2348                                         }
2349                                 }
2350                                 if (typeof async == 'function') async(renew);
2351                                 return renew;
2352                         } catch(E) {
2353                                 JSAN.use('util.error'); var error = new util.error();
2354                                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2355                                 return null;
2356                         }
2357                 }
2358
2359                 var renew = obj.network.simple_request(
2360                         'CHECKOUT_RENEW',
2361                         [ ses(), params ],
2362                         async ? renew_callback : null,
2363                         {
2364                                 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
2365                                 'overridable_events' : [
2366                     null /* custom event */,
2367                                         1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
2368                                         1213 /* PATRON_BARRED */,
2369                                         1215 /* CIRC_EXCEEDS_COPY_RANGE */,
2370                     1232 /* ITEM_DEPOSIT_REQUIRED */,
2371                     1233 /* ITEM_RENTAL_FEE_REQUIRED */,
2372                                         1234 /* ITEM_DEPOSIT_PAID */,
2373                                         7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
2374                                         7003 /* COPY_CIRC_NOT_ALLOWED */,
2375                                         7004 /* COPY_NOT_AVAILABLE */,
2376                                         7006 /* COPY_IS_REFERENCE */,
2377                                         7007 /* COPY_NEEDED_FOR_HOLD */,
2378                                         7008 /* MAX_RENEWALS_REACHED */,
2379                                         7009 /* CIRC_CLAIMS_RETURNED */,
2380                                         7010 /* COPY_ALERT_MESSAGE */,
2381                                         7013 /* PATRON_EXCEEDS_FINES */,
2382                                 ],
2383                                 'text' : {
2384                                         '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2385                                         '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2386                                         '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2387                     '1232' : function(r) {
2388                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [barcode]);
2389                     },
2390                     '1233' : function(r) {
2391                         return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [barcode]);
2392                     },
2393                                         '1234' : function(r) {
2394                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
2395                                         },
2396                                         '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2397                                         '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2398                                         '7004' : function(r) {
2399                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [barcode, typeof r.payload.status() == 'object' ? r.payload.status().name() : obj.data.hash.ccs[ r.payload.status() ].name()]);
2400                                         },
2401                                         '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2402                                         '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2403                                         '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2404                                         '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); },
2405                                         '7010' : function(r) {
2406                                                 return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [barcode, r.payload]);
2407                                         },
2408                                         '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [barcode]); }
2409                                 }
2410                         }
2411                 );
2412                 if (! async ) {
2413                         return renew_callback( { 'getResultObject' : function() { return renew; } } );
2414                 }
2415
2416         } catch(E) {
2417                 JSAN.use('util.error'); var error = new util.error();
2418                 error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [barcode]), E);
2419                 return null;
2420         }
2421 };
2422
2423 dump('exiting circ/util.js\n');