2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron Display -->
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
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"?>
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
14 <!DOCTYPE window PUBLIC "" ""[
15 <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
22 <window id="patron_info_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">
26 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28 <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
29 <scripts id="openils_util_scripts"/>
31 <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
35 function $(id) { return document.getElementById(id); }
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/');
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'});
49 g.error.sdump('D_TRACE','my_init() for patron_info.xul');
51 g.patron_id = xul_param('patron_id');
58 var err_msg = "!! This software has encountered an error. Please tell your friendly " +
59 "system administrator or software developer the following:\npatron_info.xul\n" + E + '\n';
60 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
66 retrieve_notes(); render_notes();
69 function retrieve_notes() {
71 g.notes = g.network.simple_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
74 g.notes = g.network.simple_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
78 function apply(node,field,value) {
83 case 'description' : n.appendChild( document.createTextNode( value ) ); break;
84 case 'label' : n.value = value; break;
85 default : n.value = value; break;
91 function render_notes() {
92 JSAN.use('util.widgets'); util.widgets.remove_children('notes_panel');
93 var np = $('notes_panel');
94 var hbox = document.createElement('hbox'); np.appendChild(hbox);
95 var btn = document.createElement('button'); hbox.appendChild(btn);
96 btn.setAttribute('label','Add New Note');
97 btn.setAttribute('accesskey','A');
98 btn.setAttribute('oncommand','new_note()');
100 for (var i = 0; i < g.notes.length; i++) {
103 var node = $('note_template').cloneNode(true); np.appendChild(node); node.hidden = false;
104 apply(node,'create_date',g.notes[i].create_date().toString().substr(0,10));
105 util.widgets.apply(node,'name','create_date',
106 function(n){n.setAttribute("tooltiptext","Note ID: " + g.notes[i].id() + " Creator ID: " + g.notes[i].creator());}
108 apply(node,'title',g.notes[i].title());
109 apply(node,'pub',get_bool(g.notes[i].pub()) ? "Patron Visible" : "Staff Only");
110 apply(node,'value',g.notes[i].value());
111 apply(node,'id',g.notes[i].id());
112 apply(node,'creator',g.notes[i].creator());
115 var hb = document.createElement('hbox'); np.appendChild(hb);
116 var btn1 = document.createElement('button'); hb.appendChild(btn1);
117 btn1.setAttribute('label','Delete This Note');
118 btn1.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif");
120 btn1.addEventListener(
122 function(id){ return function() {
123 var r = g.error.yns_alert('Delete the note titled "' + g.notes[id].title() + '" created on ' + g.notes[id].create_date().toString().substr(0,10) + '?','Delete Note','Yes','No',null,'Check here to confirm this action');
125 g.network.simple_request('FM_AUN_DELETE',[ses(),g.notes[id].id()]);
126 setTimeout(function(){ g.new_note = true; alert('Note deleted.'); refresh();},0);
131 var btn2 = document.createElement('button'); hb.appendChild(btn2);
132 btn2.setAttribute('label','Print');
133 btn2.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif");
135 btn2.addEventListener(
137 function(id){ return function() {
139 JSAN.use('patron.util');
140 var patron_obj = patron.util.retrieve_fleshed_au_via_id(ses(),g.patron_id);
141 var staff_obj = patron.util.retrieve_name_via_id( ses(), g.notes[id].creator() );
142 JSAN.use('util.print'); var p = new util.print();
145 + '<p>Pertaining to ' +
146 ( patron_obj.prefix() ? patron_obj.prefix() + ' ' : '') +
147 patron_obj.family_name() + ', ' +
148 patron_obj.first_given_name() + ' ' +
149 ( patron_obj.second_given_name() ? patron_obj.second_given_name() + ' ' : '' ) +
150 ( patron_obj.suffix() ? patron_obj.suffix() : '')
152 + patron_obj.card().barcode() + '</p>'
154 + g.notes[id].title() + '"</b> created on ' + g.notes[id].create_date().toString().substr(0,10)
155 + ' by ' + staff_obj[0] + ' @ ' + g.data.hash.aou[ staff_obj[3] ].shortname()
157 + g.notes[id].value()
161 g.error.standard_unexpected_error_alert('printing note #' + g.notes[id].id(), E);
170 function new_note() {
172 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
173 var xml = '<groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1"><caption label="New Note"/><grid flex="1"><columns><column/><column flex="1"/></columns><rows><row><label value="Patron Visible?"/><checkbox id="pub" name="fancy_data"/></row><row><label value="Title"/><textbox id="title" name="fancy_data"/></row><row><label value="Note"/><textbox multiline="true" id="note" name="fancy_data"/></row><row><spacer/><hbox><button label="Cancel" name="fancy_cancel" accesskey="C"/><button label="Add Note" accesskey="A" name="fancy_submit"/></hbox></row></rows></grid></groupbox>';
174 //g.data.init({'via':'stash'});
175 //g.data.temp_note_xml = xml; g.data.stash('temp_note_xml');
176 JSAN.use('util.window'); var win = new util.window();
177 var fancy_prompt_data = win.open(
178 urls.XUL_FANCY_PROMPT,
179 //+ '?xml_in_stash=temp_note_xml'
180 //+ '&focus=' + window.escape('title')
181 //+ '&title=' + window.escape('Add Note'),
182 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
183 { 'xml' : xml, 'focus' : 'title', 'title' : 'Add Note' }
185 if (fancy_prompt_data.fancy_status == 'complete') {
186 //alert(js2JSON(g.data.fancy_prompt_data));
187 var note = new aun();
189 note.title( fancy_prompt_data.title );
190 note.value( fancy_prompt_data.note );
191 note.pub( get_bool( fancy_prompt_data.pub ) ? get_db_true() : get_db_false() );
192 note.usr( g.patron_id );
193 var r = g.network.simple_request('FM_AUN_CREATE',[ ses(), note ]);
194 if (typeof r.ilsevent != 'undefined') throw(r);
195 setTimeout(function(){ g.new_note = true; alert('Note added.'); refresh();},0);
198 g.error.standard_unexpected_error_alert('The note was not likely created.',E);
205 <stack hidden="true" id="note_template" flex="1">
206 <groupbox flex="1" style="background-color: black;"/>
207 <groupbox flex="1" style="background-color: #FFDE00; -moz-border-radius-topright: 35px;" >
209 <description name="title" style="font-weight: bold"/>
211 <description name="create_date" style="font-weight: bold"/>
212 <description name="pub" style="font-weight: bold"/>
214 <description name="value"/>
218 <vbox flex="1" class="my_overflow" id="notes_panel">