]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/barcode_entry.xul
a just-in-case reminder to fix this
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / patron / barcode_entry.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Retrieve Patron By Barcode -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
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
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14         <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
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">
24
25         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
26         <!-- BEHAVIOR -->
27         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
28         <scripts id="openils_util_scripts"/>
29
30         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
31         <script>
32         <![CDATA[
33                 function $(id) { return document.getElementById(id); }
34                 
35                 function my_init() {
36                         try {
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');
43
44                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
45
46                                 var tb = document.getElementById('barcode_tb');
47                                 tb.addEventListener(
48                                         'keypress',
49                                         function(ev) {
50                                                 if (ev.keyCode == 13 || ev.keyCode == 77) {
51                                                         setTimeout(
52                                                                 function() {
53                                                                         submit();
54                                                                 }, 0
55                                                         );
56                                                 }
57                                         },
58                                         false
59                                 );
60                                 tb.focus();
61         
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); }
65                     } else {
66                                         try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.barcode_entry.check_out')); } catch(E) { alert(E); }
67                     }
68                                 }
69
70                                 if (xul_param('error')) { 
71                                         var error = xul_param('error');
72                                         alert(error);
73                                 }
74
75                         } catch(E) {
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); }
78                                 alert(err_msg);
79                         }
80                 }
81
82                 function submit() {
83                         var tb;
84                         try {
85                                 JSAN.use('util.sound'); var sound = new util.sound();
86                                 tb = document.getElementById('barcode_tb');
87                                 var barcode = tb.value;
88
89                                 barcode = String( barcode ).replace( /\s+/g, '' );
90
91                                 if (!barcode) { sound.bad(); add_msg($("patronStrings").getString('staff.patron.barcode_entry.no_barcode')); tb.select(); tb.focus(); return; }
92
93                                 JSAN.use('util.network'); var net = new util.network();
94
95                                 tb.disabled = true;
96                                 document.getElementById('progress').setAttribute('hidden','false');
97                                 net.simple_request('PATRON_BARCODE_EXISTS.authoritative',[ ses(), barcode ],
98                                         function(req) {
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') {
103                                                         sound.bad();
104                                                         add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)]));
105                                                         return;
106                                                 } else if (robj == 0) {
107                                                         sound.bad(); 
108                                                         add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode]));
109                                                         return;
110                                                 }
111
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') {
115                                                                 throw(r);
116                                                         } else {
117
118                                                                 if (r == 0) {
119
120                                                                         JSAN.use('patron.util');
121                                                                         var parts = patron.util.retrieve_name_via_id( ses(), robj );
122     
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')
130                                                                                 )
131                                                                         ) {
132                                                                                 tb.select(); tb.focus();
133                                                                                 return;
134                                                                         } else {
135                                                                                 var c = net.simple_request('USER_ORG_UNIT_OPT_IN_CREATE',[ ses(), robj ]);
136                                                                                 if (typeof c.ilsevent != 'undefined') throw(r);
137                                                                         }
138                                                                 }
139     
140                                                     sound.good();
141                                                     spawn(barcode);
142                             }
143                         } else {
144                                                     sound.good();
145                                                     spawn(barcode);
146                         }
147                                         }
148                                 );
149                         } catch(E) {
150                                 tb.select(); tb.focus();
151                                 g.error.standard_unexpected_error_alert('barcode_entry.xul',E);
152                         }
153                 }
154
155                 function add_msg(text) {
156                         var x = document.getElementById('status');
157                         var d = document.createElement('description');
158                         x.appendChild(d);
159                         d.appendChild( document.createTextNode( text ) );
160                         d.setAttribute('style','color: red');
161                 }
162
163                 function spawn(barcode) {
164             if (xul_param('perm_editor')) { spawn_perm_editor(barcode); } else { spawn_checkout(barcode); }
165         }
166
167                 function spawn_checkout(barcode) {
168                         try {
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 } );
172                                 } else {
173                                         location.href = loc + '?barcode=' + window.escape(barcode);
174                                 }
175                         } catch(E) {
176                                 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.patron_display_error'),E);
177                         }
178                 }
179
180                 function spawn_perm_editor(barcode) {
181                         try {
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, {}, {} );
186                                 } else {
187                                         location.href = loc;
188                                 }
189                         } catch(E) {
190                                 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.user_perm_display_error'),E);
191                         }
192                 }
193
194
195                 function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
196         ]]>
197         </script>
198         
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" />
201
202         <vbox flex="1" class="my_overflow">
203                 <groupbox orient="vertical" flex="1">
204                         <caption label="&staff.pat.barcode_entry.retrieve_patron.label;" />
205                         <hbox>
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();"/>
209                         </hbox>
210                         <label value="&staff.pat.barcode_entry.retrieving.label;" style="color: green" id="progress" hidden="true"/>
211                         <vbox id="status">
212                         </vbox>
213                 </groupbox>
214         </vbox>
215
216 </window>
217