]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/util.js
other conditions
[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 */
281                 if (check.ilsevent == 0) {
282                         check.route_to = data.hash.acpl[ check.copy.location() ].name();
283                 }
284
285                 /* ROUTE_ITEM */
286                 if (check.ilsevent == 7000) {
287                         check.route_to = data.hash.aou[ check.org ].shortname();
288                         var rv = error.yns_alert(
289                                 'This item is in transit to ' + check.route_to + '.',
290                                 'Alert',
291                                 null,
292                                 "OK",
293                                 null,
294                                 "Check here to confirm this message"
295                         );
296                 }
297
298                 /* CIRCULATION_NOT_FOUND */
299                 if (check.ilsevent == 1500) {
300                         if ( check.copy.circ_lib() == data.list.au[0].home_ou() ) {
301                                 if ( check.copy.dummy_title() ) {
302                                         check.route_to = 'CATALOGING';
303                                         check.copy.status( 11 );
304                                         error.yns_alert(
305                                                 'This item needs to be routed to CATALOGING.',
306                                                 'Alert',
307                                                 null,
308                                                 'OK',
309                                                 null,
310                                                 "Check here to confirm this message"
311                                         );
312                                 } else {
313                                         check.route_to = data.hash.acpl[ check.copy.location() ].name();
314                                         /* FIXME -- Do we want a dialog for this case? */
315                                 }
316                         } else {
317                                 check.route_to = data.hash.aou[ check.copy.circ_lib() ].shortname();
318                                 var rv = error.yns_alert(
319                                         'There is no circulation for this item, however, its circulating library is ' + check.route_to
320                                                 + '.\nTransit this item?',
321                                         'Alert',
322                                         "Transit",
323                                         "Don't Transit",
324                                         null,
325                                         "Check here to confirm this message"
326                                 );
327                                 switch(rv) {
328                                         case 0: /* transit */
329                                                 alert('FIXME -- make transit call here');
330                                         break;
331                                         case 1: /* don't transit */
332                                                 check.route_to += ' ?';
333                                         break;
334                                 }
335                         }
336                 }
337
338                 /* ITEM_NOT_CATALOGED */
339                 if (check.ilsevent == 1202) {
340                         check.route_to = 'CATALOGING';
341                         check.copy.status( 11 );
342                         error.yns_alert(
343                                 '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                 
353                 /* COPY_NOT_FOUND */
354                 if (check.ilsevent == 1502) {
355                         check.copy = new acp();
356                         check.copy.barcode( barcode );
357                         check.copy.status( 11 );
358                         check.route_to = 'CATALOGING';
359                         error.yns_alert(
360                                 'The barcode was either mis-scanned or this item needs to be routed to CATALOGING.',
361                                 'Alert',
362                                 null,
363                                 'OK',
364                                 null,
365                                 "Check here to confirm this message"
366                         );
367                 }
368
369                 /* COPY_NEEDED_FOR_HOLD */
370                 if (check.ilsevent == 7007) {
371                         var rv = error.yns_alert(
372                                 'This copy is needed to fulfill a hold.  Capture it?',
373                                 'Alert',
374                                 "Capture",
375                                 "Don't Capture",
376                                 null,
377                                 "Check here to confirm this message"
378                         );
379                         switch(rv) {
380                                 case 0: /* captured */
381
382                                         var hold = this.hold_capture_via_copy_barcode( session, barcode, false );
383                                         if (hold.ilsevent != 7007) { check = hold; continue; }
384                                         alert('something weird');
385
386                                 break;
387                                 case 1: /* not captured */
388
389                                         alert('case 1');
390
391                                 break;
392                                 default:
393                                 
394                                         alert('case 2');
395
396                                 break;
397                         }
398                 }
399
400                 break;
401                 } /* end of while */
402 //              if (check.ilsevent != 0) {
403 //                      switch(check.ilsevent) {
404 //                              case '1': case 1: /* possible hold capture */
405 //                                      var rv = error.yns_alert(
406 //                                              check.textcode,
407 //                                              'Alert',
408 //                                              "Capture",
409 //                                              "Don't Capture",
410 //                                              null,
411 //                                              "Check here to confirm this message"
412 //                                      );
413 //                                      switch(rv) {
414 //                                              case 0: /* capture */
415 //                                              try {
416 //                                                      var check2 = this.hold_capture_via_copy_barcode( session, barcode );
417 //                                                      if (check2) {
418 //                                                              check.copy = check2.copy;
419 //                                                              check.text = check2.textcode;
420 //                                                              check.route_to = check2.route_to;
421 //                                                              JSAN.use('patron.util');
422 //                                                              var au_obj = patron.util.retrieve_au_via_id( session, check.payload.hold.usr() );
423 //                                                              alert('To Printer\n' + check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
424 //                                                                      check.record.title() + '  Author: ' + check.record.author() + 
425 //                                                                      '\r\n' + 'Route To: ' + check.route_to + '  Patron: ' + 
426 //                                                                      au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + 
427 //                                                                      au_obj.first_given_name() + '\r\n'); //FIXME
428 //
429 //                                                              /*
430 //                                                              sPrint(check.text + '<br />\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
431 //                                                                      check.record.title() + '  Author: ' + check.record.author() + 
432 //                                                                      '<br />\r\n' + 'Route To: ' + check.route_to + '  Patron: ' + 
433 //                                                                      au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + 
434 //                                                                      au_obj.first_given_name() + '<br />\r\n'
435 //                                                              );
436 //                                                              */
437 //
438 //                                                      }
439 //
440 //                                              } catch(E) { 
441 //                                                      error.sdump('D_ERROR',E + '\n'); 
442 //                                                      /* 
443 //                                                      // demo testing 
444 //                                                      check.text = 'Captured for Hold';
445 //                                                      check.route_to = 'ARL-ATH';
446 //                                                      */
447 //                                              }
448 //                                              break;
449 //                                              case 1: /* don't capture */
450 //
451 //                                                      check.text = 'Not Captured for Hold';
452 //                                              break;
453 //                                      }
454 //                              break;
455 //                              case '2': case 2: /* LOST??? */
456 //                                      JSAN.use('patron.util');
457 //                                      var au_obj = patron.util.retrieve_au_via_id( session, check.circ.usr() );
458 //                                      var msg = check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
459 //                                                      check.record.title() + '  Author: ' + check.record.author() + '\r\n' +
460 //                                                      'Patron: ' + au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' +
461 //                                                      au_obj.first_given_name();
462 //                                      var pcheck = error.yns_alert(
463 //                                              msg,
464 //                                              'Lost Item',
465 //                                              'Edit Copy & Patron',
466 //                                              "Just Continue",
467 //                                              null,
468 //                                              "Check here to confirm this message"
469 //                                      ); 
470 //                                      if (pcheck == 0) {
471 //                                              //FIXME//Re-implement
472 //                                              /*
473 //                                              var w = mw.spawn_main();
474 //                                              setTimeout(
475 //                                                      function() {
476 //                                                              mw.spawn_patron_display(w.document,'new_tab','main_tabbox',{'patron':au_obj});
477 //                                                              mw.spawn_batch_copy_editor(w.document,'new_tab','main_tabbox',
478 //                                                                      {'copy_ids':[ check.copy.id() ]});
479 //                                                      }, 0
480 //                                              );
481 //                                              */
482 //                                      }
483 //                              break;
484 //                              case '3': case 3: /* TRANSIT ELSEWHERE */
485 //                                      if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
486 //                                      var msg = check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
487 //                                                      check.record.title() + '  Author: ' + check.record.author() + 
488 //                                                      '\r\n' + 'Route To: ' + check.route_to + '\r\n';
489 //                                      var pcheck = error.yns_alert(
490 //                                              msg,
491 //                                              'Alert',
492 //                                              'Print Receipt',
493 //                                              "Don't Print",
494 //                                              null,
495 //                                              "Check here to confirm this message"
496 //                                      ); 
497 //                                      if (pcheck == 0) {
498 //                                              alert('To Printer\n' + msg); //FIXME//
499 //                                              //sPrint( msg.match( /\n/g, '<br />\r\n'), true );
500 //                                      }
501 //
502 //                              break;
503 //                              case '4': case 4: /* transit for hold is complete */
504 //                                      if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
505 //                                      var msg = check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + 
506 //                                                      check.record.title() + '  Author: ' + check.record.author() + 
507 //                                                      '\r\n' + 'Route To: ' + check.route_to +
508 //                                                      '\r\n';
509 //                                      var pcheck = error.yns_alert(
510 //                                              msg,
511 //                                              'Alert',
512 //                                              'Print Receipt',
513 //                                              "Don't Print",
514 //                                              null,
515 //                                              "Check here to confirm this message"
516 //                                      ); 
517 //                                      if (pcheck == 0) {
518 //                                              alert('To Printer\n' + msg); //FIXME//
519 //                                              //sPrint( msg.match( /\n/g, '<br />\r\n'), true );
520 //                                      }
521 //
522 //                              break;
523 //
524 //                              default: /* 1500 - "CIRCULATION_NOT_FOUND" */
525 //                                      if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
526 //                                      var msg = check.text + '\r\nBarcode: ' + barcode + '  Route To: ' + check.route_to;
527 //                                      var pcheck = error.yns_alert(
528 //                                              msg,
529 //                                              'Alert',
530 //                                              'Print Receipt',
531 //                                              "Don't Print",
532 //                                              null,
533 //                                              "Check here to confirm this message"
534 //                                      ); 
535 //                                      if (pcheck == 0) {
536 //                                              alert('To Printer\n' + msg); //FIXME//
537 //                                              //sPrint( msg.match( /\n/g, '<br />\r\n'), true );
538 //                                      }
539 //                              break;
540 //                      }
541 //              } else {  // ilsevent == 0
542 //              }
543                 return check;
544         } catch(E) {
545                 JSAN.use('util.error'); var error = new util.error();
546                 var msg = E + '\n---\n' + js2JSON(E);
547                 error.sdump('D_ERROR',msg);
548                 alert(msg);
549                 return null;
550         }
551 }
552
553 circ.util.hold_capture_via_copy_barcode = function ( session, barcode, retrieve_flag ) {
554         try {
555                 JSAN.use('util.network'); var network = new util.network();
556                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
557                 var params = { barcode: barcode }
558                 if (retrieve_flag) { params.flesh_record = retrieve_flag; params.flesh_copy = retrieve_flag; }
559                 var robj = network.request(
560                         api.CAPTURE_COPY_FOR_HOLD_VIA_BARCODE.app,
561                         api.CAPTURE_COPY_FOR_HOLD_VIA_BARCODE.method,
562                         [ session, params ]
563                 );
564                 var check = robj.payload;
565                 if (!check) {
566                         check = {};
567                         check.status = robj.ilsevent;
568                         check.copy = new acp(); check.copy.barcode( barcode );
569                 }
570                 check.text = robj.textcode;
571                 check.route_to = robj.route_to;
572                 //check.text = 'Captured for Hold';
573                 if (parseInt(check.route_to)) check.route_to = data.hash.aou[ check.route_to ].shortname();
574                 return check;
575         } catch(E) {
576                 JSAN.use('util.error'); var error = new util.error();
577                 var msg = E + '\n---\n' + js2JSON(E);
578                 error.sdump('D_ERROR',msg);
579                 alert(msg);
580                 return null;
581         }
582 }
583
584
585 dump('exiting circ/util.js\n');