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