]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/hold_notices.xul
2f394b0b1bcf2ecc5c204cc040bcd5d1e425763d
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / hold_notices.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/${locale}/lang.dtd"-->
16 ]>
17
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
19 <!-- OVERLAYS -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
21
22 <window id="hold_notices_win" width="700" height="550" persist="sizemode width height"
23         onload="try{ my_init(); font_helper(); } catch(E) { alert(E); }" title="Hold Notices"
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( $("commonStrings").getString('common.jsan.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');
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 hold_notices.xul');
50
51                                 g.ahr_id = xul_param('ahr_id');
52                                 g.ahr = g.network.simple_request('FM_AHR_RETRIEVE',[ ses(), g.ahr_id ]);
53                                 if (typeof g.ahr.ilsevent != 'undefined') { throw(g.ahr); }
54                                 g.ahr = g.ahr[0];
55
56                                 render_patron();
57
58                                 a_list_of_one();
59
60                                 document.getElementById('bib_brief').setAttribute('src',urls.XUL_BIB_BRIEF); // + '?docid=' + g.ahr.target());
61                                 get_contentWindow(document.getElementById('bib_brief')).xulG = { 'docid' : g.ahr.target() };
62
63                                 refresh();
64
65                         } catch(E) {
66                                 try { g.error.standard_unexpected_error_alert('/xul/server/patron/hold_notices.xul',E); } catch(E) { alert('FIXME: ' + js2JSON(E)); }
67                         }
68                 }
69
70                 function render_patron() {
71                         if (g.ahr.usr()) {
72                                 JSAN.use('patron.util'); 
73                                 var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.ahr.usr() );
74                                 
75                                 $('patron_name').setAttribute('value', 
76                                         ( au_obj.prefix() ? au_obj.prefix() + ' ' : '') + 
77                                         au_obj.family_name() + ', ' + 
78                                         au_obj.first_given_name() + ' ' +
79                                         ( au_obj.second_given_name() ? au_obj.second_given_name() + ' ' : '' ) +
80                                         ( au_obj.suffix() ? au_obj.suffix() : '')
81                                         + ' : ' + au_obj.card().barcode() 
82                                 );
83                         }
84                 }
85
86                 function a_list_of_one() {
87                         JSAN.use('circ.util');
88                         var columns = circ.util.hold_columns( 
89                                 { 
90                                         'status' : { 'hidden' : true },
91                                         'request_time' : { 'hidden' : false },
92                                         'pickup_lib_shortname' : { 'hidden' : false },
93                                         'current_copy' : { 'hidden' : false },
94                                         'phone_notify' : { 'hidden' : false },
95                                         'email_notify' : { 'hidden' : false },
96                                 } 
97                         );
98                         JSAN.use('util.list'); g.list = new util.list('holds_list');
99                         g.list.init(
100                                 {
101                                         'columns' : columns,
102                                         'map_row_to_columns' : circ.util.std_map_row_to_columns(),
103                                         'retrieve_row' : function(params) {
104                                                 var row = params.row;
105                                                 try {
106                                                         switch(row.my.ahr.hold_type()) {
107                                                                 case 'M' :
108                                                                         row.my.mvr = g.network.request(
109                                                                                 api.MODS_SLIM_METARECORD_RETRIEVE.app,
110                                                                                 api.MODS_SLIM_METARECORD_RETRIEVE.method,
111                                                                                 [ row.my.ahr.target() ]
112                                                                         );
113                                                                 break;
114                                                                 default:
115                                                                         row.my.mvr = g.network.simple_request(
116                                                                                 'MODS_SLIM_RECORD_RETRIEVE.authoritative',
117                                                                                 [ row.my.ahr.target() ]
118                                                                         );
119                                                                         if (row.my.ahr.current_copy()) {
120                                                                                 row.my.acp = g.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ]);
121                                                                         }
122                                                                 break;
123                                                         }
124                                                 } catch(E) {
125                                                         g.error.sdump('D_ERROR','retrieve_row: ' + E );
126                                                 }
127                                                 if (typeof params.on_retrieve == 'function') {
128                                                         params.on_retrieve(row);
129                                                 }
130                                                 return row;
131                                         },
132                                 }
133                         );
134                         g.list.append(
135                                 {
136                                         'row' : {
137                                                 'my' : {
138                                                         'ahr' : g.ahr,
139                                                 }
140                                         },
141                                         'no_auto_select' : true,
142                                 }
143                         );
144                 }
145
146                 function refresh() {
147                         retrieve_notifications(); render_notifications();
148                 }
149
150                 function retrieve_notifications() {
151                         g.notifications = g.network.simple_request('FM_AHN_RETRIEVE_VIA_AHR',[ ses(), g.ahr_id ]).reverse();
152                 }
153
154                 function apply(node,field,value) {
155                         util.widgets.apply(
156                                 node,'name',field,
157                                 function(n) {
158                                         switch(n.nodeName) {
159                                                 case 'description' : n.appendChild( document.createTextNode( value ) ); break;
160                                                 case 'label' : n.value = value; break;
161                                                 default : n.value = value; break;
162                                         }
163                                 }
164                         );
165                 }
166
167                 function render_notifications() {
168                         JSAN.use('util.widgets'); util.widgets.remove_children('notifications_panel');
169                         var np = $('notifications_panel');
170
171                         for (var i = 0; i < g.notifications.length; i++) {
172
173                                 /* template */
174                                 var node = $('notification_template').cloneNode(true); np.appendChild(node); node.hidden = false;
175                                 util.widgets.apply(node,'name','notify_time',
176                                         function(n){n.setAttribute("tooltiptext", $("patronStrings").getFormattedString('staff.patron.hold_notices.tooltiptext',[g.notifications[i].id(), g.notifications[i].hold(), g.notifications[i].notify_staff()]));
177                                 );
178                                 apply(node,'method',g.notifications[i].method ? g.notifications[i].method() : '');
179                                 apply(node,'note',g.notifications[i].note() ? g.notifications[i].note() : '');
180                                 apply(node,'notify_time',g.notifications[i].notify_time() ? g.notifications[i].notify_time().toString().substr(0,10) : '');
181                         }
182
183                 }
184                 
185                 function new_notification() {
186                         try {
187                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
188                                 var xml = '<groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1">';
189                                 xml += '<caption label="' + $("patronStrings").getString('staff.patron.hold_notices.new_notification_record') + '"/><grid flex="1"><columns><column/><column flex="1"/></columns><rows>';
190                                 xml += '<row><label value="' + $("patronStrings").getString('staff.patron.hold_notices.method') + '"/><textbox id="method" name="fancy_data"/></row>';
191                                 xml += '<row><label value="' + $("patronStrings").getString('staff.patron.hold_notices.note') + '"/><textbox multiline="true" id="note" name="fancy_data"/></row>';
192                                 xml += '<row><spacer/><hbox><button label="' + $("patronStrings").getString('staff.patron.hold_notices.cancel') + '" name="fancy_cancel"';
193                                 xml += 'accesskey="' + $("patronStrings").getString('staff.patron.hold_notices.cancel_accesskey') + '"/>';
194                                 xml += '<button label="' + $("patronStrings").getString('staff.patron.hold_notices.add_notif_record') + '";'
195                                 xml += 'accesskey="' + $("patronStrings").getString('staff.patron.hold_notices.add_notif_record_accesskey') + '" name="fancy_submit"/></hbox></row></rows></grid></groupbox>';
196                                 //g.data.init({'via':'stash'});
197                                 //g.data.temp_notification_xml = xml; g.data.stash('temp_notification_xml');
198                                 JSAN.use('util.window'); var win = new util.window();
199                                 var fancy_prompt_data = win.open(
200                                         urls.XUL_FANCY_PROMPT,
201                                         //+ '?xml_in_stash=temp_notification_xml'
202                                         //+ '&focus=' + window.escape('method')
203                                         //+ '&title=' + window.escape('Add Notification Record'),
204                                         'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
205                                         { 'xml' : xml, 'focus' : 'method', 'title' : $("patronStrings").getString('staff.patron.hold_notices.add_notif_record') }
206                                 );
207                                 if (fancy_prompt_data.fancy_status == 'complete') {
208                                         var notification = new ahn();
209                                         notification.isnew(1);
210                                         notification.hold(g.ahr_id);
211                                         notification.method( fancy_prompt_data.method );
212                                         notification.note( fancy_prompt_data.note );
213                                         var r = g.network.simple_request('FM_AHN_CREATE',[ ses(), notification ]); if (typeof r.ilsevent != 'undefined') throw(r);
214                                         setTimeout(function(){refresh();},0);
215                                 }
216                         } catch(E) {
217                                 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.hold_notices.new_notification.not_created'),E);
218                                 setTimeout(function(){refresh();},0);
219                         }
220                 }
221
222         ]]>
223         </script>
224
225         <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale' -->/circ.properties"/>
226         <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties"/>
227         <messagecatalog id="commonStrings" src="/xul/server/locale/<!--#echo var='locale'-->/common.properties" />      
228
229         <stack hidden="true" id="notification_template" flex="1">
230                 <groupbox flex="1" style="background-color: black;"/>
231                 <groupbox flex="1" style="background-color: #FFDE00; -moz-border-radius-topright: 35px;" >
232                         <hbox>
233                                 <description name="method" label="Method:" style="font-weight: bold"/>
234                                 <spacer flex="1"/>
235                                 <description name="notify_time" style="font-weight: bold"/>
236                         </hbox>
237                         <description name="note"/>
238                 </groupbox>
239         </stack>
240
241     <vbox id="v1" flex="1" persist="height">
242         <label id="patron_name" class="patronNameLarge"/>
243         <iframe id="bib_brief" flex="1"/>
244     </vbox>
245
246     <splitter><grippy/></splitter>
247
248     <vbox id="v2" flex="1" persist="height">
249         <vbox flex="1">
250             <tree id="holds_list" flex="1" enableColumnDrag="true" style=""/>
251         </vbox>
252         <hbox>
253             <button label="&staff.patron.hold_notices.add_record_notification.label;" accesskey="&staff.patron.hold_notices.add_record_notification.accesskey;" oncommand="new_notification()"/>
254             <spacer flex="1"/>
255             <button label="&staff.patron.hold_notices.close_window.label;" accesskey="&staff.patron.hold_notices.close_window.accesskey;" oncommand="window.close()"/>
256         </hbox>
257         </vbox>
258
259     <splitter><grippy/></splitter>
260
261         <vbox persist="height" flex="9" class="my_overflow" id="notifications_panel">
262         </vbox>
263
264
265 </window>
266