]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/circ/offline.js
template tweaks
[working/Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / circ / offline.js
1 dump('entering circ.offline.js\n');
2
3 if (typeof circ == 'undefined') circ = {};
4 circ.offline = function (params) {
5         try {
6                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7                 JSAN.use('util.error'); this.error = new util.error();
8         } catch(E) {
9                 dump('circ.offline: ' + E + '\n');
10         }
11 }
12
13 circ.offline.prototype = {
14
15         'init' : function( params ) {
16
17                 try {
18                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
19
20                         var obj = this;
21
22                         JSAN.use('util.deck'); obj.deck = new util.deck('main');
23
24                         JSAN.use('util.controller'); obj.controller = new util.controller();
25                         obj.controller.init(
26                                 {
27                                         control_map : {
28                                                 'cmd_broken' : [
29                                                         ['command'],
30                                                         function() { alert('Not Yet Implemented'); }
31                                                 ],
32                                                 'cmd_checkout' : [
33                                                         ['command'],
34                                                         function() { obj.deck.set_iframe('offline_checkout.xul',{},{}); }
35                                                 ],
36                                                 'cmd_renew' : [
37                                                         ['command'],
38                                                         function() { obj.deck.set_iframe('offline_renew.xul',{},{}); }
39                                                 ],
40                                                 'cmd_in_house_use' : [
41                                                         ['command'],
42                                                         function() { obj.deck.set_iframe('offline_in_house_use.xul',{},{}); }
43                                                 ],
44                                                 'cmd_checkin' : [
45                                                         ['command'],
46                                                         function() { obj.deck.set_iframe('offline_checkin.xul',{},{}); }
47                                                 ],
48                                                 'cmd_register_patron' : [
49                                                         ['command'],
50                                                         function() { obj.deck.set_iframe('offline_register.xul',{},{}); }
51                                                 ],
52                                                 'cmd_print_last_receipt' : [
53                                                         ['command'],
54                                                         function() { 
55                                                                 JSAN.use('util.print'); var print = new util.print();
56                                                                 print.reprint_last();
57                                                         }
58                                                 ],
59                                                 'cmd_exit' : [
60                                                         ['command'],
61                                                         function() { window.close(); }
62                                                 ],
63                                         }
64                                 }
65                         );
66
67                         obj.receipt_init();
68
69                         obj.patron_init();
70
71                 } catch(E) {
72                         this.error.sdump('D_ERROR','circ.offline.init: ' + E + '\n');
73                 }
74         },
75
76         'receipt_init' : function() {
77                 function backup_receipt_templates() {
78                         data.print_list_templates = {
79                                 'offline_checkout' : {
80                                         'type' : 'offline_checkout',
81                                         'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
82                                         'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
83                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
84                                 },
85                                 'offline_checkin' : {
86                                         'type' : 'offline_checkin',
87                                         'header' : 'You checked in the following items:<hr/><ol>',
88                                         'line_item' : '<li>Barcode: %barcode%\r\n',
89                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
90                                 },
91                                 'offline_renew' : {
92                                         'type' : 'offline_renew',
93                                         'header' : 'You renewed the following items:<hr/><ol>',
94                                         'line_item' : '<li>Barcode: %barcode%\r\n',
95                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
96                                 },
97                                 'offline_inhouse_use' : {
98                                         'type' : 'offline_inhouse_use',
99                                         'header' : 'You marked the following in-house items used:<hr/><ol>',
100                                         'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
101                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
102                                 },
103                         };
104                         data.stash('print_list_templates');
105                 }
106
107                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
108                 JSAN.use('util.file'); var file = new util.file('print_list_templates');
109                 if (file._file.exists()) {
110                         try {
111                                 var x = file.get_object();
112                                 if (x) {
113                                         data.print_list_templates = x;
114                                         data.stash('print_list_templates');
115                                 } else {
116                                         backup_receipt_templates();
117                                 }
118                         } catch(E) {
119                                 alert(E);
120                                 backup_receipt_templates();
121                         }
122                 } else {
123                         backup_receipt_templates();
124                 }
125                 file.close();
126         },
127
128         'patron_init' : function() {
129                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
130                 JSAN.use('util.file'); var file = new util.file('offline_patron_list');
131                 if (file._file.exists()) {
132                         var lines = file.get_content().split(/\n/);
133                         var hash = {};
134                         for (var i = 0; i < lines.length; i++) {
135                                 hash[ lines[i].split(/\s+/)[0] ] = lines[i].split(/\s+/)[1];
136                         }
137                         delete(lines);
138                         data.bad_patrons = hash;
139                         data.stash('bad_patrons');
140                         var file2 = new util.file('offline_patron_list.date');
141                         if (file2._file.exists()) {
142                                 data.bad_patrons_date = file2.get_content();
143                                 data.stash('bad_patrons_date');
144                         }
145                         file2.close();
146                 } else {
147                         data.bad_patrons = {};
148                         data.stash('bad_patrons');
149                 }
150                 file.close();
151         },
152
153 }
154
155 dump('exiting circ.offline.js\n');