From cb90a8a068266d4edbc4d1241d87209b0efabbdf Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 7 Feb 2006 17:32:51 +0000 Subject: [PATCH] pre cat checkout git-svn-id: svn://svn.open-ils.org/ILS/trunk@2999 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/main/constants.js | 1 + .../xul/staff_client/server/circ/checkout.js | 173 ++++++++++++------ .../server/circ/pre_cat_fields.xul | 82 +++++++++ 3 files changed, 196 insertions(+), 60 deletions(-) create mode 100644 Open-ILS/xul/staff_client/server/circ/pre_cat_fields.xul diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 1c60be730f..f54a00d204 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -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', diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index ec660004aa..9c45c2dbc8 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -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 index 0000000000..d680598918 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/circ/pre_cat_fields.xul @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +