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="/xul/server/skin/global.css" type="text/css"?>
10 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!DOCTYPE window PUBLIC "" ""[
13 <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
16 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20 <window id="patron_barcode_entry_win"
21 onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
22 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
24 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
26 <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
27 <scripts id="openils_util_scripts"/>
29 <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
32 function $(id) { return document.getElementById(id); }
36 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
37 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
38 JSAN.errorLevel = "die"; // none, warn, or die
39 JSAN.addRepository('/xul/server/');
40 JSAN.use('util.error'); g.error = new util.error();
41 g.error.sdump('D_TRACE','my_init() for patron/barcode_entry.xul');
43 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
45 var tb = document.getElementById('barcode_tb');
49 if (ev.keyCode == 13 || ev.keyCode == 77) {
61 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
62 if (xul_param('perm_editor')) {
63 try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.barcode_entry.user_permission_editor')); } catch(E) { alert(E); }
65 try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.barcode_entry.check_out')); } catch(E) { alert(E); }
69 if (xul_param('error')) {
70 var error = xul_param('error');
75 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/barcode_entry.xul', E]);
76 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
84 JSAN.use('util.sound'); var sound = new util.sound();
85 tb = document.getElementById('barcode_tb');
86 var barcode = tb.value;
88 barcode = String( barcode ).replace( /\s+/g, '' );
90 if (!barcode) { sound.bad(); add_msg($("patronStrings").getString('staff.patron.barcode_entry.no_barcode')); tb.select(); tb.focus(); return; }
92 JSAN.use('util.network'); var net = new util.network();
95 document.getElementById('progress').setAttribute('hidden','false');
96 net.simple_request('FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME',[ ses(), barcode, null ],
98 document.getElementById('progress').setAttribute('hidden','true');
99 tb.disabled = false; tb.select(); tb.focus(); ;
100 var robj = req.getResultObject();
101 if (typeof robj.ilsevent != 'undefined') {
103 switch(Number(robj.ilsevent)) {
104 case 1002 /* ACTOR_USER_NOT_FOUND */:
105 add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode]));
108 add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)]));
113 if (g.data.user_org_unit_opt_in_enabled) {
114 var r = net.simple_request('USER_ORG_UNIT_OPT_IN_CHECK',[ ses(), robj ]);
115 if (typeof r.ilsevent != 'undefined') {
121 JSAN.use('patron.util');
122 var parts = patron.util.retrieve_name_via_id( ses(), robj );
124 if (0 != g.error.yns_alert(
125 $("patronStrings").getFormattedString('staff.patron.barcode_entry.consent_from_patron',
126 [parts[0], parts[1] + (parts[2] ? ' ' + parts[2] : ''), g.data.hash.aou[ parts[3] ].name(), g.data.hash.aou[ parts[3] ].shortname()]),
127 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_title'),
128 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_accept'),
129 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_deny'), null,
130 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_confirm')
133 tb.select(); tb.focus();
136 var c = net.simple_request('USER_ORG_UNIT_OPT_IN_CREATE',[ ses(), robj ]);
137 if (typeof c.ilsevent != 'undefined') throw(r);
151 tb.select(); tb.focus();
152 g.error.standard_unexpected_error_alert('barcode_entry.xul',E);
156 function add_msg(text) {
157 var x = document.getElementById('status');
158 var d = document.createElement('description');
160 d.appendChild( document.createTextNode( text ) );
161 d.setAttribute('style','color: red');
164 function spawn(barcode) {
165 if (xul_param('perm_editor')) { spawn_perm_editor(barcode); } else { spawn_checkout(barcode); }
168 function spawn_checkout(barcode) {
170 var horizontal_interface = String( g.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
171 var loc = xulG.url_prefix( horizontal_interface ? urls.XUL_PATRON_HORIZ_DISPLAY : urls.XUL_PATRON_DISPLAY );
172 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
173 window.xulG.set_tab( loc, {}, { 'barcode' : barcode } );
175 location.href = loc + '?barcode=' + window.escape(barcode);
178 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.patron_display_error'),E);
182 function spawn_perm_editor(barcode) {
184 JSAN.use('patron.util'); var patron_obj = patron.util.retrieve_fleshed_au_via_barcode( ses(), barcode );
185 var loc = urls.XUL_USER_PERM_EDITOR + '?ses=' + window.escape(ses()) + '&usr=' + patron_obj.id();
186 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
187 window.xulG.set_tab( loc, {}, {} );
192 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.user_perm_display_error'),E);
197 function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
201 <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
203 <vbox flex="1" class="my_overflow">
204 <groupbox orient="vertical" flex="1">
205 <caption label="&staff.pat.barcode_entry.retrieve_patron.label;" />
207 <label value="&staff.pat.barcode_entry.barcode.label;" accesskey="&staff.pat.barcode_entry.barcode.accesskey;" control="barcode_tb"/>
208 <textbox id="barcode_tb" context="clipboard"/>
209 <button label="&staff.pat.barcode_entry.submit_btn.label;" accesskey="&staff.pat.barcode_entry.submit_btn.accesskey;" oncommand="submit();"/>
211 <label value="&staff.pat.barcode_entry.retrieving.label;" style="color: green" id="progress" hidden="true"/>