]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/adv_barcode_entry.xul
xul_param and modal xulG conversion
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / adv_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/en-US/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 my_init() {
34                         try {
35                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
36                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
37                                 JSAN.errorLevel = "die"; // none, warn, or die
38                                 JSAN.addRepository('/xul/server/');
39                                 JSAN.use('util.error'); g.error = new util.error();
40                                 g.error.sdump('D_TRACE','my_init() for patron/barcode_entry.xul');
41
42                                 var tb = document.getElementById('barcode_tb');
43                                 tb.addEventListener(
44                                         'keypress',
45                                         function(ev) {
46                                                 if (ev.keyCode == 13 || ev.keyCode == 77) {
47                                                         setTimeout(
48                                                                 function() {
49                                                                         submit();
50                                                                 }, 0
51                                                         );
52                                                 }
53                                         },
54                                         false
55                                 );
56                                 tb.focus();
57         
58                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
59                                         try { window.xulG.set_tab_name('User Permission Editor'); } catch(E) { alert(E); }
60                                 }
61
62                                 if (xul_param('error')) { 
63                                         var error = xul_param('error');
64                                         alert(error);
65                                 }
66
67                         } catch(E) {
68                                 var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
69                                         "system administrator or software developer the following:\n" + E + '\n';
70                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
71                                 alert(err_msg);
72                         }
73                 }
74
75                 function submit() {
76                         var tb;
77                         try {
78                                 JSAN.use('util.sound'); var sound = new util.sound();
79                                 tb = document.getElementById('barcode_tb');
80                                 var barcode = tb.value;
81
82                                 barcode = String( barcode ).replace( /\s+/g, '' );
83
84                                 if (!barcode) { sound.bad(); add_msg('No barcode entered.'); tb.select(); tb.focus(); return; }
85
86                                 JSAN.use('util.network'); var net = new util.network();
87
88                                 tb.disabled = true;
89                                 document.getElementById('progress').setAttribute('hidden','false');
90                                 net.simple_request('PATRON_BARCODE_EXISTS',[ ses(), barcode ],
91                                         function(req) {
92                                                 document.getElementById('progress').setAttribute('hidden','true');
93                                                 tb.disabled = false; tb.select(); tb.focus(); ;
94                                                 var robj = req.getResultObject();
95                                                 if (typeof robj.ilsevent != 'undefined') {
96                                                         sound.bad();
97                                                         add_msg('Problem retrieving ' + barcode + '.  Please report this message: \n' + js2JSON(robj));
98                                                         return;
99                                                 } else if (robj == 0) {
100                                                         sound.bad(); 
101                                                         add_msg('Barcode ' + barcode + ' not found.');
102                                                         return;
103                                                 }
104
105                                                 sound.good();
106
107                                                 spawn(barcode);
108                                         }
109                                 );
110                         } catch(E) {
111                                 tb.select(); tb.focus();
112                                 g.error.standard_unexpected_error_alert('barcode_entry.xul',E);
113                         }
114                 }
115
116                 function add_msg(text) {
117                         var x = document.getElementById('status');
118                         var d = document.createElement('description');
119                         x.appendChild(d);
120                         d.appendChild( document.createTextNode( text ) );
121                         d.setAttribute('style','color: red');
122                 }
123
124                 function spawn(barcode) {
125                         try {
126
127                                 JSAN.use('patron.util'); var patron_obj = patron.util.retrieve_fleshed_au_via_barcode( ses(), barcode );
128
129                                 var loc = urls.XUL_USER_PERM_EDITOR + '?ses=' + window.escape(ses()) + '&usr=' + patron_obj.id();
130
131                                 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
132
133                                         window.xulG.set_tab( loc, {}, {} );
134                                 } else {
135
136                                         location.href = loc;
137 ;
138                                 }
139                         } catch(E) {
140                                 g.error.standard_unexpected_error_alert('spawning patron display',E);
141                         }
142                 }
143
144                 function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
145         ]]>
146         </script>
147
148         <vbox flex="1" class="my_overflow">
149                 <groupbox orient="vertical" flex="1">
150                         <caption label="Retrieve Patron" />
151                         <hbox>
152                                 <label value="Barcode:" accesskey="B" control="barcode_tb"/>
153                                 <textbox id="barcode_tb" />
154                                 <button label="Submit" accesskey="S" oncommand="submit();"/>
155                         </hbox>
156                         <label value="Retrieving..." style="color: green" id="progress" hidden="true"/>
157                         <vbox id="status">
158                         </vbox>
159                 </groupbox>
160         </vbox>
161
162 </window>
163