From 29ae3af3ada1a753198c417f9a99fc8edf376e90 Mon Sep 17 00:00:00 2001 From: pzed Date: Tue, 18 Aug 2009 15:31:43 +0000 Subject: [PATCH] updated to include circ logging developed by Art git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@623 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- circ/circ_duration.js | 161 ++++++++++++++++++++++++---------------------- circ/circ_duration_OWA.js | 11 ++++ 2 files changed, 95 insertions(+), 77 deletions(-) diff --git a/circ/circ_duration.js b/circ/circ_duration.js index bcc8a2f817..58d47bc00e 100755 --- a/circ/circ_duration.js +++ b/circ/circ_duration.js @@ -1,77 +1,84 @@ -function go(){ - -load_lib('circ/circ_item_config.js'); -load_lib('JSON_v1.js'); -log_vars('circ_duration'); - -try { - /* load circ rules for specific institutions */ - var circ_duration_institution_file = 'circ/circ_duration_' + currentLocation.shortname + '.js'; - load_lib(circ_duration_institution_file); - - log_error(circ_duration_institution_file); - - /* if an institution specific script was loaded, then stop */ - if (result.durationRule) return; -} catch (e) { - // fall through to system-wide defaults -} - -/* treat pre-cat copies like vanilla books */ -if( isTrue(isPrecat) ) { - log_info("pre-cat copy getting duration defaults..."); - result.durationRule = 'default'; - result.recurringFinesRule = 'default'; - result.maxFine = 'default' - return; -} - - -/* grab the config from the config script */ -var config = getItemConfig(); -var itemForm = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : ""; - - -/* ----------------------------------------------------------------------------- - Now set the rule values based on the config. If there is no configured info - on this copy, fall back on defaults. - ----------------------------------------------------------------------------- */ -if( config ) { - - log_debug("circ_duration found a config for the copy"); - result.durationRule = config.durationRule; - result.recurringFinesRule = config.recurringFinesRule; - result.maxFine = config.maxFine; - -} else { - - result.durationRule = 'default'; - result.recurringFinesRule = 'default'; - result.maxFine = 'default'; -} - -if (patronProfile == 'Faculty') { - result.durationRule = '120_days_2_renew'; -} -if (patronProfile == 'Graduate') { - result.durationRule = '120_days_2_renew'; -} -if (patronProfile == 'Undergraduate') { - result.durationRule = '3_weeks_2_renew'; -} -if (patronProfile == 'Staff members') { - result.durationRule = '3_weeks_2_renew'; -} -if (patronProfile == 'Readers') { - result.durationRule = '3_weeks_2_renew'; -} - - -log_info('final duration results: ' + - result.durationRule + ' : ' + result.recurringFinesRule + ' : ' + result.maxFine ); - -} go(); - - - - +function go(){ + +load_lib('circ/circ_item_config.js'); +load_lib('JSON_v1.js'); +log_vars('circ_duration'); + +var currentTime = new Date(); +var debugStamp = "circ" + (currentTime.getMonth() + 1) + "" + + "" + currentTime.getDate() + "" + currentTime.getFullYear() + + ": "; + + +log_info(debugStamp + "location identified as " + currentLocation.shortname); + +try { + /* load circ rules for specific institutions */ + var circ_duration_institution_file = 'circ/circ_duration_' + currentLocation.shortname + '.js'; + load_lib(circ_duration_institution_file); + + log_error(circ_duration_institution_file); + + /* if an institution specific script was loaded, then stop */ + if (result.durationRule) return; +} catch (e) { + // fall through to system-wide defaults + log_info("circ0814: error loading " + e); +} + +/* treat pre-cat copies like vanilla books */ +if( isTrue(isPrecat) ) { + log_info("pre-cat copy getting duration defaults..."); + result.durationRule = 'default'; + result.recurringFinesRule = 'default'; + result.maxFine = 'default' + return; +} + + +/* grab the config from the config script */ +var config = getItemConfig(); +var itemForm = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : ""; + + +/* ----------------------------------------------------------------------------- + Now set the rule values based on the config. If there is no configured info + on this copy, fall back on defaults. + ----------------------------------------------------------------------------- */ +if( config ) { + + log_info("config exists"); + log_debug("circ_duration found a config for the copy"); + result.durationRule = config.durationRule; + result.recurringFinesRule = config.recurringFinesRule; + result.maxFine = config.maxFine; + +} else { + log_info("falling back to default"); + + result.durationRule = 'default'; + result.recurringFinesRule = 'default'; + result.maxFine = 'default'; +} + +if (patronProfile == 'Faculty') { + result.durationRule = '120_days_2_renew'; +} +if (patronProfile == 'Graduate') { + result.durationRule = '120_days_2_renew'; +} +if (patronProfile == 'Undergraduate') { + result.durationRule = '3_weeks_2_renew'; +} +if (patronProfile == 'Staff members') { + result.durationRule = '3_weeks_2_renew'; +} +if (patronProfile == 'Readers') { + result.durationRule = '3_weeks_2_renew'; +} + + +log_info('final duration results: ' + + result.durationRule + ' : ' + result.recurringFinesRule + ' : ' + result.maxFine ); + +} go(); diff --git a/circ/circ_duration_OWA.js b/circ/circ_duration_OWA.js index 8d48fc1767..61155cecca 100644 --- a/circ/circ_duration_OWA.js +++ b/circ/circ_duration_OWA.js @@ -1,5 +1,12 @@ // circ duration rules for Windsor Leddy (OWA) +/* we use a date based identifier to pick up values in the log +*/ +var currentTime = new Date(); +var debugStamp = "circ" + (currentTime.getMonth() + 1) + "" + + "" + currentTime.getDate() + "" + currentTime.getFullYear() + + ": "; + /* set item type defaults - if the either the patron group or the circ modifier is missing or invalid, these settings will be used */ @@ -17,6 +24,8 @@ result.maxFine = '10_dollars'; /* adjust rules by patron group and circ modifier */ +log_info(debugStamp + 'patronProfile is ' + patronProfile + ' - modifier ' + copy.circ_modifier); + switch(patronProfile) { // currently, Patrons group is not used; rules are the same as Readers group @@ -373,4 +382,6 @@ switch(patronProfile) { break; } break; + } +log_info("circ0814 - results: " + result.durationRule); -- 2.11.0