]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
don't need this anymore
[Evergreen.git] / Open-ILS / xul / staff_client / server / circ / util.js
1 dump('entering circ/util.js\n');
2
3 if (typeof circ == 'undefined') var circ = {};
4 circ.util = {};
5
6 circ.util.EXPORT_OK     = [ 
7         'columns', 'hold_columns', 'CHECKIN_VIA_BARCODE', 'std_map_row_to_column', 'hold_capture_via_copy_barcode'
8 ];
9 circ.util.EXPORT_TAGS   = { ':all' : circ.util.EXPORT_OK };
10
11 circ.util.columns = function(modify) {
12         
13         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
14
15         function getString(s) { return data.entities[s]; }
16
17         var c = [
18                 {
19                         'id' : 'acp_id', 'label' : getString('staff.acp_label_id'), 'flex' : 1,
20                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.id()'
21                 },
22                 {
23                         'id' : 'circ_id', 'label' : getString('staff.circ_label_id'), 'flex' : 1,
24                         'primary' : false, 'hidden' : true, 'render' : 'my.circ.id()'
25                 },
26                 {
27                         'id' : 'mvr_doc_id', 'label' : getString('staff.mvr_label_doc_id'), 'flex' : 1,
28                         'primary' : false, 'hidden' : true, 'render' : 'my.mvr.doc_id()'
29                 },
30                 {
31                         'id' : 'barcode', 'label' : getString('staff.acp_label_barcode'), 'flex' : 1,
32                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.barcode()'
33                 },
34                 {
35                         'id' : 'call_number', 'label' : getString('staff.acp_label_call_number'), 'flex' : 1,
36                         'primary' : false, 'hidden' : true, 'render' : 'if (my.acp.call_number() == -1) { "Not Cataloged"; } else { var x = obj.network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]); if (x.ilsevent) { "Not Cataloged"; } else { x.label(); } }'
37                 },
38                 {
39                         'id' : 'copy_number', 'label' : getString('staff.acp_label_copy_number'), 'flex' : 1,
40                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.copy_number()'
41                 },
42                 {
43                         'id' : 'location', 'label' : getString('staff.acp_label_location'), 'flex' : 1,
44                         'primary' : false, 'hidden' : true, 'render' : 'obj.data.hash.acpl[ my.acp.location() ].name()'
45                 },
46                 {
47                         'id' : 'loan_duration', 'label' : getString('staff.acp_label_loan_duration'), 'flex' : 1,
48                         'primary' : false, 'hidden' : true, 
49                         'render' : 'switch(my.acp.loan_duration()){ case 1: "Short"; break; case 2: "Normal"; break; case 3: "Long"; break; }'
50                 },
51                 {
52                         'id' : 'circ_lib', 'label' : getString('staff.acp_label_circ_lib'), 'flex' : 1,
53                         'primary' : false, 'hidden' : true, 'render' : 'obj.data.hash.aou[ my.acp.circ_lib() ].shortname()'
54                 },
55                 {
56                         'id' : 'fine_level', 'label' : getString('staff.acp_label_fine_level'), 'flex' : 1,
57                         'primary' : false, 'hidden' : true,
58                         'render' : 'switch(my.acp.fine_level()){ case 1: "Low"; break; case 2: "Normal"; break; case 3: "High"; break; }'
59                 },
60                 {
61                         'id' : 'deposit', 'label' : getString('staff.acp_label_deposit'), 'flex' : 1,
62                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.deposit()'
63                 },
64                 {
65                         'id' : 'deposit_amount', 'label' : getString('staff.acp_label_deposit_amount'), 'flex' : 1,
66                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.deposit_amount()'
67                 },
68                 {
69                         'id' : 'price', 'label' : getString('staff.acp_label_price'), 'flex' : 1,
70                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.price()'
71                 },
72                 {
73                         'id' : 'circ_as_type', 'label' : getString('staff.acp_label_circ_as_type'), 'flex' : 1,
74                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_as_type()'
75                 },
76                 {
77                         'id' : 'circ_modifier', 'label' : getString('staff.acp_label_circ_modifier'), 'flex' : 1,
78                         'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_modifier()'
79                 },
80                 {
81                         'id' : 'xact_start', 'label' : getString('staff.circ_label_xact_start'), 'flex' : 1,
82                         'primary' : false, 'hidden' : true, 'render' : 'my.circ.xact_start()'
83                 },
84                 {
85                         'id' : 'xact_finish', 'label' : getString('staff.circ_label_xact_finish'), 'flex' : 1,
86                         'primary' : false, 'hidden' : true, 'render' : 'my.circ.xact_finish()'
87                 },
88                 {
89                         'id' : 'due_date', 'label' : getString('staff.circ_label_due_date'), 'flex' : 1,
90                         'primary' : false, 'hidden' : true, 'render' : 'my.circ.due_date().substr(0,10)'
91                 },
92                 {
93                         'id' : 'title', 'label' : getString('staff.mvr_label_title'), 'flex' : 2,
94                         'primary' : false, 'hidden' : true, 'render' : 'try { my.mvr.title(); } catch(E) { my.acp.dummy_title(); }'
95                 },
96                 {
97                         'id' : 'author', 'label' : getString('staff.mvr_label_author'), 'flex' : 1,
98                         'primary' : false, 'hidden' : true, 'render' : 'try { my.mvr.author(); } catch(E) { my.acp.dummy_author(); }'
99                 },
100                 {
101                         'id' : 'renewal_remaining', 'label' : getString('staff.circ_label_renewal_remaining'), 'flex' : 0,
102                         'primary' : false, 'hidden' : true, 'render' : 'my.circ.renewal_remaining()'
103                 },
104                 {
105                         'id' : 'status', 'label' : getString('staff.acp_label_status'), 'flex' : 1,
106                         'primary' : false, 'hidden' : true, 'render' : 'obj.data.hash.ccs[ my.acp.status() ].name()'
107                 },
108                 {
109                         'id' : 'route_to', 'label' : 'Route To', 'flex' : 1,
110                         'primary' : false, 'hidden' : true, 'render' : 'my.route_to.toString()'
111                 },
112                 {
113                         'id' : 'message', 'label' : 'Message', 'flex' : 1,
114                         'primary' : false, 'hidden' : true, 'render' : 'my.message.toString()'
115                 }
116
117         ];
118         for (var i = 0; i < c.length; i++) {
119                 if (modify[ c[i].id ]) {
120                         for (var j in modify[ c[i].id ]) {
121                                 c[i][j] = modify[ c[i].id ][j];
122                         }
123                 }
124         }
125         return c;
126 }
127
128 circ.util.hold_columns = function(modify) {
129         
130         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
131
132         function getString(s) { return data.entities[s]; }
133
134         var c = [
135                 {
136                         'id' : 'request_time', 'label' : getString('staff.ahr_request_time_label'), 'flex' : 0,
137                         'primary' : false, 'hidden' : true,  
138                         'render' : 'my.ahr.request_time().toString().substr(0,10)'
139                 },
140                 {
141                         'id' : 'capture_time', 'label' : getString('staff.ahr_capture_time_label'), 'flex' : 1,
142                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.capture_time()'
143                 },
144                 {
145                         'id' : 'status', 'label' : getString('staff.ahr_status_label'), 'flex' : 1,
146                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.status()'
147                 },
148                 {
149                         'id' : 'hold_type', 'label' : getString('staff.ahr_hold_type_label'), 'flex' : 0,
150                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.hold_type()'
151                 },
152                 {
153                         'id' : 'pickup_lib', 'label' : getString('staff.ahr_pickup_lib_label'), 'flex' : 1,
154                         'primary' : false, 'hidden' : true,  
155                         'render' : 'obj.data.hash.aou[ my.ahr.pickup_lib() ].name()'
156                 },
157                 {
158                         'id' : 'pickup_lib_shortname', 'label' : getString('staff.ahr_pickup_lib_label'), 'flex' : 0,
159                         'primary' : false, 'hidden' : true,  
160                         'render' : 'obj.data.hash.aou[ my.ahr.pickup_lib() ].shortname()'
161                 },
162                 {
163                         'id' : 'current_copy', 'label' : getString('staff.ahr_current_copy_label'), 'flex' : 1,
164                         'primary' : false, 'hidden' : true,  'render' : 'my.acp.barcode()'
165                 },
166                 {
167                         'id' : 'email_notify', 'label' : getString('staff.ahr_email_notify_label'), 'flex' : 1,
168                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.email_notify()'
169                 },
170                 {
171                         'id' : 'expire_time', 'label' : getString('staff.ahr_expire_time_label'), 'flex' : 1,
172                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.expire_time()'
173                 },
174                 {
175                         'id' : 'fulfillment_time', 'label' : getString('staff.ahr_fulfillment_time_label'), 'flex' : 1,
176                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.fulfillment_time()'
177                 },
178                 {
179                         'id' : 'holdable_formats', 'label' : getString('staff.ahr_holdable_formats_label'), 'flex' : 1,
180                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.holdable_formats()'
181                 },
182                 {
183                         'id' : 'id', 'label' : getString('staff.ahr_id_label'), 'flex' : 1,
184                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.id()'
185                 },
186                 {
187                         'id' : 'phone_notify', 'label' : getString('staff.ahr_phone_notify_label'), 'flex' : 1,
188                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.phone_notify()'
189                 },
190                 {
191                         'id' : 'prev_check_time', 'label' : getString('staff.ahr_prev_check_time_label'), 'flex' : 1,
192                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.prev_check_time()'
193                 },
194                 {
195                         'id' : 'requestor', 'label' : getString('staff.ahr_requestor_label'), 'flex' : 1,
196                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.requestor()'
197                 },
198                 {
199                         'id' : 'selection_depth', 'label' : getString('staff.ahr_selection_depth_label'), 'flex' : 1,
200                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.selection_depth()'
201                 },
202                 {
203                         'id' : 'target', 'label' : getString('staff.ahr_target_label'), 'flex' : 1,
204                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.target()'
205                 },
206                 {
207                         'id' : 'usr', 'label' : getString('staff.ahr_usr_label'), 'flex' : 1,
208                         'primary' : false, 'hidden' : true,  'render' : 'my.ahr.usr()'
209                 },
210                 {
211                         'id' : 'title', 'label' : getString('staff.mvr_label_title'), 'flex' : 1,
212                         'primary' : false, 'hidden' : true, 'render' : 'my.mvr.title()'
213                 },
214                 {
215                         'id' : 'author', 'label' : getString('staff.mvr_label_author'), 'flex' : 1,
216                         'primary' : false, 'hidden' : true, 'render' : 'my.mvr.author()'
217                 },
218
219         ];
220         for (var i = 0; i < c.length; i++) {
221                 if (modify[ c[i].id ]) {
222                         for (var j in modify[ c[i].id ]) {
223                                 c[i][j] = modify[ c[i].id ][j];
224                         }
225                 }
226         }
227         return c;
228 }
229
230 circ.util.std_map_row_to_column = function() {
231         return function(row,col) {
232                 // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
233                 // col contains one of the objects listed above in columns
234                 
235                 // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
236                 var obj = {}; 
237                 JSAN.use('util.error'); obj.error = new util.error();
238                 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
239                 JSAN.use('util.network'); obj.network = new util.network();
240
241                 var my = row.my;
242                 var value;
243                 try { 
244                         value = eval( col.render );
245                 } catch(E) {
246                         obj.error.sdump('D_WARN','map_row_to_column: ' + E);
247                         value = '???';
248                 }
249                 return value;
250         }
251 }
252
253 circ.util.checkin_via_barcode = function(session,barcode,backdate) {
254         try {
255                 JSAN.use('util.error'); var error = new util.error();
256                 JSAN.use('util.network'); var network = new util.network();
257                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
258                 JSAN.use('util.date');
259                 if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
260
261                 var params = { 'barcode' : barcode };
262                 if (backdate) params.backdate = backdate;
263
264                 var check = network.request(
265                         api.CHECKIN_VIA_BARCODE.app,
266                         api.CHECKIN_VIA_BARCODE.method,
267                         [ session, params ]
268                 );
269
270                 while(true) { /* only loops under certain conditions */
271
272                 check.message = check.textcode;
273
274                 if (check.payload && check.payload.copy) check.copy = check.payload.copy;
275                 if (check.payload && check.payload.record) check.record = check.payload.record;
276                 if (check.payload && check.payload.circ) check.circ = check.payload.circ;
277
278                 if (!check.route_to) check.route_to = '???';
279
280                 /* SUCCESS  /  NO_CHANGE  /  ITEM_NOT_CATALOGED */
281                 if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
282                         check.route_to = data.hash.acpl[ check.copy.location() ].name();
283                         var msg = '';
284                         if (check.ilsevent == 3) msg = 'This item is already checked in.\n';
285                         if (check.ilsevent == 1202 && check.copy.status() != 11) {
286                                 msg = 'FIXME -- ITEM_NOT_CATALOGED event but copy status is '
287                                         + data.hash.ccs[ check.copy.status() ].name() + '\n';
288                         }
289                         switch(check.copy.status()) {
290                                 case 0: /* AVAILABLE */
291                                 case 7: /* RESHELVING */
292                                         if (msg) msg += 'This item needs to be routed to ' + check.route_to + '.';
293                                 break;
294                                 case 8: /* ON HOLDS SHELF */
295                                         check.route_to = 'HOLDS SHELF';
296                                         msg += 'This item needs to be routed to ' + check.route_to + '.\n';
297                                         var rv = error.yns_alert(
298                                                 msg,
299                                                 'Alert',
300                                                 "Print Hold Slip",
301                                                 "Don't Print",
302                                                 null,
303                                                 "Check here to confirm this message"
304                                         );
305                                         msg = '';
306                                 break;
307                                 case 6: /* IN TRANSIT */
308                                         check.route_to = 'TRANSIT SHELF??';
309                                         msg += ("FIXME -- I didn't think we could get here.\n");
310                                 break;
311                                 case 11: /* CATALOGING */
312                                         check.route_to = 'CATALOGING';
313                                         msg += 'This item needs to be routed to ' + check.route_to + '.';
314                                 break;
315                                 default:
316                                         msg += ("FIXME -- this case is unhandled\n");
317                                         msg += 'This item needs to be routed to ' + check.route_to + '.';
318                                 break;
319                         }
320                         if (msg) error.yns_alert(msg,'Alert',null,'OK',null,"Check here to confirm this message");
321                 }
322
323                 /* ROUTE_ITEM */
324                 if (check.ilsevent == 7000) {
325                         check.route_to = data.hash.aou[ check.org ].shortname();
326                         var rv = error.yns_alert(
327                                 'This item is in transit to ' + check.route_to + '.',
328                                 'Alert',
329                                 "Print Transit Slip",
330                                 "Don't Print",
331                                 null,
332                                 "Check here to confirm this message"
333                         );
334                 }
335
336                 /* COPY_NOT_FOUND */
337                 if (check.ilsevent == 1502) {
338                         check.copy = new acp();
339                         check.copy.barcode( barcode );
340                         check.copy.status( 11 );
341                         check.route_to = 'CATALOGING';
342                         error.yns_alert(
343                                 'The barcode was either mis-scanned or this item needs to be routed to CATALOGING.',
344                                 'Alert',
345                                 null,
346                                 'OK',
347                                 null,
348                                 "Check here to confirm this message"
349                         );
350                 }
351
352 //              /* COPY_NEEDED_FOR_HOLD */
353 //              if (check.ilsevent == 7007) {
354 //                      var rv = error.yns_alert(
355 //                              'This copy is needed to fulfill a hold.  Capture it?',
356 //                              'Alert',
357 //                              "Capture",
358 //                              "Don't Capture",
359 //                              null,
360 //                              "Check here to confirm this message"
361 //                      );
362 //                      switch(rv) {
363 //                              case 0: /* captured */
364 //
365 //                                      var hold = this.hold_capture_via_copy_barcode( session, barcode, false );
366 //                                      if (hold.ilsevent != 7007) { check = hold; continue; }
367 //                                      alert('something weird');
368 //
369 //                              break;
370 //                              case 1: /* not captured */
371 //
372 //                                      alert('case 1');
373 //
374 //                              break;
375 //                              default:
376 //                              
377 //                                      alert('case 2');
378 //
379 //                              break;
380 //                      }
381 //              }
382 //
383                 break;
384                 } /* end of while */
385 //              if (check.ilsevent != 0) {
386 //                      switch(check.ilsevent) {
387 //                              case '1': case 1: /* possible hold capture */
388 //                                      var rv = error.yns_alert(
389 //                                              check.textcode,
390 //                                              'Alert',
391 //                                              "Capture",
392 //                                              "Don't Capture",
393 //                                              null,
394 //                                              "Check here to confirm this message"
395 //                                      );
396 //                                      switch(rv) {
397 //                                              case 0: /* capture */
398 //                                              try {
399 //                                                      var check2 = this.hold_capture_via_copy_barcode( session, barcode );
400 //                                                      if (check2) {
401 //                                                              check.copy = check2.copy;
402 //                                                              check.text = check2.textcode;
403 //                                                              check.route_to = check2.route_to;
404 //                                                              JSAN.use('patron.util');
405 //                                                              var au_obj = patron.util.retrieve_au_via_id( session, check.payload.hold.usr() );
406 //                                                              alert('To Printer\n' + check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
407 //                                                                      check.record.title() + '  Author: ' + check.record.author() + 
408 //                                                                      '\r\n' + 'Route To: ' + check.route_to + '  Patron: ' + 
409 //                                                                      au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + 
410 //                                                                      au_obj.first_given_name() + '\r\n'); //FIXME
411 //
412 //                                                              /*
413 //                                                              sPrint(check.text + '<br />\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
414 //                                                                      check.record.title() + '  Author: ' + check.record.author() + 
415 //                                                                      '<br />\r\n' + 'Route To: ' + check.route_to + '  Patron: ' + 
416 //                                                                      au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + 
417 //                                                                      au_obj.first_given_name() + '<br />\r\n'
418 //                                                              );
419 //                                                              */
420 //
421 //                                                      }
422 //
423 //                                              } catch(E) { 
424 //                                                      error.sdump('D_ERROR',E + '\n'); 
425 //                                                      /* 
426 //                                                      // demo testing 
427 //                                                      check.text = 'Captured for Hold';
428 //                                                      check.route_to = 'ARL-ATH';
429 //                                                      */
430 //                                              }
431 //                                              break;
432 //                                              case 1: /* don't capture */
433 //
434 //                                                      check.text = 'Not Captured for Hold';
435 //                                              break;
436 //                                      }
437 //                              break;
438 //                              case '2': case 2: /* LOST??? */
439 //                                      JSAN.use('patron.util');
440 //                                      var au_obj = patron.util.retrieve_au_via_id( session, check.circ.usr() );
441 //                                      var msg = check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
442 //                                                      check.record.title() + '  Author: ' + check.record.author() + '\r\n' +
443 //                                                      'Patron: ' + au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' +
444 //                                                      au_obj.first_given_name();
445 //                                      var pcheck = error.yns_alert(
446 //                                              msg,
447 //                                              'Lost Item',
448 //                                              'Edit Copy & Patron',
449 //                                              "Just Continue",
450 //                                              null,
451 //                                              "Check here to confirm this message"
452 //                                      ); 
453 //                                      if (pcheck == 0) {
454 //                                              //FIXME//Re-implement
455 //                                              /*
456 //                                              var w = mw.spawn_main();
457 //                                              setTimeout(
458 //                                                      function() {
459 //                                                              mw.spawn_patron_display(w.document,'new_tab','main_tabbox',{'patron':au_obj});
460 //                                                              mw.spawn_batch_copy_editor(w.document,'new_tab','main_tabbox',
461 //                                                                      {'copy_ids':[ check.copy.id() ]});
462 //                                                      }, 0
463 //                                              );
464 //                                              */
465 //                                      }
466 //                              break;
467 //                              case '3': case 3: /* TRANSIT ELSEWHERE */
468 //                                      if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
469 //                                      var msg = check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
470 //                                                      check.record.title() + '  Author: ' + check.record.author() + 
471 //                                                      '\r\n' + 'Route To: ' + check.route_to + '\r\n';
472 //                                      var pcheck = error.yns_alert(
473 //                                              msg,
474 //                                              'Alert',
475 //                                              'Print Receipt',
476 //                                              "Don't Print",
477 //                                              null,
478 //                                              "Check here to confirm this message"
479 //                                      ); 
480 //                                      if (pcheck == 0) {
481 //                                              alert('To Printer\n' + msg); //FIXME//
482 //                                              //sPrint( msg.match( /\n/g, '<br />\r\n'), true );
483 //                                      }
484 //
485 //                              break;
486 //                              case '4': case 4: /* transit for hold is complete */
487 //                                      if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
488 //                                      var msg = check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
489 //                                                      check.record.title() + '  Author: ' + check.record.author() + 
490 //                                                      '\r\n' + 'Route To: ' + check.route_to +
491 //                                                      '\r\n';
492 //                                      var pcheck = error.yns_alert(
493 //                                              msg,
494 //                                              'Alert',
495 //                                              'Print Receipt',
496 //                                              "Don't Print",
497 //                                              null,
498 //                                              "Check here to confirm this message"
499 //                                      ); 
500 //                                      if (pcheck == 0) {
501 //                                              alert('To Printer\n' + msg); //FIXME//
502 //                                              //sPrint( msg.match( /\n/g, '<br />\r\n'), true );
503 //                                      }
504 //
505 //                              break;
506 //
507 //                              default: /* 1500 - "CIRCULATION_NOT_FOUND" */
508 //                                      if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
509 //                                      var msg = check.text + '\r\nBarcode: ' + barcode + '  Route To: ' + check.route_to;
510 //                                      var pcheck = error.yns_alert(
511 //                                              msg,
512 //                                              'Alert',
513 //                                              'Print Receipt',
514 //                                              "Don't Print",
515 //                                              null,
516 //                                              "Check here to confirm this message"
517 //                                      ); 
518 //                                      if (pcheck == 0) {
519 //                                              alert('To Printer\n' + msg); //FIXME//
520 //                                              //sPrint( msg.match( /\n/g, '<br />\r\n'), true );
521 //                                      }
522 //                              break;
523 //                      }
524 //              } else {  // ilsevent == 0
525 //              }
526                 return check;
527         } catch(E) {
528                 JSAN.use('util.error'); var error = new util.error();
529                 var msg = E + '\n---\n' + js2JSON(E);
530                 error.sdump('D_ERROR',msg);
531                 alert(msg);
532                 return null;
533         }
534 }
535
536 circ.util.hold_capture_via_copy_barcode = function ( session, barcode, retrieve_flag ) {
537         try {
538                 JSAN.use('util.network'); var network = new util.network();
539                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
540                 var params = { barcode: barcode }
541                 if (retrieve_flag) { params.flesh_record = retrieve_flag; params.flesh_copy = retrieve_flag; }
542                 var robj = network.request(
543                         api.CAPTURE_COPY_FOR_HOLD_VIA_BARCODE.app,
544                         api.CAPTURE_COPY_FOR_HOLD_VIA_BARCODE.method,
545                         [ session, params ]
546                 );
547                 var check = robj.payload;
548                 if (!check) {
549                         check = {};
550                         check.status = robj.ilsevent;
551                         check.copy = new acp(); check.copy.barcode( barcode );
552                 }
553                 check.text = robj.textcode;
554                 check.route_to = robj.route_to;
555                 //check.text = 'Captured for Hold';
556                 if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
557                 return check;
558         } catch(E) {
559                 JSAN.use('util.error'); var error = new util.error();
560                 var msg = E + '\n---\n' + js2JSON(E);
561                 error.sdump('D_ERROR',msg);
562                 alert(msg);
563                 return null;
564         }
565 }
566
567
568 dump('exiting circ/util.js\n');