entry point for user perm editor
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 27 Sep 2006 19:05:27 +0000 (19:05 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 27 Sep 2006 19:05:27 +0000 (19:05 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6232 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/patron/adv_barcode_entry.xul

index 6698407..526ab34 100644 (file)
@@ -229,7 +229,7 @@ const urls = {
        'XUL_PATRON_BILL_WIZARD' : '/xul/server/patron/bill_wizard.xul',
        'XUL_PATRON_DISPLAY' : '/xul/server/patron/display.xul',
        'XUL_PATRON_EDIT' : '/xul/server/patron/ue.xhtml',
-       'XUL_ADV_PATRON_EDIT' : '/xul/server/patron/user_edit.xml',
+       'XUL_USER_PERM_EDITOR' : '/xul/server/patron/user_edit.xml',
        'XUL_PATRON_HOLDS' : '/xul/server/patron/holds.xul',
        'XUL_PATRON_INFO' : '/xul/server/patron/info.xul',
        'XUL_PATRON_INFO_NOTES' : '/xul/server/patron/info_notes.xul',
index 25fda9e..cbf9129 100644 (file)
@@ -19,6 +19,7 @@
 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
 
 <window id="patron_barcode_entry_win" 
+       onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
        <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
         <scripts id="openils_util_scripts"/>
 
        <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+       <script>
+       <![CDATA[
+               function my_init() {
+                       try {
+                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                               if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+                               JSAN.errorLevel = "die"; // none, warn, or die
+                               JSAN.addRepository('/xul/server/');
+                               JSAN.use('util.error'); g.error = new util.error();
+                               g.error.sdump('D_TRACE','my_init() for patron/barcode_entry.xul');
+
+                               g.cgi = new CGI();
+
+                               var tb = document.getElementById('barcode_tb');
+                               tb.addEventListener(
+                                       'keypress',
+                                       function(ev) {
+                                               if (ev.keyCode == 13 || ev.keyCode == 77) {
+                                                       setTimeout(
+                                                               function() {
+                                                                       submit();
+                                                               }, 0
+                                                       );
+                                               }
+                                       },
+                                       false
+                               );
+                               tb.focus();
+       
+                               if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+                                       try { window.xulG.set_tab_name('User Permission Editor'); } catch(E) { alert(E); }
+                               }
+
+                               if (g.cgi.param('error')) { 
+                                       var error = g.cgi.param('error');
+                                       alert(error);
+                               }
+
+                       } catch(E) {
+                               var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
+                                       "system administrator or software developer the following:\n" + E + '\n';
+                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+                               alert(err_msg);
+                       }
+               }
+
+               function submit() {
+                       var tb;
+                       try {
+                               JSAN.use('util.sound'); var sound = new util.sound();
+                               tb = document.getElementById('barcode_tb');
+                               var barcode = tb.value;
+
+                               barcode = String( barcode ).replace( /\s+/g, '' );
+
+                               if (!barcode) { sound.bad(); add_msg('No barcode entered.'); tb.select(); tb.focus(); return; }
+
+                               JSAN.use('util.network'); var net = new util.network();
+
+                               tb.disabled = true;
+                               document.getElementById('progress').setAttribute('hidden','false');
+                               net.simple_request('PATRON_BARCODE_EXISTS',[ ses(), barcode ],
+                                       function(req) {
+                                               document.getElementById('progress').setAttribute('hidden','true');
+                                               tb.disabled = false; tb.select(); tb.focus(); ;
+                                               var robj = req.getResultObject();
+                                               if (typeof robj.ilsevent != 'undefined') {
+                                                       sound.bad();
+                                                       add_msg('Problem retrieving ' + barcode + '.  Please report this message: \n' + js2JSON(robj));
+                                                       return;
+                                               } else if (robj == 0) {
+                                                       sound.bad(); 
+                                                       add_msg('Barcode ' + barcode + ' not found.');
+                                                       return;
+                                               }
+
+                                               sound.good();
+
+                                               spawn(barcode);
+                                       }
+                               );
+                       } catch(E) {
+                               tb.select(); tb.focus();
+                               g.error.standard_unexpected_error_alert('barcode_entry.xul',E);
+                       }
+               }
+
+               function add_msg(text) {
+                       var x = document.getElementById('status');
+                       var d = document.createElement('description');
+                       x.appendChild(d);
+                       d.appendChild( document.createTextNode( text ) );
+                       d.setAttribute('style','color: red');
+               }
+
+               function spawn(barcode) {
+                       try {
+
+                               JSAN.use('patron.util'); var patron_obj = patron.util.retrieve_fleshed_au_via_barcode( ses(), barcode );
+
+                               var loc = urls.XUL_USER_PERM_EDITOR + '?ses=' + window.escape(ses()) + '&usr=' + patron_obj.id();
+
+                               if (typeof window.xulG == 'object' && typeof window.xulG.set_tab == 'function') {
+
+                                       window.xulG.set_tab( loc, {}, {} );
+                               } else {
+
+                                       location.href = loc;
+;
+                               }
+                       } catch(E) {
+                               g.error.standard_unexpected_error_alert('spawning patron display',E);
+                       }
+               }
+
+               function default_focus() { try { setTimeout( function() { document.getElementById('barcode_tb').focus(); }, 0); } catch(E) {} }
+       ]]>
+       </script>
 
        <vbox flex="1" class="my_overflow">
                <groupbox orient="vertical" flex="1">
-                       <label value="This interface has been disabled."/>
+                       <caption label="Retrieve Patron" />
+                       <hbox>
+                               <label value="Barcode:" accesskey="B" control="barcode_tb"/>
+                               <textbox id="barcode_tb" />
+                               <button label="Submit" accesskey="S" oncommand="submit();"/>
+                       </hbox>
+                       <label value="Retrieving..." style="color: green" id="progress" hidden="true"/>
+                       <vbox id="status">
+                       </vbox>
                </groupbox>
        </vbox>