]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/display.js
Simple in-client "activity log" interface (Admin -> Local Administration -> Work...
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / patron / display.js
1 dump('entering patron/display.js\n');
2
3 function $(id) { return document.getElementById(id); }
4
5 if (typeof patron == 'undefined') patron = {};
6 patron.display = function (params) {
7
8         JSAN.use('util.error'); this.error = new util.error();
9         JSAN.use('util.window'); this.window = new util.window();
10         JSAN.use('util.network'); this.network = new util.network();
11         this.w = window;
12 }
13
14 patron.display.prototype = {
15
16         'retrieve_ids' : [],
17         'stop_checkouts' : false,
18         'check_stop_checkouts' : function() { return this.stop_checkouts; },
19
20         'init' : function( params ) {
21
22                 var obj = this;
23
24                 obj.barcode = params['barcode'];
25                 obj.id = params['id'];
26
27                 JSAN.use('OpenILS.data'); this.OpenILS = {}; 
28                 obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
29                 
30                 //var horizontal_interface = String( obj.OpenILS.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
31                 //document.getElementById('ui.circ.patron_summary.horizontal').setAttribute('orient', horizontal_interface ? 'vertical' : 'horizontal');
32                 //document.getElementById('pdms1').setAttribute('orient', horizontal_interface ? 'vertical' : 'horizontal');
33                 
34                 JSAN.use('util.deck'); 
35                 obj.right_deck = new util.deck('patron_right_deck');
36                 obj.left_deck = new util.deck('patron_left_deck');
37
38                 function spawn_checkout_interface() {
39                     try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_checkout" ) ); } catch(E) {};
40                 obj.reset_nav_styling('cmd_patron_checkout',true);
41                         var frame = obj.right_deck.set_iframe(
42                                 urls.XUL_CHECKOUT,
43                                 {},
44                                 { 
45                                         'set_tab' : xulG.set_tab,
46                                         'patron_id' : obj.patron.id(),
47                     'patron' : obj.patron,
48                                         'check_stop_checkouts' : function() { return obj.check_stop_checkouts(); },
49                                         'on_list_change' : function(checkout) {
50                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
51                                                 var x = obj.summary_window.g.summary.controller.view.patron_checkouts;
52                                                 var n = Number(x.getAttribute('value'));
53                                                 x.setAttribute('value',n+1);
54                                         },
55                                         'on_list_change_old' : function(checkout) {
56                                         
57                                                 /* this stops noncats from getting pushed into Items Out */
58                                                 if (!checkout.circ.id()) return; 
59
60                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
61                                                 obj.summary_window.g.summary.controller.render('patron_checkouts');
62                                                 obj.summary_window.g.summary.controller.render('patron_standing_penalties');
63                                                 if (obj.items_window) {
64                                                         obj.items_window.g.items.list.append(
65                                                                 {
66                                                                         'row' : {
67                                                                                 'my' : {
68                                                                                         'circ_id' : checkout.circ.id()
69                                                                                 }
70                                                                         }
71                                                                 }
72                                                         )
73                                                 }
74                                         }
75                                 }
76                         );
77                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
78                         obj.checkout_window = get_contentWindow(frame);
79                 }
80
81                 JSAN.use('util.controller'); obj.controller = new util.controller();
82                 obj.controller.init(
83                         {
84                                 control_map : {
85                                         'cmd_broken' : [
86                                                 ['command'],
87                                                 function() { alert($("commonStrings").getString('common.unimplemented')); }
88                                         ],
89                                         'cmd_patron_retrieve' : [
90                                                 ['command'],
91                                                 function(ev) {
92                                                         if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
93                                                                 for (var i = 0; i < obj.retrieve_ids.length; i++) {     
94                                                                         try {
95                                                                                 window.xulG.new_patron_tab(
96                                                                                         {}, { 'id' : obj.retrieve_ids[i] }
97                                                                                 );
98                                                                         } catch(E) {
99                                                                                 alert(E);
100                                                                         }
101                                                                 }
102                                                         }
103                                                 }
104                                         ],
105                     'cmd_patron_merge' : [
106                         ['command'],
107                         function(ev) {
108                             JSAN.use('patron.util');
109                             if (patron.util.merge( obj.retrieve_ids )) {
110                                 obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true');
111                                 obj.controller.view.cmd_patron_merge.setAttribute('disabled','true');
112                                 var sobj = obj.search_result.g.search_result;
113                                 if ( sobj.query ) { sobj.search( sobj.query ); }
114                             }
115                         }
116                     ],
117                     'cmd_patron_toggle_summary' : [
118                         ['command'],
119                         function(ev) {
120                             document.getElementById('splitter_grippy').doCommand();
121                         }
122                     ],
123                     'cmd_patron_delete' : [
124                         ['command'],
125                         function(ev) {
126                             try {
127                                 if (get_bool( obj.patron.super_user() )) {
128                                     alert($("patronStrings").getString('staff.patron.display.cmd_patron_delete.deny_deletion_of_super_user'));
129                                     return;
130                                 }
131                                 if (obj.patron.id() == obj.OpenILS.data.list.au[0].id()) {
132                                     alert($("patronStrings").getString('staff.patron.display.cmd_patron_delete.deny_deletion_of_self'));
133                                     return;
134                                 }
135                                 var rv = obj.error.yns_alert_original(
136                                     $("patronStrings").getString('staff.patron.display.cmd_patron_delete.dialog.message'),
137                                     $("patronStrings").getString('staff.patron.display.cmd_patron_delete.dialog.title'),
138                                     $("patronStrings").getString('staff.patron.display.cmd_patron_delete.dialog.okay'),
139                                     $("patronStrings").getString('staff.patron.display.cmd_patron_delete.dialog.cancel'),
140                                     null,
141                                     $("patronStrings").getString('staff.patron.display.cmd_patron_delete.dialog.confirmation')
142                                 );
143                                 //alert('rv = ' + rv + ' (' + typeof rv + ')');
144                                 if (rv == 0) {
145                                     obj.network.simple_request(
146                                         'FM_AU_DELETE',
147                                         [ ses(), obj.patron.id() ]
148                                     );
149                                 }
150                                 obj.refresh_all();
151                             } catch(E) {
152                                 obj.error.standard_unexpected_error_alert('Error in server/patron/display.js -> cmd_patron_delete: ',E);
153                             }
154                         }
155                     ],
156                                         'cmd_search_form' : [
157                                                 ['command'],
158                                                 function(ev) {
159                                                         obj.controller.view.cmd_search_form.setAttribute('disabled','true');
160                                                         obj.left_deck.node.selectedIndex = 0;
161                                                         obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.cmd_search_form.no_patron'));
162                                                         removeCSSClass(document.documentElement,'PATRON_HAS_BILLS');
163                                                         removeCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
164                                                         removeCSSClass(document.documentElement,'PATRON_HAS_NOTES');
165                                                         removeCSSClass(document.documentElement,'PATRON_EXCEEDS_CHECKOUT_COUNT');
166                                                         removeCSSClass(document.documentElement,'PATRON_EXCEEDS_OVERDUE_COUNT');
167                                                         removeCSSClass(document.documentElement,'PATRON_EXCEEDS_FINES');
168                                                         removeCSSClass(document.documentElement,'NO_PENALTIES');
169                                                         removeCSSClass(document.documentElement,'ONE_PENALTY');
170                                                         removeCSSClass(document.documentElement,'MULTIPLE_PENALTIES');
171                                                         removeCSSClass(document.documentElement,'PATRON_HAS_ALERT');
172                                                         removeCSSClass(document.documentElement,'PATRON_BARRED');
173                                                         removeCSSClass(document.documentElement,'PATRON_INACTIVE');
174                                                         removeCSSClass(document.documentElement,'PATRON_EXPIRED');
175                                                         removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_DOB');
176                                                         removeCSSClass(document.documentElement,'PATRON_JUVENILE');
177                                                         removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
178                                                         removeCSSClass(document.documentElement,'PATRON_AGE_GE_65');
179                                                         removeCSSClass(document.documentElement,'PATRON_AGE_LT_65');
180                                                         removeCSSClass(document.documentElement,'PATRON_AGE_GE_24');
181                                                         removeCSSClass(document.documentElement,'PATRON_AGE_LT_24');
182                                                         removeCSSClass(document.documentElement,'PATRON_AGE_GE_21');
183                                                         removeCSSClass(document.documentElement,'PATRON_AGE_LT_21');
184                                                         removeCSSClass(document.documentElement,'PATRON_AGE_GE_18');
185                                                         removeCSSClass(document.documentElement,'PATRON_AGE_LT_18');
186                                                         removeCSSClass(document.documentElement,'PATRON_AGE_GE_13');
187                                                         removeCSSClass(document.documentElement,'PATRON_AGE_LT_13');
188                                                         removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_1');
189                                                         removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_2');
190                                                         removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_3');
191                                                 }
192                                         ],
193                                         'cmd_patron_refresh' : [
194                                                 ['command'],
195                                                 function(ev) {
196                             try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_refresh" ) ); } catch(E) {};
197                                                         obj.network.simple_request(
198                                                                 'RECALCULATE_STANDING_PENALTIES',
199                                                                 [ ses(), obj.patron.id() ]
200                                                         );
201                                                         obj.refresh_all();
202                                                 }
203                                         ],
204                                         'cmd_patron_checkout' : [
205                                                 ['command'],
206                         function(ev) {
207                                     obj.reset_nav_styling('cmd_patron_checkout');
208                             spawn_checkout_interface();
209                         }
210                                         ],
211                                         'cmd_patron_items' : [
212                                                 ['command'],
213                                                 function(ev) {
214                             try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_items" ) ); } catch(E) {};
215                                                         obj.reset_nav_styling('cmd_patron_items');
216                                                         var frame = obj.right_deck.set_iframe(
217                                                                 urls.XUL_PATRON_ITEMS,
218                                                                 //+ '?patron_id=' + window.escape( obj.patron.id() ),
219                                                                 {},
220                                                                 {
221                                                                         'patron_id' : obj.patron.id(),
222                                                                         'on_list_change' : function(b) {
223                                                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
224                                                                                 obj.summary_window.g.summary.controller.render('patron_checkouts');
225                                                                                 obj.summary_window.g.summary.controller.render('patron_standing_penalties');
226                                                                                 obj.summary_window.g.summary.controller.render('patron_bill');
227                                                                                 obj.bill_window.g.bills.refresh(true);
228                                                                         },
229                                                                         'url_prefix' : xulG.url_prefix,
230                                                                         'new_tab' : xulG.new_tab,
231                                                                         'new_patron_tab' : xulG.new_patron_tab
232                                                                 }
233                                                         );
234                                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
235                                                         obj.items_window = get_contentWindow(frame);
236                                                 }
237                                         ],
238                                         'cmd_patron_edit' : [
239                                                 ['command'],
240                                                 function(ev) {
241                                 try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_edit" ) ); } catch(E) {};
242                                                                 obj.reset_nav_styling('cmd_patron_edit');
243
244                                                                 function spawn_search(s) {
245                                                                         obj.error.sdump('D_TRACE', $("commonStrings").getFormattedString('staff.patron.display.cmd_patron_edit.edit_search', [js2JSON(s)]) ); 
246                                                                         obj.OpenILS.data.stash_retrieve();
247                                                                         xulG.new_patron_tab( {}, { 'doit' : 1, 'query' : s } );
248                                                                 }
249
250                                                                 function spawn_editor(p) {
251                                                                         var url = urls.XUL_PATRON_EDIT;
252                                                                         //var param_count = 0;
253                                                                         //for (var i in p) {
254                                                                         //      if (param_count++ == 0) url += '?'; else url += '&';
255                                                                         //      url += i + '=' + window.escape(p[i]);
256                                                                         //}
257                                                                         var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER ); // + '?url=' + window.escape( url );
258                                                                         xulG.new_tab(
259                                                                                 loc, 
260                                                                                 {}, 
261                                                                                 { 
262                                                                                         'url' : url,
263                                                                                         'show_print_button' : true , 
264                                                                                         'tab_name' : $("patronStrings").getString('staff.patron.display.spawn_editor.editing_related_patron'),
265                                                                                         'passthru_content_params' : {
266                                                                                                 'spawn_search' : spawn_search,
267                                                                                                 'spawn_editor' : spawn_editor,
268                                                                                                 'url_prefix' : xulG.url_prefix,
269                                                                                                 'new_tab' : xulG.new_tab,
270                                                                                     'new_patron_tab' : xulG.new_patron_tab,
271                                                                                                 'params' : p
272                                                                                         }
273                                                                                 }
274                                                                         );
275                                                                 }
276
277                                                         obj.right_deck.set_iframe(
278                                                                 urls.XUL_REMOTE_BROWSER + '?patron_edit=1',
279                                                                 //+ '?url=' + window.escape( 
280                                                                 //      urls.XUL_PATRON_EDIT
281                                                                 //      + '?ses=' + window.escape( ses() )
282                                                                 //      + '&usr=' + window.escape( obj.patron.id() )
283                                                                 //),
284                                                                 {}, {
285                                                                         'url' : urls.XUL_PATRON_EDIT,
286                                                                         'show_print_button' : true,
287                                                                         'passthru_content_params' : {
288                                                                                 'params' : {
289                                                                                         'ses' : ses(),
290                                                                                         'usr' : obj.patron.id()
291                                                                                 },
292                                                                                 'on_save' : function(p) {
293                                                                                         try {
294                                                                                                 if (obj.barcode) obj.barcode = p.card().barcode();
295                                                                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
296                                                                                                 //obj.summary_window.g.summary.retrieve();
297                                                                                                 obj.refresh_all();
298                                                                                         } catch(E) {
299                                                                                                 alert(E);
300                                                                                         }
301                                                                                 },
302                                                                                 'spawn_search' : spawn_search,
303                                                                                 'spawn_editor' : spawn_editor,
304                                                                                 'url_prefix' : xulG.url_prefix,
305                                                                                 'new_tab' : xulG.new_tab,
306                                                                             'new_patron_tab' : xulG.new_patron_tab
307                                                                         }
308                                                                 }
309                                                         );
310                                                 }
311                                         ],
312                     'cmd_patron_other' : [
313                                                 ['command'],
314                                                 function(ev) {
315                             try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_other" ) ); } catch(E) {};
316                                                         obj.reset_nav_styling('cmd_patron_other');
317                             try { document.getElementById('PatronNavBar_other').firstChild.showPopup(); } catch(E) {};
318                         }
319                     ],
320                                         'cmd_patron_info_notes' : [
321                                                 ['command'],
322                                                 function(ev) {
323                                                         obj.right_deck.set_iframe(
324                                 urls.XUL_PATRON_INFO_NOTES,
325                                                                 {},
326                                                                 {
327                                                                         'patron_id' : obj.patron.id(),
328                                                                         'url_prefix' : xulG.url_prefix,
329                                                                         'new_tab' : xulG.new_tab,
330                                                                         'new_patron_tab' : xulG.new_patron_tab
331                                                                 }
332                                                         );
333                                                 }
334                                         ],
335                                         'cmd_patron_info_stats' : [
336                                                 ['command'],
337                                                 function(ev) {
338                                                         obj.right_deck.set_iframe(
339                                 urls.XUL_PATRON_INFO_STAT_CATS,
340                                                                 {},
341                                                                 {
342                                                                         'patron_id' : obj.patron.id(),
343                                                                         'url_prefix' : xulG.url_prefix,
344                                                                         'new_tab' : xulG.new_tab,
345                                                                         'new_patron_tab' : xulG.new_patron_tab
346                                                                 }
347                                                         );
348                                                 }
349                                         ],
350                                         'cmd_patron_info_surveys' : [
351                                                 ['command'],
352                                                 function(ev) {
353                                                         obj.right_deck.set_iframe(
354                                 urls.XUL_PATRON_INFO_SURVEYS,
355                                                                 {},
356                                                                 {
357                                                                         'patron_id' : obj.patron.id(),
358                                                                         'url_prefix' : xulG.url_prefix,
359                                                                         'new_tab' : xulG.new_tab,
360                                                                         'new_patron_tab' : xulG.new_patron_tab
361                                                                 }
362                                                         );
363                                                 }
364                                         ],
365                                         'cmd_patron_info_groups' : [
366                                                 ['command'],
367                                                 function(ev) {
368                                                         obj.right_deck.set_iframe(
369                                 urls.XUL_PATRON_INFO_GROUP,
370                                                                 {},
371                                                                 {
372                                                                         'patron_id' : obj.patron.id(),
373                                                                         'url_prefix' : xulG.url_prefix,
374                                                                         'new_tab' : xulG.new_tab,
375                                                                         'new_patron_tab' : xulG.new_patron_tab
376                                                                 }
377                                                         );
378                                                 }
379                                         ],
380                     'cmd_patron_alert' : [
381                         ['command'],
382                         function(ev) {
383                             if (obj.msg_url) {
384                                 obj.right_deck.set_iframe('data:text/html,'+obj.msg_url,{},{});
385                             } else {
386                                 obj.right_deck.set_iframe('data:text/html,<h1>' + $("patronStrings").getString('staff.patron.display.no_alerts_or_messages') + '</h1>',{},{});
387                             }
388                         }
389                     ],
390                                         'cmd_patron_exit' : [
391                                                 ['command'],
392                                                 function(ev) {
393                                                         xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
394                                                 }
395                                         ],
396                                         'cmd_patron_holds' : [
397                                                 ['command'],
398                                                 function(ev) {
399                             try {
400                                 try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_holds" ) ); } catch(E) {};
401                                 obj.reset_nav_styling('cmd_patron_holds');
402                                 obj.right_deck.set_iframe(
403                                     urls.XUL_PATRON_HOLDS,      
404                                     //+ '?patron_id=' + window.escape( obj.patron.id() ),
405                                     {},
406                                     {
407                                         'display_window' : window,
408                                         'patron_id' : obj.patron.id(),
409                                         'patron_barcode' : obj.patron.card().barcode(),
410                                         'on_list_change' : function(h) {
411                                             try {
412                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
413                                                 obj.summary_window.g.summary.controller.render('patron_holds');
414                                             } catch(E) {
415                                                 alert(E);
416                                             }
417                                         },
418                                         'url_prefix' : xulG.url_prefix,
419                                         'new_tab' : xulG.new_tab,
420                                                                             'new_patron_tab' : xulG.new_patron_tab
421                                     }
422                                 );
423                             } catch(E) {
424                                 alert(E);
425                             }
426                                                 }
427                                         ],
428                                         'cmd_patron_bills' : [
429                                                 ['command'],
430                                                 function(ev) {
431                             try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_bills" ) ); } catch(E) {};
432                                                         obj.reset_nav_styling('cmd_patron_bills');
433                                                         var f = obj.right_deck.set_iframe(
434                                                                 urls.XUL_PATRON_BILLS,
435                                                                 //+ '?patron_id=' + window.escape( obj.patron.id() ),
436                                                                 {},
437                                                                 {
438                                                                         'patron_id' : obj.patron.id(),
439                                                                         'url_prefix' : xulG.url_prefix,
440                                                                         'on_money_change' : function(b) {
441                                                                                 //alert('test');
442                                                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
443                                                                                 //obj.summary_window.g.summary.retrieve(true);
444                                                                                 //obj.items_window.g.items.retrieve(true);
445                                                                                 obj.refresh_all();
446                                                                         }
447                                                                 }
448                                                         );
449                                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
450                                                         obj.bill_window = get_contentWindow(f);
451                                                 }
452                                         ],
453                                         'patron_name' : [
454                                                 ['render'],
455                                                 function(e) {
456                                                         return function() { 
457                                                                 e.setAttribute('value',
458                                                                         ( obj.patron.prefix() ? obj.patron.prefix() + ' ' : '') + 
459                                                                         obj.patron.family_name() + ', ' + 
460                                                                         obj.patron.first_given_name() + ' ' +
461                                                                         ( obj.patron.second_given_name() ? obj.patron.second_given_name() + ' ' : '' ) +
462                                                                         ( obj.patron.suffix() ? obj.patron.suffix() : '')
463                                                                 );
464                                                                 JSAN.use('patron.util'); patron.util.set_penalty_css(obj.patron);
465                                                         };
466                                                 }
467                                         ],
468                                         'PatronNavBar' : [
469                                                 ['render'],
470                                                 function(e) {
471                                                         return function() {}
472                                                 }
473                                         ],
474                     'cmd_verify_credentials' : [
475                         ['command'],
476                         function() {
477                             var vframe = obj.right_deck.reset_iframe(
478                                 urls.XUL_VERIFY_CREDENTIALS,
479                                 {},
480                                 {
481                                     'barcode' : obj.patron.card().barcode(),
482                                     'usrname' : obj.patron.usrname()
483                                 }
484                             );
485                         } 
486                     ],
487                     'cmd_perm_editor' : [
488                         ['command'],
489                         function() {
490                              var frame = obj.right_deck.reset_iframe( urls.XUL_USER_PERM_EDITOR + '?ses=' + window.escape(ses()) + '&usr=' + obj.patron.id(), {}, {});
491                         }
492                     ],
493                     'cmd_standing_penalties' : [
494                         ['command'],
495                         function() {
496                             function penalty_interface() {
497                                 try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_messages" ) ); } catch(E) {};
498                                                             obj.reset_nav_styling('cmd_standing_penalties');
499                                 return obj.right_deck.set_iframe(
500                                     urls.XUL_STANDING_PENALTIES,
501                                     {},
502                                     {
503                                         'patron' : obj.patron,
504                                         'refresh' : function() { 
505                                             obj.refresh_all(); 
506                                         }
507                                     }
508                                 );
509                             }
510                             penalty_interface();
511                         } 
512                     ]
513                                 }
514                         }
515                 );
516
517         var x = document.getElementById("PatronNavBar_checkout");
518         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
519         var x = document.getElementById("PatronNavBar_refresh");
520         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
521         var x = document.getElementById("PatronNavBar_items");
522         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
523         var x = document.getElementById("PatronNavBar_holds");
524         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
525         var x = document.getElementById("PatronNavBar_other");
526         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
527         var x = document.getElementById("PatronNavBar_edit");
528         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
529         var x = document.getElementById("PatronNavBar_bills");
530         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
531         var x = document.getElementById("PatronNavBar_messages");
532         x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
533
534                 if (obj.barcode || obj.id) {
535                         if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
536                                 try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.display.init.retrieving_patron')); } catch(E) { alert(E); }
537                         }
538
539                         obj.controller.view.PatronNavBar.selectedIndex = 1;
540                         JSAN.use('util.widgets'); 
541                         util.widgets.enable_accesskeys_in_node_and_children(
542                                 obj.controller.view.PatronNavBar.lastChild
543                         );
544                         util.widgets.disable_accesskeys_in_node_and_children(
545                                 obj.controller.view.PatronNavBar.firstChild
546                         );
547                         obj.controller.view.cmd_patron_refresh.setAttribute('disabled','true');
548                         obj.controller.view.cmd_patron_checkout.setAttribute('disabled','true');
549                         obj.controller.view.cmd_patron_items.setAttribute('disabled','true');
550                         obj.controller.view.cmd_patron_holds.setAttribute('disabled','true');
551                         obj.controller.view.cmd_patron_bills.setAttribute('disabled','true');
552                         obj.controller.view.cmd_patron_edit.setAttribute('disabled','true');
553                         obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.init.retrieving'));
554                         document.documentElement.setAttribute('class','');
555                         var frame = obj.left_deck.set_iframe(
556                                 urls.XUL_PATRON_SUMMARY,
557                                 {},
558                                 {
559                     'display_window' : window,
560                                         'barcode' : obj.barcode,
561                                         'id' : obj.id,
562                     'refresh' : function() { obj.refresh_all(); },
563                                         'on_finished' : function(patron) {
564
565                                                 obj.patron = patron; obj.controller.render();
566
567                                                 obj.controller.view.cmd_patron_refresh.setAttribute('disabled','false');
568                                                 obj.controller.view.cmd_patron_checkout.setAttribute('disabled','false');
569                                                 obj.controller.view.cmd_patron_items.setAttribute('disabled','false');
570                                                 obj.controller.view.cmd_patron_holds.setAttribute('disabled','false');
571                                                 obj.controller.view.cmd_patron_bills.setAttribute('disabled','false');
572                                                 obj.controller.view.cmd_patron_edit.setAttribute('disabled','false');
573
574                                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
575                                                         try { 
576                                                                 window.xulG.set_tab_name(
577                                                                         $("patronStrings").getString('staff.patron.display.tab_name')
578                                                                                 + ' ' + patron.family_name() + ', ' + patron.first_given_name() + ' ' 
579                                                                                 + (patron.second_given_name() ? patron.second_given_name() : '' ) 
580                                                                 ); 
581                                                         } catch(E) { 
582                                                                 obj.error.sdump('D_ERROR',E);
583                                                         }
584                                                 }
585
586                                                 if (!obj._checkout_spawned) {
587                                                         spawn_checkout_interface();
588                                                         obj._checkout_spawned = true;
589                                                 }
590
591                                                 obj.network.simple_request(
592                                                         'FM_AHR_COUNT_RETRIEVE.authoritative',
593                                                         [ ses(), patron.id() ],
594                                                         function(req) {
595                                                                 try {
596                                                                         var msg = ''; obj.stop_checkouts = false;
597                                                                         if (patron.alert_message())
598                                                                                 msg += $("patronStrings").getFormattedString('staff.patron.display.init.network_request.alert_message', [patron.alert_message()]);
599                                                                         //alert('obj.barcode = ' + obj.barcode);
600                                                                         if (obj.barcode) {
601                                                                                 if (patron.cards()) for (var i = 0; i < patron.cards().length; i++) {
602                                                                                         //alert('card #'+i+' == ' + js2JSON(patron.cards()[i]));
603                                                                                         if ( (patron.cards()[i].barcode()==obj.barcode) && ( ! get_bool(patron.cards()[i].active()) ) ) {
604                                                                                                 msg += $("patronStrings").getString('staff.patron.display.init.network_request.inactive_card');
605                                                                                                 obj.stop_checkouts = true;
606                                                                                         }
607                                                                                 }
608                                                                         }
609                                                                         if (get_bool(patron.barred())) {
610                                                                                 msg += $("patronStrings").getString('staff.patron.display.init.network_request.account_barred');
611                                                                                 obj.stop_checkouts = true;
612                                                                         }
613                                                                         if (!get_bool(patron.active())) {
614                                                                                 msg += $("patronStrings").getString('staff.patron.display.init.network_request.account_inactive');
615                                                                                 obj.stop_checkouts = true;
616                                                                         }
617                                                                         if (patron.expire_date()) {
618                                                                                 var now = new Date();
619                                                                                 now = now.getTime()/1000;
620
621                                                                                 var expire_parts = patron.expire_date().substr(0,10).split('-');
622                                                                                 expire_parts[1] = expire_parts[1] - 1;
623
624                                                                                 var expire = new Date();
625                                                                                 expire.setFullYear(expire_parts[0], expire_parts[1], expire_parts[2]);
626                                                                                 expire = expire.getTime()/1000
627
628                                                                                 if (expire < now) {
629                                                                                         msg += $("patronStrings").getString('staff.patron.display.init.network_request.account_expired');
630                                                                                 obj.stop_checkouts = true;
631                                                                                 }
632                                                                         }
633                                                                     var penalties = obj.patron.standing_penalties();
634                                                                     for (var i = 0; i < penalties.length; i++) {
635                                         if (penalties[i].standing_penalty().block_list()) {
636                                             msg += obj.OpenILS.data.hash.aou[ penalties[i].org_unit() ].shortname() + ' : ' + penalties[i].standing_penalty().label() + '<br/>';
637                                         }
638                                     }
639                                                                         var holds = req.getResultObject();
640                                                                         if (holds.ready && holds.ready > 0) {
641                                                                                 msg += $("patronStrings").getFormattedString('staff.patron.display.init.holds_ready', [holds.ready]);
642                                                                         }
643                                                                         if (msg) {
644                                                                                 if (msg != obj.old_msg) {
645                                                                                         //obj.error.yns_alert(msg,'Alert Message','OK',null,null,'Check here to confirm this message.');
646                                                                                         document.documentElement.firstChild.focus();
647                                                                                         var data_url = window.escape("<img src='" + xulG.url_prefix('/xul/server/skin/media/images/stop_sign.png') + "'/>" + '<h1>'
648                                                                                                 + $("patronStrings").getString('staff.patron.display.init.network_request.window_title') + '</h1><blockquote><p>' + msg + '</p>\r\n\r\n<pre>'
649                                                                                                 + $("patronStrings").getString('staff.patron.display.init.network_request.window_message') + '</pre></blockquote>');
650                                                                                         obj.right_deck.set_iframe('data:text/html,'+data_url,{},{});
651                                                                                         obj.old_msg = msg;
652                                             obj.msg_url = data_url;
653                                                                                 } else {
654                                                                                         obj.error.sdump('D_TRACE',$("patronStrings").getFormattedString('staff.patron.display.init.network_request.dump_error_message', [msg]));
655                                                                                 }
656                                                                         }
657                                                                         if (obj.stop_checkouts && obj.checkout_window) {
658                                                                                 setTimeout( function() {
659                                                                                         try {
660                                                                                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
661                                                                                                 obj.checkout_window.g.checkout.check_disable();
662                                                                                         } catch(E) { }
663                                                                                 }, 1000);
664                                                                         }
665                                                                 } catch(E) {
666                                                                         obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.display.init.network_request.error_showing_alert'),E);
667                                                                 }
668                                                         }
669                                                 );
670
671                                         },
672                                         'on_error' : function(E) {
673                                                 try {
674                                                         var error;
675                                                         if (typeof E.ilsevent != 'undefined') {
676                                                                 error = E.textcode;
677                                                         } else {
678                                                                 error = js2JSON(E).substr(0,100);
679                                                         }
680                                                         location.href = urls.XUL_PATRON_BARCODE_ENTRY + '?error=' + window.escape(error);
681                                                 } catch(F) {
682                                                         alert(F);
683                                                 }
684                                         }
685                                 }
686                         );
687                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
688                         obj.summary_window = get_contentWindow(frame);
689                 } else {
690                         obj.render_search_form(params);
691                 }
692         },
693
694         'reset_nav_styling' : function(btn,dont_hide_summary) {
695         try {
696             this.controller.view.cmd_patron_checkout.setAttribute('style','');
697             this.controller.view.cmd_patron_items.setAttribute('style','');
698             this.controller.view.cmd_patron_edit.setAttribute('style','');
699             this.controller.view.cmd_patron_other.setAttribute('style','');
700             this.controller.view.cmd_patron_holds.setAttribute('style','');
701             this.controller.view.cmd_patron_bills.setAttribute('style','');
702             this.controller.view.cmd_standing_penalties.setAttribute('style','');
703             this.controller.view[ btn ].setAttribute('style','background: blue; color: white;');
704             var x = document.getElementById('splitter_grippy'); 
705             if (x && ! dont_hide_summary) {
706                 if (! this.summary_hidden_once_already ) {
707                     var first_deck = x.parentNode.previousSibling;
708                     if (! first_deck.collapsed) x.doCommand();
709                     this.summary_hidden_once_already = true;
710                 }
711             }
712         } catch(E) {
713             alert(E);
714         }
715         },
716
717         'render_search_form' : function(params) {
718                 var obj = this;
719                         if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
720                                 try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.display.render_search_form.patron_search')); } catch(E) { alert(E); }
721                         }
722
723                         obj.controller.view.PatronNavBar.selectedIndex = 0;
724                         obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true');
725                         obj.controller.view.cmd_patron_merge.setAttribute('disabled','true');
726                         obj.controller.view.cmd_search_form.setAttribute('disabled','true');
727
728                     var horizontal_interface = String( obj.OpenILS.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
729                         var loc = horizontal_interface ? urls.XUL_PATRON_HORIZONTAL_SEARCH_FORM : urls.XUL_PATRON_SEARCH_FORM; 
730                         var my_xulG = {
731                                 'clear_left_deck' : function() {
732                                         setTimeout( function() {
733                                                 obj.left_deck.clear_all_except(loc);
734                                                 obj.render_search_form(params);
735                                         }, 0);
736                                 },
737                                 'on_submit' : function(query,search_limit,search_sort) {
738                                         obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true');
739                                 obj.controller.view.cmd_patron_merge.setAttribute('disabled','true');
740                                         var list_frame = obj.right_deck.reset_iframe(
741                                                 urls.XUL_PATRON_SEARCH_RESULT, // + '?' + query,
742                                                 {},
743                                                 {
744                                                         'query' : query,
745                                                         'search_limit' : search_limit,
746                                                         'search_sort' : search_sort,
747                                                         'on_select' : function(list) {
748                                                                 if (!list) return;
749                                                                 if (list.length < 1) return;
750                                                                 obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','false');
751                                                                 if (list.length > 1) obj.controller.view.cmd_patron_merge.setAttribute('disabled','false');
752                                                                 obj.controller.view.cmd_search_form.setAttribute('disabled','false');
753                                                                 obj.retrieve_ids = list;
754                                                                 obj.controller.view.patron_name.setAttribute('value',$("patronStrings").getString('staff.patron.display.init.retrieving'));
755                                                                 document.documentElement.setAttribute('class','');
756                                                                 setTimeout(
757                                                                         function() {
758                                                                                 var frame = obj.left_deck.set_iframe(
759                                                                                         urls.XUL_PATRON_SUMMARY + '?id=' + window.escape(list[0]),
760                                                                                         {},
761                                                                                         {
762                                                                                                 //'id' : list[0],
763                                                                                                 'on_finished' : function(patron) {
764                                                                                                         obj.patron = patron;
765                                                                                                         obj.controller.render();
766                                                                                                 }
767                                                                                         }
768                                                                                 );
769                                                                                 netscape.security.PrivilegeManager.enablePrivilege(
770                                                                                         "UniversalXPConnect"
771                                                                                 );
772                                                                                 obj.summary_window = get_contentWindow(frame);
773                                                                                 obj.patron = obj.summary_window.g.summary.patron;
774                                                                                 obj.controller.render('patron_name');
775                                                                         }, 0
776                                                                 );
777                                                         }
778                                                 }
779                                         );
780                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
781                                         obj.search_result = get_contentWindow(list_frame);
782                                 }
783                         };
784
785                         if (params['query']) {
786                                 my_xulG.query = JSON2js(params['query']);
787                                 if (params.doit) my_xulG.doit = 1;
788                         }
789
790                         var form_frame = obj.left_deck.set_iframe(
791                                 loc,
792                                 {},
793                                 my_xulG
794                         );
795                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
796                         obj.search_window = get_contentWindow(form_frame);
797                         obj._checkout_spawned = true;
798         },
799
800         '_checkout_spawned' : false,
801
802         'refresh_deck' : function(url) {
803                 var obj = this;
804                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
805                 for (var i = 0; i < obj.right_deck.node.childNodes.length; i++) {
806                         try {
807                                 var f = obj.right_deck.node.childNodes[i];
808                                 var w = get_contentWindow(f);
809                                 if (url) {
810                                         if (w.location.href == url) w.refresh(true);
811                                 } else {
812                                         if (typeof w.refresh == 'function') {
813                                                 w.refresh(true);
814                                         }
815                                 }
816
817                         } catch(E) {
818                                 obj.error.sdump('D_ERROR','refresh_deck: ' + E + '\n');
819                         }
820                 }
821         },
822         
823         'refresh_all' : function() {
824                 var obj = this;
825                 obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.init.retrieving'));
826                 document.documentElement.setAttribute('class','');
827                 try { obj.summary_window.refresh(); } catch(E) { obj.error.sdump('D_ERROR', E + '\n'); }
828                 try { obj.refresh_deck(); } catch(E) { obj.error.sdump('D_ERROR', E + '\n'); }
829         },
830 }
831
832 dump('exiting patron/display.js\n');