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('PATRON_BARCODE_EXISTS.authoritative',[ ses(), barcode ],
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 add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)]));
106 } else if (robj == 0) {
108 add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode]));
112 if (g.data.user_org_unit_opt_in_enabled) {
113 var r = net.simple_request('USER_ORG_UNIT_OPT_IN_CHECK',[ ses(), robj ]); // FIXME -- robj is no longer returning a usr id
114 if (typeof r.ilsevent != 'undefined') {
120 JSAN.use('patron.util');
121 var parts = patron.util.retrieve_name_via_id( ses(), robj );
123 if (0 != g.error.yns_alert(
124 $("patronStrings").getFormattedString('staff.patron.barcode_entry.consent_from_patron',
125 [parts[0], parts[1] + (parts[2] ? ' ' + parts[2] : ''), g.data.hash.aou[ parts[3] ].name(), g.data.hash.aou[ parts[3] ].shortname()]),
126 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_title'),
127 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_accept'),
128 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_deny'), null,
129 $("patronStrings").getString('staff.patron.barcode_entry.patron_consent_confirm')
132 tb.select(); tb.focus();
135 var c = net.simple_request('USER_ORG_UNIT_OPT_IN_CREATE',[ ses(), robj ]);
136 if (typeof c.ilsevent != 'undefined') throw(r);
150 tb.select(); tb.focus();
151 g.error.standard_unexpected_error_alert('barcode_entry.xul',E);
155 function add_msg(text) {
156 var x = document.getElementById('status');
157 var d = document.createElement('description');
159 d.appendChild( document.createTextNode( text ) );
160 d.setAttribute('style','color: red');
163 function spawn(barcode) {
164 if (xul_param('perm_editor')) { spawn_perm_editor(barcode); } else { spawn_checkout(barcode); }
167 function spawn_checkout(barcode) {
169 var loc = urls.XUL_PATRON_DISPLAY; // + '?barcode=' + window.escape(barcode);
170 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
171 window.xulG.set_tab( loc, {}, { 'barcode' : barcode } );
173 location.href = loc + '?barcode=' + window.escape(barcode);
176 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.patron_display_error'),E);
180 function spawn_perm_editor(barcode) {
182 JSAN.use('patron.util'); var patron_obj = patron.util.retrieve_fleshed_au_via_barcode( ses(), barcode );
183 var loc = urls.XUL_USER_PERM_EDITOR + '?ses=' + window.escape(ses()) + '&usr=' + patron_obj.id();
184 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
185 window.xulG.set_tab( loc, {}, {} );
190 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.user_perm_display_error'),E);
195 function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
199 <messagecatalog id="commonStrings" src="/xul/server/locale/<!--#echo var='locale'-->/common.properties" />
200 <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
202 <vbox flex="1" class="my_overflow">
203 <groupbox orient="vertical" flex="1">
204 <caption label="&staff.pat.barcode_entry.retrieve_patron.label;" />
206 <label value="&staff.pat.barcode_entry.barcode.label;" accesskey="&staff.pat.barcode_entry.barcode.accesskey;" control="barcode_tb"/>
207 <textbox id="barcode_tb" />
208 <button label="&staff.pat.barcode_entry.submit_btn.label;" accesskey="&staff.pat.barcode_entry.submit_btn.accesskey;" oncommand="submit();"/>
210 <label value="&staff.pat.barcode_entry.retrieving.label;" style="color: green" id="progress" hidden="true"/>