updated to include circ logging developed by Art
authorpzed <pzed@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 18 Aug 2009 15:31:43 +0000 (15:31 +0000)
committerpzed <pzed@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 18 Aug 2009 15:31:43 +0000 (15:31 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@623 6d9bc8c9-1ec2-4278-b937-99fde70a366f

circ/circ_duration.js
circ/circ_duration_OWA.js

index bcc8a2f..58d47bc 100755 (executable)
@@ -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(){\r
+\r
+load_lib('circ/circ_item_config.js');\r
+load_lib('JSON_v1.js');\r
+log_vars('circ_duration');\r
+\r
+var currentTime = new Date();\r
+var debugStamp = "circ" + (currentTime.getMonth() + 1) + "" +\r
+       "" + currentTime.getDate() + "" + currentTime.getFullYear() +\r
+       ": ";\r
+\r
+\r
+log_info(debugStamp + "location identified as " + currentLocation.shortname);\r
+\r
+try {   \r
+       /* load circ rules for specific institutions */\r
+       var circ_duration_institution_file = 'circ/circ_duration_' + currentLocation.shortname + '.js';\r
+       load_lib(circ_duration_institution_file);\r
+\r
+       log_error(circ_duration_institution_file);\r
+\r
+       /* if an institution specific script was loaded, then stop */\r
+       if (result.durationRule) return;\r
+} catch (e) {\r
+       // fall through to system-wide defaults\r
+       log_info("circ0814: error loading " + e);\r
+}\r
+\r
+/* treat pre-cat copies like vanilla books */\r
+if( isTrue(isPrecat) ) {\r
+       log_info("pre-cat copy getting duration defaults...");\r
+       result.durationRule                     = 'default';\r
+       result.recurringFinesRule       = 'default';\r
+       result.maxFine                          = 'default'\r
+       return;\r
+}\r
+\r
+\r
+/* grab the config from the config script */\r
+var config = getItemConfig();\r
+var itemForm   = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";\r
+\r
+\r
+/* ----------------------------------------------------------------------------- \r
+       Now set the rule values based on the config.  If there is no configured info\r
+       on this copy, fall back on defaults.\r
+       ----------------------------------------------------------------------------- */\r
+if( config ) {\r
+\r
+       log_info("config exists");\r
+       log_debug("circ_duration found a config for the copy");\r
+       result.durationRule                     = config.durationRule;\r
+       result.recurringFinesRule       = config.recurringFinesRule;\r
+       result.maxFine                      = config.maxFine;\r
+\r
+} else {\r
+       log_info("falling back to default");\r
+\r
+       result.durationRule = 'default';\r
+       result.recurringFinesRule = 'default';\r
+       result.maxFine = 'default';\r
+}\r
+\r
+if (patronProfile == 'Faculty') {\r
+       result.durationRule = '120_days_2_renew';\r
+}\r
+if (patronProfile == 'Graduate') {\r
+       result.durationRule = '120_days_2_renew';\r
+}\r
+if (patronProfile == 'Undergraduate') {\r
+       result.durationRule = '3_weeks_2_renew';\r
+}\r
+if (patronProfile == 'Staff members') {\r
+       result.durationRule = '3_weeks_2_renew';\r
+}\r
+if (patronProfile == 'Readers') {\r
+       result.durationRule = '3_weeks_2_renew';\r
+}\r
+\r
+\r
+log_info('final duration results: ' + \r
+    result.durationRule + ' : ' + result.recurringFinesRule + ' : ' + result.maxFine );\r
+\r
+} go();\r
index 8d48fc1..61155ce 100644 (file)
@@ -1,5 +1,12 @@
 // circ duration rules for Windsor Leddy (OWA)\r
 \r
+/* we use a date based identifier to pick up values in the log\r
+*/\r
+var currentTime = new Date();\r
+var debugStamp = "circ" + (currentTime.getMonth() + 1) + "" +\r
+        "" + currentTime.getDate() + "" + currentTime.getFullYear() +\r
+        ": ";\r
+\r
 /* set item type defaults - if the either the patron group or the circ modifier\r
    is missing or invalid, these settings will be used */\r
 \r
@@ -17,6 +24,8 @@ result.maxFine = '10_dollars';
 \r
 /* adjust rules by patron group and circ modifier */\r
 \r
+log_info(debugStamp + 'patronProfile is ' + patronProfile + ' - modifier ' + copy.circ_modifier);\r
+\r
 switch(patronProfile) {\r
 \r
     // currently, Patrons group is not used; rules are the same as Readers group\r
@@ -373,4 +382,6 @@ switch(patronProfile) {
                 break;\r
         }\r
         break;\r
+\r
 }\r
+log_info("circ0814 - results: " + result.durationRule);\r