2 function $(id) { return document.getElementById(id); }
6 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
8 JSAN.errorLevel = "die"; // none, warn, or die
9 JSAN.addRepository('/xul/server/');
12 dojo.require('openils.PermaCrud');
13 JSAN.use('util.error'); g.error = new util.error();
14 JSAN.use('util.network'); g.network = new util.network();
15 JSAN.use('util.date'); JSAN.use('util.money'); JSAN.use('patron.util');
16 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
18 g.error.sdump('D_TRACE','my_init() for hold_notices.xul');
20 g.ahr_id = xul_param('ahr_id');
22 g.ahr = g.network.simple_request('FM_AHR_RETRIEVE',[ ses(), g.ahr_id ]);
23 if (typeof g.ahr.ilsevent != 'undefined') { throw(g.ahr); }
30 var x = document.getElementById('bib_brief_box'); while (x.firstChild) x.removeChild(x.lastChild);
31 var bib_brief = document.createElement('iframe'); x.appendChild(bib_brief);
32 bib_brief.setAttribute('flex',1);
33 bib_brief.setAttribute('src',urls.XUL_BIB_BRIEF);
34 get_contentWindow(bib_brief).xulG = { 'docid' : g.ahr.target() };
39 try { g.error.standard_unexpected_error_alert('/xul/server/patron/hold_notices.xul',E); } catch(E) { alert('FIXME: ' + js2JSON(E)); }
43 function render_patron() {
45 JSAN.use('patron.util');
46 var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.ahr.usr() );
48 $('patron_name').setAttribute('value',
49 ( au_obj.prefix() ? au_obj.prefix() + ' ' : '') +
50 au_obj.family_name() + ', ' +
51 au_obj.first_given_name() + ' ' +
52 ( au_obj.second_given_name() ? au_obj.second_given_name() + ' ' : '' ) +
53 ( au_obj.suffix() ? au_obj.suffix() : '')
54 + ' : ' + au_obj.card().barcode()
59 function a_list_of_one() {
60 JSAN.use('circ.util');
61 var columns = circ.util.hold_columns(
63 'status' : { 'hidden' : true },
64 'request_time' : { 'hidden' : false },
65 'pickup_lib_shortname' : { 'hidden' : false },
66 'current_copy' : { 'hidden' : false },
67 'phone_notify' : { 'hidden' : false },
68 'email_notify' : { 'hidden' : false },
71 JSAN.use('util.list'); g.list = new util.list('holds_list');
75 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
76 'retrieve_row' : function(params) {
79 switch(row.my.ahr.hold_type()) {
81 row.my.mvr = g.network.request(
82 api.MODS_SLIM_METARECORD_RETRIEVE.app,
83 api.MODS_SLIM_METARECORD_RETRIEVE.method,
84 [ row.my.ahr.target() ]
88 row.my.mvr = g.network.simple_request(
89 'MODS_SLIM_RECORD_RETRIEVE.authoritative',
90 [ row.my.ahr.target() ]
92 if (row.my.ahr.current_copy()) {
93 row.my.acp = g.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ]);
98 g.error.sdump('D_ERROR','retrieve_row: ' + E );
100 if (typeof params.on_retrieve == 'function') {
101 params.on_retrieve(row);
114 'no_auto_select' : true,
120 retrieve_notifications(); render_notifications(); retrieve_notes(); render_notes();
123 function retrieve_notifications() {
124 g.notifications = g.network.simple_request('FM_AHN_RETRIEVE_VIA_AHR',[ ses(), g.ahr_id ]).reverse();
127 function retrieve_notes() {
129 g.ahr_id = xul_param('ahr_id');
131 g.notes = new openils.PermaCrud(
135 ).search('ahrn', {hold:g.ahr_id});
141 function apply(node,field,value) {
146 case 'description' : n.appendChild( document.createTextNode( value ) ); break;
147 case 'label' : n.value = value; break;
148 default : n.value = value; break;
154 function render_notifications() {
155 JSAN.use('util.widgets'); util.widgets.remove_children('notifications_panel');
156 var np = $('notifications_panel');
158 for (var i = 0; i < g.notifications.length; i++) {
161 var node = $('notification_template').cloneNode(true); np.appendChild(node); node.hidden = false;
162 util.widgets.apply(node,'name','notify_time',
166 $("patronStrings").getFormattedString('staff.patron.hold_notices.tooltiptext',[g.notifications[i].id(), g.notifications[i].hold(), g.notifications[i].notify_staff()])
170 apply(node,'method',g.notifications[i].method() ? g.notifications[i].method() : '');
171 apply(node,'note',g.notifications[i].note() ? g.notifications[i].note() : '');
172 apply(node,'notify_time',g.notifications[i].notify_time() ? g.notifications[i].notify_time().toString().substr(0,10) : '');
177 function render_notes() {
179 JSAN.use('util.widgets'); util.widgets.remove_children('notes_panel');
180 var notep = $('notes_panel');
182 for (var i = 0; i < g.notes.length; i++) {
185 var notenode = $('note_template').cloneNode(true); notep.appendChild(notenode); notenode.hidden = false;
187 /* alert('notenode = '
188 + notenode + ' title = ' + g.notes[i].title() + ' note = ' +
189 g.notes[i].body() + ' pub = ' + g.notes[i].pub() + ' slip = ' +
190 g.notes[i].slip() );*/
192 apply(notenode,'title',g.notes[i].title() ? g.notes[i].title() : 'NO TITLE');
193 apply(notenode,'note',g.notes[i].body() ? g.notes[i].body() : 'NO NOTE');
194 apply(notenode,'pub',g.notes[i].pub() ? g.notes[i].pub() : 'NOT PUBLIC');
195 apply(notenode,'slip',g.notes[i].slip() ? g.notes[i].slip() : 'NOT PRINTING ON SLIP');
198 function new_notification() {
200 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
201 var xml = '<groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1">';
202 xml += '<caption label="' + $("patronStrings").getString('staff.patron.hold_notices.new_notification_record') + '"/><grid flex="1"><columns><column/><column flex="1"/></columns><rows>';
203 xml += '<row><label value="' + $("patronStrings").getString('staff.patron.hold_notices.method') + '"/><textbox id="method" name="fancy_data" context="clipboard"/></row>';
204 xml += '<row><label value="' + $("patronStrings").getString('staff.patron.hold_notices.note') + '"/><textbox multiline="true" id="note" name="fancy_data" context="clipboard"/></row>';
205 xml += '<row><spacer/><hbox><button label="' + $("patronStrings").getString('staff.patron.hold_notices.cancel') + '" name="fancy_cancel" ';
206 xml += 'accesskey="' + $("patronStrings").getString('staff.patron.hold_notices.cancel_accesskey') + '"/>';
207 xml += '<button label="' + $("patronStrings").getString('staff.patron.hold_notices.add_notif_record') + '" ';
208 xml += 'accesskey="' + $("patronStrings").getString('staff.patron.hold_notices.add_notif_record_accesskey') + '" name="fancy_submit"/></hbox></row></rows></grid></groupbox>';
209 JSAN.use('util.window'); var win = new util.window();
210 var fancy_prompt_data = win.open(
211 urls.XUL_FANCY_PROMPT,
212 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
213 { 'xml' : xml, 'focus' : 'method', 'title' : $("patronStrings").getString('staff.patron.hold_notices.add_notif_record') }
215 if (fancy_prompt_data.fancy_status == 'complete') {
216 var notification = new ahn();
217 notification.isnew(1);
218 notification.hold(g.ahr_id);
219 notification.method( fancy_prompt_data.method );
220 notification.note( fancy_prompt_data.note );
221 var r = g.network.simple_request('FM_AHN_CREATE',[ ses(), notification ]); if (typeof r.ilsevent != 'undefined') throw(r);
222 setTimeout(function(){refresh();},0);
225 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.hold_notices.new_notification.not_created'),E);
226 setTimeout(function(){refresh();},0);
230 function new_note() {
232 var newNote = new fieldmapper.ahrn();
234 newNote.body(document.getElementById('hold_note_text').value);
235 newNote.hold(g.ahr_id);
236 newNote.title(document.getElementById('hold_note_title').value);
238 if($('pub_bool').checked){
243 if($('print_bool').checked){
250 new openils.PermaCrud({authtoken :ses()}).create(newNote);
254 alert('new_note FAILED');