pre cat checkout
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Feb 2006 17:32:51 +0000 (17:32 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Feb 2006 17:32:51 +0000 (17:32 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2999 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/circ/checkout.js
Open-ILS/xul/staff_client/server/circ/pre_cat_fields.xul [new file with mode: 0644]

index 1c60be7..f54a00d 100644 (file)
@@ -87,6 +87,7 @@ var urls = {
        'XUL_PATRON_SEARCH_FORM' : '/xul/server/patron/search_form.xul',
        'XUL_PATRON_SEARCH_RESULT' : '/xul/server/patron/search_result.xul',
        'XUL_PATRON_SUMMARY' : '/xul/server/patron/summary.xul',
+       'XUL_PRE_CAT' : '/xul/server/circ/pre_cat_fields.xul',
        'XUL_REMOTE_BROWSER' : '/xul/server/util/rbrowser.xul',
        'XUL_STAT_CAT_EDIT' : '/xul/server/admin/stat_cat_editor.xml',
        'XUL_SURVEY_WIZARD' : 'chrome://open_ils_staff_client/content/admin/survey_wizard.xul',
index ec66000..9c45c2d 100644 (file)
@@ -129,85 +129,138 @@ circ.checkout.prototype = {
        'checkout' : function(params) {
                if (!params) params = {};
                var obj = this;
-               try {
 
-                       params.patron = obj.patron_id;
+               /**********************************************************************************************************************/
+               /* This does the actual checkout/renewal, but is called after a permit test further below */
+               function check_out(params) {
 
-                       var permit = obj.network.request(
-                               api.CHECKOUT_PERMIT.app,
-                               api.CHECKOUT_PERMIT.method,
+                       var checkout = obj.network.request(
+                               api.CHECKOUT.app,
+                               api.CHECKOUT.method,
                                [ obj.session, params ]
                        );
 
-                       if (permit.ilsevent == 0) {
+                       if (checkout.ilsevent == 0) {
 
-                               params.permit_key = permit.payload;
+                               if (!checkout.payload) checkout.payload = {};
 
-                               var checkout = obj.network.request(
-                                       api.CHECKOUT.app,
-                                       api.CHECKOUT.method,
-                                       [ obj.session, params ]
-                               );
-                               if (checkout.ilsevent == 0) {
-                                       if (!checkout.payload) checkout.payload = {};
-                                       if (!checkout.payload.circ) {
-                                               checkout.payload.circ = new aoc();
-                                               if (checkout.payload.noncat_circ) {
-                                                       checkout.payload.circ.circ_lib( checkout.payload.noncat_circ.circ_lib() );
-                                                       checkout.payload.circ.circ_staff( checkout.payload.noncat_circ.staff() );
-                                                       checkout.payload.circ.usr( checkout.payload.noncat_circ.patron() );
-                                                       
-                                                       JSAN.use('util.date');
-                                                       var c = checkout.payload.noncat_circ.circ_time();
-                                                       var d = c == "now" ? new Date() : util.date.db_date2Date( c );
-                                                       var t =obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ];
-                                                       var cd = t.circ_duration() || "14 days";
-                                                       var i = util.date.interval_to_seconds( cd ) * 1000;
-                                                       d.setTime( Date.parse(d) + i );
-                                                       checkout.payload.circ.due_date( util.date.formatted_date(d,'%F') );
+                               if (!checkout.payload.circ) {
+                                       checkout.payload.circ = new aoc();
+                                       /*********************************************************************************************/
+                                       /* Non Cat */
+                                       if (checkout.payload.noncat_circ) {
+                                               checkout.payload.circ.circ_lib( checkout.payload.noncat_circ.circ_lib() );
+                                               checkout.payload.circ.circ_staff( checkout.payload.noncat_circ.staff() );
+                                               checkout.payload.circ.usr( checkout.payload.noncat_circ.patron() );
+                                               
+                                               JSAN.use('util.date');
+                                               var c = checkout.payload.noncat_circ.circ_time();
+                                               var d = c == "now" ? new Date() : util.date.db_date2Date( c );
+                                               var t =obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ];
+                                               var cd = t.circ_duration() || "14 days";
+                                               var i = util.date.interval_to_seconds( cd ) * 1000;
+                                               d.setTime( Date.parse(d) + i );
+                                               checkout.payload.circ.due_date( util.date.formatted_date(d,'%F') );
 
-                                               }
-                                       }
-                                       if (!checkout.payload.record) {
-                                               checkout.payload.record = new mvr();
-                                               if (checkout.payload.noncat_circ) {
-                                                       checkout.payload.record.title(
-                                                               obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ].name()
-                                                       );
-                                               }
                                        }
-                                       if (!checkout.payload.copy) {
-                                               checkout.payload.copy = new acp();
-                                               checkout.payload.copy.barcode( 'special' );
+                               }
+
+                               if (!checkout.payload.record) {
+                                       checkout.payload.record = new mvr();
+                                       /*********************************************************************************************/
+                                       /* Non Cat */
+                                       if (checkout.payload.noncat_circ) {
+                                               checkout.payload.record.title(
+                                                       obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ].name()
+                                               );
                                        }
-                                       obj.list.append(
-                                               {
-                                                       'row' : {
-                                                               'my' : {
-                                                               'circ' : checkout.payload.circ,
-                                                               'mvr' : checkout.payload.record,
-                                                               'acp' : checkout.payload.copy
-                                                               }
+                               }
+
+                               if (!checkout.payload.copy) {
+                                       checkout.payload.copy = new acp();
+                                       checkout.payload.copy.barcode( '' );
+                               }
+
+                               /*********************************************************************************************/
+                               /* Override mvr title/author with dummy title/author for Pre cat */
+                               if (checkout.payload.copy.dummy_title())  checkout.payload.record.title( checkout.payload.copy.dummy_title() );
+                               if (checkout.payload.copy.dummy_author())  checkout.payload.record.author( checkout.payload.copy.dummy_author() );
+
+                               obj.list.append(
+                                       {
+                                               'row' : {
+                                                       'my' : {
+                                                       'circ' : checkout.payload.circ,
+                                                       'mvr' : checkout.payload.record,
+                                                       'acp' : checkout.payload.copy
                                                        }
-                                               //I could override map_row_to_column here
                                                }
-                                       );
-                                       if (typeof obj.on_checkout == 'function') {
-                                               obj.on_checkout(checkout.payload);
-                                       }
-                                       if (typeof window.xulG == 'object' && typeof window.xulG.on_checkout == 'function') {
-                                               obj.error.sdump('D_CIRC','circ.checkout: Calling external .on_checkout()\n');
-                                               window.xulG.on_checkout(checkout.payload);
-                                       } else {
-                                               obj.error.sdump('D_CIRC','circ.checkout: No external .on_checkout()\n');
+                                       //I could override map_row_to_column here
                                        }
+                               );
+                               if (typeof obj.on_checkout == 'function') {
+                                       obj.on_checkout(checkout.payload);
+                               }
+                               if (typeof window.xulG == 'object' && typeof window.xulG.on_checkout == 'function') {
+                                       obj.error.sdump('D_CIRC','circ.checkout: Calling external .on_checkout()\n');
+                                       window.xulG.on_checkout(checkout.payload);
                                } else {
-                                       throw(checkout);
+                                       obj.error.sdump('D_CIRC','circ.checkout: No external .on_checkout()\n');
                                }
+                       } else {
+                               throw(checkout);
+                       }
+               }
+
+               /**********************************************************************************************************************/
+               /* Permissibility test before checkout */
+               try {
+
+                       params.patron = obj.patron_id;
+
+                       var permit = obj.network.request(
+                               api.CHECKOUT_PERMIT.app,
+                               api.CHECKOUT_PERMIT.method,
+                               [ obj.session, params ]
+                       );
+
+                       /**********************************************************************************************************************/
+                       /* Normal case, proceed with checkout */
+                       if (permit.ilsevent == 0) {
+
+                               params.permit_key = permit.payload;
+                               check_out( params );
+
+                       /**********************************************************************************************************************/
+                       /* Item not cataloged or barcode mis-scan.  Prompt for pre-cat option */
+                       } else if (permit.ilsevent == 1202) {
+
+                               if ( 1 == obj.error.yns_alert(
+                                       'Mis-scan or non-cataloged item.  Checkout as a pre-cataloged item?',
+                                       'Alert',
+                                       'Cancel',
+                                       'Pre-Cat',
+                                       null,
+                                       null
+                               ) ) {
+
+                                       obj.data.dummy_title = ''; obj.data.dummy_author = ''; obj.data.stash('dummy_title','dummy_author');
+                                       JSAN.use('util.window'); var win = new util.window();
+                                       win.open(urls.XUL_PRE_CAT, 'dummy_fields', 'chrome,resizable,modal');
+                                       obj.data.stash_retrieve();
+
+                                       params.permit_key = permit.payload;
+                                       params.dummy_title = obj.data.dummy_title;
+                                       params.dummy_author = obj.data.dummy_author;
+                                       params.precat = 1;
+
+                                       if (params.dummy_title != '') { check_out( params ); } else { throw('Checkout cancelled'); }
+                               } 
 
                        } else {
                                throw(permit);
                        }
+
                } catch(E) {
                        alert('FIXME: need special alert and error handling\n'
                                + js2JSON(E));
diff --git a/Open-ILS/xul/staff_client/server/circ/pre_cat_fields.xul b/Open-ILS/xul/staff_client/server/circ/pre_cat_fields.xul
new file mode 100644 (file)
index 0000000..d680598
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Patron Display -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="pre_cat_fields" title="CC Info"
+       orient="vertical" style="overflow: auto"
+       onload="try{my_init();}catch(E){alert(E);}"
+       onunload="try{my_finish();}catch(E){alert(E);}"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+        <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; 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() {
+                       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 pre_cat_fields.xul');
+                       JSAN.use('OpenILS.data'); g.data = new OpenILS.data();
+                       g.data.init({'via':'stash'});
+
+                       document.getElementById('dummy_title').focus();
+               }
+
+               function my_finish() {
+                       /* FIXME -- need unique temp space name */
+                       /* FIXME -- We need to blank dummy_title on a forced window close */
+                       g.data.stash('dummy_title','dummy_author');
+               }
+
+       ]]>
+       </script>
+
+
+       <groupbox>
+               <caption label="Pre-Catalog Field Entry"/>
+               <grid>
+                       <columns><column /><column flex="1"/></columns>
+                       <rows>
+                               <row>
+                                       <label value="Title" control="dummy_title"/>
+                                       <textbox id="dummy_title" onchange="g.data.dummy_title = event.target.value;"/>
+                               </row>
+                               <row>
+                                       <label value="Author" control="dummy_author"/>
+                                       <textbox id="dummy_author" onchange="g.data.dummy_author = event.target.value;"/>
+                               </row>
+                       </rows>
+               </grid>
+               <hbox>
+                       <spacer flex="1"/>
+                       <button label="Cancel" oncommand="g.data.dummy_title = ''; window.close()" accesskey="C"/>
+                       <button label="Checkout" oncommand="window.close();" accesskey="o"/>
+               </hbox>
+       </groupbox>
+
+</window>
+
+