]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/summary.js
Stat Cats (where usr_summary is true) in horizontal patron summary pane. Give pcrud...
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / summary.js
1 dump('entering patron.summary.js\n');
2
3 function $(id) { return document.getElementById(id); }
4 var patronStrings = $('patronStrings');
5
6 if (typeof patron == 'undefined') patron = {};
7 patron.summary = function (params) {
8
9     JSAN.use('util.error'); this.error = new util.error();
10     JSAN.use('util.window'); this.window = new util.window();
11     JSAN.use('util.network'); this.network = new util.network();
12     JSAN.use('util.widgets');
13     this.w = window;
14 }
15
16 patron.summary.prototype = {
17
18     'init' : function( params ) {
19
20         var obj = this;
21
22         obj.barcode = params['barcode'];
23         obj.id = params['id'];
24         if (params['show_name']) {
25             document.getElementById('patron_name').hidden = false;
26             document.getElementById('patron_name').setAttribute('hidden','false');
27         }
28
29         JSAN.use('OpenILS.data'); this.OpenILS = {}; 
30         obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
31         var obscure_dob = String( obj.OpenILS.data.hash.aous['circ.obscure_dob'] ) == 'true';
32
33         JSAN.use('util.functional'); JSAN.use('patron.util'); JSAN.use('util.list'); 
34
35         obj.group_list = new util.list('group_list');
36         obj.group_list.init( {
37             'columns' : [
38                 { 'id' : 'gl_family_name', 'flex' : 1, 
39                     'label' : patronStrings.getString('staff.patron.summary.group_list.column.family_name.label'),
40                     'render' : function(my) { return my.family_name; } },
41                 { 'id' : 'gl_first_given_name', 'flex' : 1, 
42                     'label' : patronStrings.getString('staff.patron.summary.group_list.column.first_given_name.label'),
43                     'render' : function(my) { return my.first_given_name; } },
44                 { 'id' : 'gl_second_given_name', 'flex' : 1, 'hidden' : true, 
45                     'label' : patronStrings.getString('staff.patron.summary.group_list.column.second_given_name.label'),
46                     'render' : function(my) { return my.second_given_name; } },
47                 { 'id' : 'gl_home_lib', 'flex' : 1, 'hidden' : true, 
48                     'label' : patronStrings.getString('staff.patron.summary.group_list.column.home_ou.label'),
49                     'render' : function(my) { return obj.OpenILS.data.hash.aou[ my.home_ou ].shortname(); } }
50             ],
51             'retrieve_row' : function(params) {
52                 var id = params.retrieve_id;
53                 var blob = patron.util.retrieve_name_via_id( ses(), id );
54                 var row = params.row; if (typeof row.my == 'undefined') { row.my = {}; }
55                 row.my.family_name = blob[0];
56                 row.my.first_given_name = blob[1];
57                 row.my.second_given_name = blob[2];
58                 row.my.home_ou = blob[3];
59                 if (typeof params.on_retrieve == 'function') {
60                     params.on_retrieve(row);
61                 }
62                 return row;
63             }
64         } );
65         $('group_list_actions').appendChild( obj.group_list.render_list_actions() );
66         obj.group_list.set_list_actions();
67
68         obj.stat_cat_list = new util.list('stat_cat_list');
69         obj.stat_cat_list.init( {
70             'columns' : [].concat(
71                 obj.stat_cat_list.fm_columns( 'actsc', {
72                     'actsc_id' : { 'hidden' : true },
73                     'actsc_opac_visible' : { 'hidden' : true },
74                     'actsc_usr_summary' : { 'hidden' : true }
75                 } )
76             ).concat(
77                 obj.stat_cat_list.fm_columns( 'actscecm', {
78                     'actscecm_id' : { 'hidden' : true }
79                 } )
80             )
81         } );
82         $('stat_cat_list_actions').appendChild( obj.stat_cat_list.render_list_actions() );
83         obj.stat_cat_list.set_list_actions();
84
85         JSAN.use('util.controller'); obj.controller = new util.controller();
86         obj.controller.init(
87             {
88                 control_map : {
89                     'cmd_broken' : [
90                         ['command'],
91                         function() { alert($("commonStrings").getString('common.unimplemented')); }
92                     ],
93                     'radio_address' : [
94                         ['render'],
95                         function(e) {
96                             return function() {
97                                 if (e.value == 'physical') { e.selectedIndex = 1; $('address_deck').selectedIndex = 1; }
98                             };
99                         }
100                     ],
101                     'group_tab' : [
102                         ['command'],
103                         function() {
104                             try {
105                                 if (! obj.group_frame_loaded) {
106                                     obj.group_frame();
107                                     obj.group_frame_loaded = true;
108                                 }
109                             } catch(E) {
110                                 alert('Error in summary.js, group_tab: ' + E);
111                             }
112                         }
113                     ],
114                     'stat_cat_tab' : [
115                         ['command'],
116                         function() {
117                             try {
118                                 obj.stat_cat_list.clear();
119                                 var entries = obj.patron.stat_cat_entries();
120                                 for (var i = 0; i < entries.length; i++) {
121                                     var stat_cat = obj.OpenILS.data.hash.my_actsc[ entries[i].stat_cat() ];
122                                     if (!stat_cat) {
123                                         stat_cat = obj.OpenILS.data.hash.actsc[ entries[i].stat_cat() ];
124                                     }
125                                     if (!stat_cat) {
126                                         var robj = obj.network.simple_request('FM_ACTSC_RETRIEVE_VIA_PCRUD',[ ses(), { 'id' : { '=' : entries[i].stat_cat() } }]);
127                                         if (typeof robj == 'object' && typeof robj.ilsevent != 'undefined') {
128                                             obj.OpenILS.data.hash.actsc[ entries[i].stat_cat() ] = robj;
129                                             obj.OpenILS.data.stash( 'hash' );
130                                             stat_cat = robj;
131                                         }
132                                     }
133                                     if (!stat_cat) { continue; }
134                                     if (get_bool( stat_cat.usr_summary() )) {
135                                         obj.stat_cat_list.append( {
136                                             'row' : {
137                                                 'my' : {
138                                                     'actsc' : stat_cat,
139                                                     'actscecm' : entries[i],
140                                                 }
141                                             }
142                                         } );
143                                     }
144                                 }
145                             } catch(E) {
146                                 alert('Error in summary.js, stat_cat_tab: ' + E);
147                             }
148                         }
149                     ],
150                     'group_tab_retrieve_patron' : [
151                         ['command'],
152                         function() {
153                             var selected_ids = util.functional.map_list(
154                                 obj.group_list.retrieve_selection(),
155                                 function(o) {
156                                     return o.getAttribute('retrieve_id');
157                                 }
158                             );
159                             for (var i = 0; i < selected_ids.length; i++) {
160                                 try {
161                                     window.xulG.new_patron_tab(
162                                         { 'tab_name' : patronStrings.getString('staff.patron.info_group.retrieve_patron.tab_name') },
163                                         {
164                                             'id' : selected_ids[i],
165                                             'url_prefix' : xulG.url_prefix,
166                                             'new_tab' : xulG.new_tab,
167                                             'set_tab' : xulG.set_tab
168                                         }
169                                     );
170                                 } catch(E) {
171                                     alert('Error in summary.js, group_tab_retrieve_patron: ' + E);
172                                 }
173                             }
174                         }
175                     ],
176                     'patron_alert' : [
177                         ['render'],
178                         function(e) {
179                             return function() {
180                                 util.widgets.set_text( e, obj.patron.alert_message() || '' );
181                                 if (obj.patron.alert_message()) {
182                                     e.parentNode.hidden = false;
183                                 } else {
184                                     e.parentNode.hidden = true;
185                                 }
186                             };
187                         }
188                     ],
189                     'patron_usrname' : [
190                         ['render'],
191                         function(e) {
192                             return function() {
193                                 util.widgets.set_text(e,obj.patron.usrname());
194                             };
195                         }
196                     ],
197                     'patron_profile' : [
198                         ['render'],
199                         function(e) {
200                             return function() { 
201                                 util.widgets.set_text(e,
202                                     obj.OpenILS.data.hash.pgt[
203                                         obj.patron.profile()
204                                     ].name()
205                                 );
206                             };
207                         }
208                     ],
209                     'patron_net_access' : [
210                         ['render'],
211                         function(e) {
212                             return function() { 
213                                 util.widgets.set_text(e,
214                                     patronStrings.getString('staff.patron.summary.patron_net_access') + 
215                                     ' ' + obj.OpenILS.data.hash.cnal[
216                                         obj.patron.net_access_level()
217                                     ].name()
218                                 );
219                             };
220                         }
221                     ],
222                     'patron_credit' : [
223                         ['render'],
224                         function(e) {
225                             return function() { 
226                                 JSAN.use('util.money');
227                                 util.widgets.set_text(e,
228                                     '$' + 
229                                     util.money.sanitize(
230                                         obj.patron.credit_forward_balance()
231                                     )
232                                 );
233                             };
234                         }
235                     ],
236                     'patron_bill' : [
237                         ['render'],
238                         function(e) {
239                             return function() { 
240                                 util.widgets.set_text(e,'...');
241                                 var under_btn; 
242                                 if (xulG) {
243                                     if (xulG.display_window) {
244                                         under_btn = xulG.display_window.document.getElementById('under_bills');
245                                         if (under_btn) util.widgets.set_text(under_btn,'...');
246                                     }
247                                 }
248                                 obj.network.simple_request(
249                                     'FM_MOUS_RETRIEVE.authoritative',
250                                     [ ses(), obj.patron.id() ],
251                                     function(req) {
252                                         try {
253                                             JSAN.use('util.money');
254                                             var robj = req.getResultObject();
255                                             util.widgets.set_text(e, patronStrings.getFormattedString('staff.patron.summary.patron_bill.money', [util.money.sanitize( robj.balance_owed() )]));
256                                             if (under_btn) util.widgets.set_text(under_btn, 
257                                                 patronStrings.getFormattedString('staff.patron.summary.patron_bill.money', [util.money.sanitize( robj.balance_owed() )]));
258                                             var show_billing_tab_on_bills = String( obj.OpenILS.data.hash.aous['ui.circ.show_billing_tab_on_bills'] ) == 'true';
259                                             if (show_billing_tab_on_bills && Number(robj.balance_owed()) > 0) {
260                                                 if (xulG) {
261                                                     if (xulG.display_window) {
262                                                         if (! obj.show_billing_tab_on_bills_done_once ) {
263                                                             xulG.display_window.g.patron.skip_hide_summary = true;
264                                                             xulG.display_window.util.widgets.dispatch('command','cmd_patron_bills');
265                                                             obj.show_billing_tab_on_bills_done_once = 1;
266                                                         }
267                                                     }
268                                                 }
269                                             }
270                                             obj.bills_summary = robj;
271                                             if (obj.holds_summary && obj.bills_summary) 
272                                                 if (typeof window.xulG == 'object' && typeof window.xulG.stop_sign_page == 'function')
273                                                     window.xulG.stop_sign_page( obj.patron, { 'holds_summary' : obj.holds_summary, 'bills_summary' : obj.bills_summary } ); 
274                                         } catch(E) {
275                                             alert('Error in summary.js, patron_bill callback: ' + E);
276                                         }
277                                     }
278                                 );
279                             };
280                         }
281                     ],
282                     'patron_checkouts' : [
283                         ['render'],
284                         function(e) {
285                             return function() { 
286                                 util.widgets.set_text(e,'...');
287                                 var e2 = document.getElementById( 'patron_overdue' ); if (e2) util.widgets.set_text(e2,'...');
288                                 var e3 = document.getElementById( 'patron_claimed_returned' ); if (e3) util.widgets.set_text(e3,'...');
289                                 var e4 = document.getElementById( 'patron_long_overdue' ); if (e4) util.widgets.set_text(e4,'...');
290                                 var e5 = document.getElementById( 'patron_lost' ); if (e5) util.widgets.set_text(e5,'...');
291                                 var e6 = document.getElementById( 'patron_noncat' ); if (e6) util.widgets.set_text(e6,'...');
292                                 var under_btn; 
293                                 if (xulG) {
294                                     if (xulG.display_window) {
295                                         under_btn = xulG.display_window.document.getElementById('under_items');
296                                         if (under_btn) util.widgets.set_text(under_btn,'...');
297                                     }
298                                 }
299                                 obj.network.simple_request(
300                                     'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative',
301                                     [ ses(), obj.patron.id() ],
302                                     function(req) {
303                                         try {
304                                             var robj = req.getResultObject();
305                                             util.widgets.set_text(e, robj.out + robj.overdue + robj.claims_returned + robj.long_overdue );
306                                             if (e2) util.widgets.set_text(e2, robj.overdue    );
307                                             if (e3) util.widgets.set_text(e3, robj.claims_returned    );
308                                             if (e4) util.widgets.set_text(e4, robj.long_overdue    );
309                                             if (e5) util.widgets.set_text(e5, robj.lost    );
310                                             if (under_btn) util.widgets.set_text(under_btn, 
311                                                 String( robj.out + robj.overdue + robj.claims_returned + robj.long_overdue) + 
312                                                 ( robj.overdue > 0 ? '*' : '' )
313                                             );
314                                         } catch(E) {
315                                             alert(E);
316                                         }
317                                     }
318                                 );
319                                 obj.network.simple_request(
320                                     'FM_ANCC_RETRIEVE_VIA_USER.authoritative',
321                                     [ ses(), obj.patron.id() ],
322                                     function(req) {
323                                         var robj = req.getResultObject();
324                                         if (e6) util.widgets.set_text(e6,robj.length);
325                                     }
326                                 );
327                             };
328                         }
329                     ],
330                     'patron_overdue' : [
331                         ['render'],
332                         function(e) {
333                             return function() { 
334                                 /* handled by 'patron_checkouts' */
335                             };
336                         }
337                     ],
338                     'patron_holds' : [
339                         ['render'],
340                         function(e) {
341                             return function() { 
342                                 util.widgets.set_text(e,'...');
343                                 var e2 = document.getElementById('patron_holds_available');
344                                 if (e2) util.widgets.set_text(e2,'...');
345                                 var under_btn; 
346                                 if (xulG) {
347                                     if (xulG.display_window) {
348                                         under_btn = xulG.display_window.document.getElementById('under_holds');
349                                         if (under_btn) util.widgets.set_text(under_btn,'...');
350                                     }
351                                 }
352                                 obj.network.simple_request(
353                                     'FM_AHR_COUNT_RETRIEVE.authoritative',
354                                     [ ses(), obj.patron.id() ],
355                                     function(req) {
356                                         var robj = req.getResultObject();
357                                         util.widgets.set_text(e,
358                                             robj.total
359                                         );
360                                         if (e2) util.widgets.set_text(e2,
361                                             robj.ready
362                                         );
363                                         if (under_btn) util.widgets.set_text(under_btn, req.getResultObject().ready + '/' + req.getResultObject().total );
364                                         obj.holds_summary = robj;
365                                         if (obj.holds_summary && obj.bills_summary) 
366                                             if (typeof window.xulG == 'object' && typeof window.xulG.stop_sign_page == 'function')
367                                                 window.xulG.stop_sign_page( obj.patron, { 'holds_summary' : obj.holds_summary, 'bills_summary' : obj.bills_summary } ); 
368                                     }
369                                 );
370                             };
371                         }
372                     ],
373                     'patron_holds_available' : [
374                         ['render'],
375                         function(e) {
376                             return function() { 
377                                 /* handled by 'patron_holds' */
378                             };
379                         }
380                     ],
381                     'patron_card' : [
382                         ['render'],
383                         function(e) {
384                             return function() { 
385                                 util.widgets.set_text(e,
386                                     obj.patron.card().barcode()
387                                 );
388                             };
389                         }
390                     ],
391                     'patron_ident_type_1' : [
392                         ['render'],
393                         function(e) {
394                             return function() { 
395                                 var ident_string = '';
396                                 var ident = obj.OpenILS.data.hash.cit[
397                                     obj.patron.ident_type()
398                                 ];
399                                 if (ident) ident_string = ident.name()
400                                 util.widgets.set_text(e,
401                                     ident_string
402                                 );
403                             };
404                         }
405                     ],
406                     'patron_ident_value_1' : [
407                         ['render'],
408                         function(e) {
409                             return function() { 
410                                 var val = obj.patron.ident_value();
411                                 if (val) val = val.replace(/.+(\d\d\d\d)$/,'xxxx$1');   // must avoid val.replace if val is NULL
412                                 util.widgets.set_text(e, val);
413                             };
414                         }
415                     ],
416                     'patron_ident_type_2' : [
417                         ['render'],
418                         function(e) {
419                             return function() { 
420                                 var ident_string = '';
421                                 var ident = obj.OpenILS.data.hash.cit[
422                                     obj.patron.ident_type2()
423                                 ];
424                                 if (ident) ident_string = ident.name()
425                                 util.widgets.set_text(e,
426                                     ident_string
427                                 );
428                             };
429                         }
430                     ],
431                     'patron_ident_value_2' : [
432                         ['render'],
433                         function(e) {
434                             return function() { 
435                                 var val = obj.patron.ident_value2();
436                                 if (val) val = val.replace(/.+(\d\d\d\d)$/,'xxxx$1');   // must avoid val.replace if val is NULL
437                                 util.widgets.set_text(e, val);
438                             };
439                         }
440                     ],
441                     'patron_date_of_exp' : [
442                         ['render'],
443                         function(e) {
444                             return function() { 
445                                 util.widgets.set_text(e,
446                                     patronStrings.getString('staff.patron.summary.expires_on') + ' ' + (
447                                         obj.patron.expire_date() ?
448                                         obj.patron.expire_date().substr(0,10) :
449                                         patronStrings.getString('staff.patron.field.unset') 
450                                     )
451                                 );
452                             };
453                         }
454                     ],
455                     'patron_hold_alias' : [
456                         ['render'],
457                         function(e) {
458                             return function() {
459                                 util.widgets.set_text(e,
460                                     obj.patron.alias() ? obj.patron.alias() : ''
461                                 );
462                             }
463                         }
464                     ],
465                     'patron_date_of_birth' : [
466                         ['render'],
467                         function(e) {
468                             return function() { 
469                                 var hide_value = e.getAttribute('hide_value');
470                                 if ( obscure_dob && hide_value == 'true' ) {
471                                     e.setAttribute( 'hidden_value',
472                                         obj.patron.dob() ?
473                                         obj.patron.dob().substr(0,10) :
474                                         patronStrings.getString('staff.patron.field.unset') 
475                                     );
476                                     util.widgets.set_text(e,
477                                         patronStrings.getString('staff.patron.field.hidden') 
478                                     );
479                                 } else {
480                                     util.widgets.set_text(e,
481                                         obj.patron.dob() ?
482                                         obj.patron.dob().substr(0,10) :
483                                         patronStrings.getString('staff.patron.field.unset') 
484                                     );
485                                     e.setAttribute( 'hidden_value',
486                                         patronStrings.getString('staff.patron.field.hidden') 
487                                     );
488                                 }
489                                 var x = document.getElementById('PatronSummaryContact_date_of_birth_label');
490                                 if (x) {
491                                     var click_to_hide_dob = x.getAttribute('click_to_hide_dob');
492                                     if (!obscure_dob || click_to_hide_dob != 'true') {
493                                         removeCSSClass(x,'click_link');
494                                     } 
495                                     if (obscure_dob && click_to_hide_dob == 'true') {
496                                         addCSSClass(x,'click_link');
497                                         x.onclick = function() {
498                                             hide_value = e.getAttribute('hide_value');
499                                             e.setAttribute('hide_value', hide_value == 'true' ? 'false' : 'true'); 
500                                             var value = util.widgets.get_text(e);
501                                             var hidden_value = e.getAttribute('hidden_value');
502                                             util.widgets.set_text(e,hidden_value);
503                                             e.setAttribute('hidden_value',value);
504                                         }
505                                     }
506                                 }
507                             };
508                         }
509                     ],
510                     'patron_day_phone' : [
511                         ['render'],
512                         function(e) {
513                             return function() { 
514                                 util.widgets.set_text(e,
515                                     obj.patron.day_phone()
516                                 );
517                             };
518                         }
519                     ],
520                     'patron_evening_phone' : [
521                         ['render'],
522                         function(e) {
523                             return function() { 
524                                 util.widgets.set_text(e,
525                                     obj.patron.evening_phone()
526                                 );
527                             };
528                         }
529                     ],
530                     'patron_other_phone' : [
531                         ['render'],
532                         function(e) {
533                             return function() { 
534                                 util.widgets.set_text(e,
535                                     obj.patron.other_phone()
536                                 );
537                             };
538                         }
539                     ],
540                     'patron_email' : [
541                         ['render'],
542                         function(e) {
543                             return function() { 
544                                 util.widgets.set_text(e,
545                                     obj.patron.email()
546                                 );
547                             };
548                         }
549                     ],
550                     'patron_alias' : [
551                         ['render'],
552                         function(e) {
553                             return function() { 
554                                 util.widgets.set_text(e,
555                                     obj.patron.alias()
556                                 );
557                             };
558                         }
559                     ],
560                     'patron_photo_url' : [
561                         ['render'],
562                         function(e) {
563                             return function() { 
564                                 e.setAttribute('src',
565                                     obj.patron.photo_url()
566                                 );
567                             };
568                         }
569                     ],
570                     'patron_library' : [
571                         ['render'],
572                         function(e) {
573                             return function() { 
574                                 util.widgets.set_text(e,
575                                     obj.OpenILS.data.hash.aou[
576                                         obj.patron.home_ou()
577                                     ].shortname()
578                                 );
579                                 e.setAttribute('tooltiptext',
580                                     obj.OpenILS.data.hash.aou[
581                                         obj.patron.home_ou()
582                                     ].name()
583                                 );
584                             };
585                         }
586                     ],
587                     'patron_last_library' : [
588                         ['render'],
589                         function(e) {
590                             return function() { 
591                                 util.widgets.set_text(e,
592                                     obj.OpenILS.data.hash.aou[
593                                         obj.patron.home_ou()
594                                     ].shortname()
595                                 );
596                                 e.setAttribute('tooltiptext',
597                                     obj.OpenILS.data.hash.aou[
598                                         obj.patron.home_ou()
599                                     ].name()
600                                 );
601                             };
602                         }
603                     ],
604                     'patron_mailing_address_street1' : [
605                         ['render'],
606                         function(e) {
607                             return function() { 
608                                 util.widgets.set_text(e,
609                                     obj.patron.mailing_address().street1()
610                                 );
611                                 if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
612                             };
613                         }
614                     ],
615                     'patron_mailing_address_street2' : [
616                         ['render'],
617                         function(e) {
618                             return function() { 
619                                 util.widgets.set_text(e,
620                                     obj.patron.mailing_address().street2()
621                                 );
622                                 if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
623                             };
624                         }
625                     ],
626                     'patron_mailing_address_city' : [
627                         ['render'],
628                         function(e) {
629                             return function() { 
630                                 util.widgets.set_text(e,
631                                     obj.patron.mailing_address().city()
632                                 );
633                                 if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
634                             };
635                         }
636                     ],
637                     'patron_mailing_address_state' : [
638                         ['render'],
639                         function(e) {
640                             return function() { 
641                                 util.widgets.set_text(e,
642                                     obj.patron.mailing_address().state()
643                                 );
644                                 if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
645                             };
646                         }
647                     ],
648                     'patron_mailing_address_post_code' : [
649                         ['render'],
650                         function(e) {
651                             return function() { 
652                                 util.widgets.set_text(e,
653                                     obj.patron.mailing_address().post_code()
654                                 );
655                                 if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
656                             };
657                         }
658                     ],
659                     'patron_physical_address_street1' : [
660                         ['render'],
661                         function(e) {
662                             return function() { 
663                                 util.widgets.set_text(e,
664                                     obj.patron.billing_address().street1()
665                                 );
666                                 if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
667                             };
668                         }
669                     ],
670                     'patron_physical_address_street2' : [
671                         ['render'],
672                         function(e) {
673                             return function() { 
674                                 util.widgets.set_text(e,
675                                     obj.patron.billing_address().street2()
676                                 );
677                                 if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
678                             };
679                         }
680                     ],
681                     'patron_physical_address_city' : [
682                         ['render'],
683                         function(e) {
684                             return function() { 
685                                 util.widgets.set_text(e,
686                                     obj.patron.billing_address().city()
687                                 );
688                                 if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
689                             };
690                         }
691                     ],
692                     'patron_physical_address_state' : [
693                         ['render'],
694                         function(e) {
695                             return function() { 
696                                 util.widgets.set_text(e,
697                                     obj.patron.billing_address().state()
698                                 );
699                                 if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
700                             };
701                         }
702                     ],
703                     'patron_physical_address_post_code' : [
704                         ['render'],
705                         function(e) {
706                             return function() { 
707                                 util.widgets.set_text(e,
708                                     obj.patron.billing_address().post_code()
709                                 );
710                                 if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
711                             };
712                         }
713                     ]
714                 }
715             }
716         );
717
718         obj.retrieve();
719
720         try {
721             var caption = document.getElementById("PatronSummaryContact_caption");
722             var arrow = document.getAnonymousNodes(caption)[0];
723             var gb_content = document.getAnonymousNodes(caption.parentNode)[1];
724             arrow.addEventListener(
725                 'click',
726                 function() {
727                     setTimeout(
728                         function() {
729                             //alert('setting shrink_state to ' + gb_content.hidden);
730                             //caption.setAttribute('shrink_state',gb_content.hidden);
731                             netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
732                             JSAN.use('util.file'); var file = new util.file('patron_id_shrink');
733                             file.set_object(String(gb_content.hidden)); file.close();
734                         }, 0
735                     );
736                 }, false
737             );
738             //var shrink_state = caption.getAttribute('shrink_state');
739             var shrink_state = false;
740             netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
741             JSAN.use('util.file'); var file = new util.file('patron_id_shrink');
742             if (file._file.exists()) {
743                 shrink_state = file.get_object(); file.close();
744             }
745             //alert('shrink_state retrieved as ' + shrink_state);
746             if (shrink_state != 'false' && shrink_state) {
747                 //alert('clicking the widget');
748                 util.widgets.click( arrow );
749             }
750         } catch(E) {
751             obj.error.sdump('D_ERROR','with shrink_state in summary.js: ' + E);
752         }
753     },
754
755     'retrieve' : function() {
756
757         try {
758
759             var obj = this;
760
761             var chain = [];
762
763             // Retrieve the patron
764                 function blah_retrieve() {
765                     try {
766                         var robj;
767                         if (obj.barcode && obj.barcode != 'null') {
768                             robj = obj.network.simple_request(
769                                 'FM_AU_RETRIEVE_VIA_BARCODE.authoritative',
770                                 [ ses(), obj.barcode ]
771                             );
772                         } else if (obj.id && obj.id != 'null') {
773                             robj = obj.network.simple_request(
774                                 'FM_AU_FLESHED_RETRIEVE_VIA_ID',
775                                 [ ses(), obj.id ]
776                             );
777                         } else {
778                             throw(patronStrings.getString('staff.patron.summary.retrieve.no_barcode'));
779                         }
780                         if (robj) {
781
782                             if (instanceOf(robj,au)) {
783
784                                 obj.patron = robj;
785                                 JSAN.use('patron.util');
786                                 util.widgets.set_text('patron_name',
787                                     patron.util.format_name( obj.patron )
788                                 );
789                                 patron.util.set_penalty_css(obj.patron);
790                                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
791                                 data.last_patron = obj.patron.id(); data.stash('last_patron');
792
793                             } else {
794
795                                 throw(robj);
796
797                             }
798                         } else {
799
800                             throw(robj);
801
802                         }
803
804                     } catch(E) {
805                         throw(E);
806                     }
807                 };
808                 blah_retrieve();
809
810             /*
811             // Retrieve the survey responses for required surveys
812             chain.push(
813                 function() {
814                     try {
815                         var surveys = obj.OpenILS.data.list.my_asv;
816                         var survey_responses = {};
817                         for (var i = 0; i < surveys.length; i++) {
818                             var s = obj.network.request(
819                                 api.FM_ASVR_RETRIEVE.app,
820                                 api.FM_ASVR_RETRIEVE.method,
821                                 [ ses(), surveys[i].id(), obj.patron.id() ]
822                             );
823                             survey_responses[ surveys[i].id() ] = s;
824                         }
825                         obj.patron.survey_responses( survey_responses );
826                     } catch(E) {
827                         var error = ('patron.summary.retrieve : ' + js2JSON(E));
828                         obj.error.sdump('D_ERROR',error);
829                         throw(error);
830                     }
831                 }
832             );
833             */
834
835             // Update the screen
836             chain.push( function() { obj.controller.render(); } );
837
838             // On Complete
839
840             chain.push( function() {
841
842                 if (typeof window.xulG == 'object' && typeof window.xulG.on_finished == 'function') {
843                     obj.error.sdump('D_PATRON_SUMMARY',
844                         'patron.summary: Calling external .on_finished()\n');
845                     window.xulG.on_finished(obj.patron);
846                 } else {
847                     obj.error.sdump('D_PATRON_SUMMARY','patron.summary: No external .on_finished()\n');
848                 }
849
850             } );
851
852             // Do it
853             JSAN.use('util.exec'); obj.exec = new util.exec();
854             obj.exec.on_error = function(E) {
855
856                 if (typeof window.xulG == 'object' && typeof window.xulG.on_error == 'function') {
857                     window.xulG.on_error(E);
858                 } else {
859                     alert(js2JSON(E));
860                 }
861
862             }
863             this.exec.chain( chain );
864
865         } catch(E) {
866             if (typeof window.xulG == 'object' && typeof window.xulG.on_error == 'function') {
867                 window.xulG.on_error(E);
868             } else {
869                 alert(js2JSON(E));
870             }
871         }
872     },
873
874     'group_frame' : function() {
875         var obj = this;
876         try {
877             obj.group_list.clear();
878
879             var robj = obj.network.simple_request(
880                 'FM_AU_LIST_RETRIEVE_VIA_GROUP.authoritative',
881                 [ ses(), obj.patron.usrgroup() ]
882             );
883             if ((robj == null) || (typeof robj.ilsevent != 'undefined') ) throw(robj);
884             var ids = util.functional.filter_list( robj, function(o) { return o != obj.patron.id(); });
885             var funcs = [];
886
887                 function gen_func(r) {
888                     return function() {
889                         obj.group_list.append( { 'retrieve_id' : r, 'row' : {} } );
890                     }
891                 }
892
893             //funcs.push( gen_func(obj.patron.id()) );
894             for (var i = 0; i < ids.length; i++) {
895                 funcs.push( gen_func(ids[i]) );
896             }
897             JSAN.use('util.exec'); var exec = new util.exec(4);
898             exec.chain( funcs );
899         } catch(E) {
900             alert('Error in summary.js, group_frame(): ' + E);
901         }
902     }
903 }
904
905 dump('exiting patron.summary.js\n');