]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/circ/offline.js
d3cc499d93816a7857cda5ba9028180ac1ff3d83
[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() {
35                                 obj.deck.set_iframe(
36                                     'offline_checkout.xul',
37                                     {},
38                                     {
39                                         'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
40                                         'unlock' : oils_unlock_page
41                                     }
42                                 );
43                             }
44                         ],
45                         'cmd_renew' : [
46                             ['command'],
47                             function() {
48                                 obj.deck.set_iframe(
49                                     'offline_renew.xul',
50                                     {},
51                                     {
52                                         'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
53                                         'unlock' : oils_unlock_page
54                                     }
55                                 );
56                             }
57                         ],
58                         'cmd_in_house_use' : [
59                             ['command'],
60                             function() {
61                                 obj.deck.set_iframe(
62                                     'offline_in_house_use.xul',
63                                     {},
64                                     {
65                                         'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
66                                         'unlock' : oils_unlock_page
67                                     }
68                                 );
69                             }
70                         ],
71                         'cmd_checkin' : [
72                             ['command'],
73                             function() {
74                                 obj.deck.set_iframe(
75                                     'offline_checkin.xul',
76                                     {},
77                                     {
78                                         'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
79                                         'unlock' : oils_unlock_page
80                                     }
81                                 );
82                             }
83                         ],
84                         'cmd_register_patron' : [
85                             ['command'],
86                             function() {
87                                 obj.deck.set_iframe(
88                                     'offline_register.xul',
89                                     {},
90                                     {
91                                         'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
92                                         'unlock' : oils_unlock_page
93                                     }
94                                 );
95                             }
96                         ],
97                         'cmd_print_last_receipt' : [
98                             ['command'],
99                             function() { 
100                                 JSAN.use('util.print'); var print = new util.print('offline');
101                                 print.reprint_last();
102                             }
103                         ],
104                         'cmd_exit' : [
105                             ['command'],
106                             function() {
107                                 try {
108                                     xulG.close_tab();
109                                 } catch(E) {
110                                     JSAN.use('util.widgets');
111                                     util.widgets.dispatch('close',window);
112                                 }
113                             }
114                         ],
115                     }
116                 }
117             );
118
119             obj.receipt_init();
120
121             obj.patron_init();
122
123         } catch(E) {
124             this.error.sdump('D_ERROR','circ.offline.init: ' + E + '\n');
125         }
126     },
127
128     'receipt_init' : function() {
129         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
130         data.print_list_defaults();
131         data.load_saved_print_templates();
132         data.fetch_print_strategy();
133         JSAN.use('util.print'); (new util.print('offline')).GetPrintSettings();
134     },
135
136     'patron_init' : function() {
137         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
138         JSAN.use('util.file'); var file = new util.file('offline_patron_list');
139         if (file._file.exists()) {
140             var lines = file.get_content().split(/\n/);
141             var hash = {};
142             for (var i = 0; i < lines.length; i++) {
143                 hash[ lines[i].split(/\s+/)[0] ] = lines[i].split(/\s+/)[1];
144             }
145             delete(lines);
146             data.bad_patrons = hash;
147             data.stash('bad_patrons');
148             var file2 = new util.file('offline_patron_list.date');
149             if (file2._file.exists()) {
150                 data.bad_patrons_date = file2.get_content();
151                 data.stash('bad_patrons_date');
152             }
153             file2.close();
154         } else {
155             data.bad_patrons = {};
156             data.stash('bad_patrons');
157         }
158         file.close();
159     },
160
161 }
162
163 dump('exiting circ.offline.js\n');