2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Retrieve Patron By Barcode -->
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"?>
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
13 <!DOCTYPE window PUBLIC "" ""[
14 <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
21 <window id="patron_barcode_entry_win"
22 onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
23 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
25 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
27 <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
28 <scripts id="openils_util_scripts"/>
30 <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
33 function $(id) { return document.getElementById(id); }
37 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
38 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
39 JSAN.errorLevel = "die"; // none, warn, or die
40 JSAN.addRepository('/xul/server/');
41 JSAN.use('util.error'); g.error = new util.error();
42 g.error.sdump('D_TRACE','my_init() for patron/barcode_entry.xul');
44 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
46 var tb = document.getElementById('barcode_tb');
50 if (ev.keyCode == 13 || ev.keyCode == 77) {
62 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
63 if (xul_param('perm_editor')) {
64 try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.barcode_entry.user_permission_editor')); } catch(E) { alert(E); }
66 try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.barcode_entry.check_out')); } catch(E) { alert(E); }
70 if (xul_param('error')) {
71 var error = xul_param('error');
76 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/barcode_entry.xul', E]);
77 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
85 JSAN.use('util.sound'); var sound = new util.sound();
86 tb = document.getElementById('barcode_tb');
87 var barcode = tb.value;
89 barcode = String( barcode ).replace( /\s+/g, '' );
91 if (!barcode) { sound.bad(); add_msg($("patronStrings").getString('staff.patron.barcode_entry.no_barcode')); tb.select(); tb.focus(); return; }
93 JSAN.use('util.network'); var net = new util.network();
96 document.getElementById('progress').setAttribute('hidden','false');
97 net.simple_request('FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME',[ ses(), barcode, null ],
99 document.getElementById('progress').setAttribute('hidden','true');
100 tb.disabled = false; tb.select(); tb.focus(); ;
101 var robj = req.getResultObject();
102 if (typeof robj.ilsevent != 'undefined') {
104 switch(Number(robj.ilsevent)) {
105 case 1002 /* ACTOR_USER_NOT_FOUND */:
106 add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode]));
109 add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)]));
114 if (g.data.user_org_unit_opt_in_enabled) {
115 var r = net.simple_request('USER_ORG_UNIT_OPT_IN_CHECK',[ ses(), robj ]);
116 if (typeof r.ilsevent != 'undefined') {
122 JSAN.use('patron.util');
123 var parts = patron.util.retrieve_name_via_id( ses(), robj );
125 if (0 != g.error.yns_alert(
126 $("patronStrings").getFormattedString('staff.patron.barcode_entry.consent_from_patron',
127 [parts[0], parts[1] + (parts[2] ? ' ' + parts[2] : ''), g.data.hash.aou[ parts[3] ].name(), g.data.hash.aou[ parts[3] ].shortname()]),
128 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_title'),
129 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_accept'),
130 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_deny'), null,
131 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_confirm')
134 tb.select(); tb.focus();
137 var c = net.simple_request('USER_ORG_UNIT_OPT_IN_CREATE',[ ses(), robj ]);
138 if (typeof c.ilsevent != 'undefined') throw(r);
152 tb.select(); tb.focus();
153 g.error.standard_unexpected_error_alert('barcode_entry.xul',E);
157 function add_msg(text) {
158 var x = document.getElementById('status');
159 var d = document.createElement('description');
161 d.appendChild( document.createTextNode( text ) );
162 d.setAttribute('style','color: red');
165 function spawn(barcode) {
166 if (xul_param('perm_editor')) { spawn_perm_editor(barcode); } else { spawn_checkout(barcode); }
169 function spawn_checkout(barcode) {
171 var horizontal_interface = String( g.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
172 var loc = xulG.url_prefix( horizontal_interface ? urls.XUL_PATRON_HORIZ_DISPLAY : urls.XUL_PATRON_DISPLAY );
173 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
174 window.xulG.set_tab( loc, {}, { 'barcode' : barcode } );
176 location.href = loc + '?barcode=' + window.escape(barcode);
179 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.patron_display_error'),E);
183 function spawn_perm_editor(barcode) {
185 JSAN.use('patron.util'); var patron_obj = patron.util.retrieve_fleshed_au_via_barcode( ses(), barcode );
186 var loc = urls.XUL_USER_PERM_EDITOR + '?ses=' + window.escape(ses()) + '&usr=' + patron_obj.id();
187 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
188 window.xulG.set_tab( loc, {}, {} );
193 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.user_perm_display_error'),E);
198 function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
202 <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
204 <vbox flex="1" class="my_overflow">
205 <groupbox orient="vertical" flex="1">
206 <caption label="&staff.pat.barcode_entry.retrieve_patron.label;" />
208 <label value="&staff.pat.barcode_entry.barcode.label;" accesskey="&staff.pat.barcode_entry.barcode.accesskey;" control="barcode_tb"/>
209 <textbox id="barcode_tb" context="clipboard"/>
210 <button label="&staff.pat.barcode_entry.submit_btn.label;" accesskey="&staff.pat.barcode_entry.submit_btn.accesskey;" oncommand="submit();"/>
212 <label value="&staff.pat.barcode_entry.retrieving.label;" style="color: green" id="progress" hidden="true"/>