]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/missing_pieces.js
Include barcode in pre-cat confirm dialog
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / circ / missing_pieces.js
1 var error;
2
3 function my_init() {
4     try {
5         if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
6         JSAN.errorLevel = "die"; // none, warn, or die
7         JSAN.addRepository('/xul/server/');
8         JSAN.use('util.error'); error = new util.error();
9         error.sdump('D_TRACE','my_init() for missing_pieces.xul');
10
11         JSAN.use('util.network');
12         var network = new util.network();
13
14         // Why the indirection of missing_pieces.xul instead of calling window.prompt in chrome/content/main/menu.js directly?
15         // So we can get free remote upgrades of the logic behind cat.util.mark_item_as_missing_pieces, since I can't call
16         // JSAN.use('cat.util'); in menu.js
17         var barcode = window.prompt(
18             $("circStrings").getString('staff.circ.missing_pieces.scan_item.prompt'),
19             '',
20             $("circStrings").getString('staff.circ.missing_pieces.scan_item.title')
21         );
22         if (!barcode) {
23             window.close();
24             return;
25         }
26
27         var copy;
28         try {
29             copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ barcode ]);
30             if (typeof copy.ilsevent != 'undefined') throw(copy); 
31             if (!copy) throw(copy);
32         } catch(E) {
33             alert($("circStrings").getFormattedString('staff.circ.missing_pieces.scan_item.error_alert', [barcode]) + '\n');
34             window.close();
35             return;
36         }
37
38         JSAN.use('cat.util');
39         cat.util.mark_item_as_missing_pieces( [ copy.id() ] );
40         window.close();
41  
42     } catch(E) {
43         try { error.standard_unexpected_error_alert('circ/missing_pieces.xul',E); } catch(F) { alert(E); }
44         window.close();
45     }
46 }
47
48