1 dump('entering patron/display.js\n');
3 if (typeof patron == 'undefined') patron = {};
4 patron.display = function (params) {
6 JSAN.use('util.error'); this.error = new util.error();
7 JSAN.use('util.window'); this.window = new util.window();
8 JSAN.use('util.network'); this.network = new util.network();
12 patron.display.prototype = {
14 'init' : function( params ) {
18 obj.session = params['session'];
19 obj.barcode = params['barcode'];
21 JSAN.use('OpenILS.data'); this.OpenILS = {};
22 obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
24 JSAN.use('util.deck');
25 obj.right_deck = new util.deck('patron_right_deck');
26 obj.left_deck = new util.deck('patron_left_deck');
28 function spawn_checkout_interface() {
29 obj.right_deck.set_iframe(
31 + '?session=' + window.escape( obj.session )
32 + '&patron_id=' + window.escape( obj.patron.id() ),
35 'on_checkout' : function(checkout) {
36 var c = obj.summary_window.g.summary.patron.checkouts();
38 obj.summary_window.g.summary.patron.checkouts( c );
39 obj.summary_window.g.summary.controller.render('patron_checkouts');
43 dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
46 JSAN.use('util.controller'); obj.controller = new util.controller();
52 function() { alert('Not Yet Implemented'); }
54 'cmd_patron_refresh' : [
57 obj.controller.view.patron_name.setAttribute(
58 'value','Retrieving...'
60 try { obj.summary_window.refresh(); } catch(E) { dump(E + '\n'); }
61 try { obj.refresh_deck(); } catch(E) { dump(E + '\n'); }
64 'cmd_patron_checkout' : [
66 spawn_checkout_interface
68 'cmd_patron_items' : [
71 obj.right_deck.set_iframe(
72 urls.remote_patron_items
73 + '?session=' + window.escape( obj.session )
74 + '&patron_id=' + window.escape( obj.patron.id() ),
77 'checkouts' : obj.patron.checkouts()
80 dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
83 'cmd_patron_holds' : [
86 obj.right_deck.set_iframe(
87 urls.remote_patron_holds
88 + '?session=' + window.escape( obj.session )
89 + '&patron_id=' + window.escape( obj.patron.id() ),
92 //FIXME//'holds' : obj.patron.holds()
95 dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
98 'cmd_patron_bills' : [
101 obj.right_deck.set_iframe(
102 urls.remote_patron_bills
103 + '?session=' + window.escape( obj.session )
104 + '&patron_id=' + window.escape( obj.patron.id() ),
107 //FIXME//'bills' : obj.patron.bills()
110 dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
113 'cmd_patron_edit' : [
116 obj.right_deck.set_iframe(
117 urls.remote_patron_edit
118 + '?ses=' + window.escape( obj.session )
119 + '&usr=' + window.escape( obj.patron.id() ),
122 dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
125 'cmd_patron_info' : [
128 obj.right_deck.set_iframe(urls.remote_patron_info);
129 dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
136 e.setAttribute('value',
137 obj.patron.family_name() + ', ' + obj.patron.first_given_name()
139 e.setAttribute('style','background-color: lime');
140 if (obj.summary_window) {
141 //FIXME//bills should become a virtual field
142 if (obj.summary_window.g.summary.patron.bills.length > 0)
143 e.setAttribute('style','background-color: yellow');
144 if (obj.summary_window.g.summary.patron.standing() == 2)
145 e.setAttribute('style','background-color: lightred');
162 obj.controller.view.PatronNavBar.selectedIndex = 1;
163 obj.controller.view.cmd_patron_refresh.setAttribute('disabled','true');
164 obj.controller.view.cmd_patron_checkout.setAttribute('disabled','true');
165 obj.controller.view.cmd_patron_items.setAttribute('disabled','true');
166 obj.controller.view.cmd_patron_holds.setAttribute('disabled','true');
167 obj.controller.view.cmd_patron_bills.setAttribute('disabled','true');
168 obj.controller.view.cmd_patron_edit.setAttribute('disabled','true');
169 obj.controller.view.cmd_patron_info.setAttribute('disabled','true');
170 obj.controller.view.patron_name.setAttribute('value','Retrieving...');
171 var frame = obj.left_deck.set_iframe(
172 urls.remote_patron_summary
173 +'?session=' + window.escape(obj.session)
174 +'&barcode=' + window.escape(obj.barcode),
177 'on_finished' : function(patron) {
178 obj.patron = patron; obj.controller.render();
179 obj.controller.view.cmd_patron_refresh.setAttribute('disabled','false');
180 obj.controller.view.cmd_patron_checkout.setAttribute('disabled','false');
181 obj.controller.view.cmd_patron_items.setAttribute('disabled','false');
182 obj.controller.view.cmd_patron_holds.setAttribute('disabled','false');
183 obj.controller.view.cmd_patron_bills.setAttribute('disabled','false');
184 obj.controller.view.cmd_patron_edit.setAttribute('disabled','false');
185 obj.controller.view.cmd_patron_info.setAttribute('disabled','false');
186 if (!obj._checkout_spawned) {
187 spawn_checkout_interface();
188 obj._checkout_spawned = true;
193 obj.summary_window = frame.contentWindow;
195 obj.controller.view.PatronNavBar.selectedIndex = 0;
196 var form_frame = obj.left_deck.set_iframe(
197 urls.remote_patron_search_form
198 +'?session=' + window.escape(obj.session),
201 'on_submit' : function(query) {
202 var list_frame = obj.right_deck.reset_iframe(
203 urls.remote_patron_search_result
204 +'?session=' + window.escape(obj.session) + '&' + query,
209 obj.search_result = list_frame.contentWindow;
213 obj.search_window = form_frame.contentWindow;
214 obj._checkout_spawned = true;
218 '_checkout_spawned' : false,
220 'refresh_deck' : function() {
222 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
223 for (var i = 0; i < obj.right_deck.node.childNodes.length; i++) {
226 var f = obj.right_deck.node.childNodes[i];
227 var w = f.contentWindow;
228 if (typeof w.refresh == 'function') {
233 dump('refresh_deck: ' + E + '\n');
239 dump('exiting patron/display.js\n');