]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/barcode_entry.xul
spawn the right (horizontal versus vertical) patron display
[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('FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME',[ ses(), barcode, null ],
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                             switch(Number(robj.ilsevent)) {
105                                                             case 1002 /* ACTOR_USER_NOT_FOUND */: 
106                                                                 add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_not_found', [barcode]));
107                                 break;
108                                 default:
109                                     add_msg($("patronStrings").getFormattedString('staff.patron.barcode_entry.barcode_retrieval_problem', [barcode, js2JSON(robj)]));
110                             }
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 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 } );
175                                 } else {
176                                         location.href = loc + '?barcode=' + window.escape(barcode);
177                                 }
178                         } catch(E) {
179                                 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.patron_display_error'),E);
180                         }
181                 }
182
183                 function spawn_perm_editor(barcode) {
184                         try {
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, {}, {} );
189                                 } else {
190                                         location.href = loc;
191                                 }
192                         } catch(E) {
193                                 g.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.barcode_entry.user_perm_display_error'),E);
194                         }
195                 }
196
197
198                 function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
199         ]]>
200         </script>
201         
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"  context="clipboard"/>
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