]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/hold_notices.xul
debugging
[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/en-US/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"
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( "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');
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.cgi = new CGI();
52                                 g.ahr_id = g.cgi.param('ahr_id');
53                                 g.ahr = g.network.simple_request('FM_AHR_RETRIEVE',[ ses(), g.ahr_id ]);
54                                 if (typeof g.ahr.ilsevent != 'undefined') { throw(g.ahr); }
55                                 g.ahr = g.ahr[0];
56
57                                 render_patron();
58
59                                 a_list_of_one();
60
61                                 document.getElementById('bib_brief').setAttribute('src',urls.XUL_BIB_BRIEF + '?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', au_obj.family_name() + ', ' + au_obj.first_given_name() + ' : ' + au_obj.card().barcode() );
76                         }
77                 }
78
79                 function a_list_of_one() {
80                         JSAN.use('circ.util');
81                         var columns = circ.util.hold_columns( 
82                                 { 
83                                         'status' : { 'hidden' : true },
84                                         'request_time' : { 'hidden' : false },
85                                         'pickup_lib_shortname' : { 'hidden' : false },
86                                         'current_copy' : { 'hidden' : false },
87                                         'phone_notify' : { 'hidden' : false },
88                                         'email_notify' : { 'hidden' : false },
89                                 } 
90                         );
91                         JSAN.use('util.list'); g.list = new util.list('holds_list');
92                         g.list.init(
93                                 {
94                                         'columns' : columns,
95                                         'map_row_to_column' : circ.util.std_map_row_to_column(),
96                                         'retrieve_row' : function(params) {
97                                                 var row = params.row;
98                                                 try {
99                                                         switch(row.my.ahr.hold_type()) {
100                                                                 case 'M' :
101                                                                         row.my.mvr = g.network.request(
102                                                                                 api.MODS_SLIM_METARECORD_RETRIEVE.app,
103                                                                                 api.MODS_SLIM_METARECORD_RETRIEVE.method,
104                                                                                 [ row.my.ahr.target() ]
105                                                                         );
106                                                                 break;
107                                                                 default:
108                                                                         row.my.mvr = g.network.request(
109                                                                                 api.MODS_SLIM_RECORD_RETRIEVE.app,
110                                                                                 api.MODS_SLIM_RECORD_RETRIEVE.method,
111                                                                                 [ row.my.ahr.target() ]
112                                                                         );
113                                                                         if (row.my.ahr.current_copy()) {
114                                                                                 row.my.acp = g.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ]);
115                                                                         }
116                                                                 break;
117                                                         }
118                                                 } catch(E) {
119                                                         g.error.sdump('D_ERROR','retrieve_row: ' + E );
120                                                 }
121                                                 if (typeof params.on_retrieve == 'function') {
122                                                         params.on_retrieve(row);
123                                                 }
124                                                 return row;
125                                         },
126                                 }
127                         );
128                         g.list.append(
129                                 {
130                                         'row' : {
131                                                 'my' : {
132                                                         'ahr' : g.ahr,
133                                                 }
134                                         }
135                                 }
136                         );
137                 }
138
139                 function refresh() {
140                         retrieve_notifications(); render_notifications();
141                 }
142
143                 function retrieve_notifications() {
144                         g.notifications = g.network.simple_request('FM_AHN_RETRIEVE_VIA_AHR',[ ses(), g.ahr_id ]).reverse();
145                 }
146
147                 function apply(node,field,value) {
148                         util.widgets.apply(
149                                 node,'name',field,
150                                 function(n) {
151                                         switch(n.nodeName) {
152                                                 case 'description' : n.appendChild( document.createTextNode( value ) ); break;
153                                                 case 'label' : n.value = value; break;
154                                                 default : n.value = value; break;
155                                         }
156                                 }
157                         );
158                 }
159
160                 function render_notifications() {
161                         JSAN.use('util.widgets'); util.widgets.remove_children('notifications_panel');
162                         var np = $('notifications_panel');
163
164                         for (var i = 0; i < g.notifications.length; i++) {
165
166                                 /* template */
167                                 var node = $('notification_template').cloneNode(true); np.appendChild(node); node.hidden = false;
168                                 util.widgets.apply(node,'name','notify_time',
169                                         function(n){n.setAttribute("tooltiptext","ID: " + g.notifications[i].id() + " Hold ID: " + g.notifications[i].hold() + " Notifying Staff ID: " + g.notifications[i].notify_staff());}
170                                 );
171                                 apply(node,'method',g.notifications[i].method ? g.notifications[i].method() : '');
172                                 apply(node,'note',g.notifications[i].note() ? g.notifications[i].note() : '');
173                                 apply(node,'notify_time',g.notifications[i].notify_time() ? g.notifications[i].notify_time().toString().substr(0,10) : '');
174                         }
175
176                 }
177                 
178                 function new_notification() {
179                         try {
180                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
181                                 var xml = '<groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1">';
182                                 xml += '<caption label="New Notification Record"/><grid flex="1"><columns><column/><column flex="1"/></columns><rows>';
183                                 xml += '<row><label value="Method"/><textbox id="method" name="fancy_data"/></row>';
184                                 xml += '<row><label value="Note"/><textbox multiline="true" id="note" name="fancy_data"/></row>';
185                                 xml += '<row><spacer/><hbox><button label="Cancel" name="fancy_cancel" accesskey="C"/>';
186                                 xml += '<button label="Add Notification Record" accesskey="A" name="fancy_submit"/></hbox></row></rows></grid></groupbox>';
187                                 window.open(
188                                         urls.XUL_FANCY_PROMPT
189                                         + '?xml=' + window.escape(xml)
190                                         + '&focus=' + window.escape('method')
191                                         + '&title=' + window.escape('Add Notification Record'),
192                                         'fancy_prompt', 'chrome,resizable,modal,width=700,height=500'
193                                 );
194                                 g.data.init({'via':'stash'});
195                                 if (g.data.fancy_prompt_data != '') {
196                                         var notification = new ahn();
197                                         notification.isnew(1);
198                                         notification.hold(g.ahr_id);
199                                         notification.method( g.data.fancy_prompt_data.method );
200                                         notification.note( g.data.fancy_prompt_data.note );
201                                         var r = g.network.simple_request('FM_AHN_CREATE',[ ses(), notification ]); if (typeof r.ilsevent != 'undefined') throw(r);
202                                         setTimeout(function(){refresh();},0);
203                                 }
204                         } catch(E) {
205                                 g.error.standard_unexpected_error_alert('The notification was not likely created.',E);
206                                 setTimeout(function(){refresh();},0);
207                         }
208                 }
209
210         ]]>
211         </script>
212
213         <stack hidden="true" id="notification_template" flex="1">
214                 <groupbox flex="1" style="background-color: black;"/>
215                 <groupbox flex="1" style="background-color: #FFDE00; -moz-border-radius-topright: 35px;" >
216                         <hbox>
217                                 <description name="method" label="Method:" style="font-weight: bold"/>
218                                 <spacer flex="1"/>
219                                 <description name="notify_time" style="font-weight: bold"/>
220                         </hbox>
221                         <description name="note"/>
222                 </groupbox>
223         </stack>
224
225         <vbox id="top_panel" flex="1">
226                 <label id="patron_name" class="patronNameLarge"/>
227                 <iframe id="bib_brief" flex="2"/>
228                 <vbox flex="1" style="min-height: 30px">
229                         <tree id="holds_list" flex="1" enableColumnDrag="true" style=""/>
230                 </vbox>
231                 <hbox>
232                         <button label="Add Record of Notification" accesskey="A" oncommand="new_notification()"/>
233                         <spacer flex="1"/>
234                         <button label="Close" accesskey="C" oncommand="window.close()"/>
235                 </hbox>
236         </vbox>
237
238         <vbox flex="9" class="my_overflow" id="notifications_panel">
239         </vbox>
240
241
242 </window>
243