first go at moving staff client 2 trap hold logic to staff client 3
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Dec 2005 16:28:35 +0000 (16:28 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Dec 2005 16:28:35 +0000 (16:28 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2403 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/circ/hold_capture.js [new file with mode: 0644]
Open-ILS/xul/staff_client/server/circ/hold_capture.xul [new file with mode: 0644]
Open-ILS/xul/staff_client/server/circ/hold_capture_overlay.xul [new file with mode: 0644]
Open-ILS/xul/staff_client/server/circ/util.js

diff --git a/Open-ILS/xul/staff_client/server/circ/hold_capture.js b/Open-ILS/xul/staff_client/server/circ/hold_capture.js
new file mode 100644 (file)
index 0000000..cd77ff1
--- /dev/null
@@ -0,0 +1,166 @@
+dump('entering circ.hold_capture.js\n');
+
+if (typeof circ == 'undefined') circ = {};
+circ.hold_capture = function (params) {
+
+       JSAN.use('util.error'); this.error = new util.error();
+       JSAN.use('util.network'); this.network = new util.network();
+       this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
+}
+
+circ.hold_capture.prototype = {
+
+       'init' : function( params ) {
+
+               var obj = this;
+
+               obj.session = params['session'];
+
+               JSAN.use('circ.util');
+               var columns = circ.util.columns( 
+                       { 
+                               'barcode' : { 'hidden' : false },
+                               'title' : { 'hidden' : false },
+                               'status' : { 'hidden' : false },
+                               //'hold_capture_status' : { 'hidden' : false },
+                               'hold_capture_route_to' : { 'hidden' : false },
+                               'hold_capture_text' : { 'hidden' : false, 'flex' : 3 },
+                       } 
+               );
+               dump('columns = ' + js2JSON(columns) + '\n');
+
+               JSAN.use('util.list'); obj.list = new util.list('hold_capture_list');
+               obj.list.init(
+                       {
+                               'columns' : columns,
+                               'map_row_to_column' : circ.util.std_map_row_to_column(),
+                       }
+               );
+               
+               JSAN.use('util.controller'); obj.controller = new util.controller();
+               obj.controller.init(
+                       {
+                               'control_map' : {
+                                       'hold_capture_barcode_entry_textbox' : [
+                                               ['keypress'],
+                                               function(ev) {
+                                                       if (ev.keyCode && ev.keyCode == 13) {
+                                                               obj.hold_capture();
+                                                       }
+                                               }
+                                       ],
+                                       'cmd_broken' : [
+                                               ['command'],
+                                               function() { alert('Not Yet Implemented'); }
+                                       ],
+                                       'cmd_hold_capture_submit_barcode' : [
+                                               ['command'],
+                                               function() {
+                                                       obj.hold_capture();
+                                               }
+                                       ],
+                                       'cmd_hold_capture_print' : [
+                                               ['command'],
+                                               function() {
+                                               }
+                                       ],
+                                       'cmd_hold_capture_reprint' : [
+                                               ['command'],
+                                               function() {
+                                               }
+                                       ],
+                                       'cmd_hold_capture_done' : [
+                                               ['command'],
+                                               function() {
+                                               }
+                                       ],
+                               }
+                       }
+               );
+               this.controller.view.hold_capture_barcode_entry_textbox.focus();
+
+       },
+
+       'hold_capture' : function() {
+               var obj = this;
+               try {
+                       var barcode = obj.controller.view.hold_capture_barcode_entry_textbox.value;
+                       JSAN.use('circ.util');
+                       var hold_capture = circ.util.hold_capture_via_barcode(
+                               obj.session, barcode, true
+                       );
+                       if (hold_capture) {
+                               JSAN.use('patron.util');
+                               var au_obj = patron.util.retrieve_via_id( hold_capture.hold.usr() );
+                               obj.list.append(
+                                       {
+                                               'row' : {
+                                                       'my' : {
+                                                               'patron' : au_obj,
+                                                               'circ' : hold_capture.circ,
+                                                               'mvr' : hold_capture.record,
+                                                               'acp' : hold_capture.copy,
+                                                               'status' : hold_capture.status,
+                                                               'route_to' : hold_capture.route_to,
+                                                               'text' : hold_capture.text,
+                                                       }
+                                               }
+                                       //I could override map_row_to_column here
+                                       }
+                               );
+                       
+                               alert('To Printer\n' + check.text + '\r\n' + 'Barcode: ' + barcode + '  Title: ' + check.record.title() + 
+                                       '  Author: ' + check.record.author() + '\r\n' +
+                                       'Route To: ' + check.route_to + 
+                                       '  Patron: ' + au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + 
+                                       '\r\n'); //FIXME
+                               /*
+                               sPrint(check.text + '<br />\r\n' + 'Barcode: ' + barcode + '  Title: ' + check.record.title() + 
+                                       '  Author: ' + check.record.author() + '<br />\r\n' +
+                                       'Route To: ' + check.route_to + 
+                                       '  Patron: ' + au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + 
+                                       '<br />\r\n'
+                               );
+                               */
+
+                               if (typeof obj.on_hold_capture == 'function') {
+                                       obj.on_hold_capture(hold_capture);
+                               }
+                               if (typeof window.xulG == 'object' && typeof window.xulG.on_hold_capture == 'function') {
+                                       obj.error.sdump('D_CIRC','circ.hold_capture: Calling external .on_hold_capture()\n');
+                                       window.xulG.on_hold_capture(hold_capture);
+                               } else {
+                                       obj.error.sdump('D_CIRC','circ.hold_capture: No external .on_hold_capture()\n');
+                               }
+                       } else {
+                               throw("Could not capture hold.");
+                       }
+
+               } catch(E) {
+                       alert('FIXME: need special alert and error handling\n'
+                               + js2JSON(E));
+                       if (typeof obj.on_failure == 'function') {
+                               obj.on_failure(E);
+                       }
+                       if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
+                               obj.error.sdump('D_CIRC','circ.hold_capture: Calling external .on_failure()\n');
+                               window.xulG.on_failure(E);
+                       } else {
+                               obj.error.sdump('D_CIRC','circ.hold_capture: No external .on_failure()\n');
+                       }
+               }
+
+       },
+
+       'on_hold_capture' : function() {
+               this.controller.view.hold_capture_barcode_entry_textbox.value = '';
+               this.controller.view.hold_capture_barcode_entry_textbox.focus();
+       },
+
+       'on_failure' : function() {
+               this.controller.view.hold_capture_barcode_entry_textbox.select();
+               this.controller.view.hold_capture_barcode_entry_textbox.focus();
+       }
+}
+
+dump('exiting circ.hold_capture.js\n');
diff --git a/Open-ILS/xul/staff_client/server/circ/hold_capture.xul b/Open-ILS/xul/staff_client/server/circ/hold_capture.xul
new file mode 100644 (file)
index 0000000..0beb608
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Patron Display -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/evergreen.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/circ.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window SYSTEM "chrome://evergreen/locale/lang.dtd">
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+<?xul-overlay href="/xul/server/circ/hold_capture_overlay.xul"?>
+
+<window id="hold_capture_win" 
+       onload="my_init()"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+        <script type="text/javascript">var myPackageDir = 'evergreen'; var IAMXUL = true; var g = {};</script>
+        <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 hold_capture.xul');
+
+                               g.cgi = new CGI();
+
+                               JSAN.use('circ.hold_capture'); g.hold_capture = new circ.hold_capture();
+                               g.hold_capture.init( 
+                                       { 
+                                               'session' : g.cgi.param('session') 
+                                       } 
+                               );
+       
+                       } catch(E) {
+                               var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
+                                       "system administrator or software developer the following:\n" 
+                                       + 'circ.hold_capture.xul\n' + E + '\n';
+                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+                               alert(err_msg);
+                       }
+               }
+
+       ]]>
+       </script>
+
+       <commandset id="hold_capture_cmds">
+               <command id="cmd_hold_capture_submit_barcode" />
+               <command id="cmd_hold_capture_print" />
+               <command id="cmd_hold_capture_reprint" />
+               <command id="cmd_hold_capture_done" />
+       </commandset>
+
+       <box id="hold_capture_main" />
+
+</window>
+
diff --git a/Open-ILS/xul/staff_client/server/circ/hold_capture_overlay.xul b/Open-ILS/xul/staff_client/server/circ/hold_capture_overlay.xul
new file mode 100644 (file)
index 0000000..a69b5f7
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!DOCTYPE overlay SYSTEM "chrome://evergreen/locale/lang.dtd">
+<overlay id="hold_capture_overlay" 
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script>dump('loading hold_capture_overlay.xul\n');</script>
+
+<commandset id="hold_capture_cmds" />
+
+<box id="hold_capture_main" flex="1" orient="vertical" class="my_overflow">
+       <vbox id="cmvb1" flex="1"/>
+</box>
+
+<vbox id="cmvb1" flex="1">
+       <groupbox id="cmgb1" flex="2">
+               <caption label="&staff.circ.hold_capture.caption;" />
+               <hbox id="hold_capture_top_ui" />
+               <tree id="hold_capture_list" flex="1" enableColumnDrag="true"/>
+               <hbox id="hold_capture_bottom_ui" />
+       </groupbox>
+</vbox>
+
+<hbox id="hold_capture_top_ui">
+       <label id="hold_capture_scan_barcode_label" 
+               value="&staff.circ.hold_capture.scan_label;" 
+               accesskey="&staff.circ.hold_capture.scan_label.accesskey;" 
+               control="hold_capture_barcode_entry_textbox"/>
+       <textbox id="hold_capture_barcode_entry_textbox"/>
+       <button id="hold_capture_submit_barcode_button" 
+               label="&staff.circ.hold_capture.submit_label;" 
+               command="cmd_hold_capture_submit_barcode"
+               accesskey="&staff.circ.hold_capture.submit_label.accesskey;"/>
+</hbox>
+
+<hbox id="hold_capture_bottom_ui">
+       <button id="hold_capture_print" 
+               label="&staff.hold_capture.print_receipt_label;" 
+               command="cmd_hold_capture_print"
+               accesskey="&staff.hold_capture.print_receipt_label.accesskey;"/>
+       <button id="hold_capture_reprint" 
+               label="&staff.hold_capture.reprint_receipt_label;" 
+               command="cmd_hold_capture_reprint"
+               accesskey="&staff.hold_capture.reprint_receipt_label.accesskey;"/>
+       <spacer id="pcii3s" flex="1"/>
+       <checkbox id="hold_capture_auto" 
+               label="&staff.hold_capture.auto_print_label;" 
+               accesskey="&staff.hold_capture.auto_print_label.accesskey;"/> 
+       <button id="hold_capture_done" 
+               label="&staff.hold_capture.done_label;" 
+               command="cmd_hold_capture_done"
+               accesskey="&staff.hold_capture.done_label.accesskey;"/>
+</hbox>
+
+</overlay>
index cea2c54..f51212c 100644 (file)
@@ -4,7 +4,7 @@ if (typeof circ == 'undefined') var circ = {};
 circ.util = {};
 
 circ.util.EXPORT_OK    = [ 
-       'columns', 'checkin_via_barcode', 'std_map_row_to_column', 'hold_capture_by_copy_barcode'
+       'columns', 'checkin_via_barcode', 'std_map_row_to_column', 'hold_capture_via_copy_barcode'
 ];
 circ.util.EXPORT_TAGS  = { ':all' : circ.util.EXPORT_OK };
 
@@ -184,7 +184,7 @@ circ.util.checkin_via_barcode = function(session,barcode,backdate) {
                                        switch(rv) {
                                                case 0: /* capture */
                                                try {
-                                                       var check2 = this.hold_capture_by_copy_barcode( session, barcode );
+                                                       var check2 = this.hold_capture_via_copy_barcode( session, barcode );
                                                        if (check2) {
                                                                check.copy = check2.copy;
                                                                check.text = check2.text;
@@ -328,7 +328,7 @@ circ.util.checkin_via_barcode = function(session,barcode,backdate) {
        }
 }
 
-circ.util.hold_capture_by_copy_barcode = function ( session, barcode, retrieve_flag ) {
+circ.util.hold_capture_via_copy_barcode = function ( session, barcode, retrieve_flag ) {
        try {
                JSAN.use('util.network'); var network = new util.network();
                JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});