]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/barcode_entry.xul
Apply Craig Ricciuto's patch to bring i18n to a number of patron interfaces
[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 = "!! This software has encountered an error.  Please tell your friendly " +
77                                         "system administrator or software developer the following:\n" + E + '\n';
78                                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/barcode_entry.xul', E]);
79                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
80                                 alert(err_msg);
81                         }
82                 }
83
84                 function submit() {
85                         var tb;
86                         try {
87                                 JSAN.use('util.sound'); var sound = new util.sound();
88                                 tb = document.getElementById('barcode_tb');
89                                 var barcode = tb.value;
90
91                                 barcode = String( barcode ).replace( /\s+/g, '' );
92
93                                 if (!barcode) { sound.bad(); add_msg($(patronStrings).getString('staff.patron.barcode_entry.no_barcode')); tb.select(); tb.focus(); return; }
94
95                                 JSAN.use('util.network'); var net = new util.network();
96
97                                 tb.disabled = true;
98                                 document.getElementById('progress').setAttribute('hidden','false');
99                                 net.simple_request('PATRON_BARCODE_EXISTS.authoritative',[ ses(), barcode ],
100                                         function(req) {
101                                                 document.getElementById('progress').setAttribute('hidden','true');
102                                                 tb.disabled = false; tb.select(); tb.focus(); ;
103                                                 var robj = req.getResultObject();
104                                                 if (typeof robj.ilsevent != 'undefined') {
105                                                         sound.bad();
106                                                         add_msg($(patronStrings).getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)]));
107                                                         return;
108                                                 } else if (robj == 0) {
109                                                         sound.bad(); 
110                                                         add_msg($(patronStrings).getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode]));
111                                                         return;
112                                                 }
113
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') {
117                                                                 throw(r);
118                                                         } else {
119
120                                                                 if (r == 0) {
121
122                                                                         JSAN.use('patron.util');
123                                                                         var parts = patron.util.retrieve_name_via_id( ses(), robj );
124     
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')
132                                                                                 )
133                                                                         ) {
134                                                                                 tb.select(); tb.focus();
135                                                                                 return;
136                                                                         } else {
137                                                                                 var c = net.simple_request('USER_ORG_UNIT_OPT_IN_CREATE',[ ses(), robj ]);
138                                                                                 if (typeof c.ilsevent != 'undefined') throw(r);
139                                                                         }
140                                                                 }
141     
142                                                     sound.good();
143                                                     spawn(barcode);
144                             }
145                         } else {
146                                                     sound.good();
147                                                     spawn(barcode);
148                         }
149                                         }
150                                 );
151                         } catch(E) {
152                                 tb.select(); tb.focus();
153                                 g.error.standard_unexpected_error_alert('barcode_entry.xul',E);
154                         }
155                 }
156
157                 function add_msg(text) {
158                         var x = document.getElementById('status');
159                         var d = document.createElement('description');
160                         x.appendChild(d);
161                         d.appendChild( document.createTextNode( text ) );
162                         d.setAttribute('style','color: red');
163                 }
164
165                 function spawn(barcode) {
166             if (xul_param('perm_editor')) { spawn_perm_editor(barcode); } else { spawn_checkout(barcode); }
167         }
168
169                 function spawn_checkout(barcode) {
170                         try {
171                                 var loc = urls.XUL_PATRON_DISPLAY; // + '?barcode=' + window.escape(barcode);
172                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
173                                         window.xulG.set_tab( loc, {}, { 'barcode' : barcode } );
174                                 } else {
175                                         location.href = loc + '?barcode=' + window.escape(barcode);
176                                 }
177                         } catch(E) {
178                                 g.error.standard_unexpected_error_alert($(patronStrings).getString('staff.patron.barcode_entry.patron_display_error'),E);
179                         }
180                 }
181
182                 function spawn_perm_editor(barcode) {
183                         try {
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, {}, {} );
188                                 } else {
189                                         location.href = loc;
190                                 }
191                         } catch(E) {
192                                 g.error.standard_unexpected_error_alert($(patronStrings).getString('staff.patron.barcode_entry.user_perm_display_error'),E);
193                         }
194                 }
195
196
197                 function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
198         ]]>
199         </script>
200         
201         <messagecatalog id="commonStrings" src="/xul/server/locale/<!--#echo var='locale'-->/common.properties" />
202         <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
203
204         <vbox flex="1" class="my_overflow">
205                 <groupbox orient="vertical" flex="1">
206                         <caption label="&staff.pat.barcode_entry.retrieve_patron.label;" />
207                         <hbox>
208                                 <label value="&staff.pat.barcode_entry.barcode.label;" accesskey="&staff.pat.barcode_entry.barcode.accesskey;" control="barcode_tb"/>
209                                 <textbox id="barcode_tb" />
210                                 <button label="&staff.pat.barcode_entry.submit_btn.label;" accesskey="&staff.pat.barcode_entry.submit_btn.accesskey;" oncommand="submit();"/>
211                         </hbox>
212                         <label value="&staff.pat.barcode_entry.retrieving.label;" style="color: green" id="progress" hidden="true"/>
213                         <vbox id="status">
214                         </vbox>
215                 </groupbox>
216         </vbox>
217
218 </window>
219