]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/info_stat_cats.xul
xul_param and modal xulG conversion
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / info_stat_cats.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron Display -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
10 <?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
11
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
13 <!-- LOCALIZATION -->
14 <!DOCTYPE window PUBLIC "" ""[
15         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
16 ]>
17
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
19 <!-- OVERLAYS -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
21
22 <window id="patron_info_stat_cats_win" width="700" height="550"
23         onload="try{ my_init(); font_helper(); } catch(E) { alert(E); }"
24         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
25
26         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
27         <!-- BEHAVIOR -->
28         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
29         <scripts id="openils_util_scripts"/>
30
31         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
32         <script>
33         <![CDATA[
34
35                 function $(id) { return document.getElementById(id); }
36
37                 function my_init() {
38                         try {
39                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
40                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
41                                 JSAN.errorLevel = "die"; // none, warn, or die
42                                 JSAN.addRepository('/xul/server/');
43
44                                 JSAN.use('util.error'); g.error = new util.error();
45                                 JSAN.use('util.network'); g.network = new util.network();
46                                 JSAN.use('util.date'); JSAN.use('util.money'); JSAN.use('patron.util'); JSAN.use('util.functional');
47                                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
48
49                                 g.error.sdump('D_TRACE','my_init() for patron_info_stat_cats.xul');
50
51                                 g.patron_id = xul_param('patron_id');
52
53                                 refresh();
54
55                         } catch(E) {
56                                 var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
57                                         "system administrator or software developer the following:\npatron_info_stat_cats.xul\n" + E + '\n';
58                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
59                                 alert(err_msg);
60                         }
61                 }
62
63                 function refresh() {
64                         retrieve_fleshed_patron(); render_stat_cats();
65                 }
66
67                 function retrieve_fleshed_patron() {
68                         try {
69
70                                 g.patron = patron.util.retrieve_fleshed_au_via_id(ses(), g.patron_id);
71                                 if (g.patron.ilsevent) throw(g.patron);
72
73                         } catch(E) {
74                                 g.error.standard_unexpected_error_alert('Failed to retrieve patron stat cats.',E);
75                                 g.patron = null;
76                         }
77
78                 }
79
80                 function apply(node,field,value) {
81                         util.widgets.apply(
82                                 node,'name',field,
83                                 function(n) {
84                                         switch(n.nodeName) {
85                                                 case 'description' : n.appendChild( document.createTextNode( value ) ); break;
86                                                 case 'label' : n.value = value; break;
87                                                 default : n.value = value; break;
88                                         }
89                                 }
90                         );
91                 }
92
93                 function render_stat_cats() {
94                         JSAN.use('util.widgets'); util.widgets.remove_children('stat_cats_panel');
95                         if (!g.patron) return;
96                         var sp = $('stat_cats_panel');
97                         var my_actsc = g.data.list.my_actsc;
98                         /* I'm throwing all the patron's stat cat entry maps in here, and pruning it as we go through my_actsc.  Those left behind are "foreign" stat cats that need to pulled from the server. */
99                         var scem_hash = {}; 
100                         for (var i = 0; i < g.patron.stat_cat_entries().length; i++) {
101                                 scem_hash[ g.patron.stat_cat_entries()[i].stat_cat() ] = function(a){ return g.patron.stat_cat_entries()[a]; }(i);
102                         }
103
104                         for (var i = 0; i < my_actsc.length; i++) {
105
106                                 /* template */
107                                 var actsc_node = $('actsc_template').cloneNode(true); sp.appendChild(actsc_node); actsc_node.hidden = false;
108                                 apply(actsc_node,'name',my_actsc[i].name());
109                                 apply(actsc_node,'opac',my_actsc[i].opac_visible() ? 'OPAC Visible' : 'Not OPAC Visible');
110                                 apply(actsc_node,'owner',g.data.hash.aou[my_actsc[i].owner()].shortname());
111
112                                 var nl = actsc_node.getElementsByAttribute('name','entry');
113                                 var entry_placeholder;
114                                 if (nl.length>0) entry_placeholder = nl[0];
115
116                                 if (entry_placeholder && scem_hash[ my_actsc[i].id() ]) {
117
118                                         /* template */
119                                         var actsce_node = $('actsce_template').cloneNode(true); entry_placeholder.appendChild(actsce_node); actsce_node.hidden = false;
120                                         var sc_id = my_actsc[i].id();
121                                         var scem = scem_hash[ sc_id ];
122                                         apply(actsce_node,'value',scem.stat_cat_entry());
123                                         delete scem_hash[ sc_id ];
124
125                                 }
126                         }
127
128                         for (var i in scem_hash) {
129
130                                 try {
131
132                                 var sc_id = scem_hash[i].stat_cat();
133                                 if (sc_id == null || sc_id == '') throw(scem_hash[i]);
134                                 var sc = g.network.simple_request('FM_ACTSC_RETRIEVE_BATCH', [ ses(), [ sc_id ] ]);
135                                 if (!sc || typeof sc.ilsevent != 'undefined') { throw(sc); continue; }
136                                 sc = sc[0];
137
138                                 /* template */
139                                 var actsc_node = $('actsc_template').cloneNode(true); sp.appendChild(actsc_node); actsc_node.hidden = false;
140                                 apply(actsc_node,'name',sc.name());
141                                 apply(actsc_node,'opac',sc.opac_visible() ? 'OPAC Visible' : 'Not OPAC Visible');
142                                 apply(actsc_node,'owner',g.data.hash.aou[sc.owner()].shortname());
143
144                                 var nl = actsc_node.getElementsByAttribute('name','entry');
145                                 var entry_placeholder;
146                                 if (nl.length>0) entry_placeholder = nl[0];
147
148                                 if (entry_placeholder) {
149
150                                         /* template */
151                                         var actsce_node = $('actsce_template').cloneNode(true); entry_placeholder.appendChild(actsce_node); actsce_node.hidden = false;
152                                         var scem = scem_hash[ i ];
153                                         apply(actsce_node,'value',scem.stat_cat_entry());
154
155                                 }
156
157                                 } catch(E) {
158                                         g.error.standard_unexpected_error_alert('rendering/retrieving stat cat',E);
159                                 }
160                         }
161                 }
162                 
163         ]]>
164         </script>
165
166         <stack hidden="true" id="actsc_template" flex="1">
167                 <groupbox flex="1" style="background-color: black;"/>
168                 <groupbox flex="1" style="background-color: #99CC66; -moz-border-radius-topright: 35px;" >
169                         <hbox>
170                                 <description name="name" style="font-weight: bold"/>
171                                 <spacer flex="1"/>
172                                 <description name="opac" style="font-weight: bold"/>
173                                 <description name="owner" style="font-weight: bold"/>
174                         </hbox>
175                         <vbox name="entry"/>
176                 </groupbox>
177         </stack>
178
179         <hbox hidden="true" id="actsce_template" flex="1">
180                 <description name="value"/>
181         </hbox>
182
183         <vbox flex="1" class="my_overflow" id="stat_cats_panel">
184         </vbox>
185
186
187 </window>
188