getting closer to the real thing
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 7 Jul 2006 20:12:04 +0000 (20:12 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 7 Jul 2006 20:12:04 +0000 (20:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4937 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/backend/circ/circ_duration.js
Open-ILS/src/javascript/backend/circ/circ_lib.js
Open-ILS/src/javascript/backend/circ/circ_max_fines.js
Open-ILS/src/javascript/backend/circ/circ_permit_copy.js
Open-ILS/src/javascript/backend/circ/circ_recurring_fines.js
Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm

index 5c61aa6..478efc7 100644 (file)
@@ -263,6 +263,8 @@ result.durationLevel        = copy.loan_duration;
        ----------------------------------------------------------------------------- */
 var marcType = getMARCItemType();
 var circMod = copy.circ_modifier;
+var itemForm = extractFixedField(marcXMLDoc,'Form');
+
 var config = 
        ( circMod && CIRC_MOD_MAP[circMod] ) ?
        CIRC_MOD_MAP[circMod] : 
@@ -286,6 +288,7 @@ log_debug("Copy circ modifier = " + circMod + " and item type = " + marcType );
        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;
@@ -293,6 +296,7 @@ if( config ) {
        result.maxFine                                  = config.maxFine;
 
 } else {
+
        result.durationRule                     = '14_days_2_renew';
        result.recurringFinesRule       = "10_cent_per_day";
        result.recurringFinesLevel = 'normal';
@@ -300,10 +304,31 @@ if( config ) {
 }
 
 
+
+
 /* ----------------------------------------------------------------------------- 
-       Add custom rules here.
+       Add custom rules here.  
        ----------------------------------------------------------------------------- */
 
+/* statelib has some special circ rules */
+
+if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) {
+
+       result.durationRule                     = '35_days_1_renew';
+       result.recurringFinesRule       = "10_cent_per_day";
+       result.recurringFinesLevel = 'normal';
+       result.maxFine                                  = "overdue_mid";
+
+       /* reference, microfiche, microfilm */
+       if(     isTrue(copy.ref)        || 
+                       itemForm == 'a' || 
+                       itemForm == 'b' ) {
+
+               result.durationRule             = '14_days_2_renew';
+       }       
+}
+
 
 
 } go();
+
index 8b80cb6..080d448 100644 (file)
@@ -159,7 +159,9 @@ function getMARCItemType() {
 
 
 function isOrgDescendent( parentName, childId ) {
-       var val = environment.__OILS_FUNC_isOrgDescendent(parentName, childId);
+       var key = scratchKey();
+       __OILS_FUNC_isOrgDescendent(scratchPad(key), parentName, childId);
+       var val = getScratch(key);
        if( val == '1' ) return true;
        return false;
 }
index 178e144..2d7cb9c 100644 (file)
@@ -8,8 +8,11 @@ log_vars('circ_permit_copy');
 if( ! isTrue(copy.circulate) ) 
        result.events.push('COPY_CIRC_NOT_ALLOWED');
 
-if( isTrue(copy.ref) ) 
-       result.events.push('COPY_IS_REFERENCE');
+
+if( ! isOrgDescendent( 'STATELIB', copy.circ_lib.id ) ) {
+       if( isTrue(copy.ref) ) 
+               result.events.push('COPY_IS_REFERENCE');
+}
 
 
 
index d7e1a82..92bd00d 100644 (file)
@@ -241,7 +241,6 @@ sub insert_org_methods {
        my ( $editor, $ctx ) = @_;
        my $runner = $ctx->{runner};
 
-
        if(!$ORG_TREE) {
                $ORG_TREE = $editor->search_actor_org_unit(
                        [
@@ -256,12 +255,17 @@ sub insert_org_methods {
                flatten_org_tree($ORG_TREE);
        }
 
-       $runner->insert("$evt.__OILS_FUNC_isOrgDescendent", 
+       $runner->insert(__OILS_FUNC_isOrgDescendent  => 
                sub {
-                       my( $sname, $id ) = @_;
+                       my( $write_key, $sname, $id ) = @_;
+                       $logger->debug("script_builder: org descendent: $sname - $id");
                        my ($parent)    = grep { $_->shortname eq $sname } @ORG_LIST;
                        my ($child)             = grep { $_->id == $id } @ORG_LIST;
-                       return is_org_descendent( $parent, $child );
+                       $logger->debug("script_builder: org descendent: $parent = $child");
+                       my $val = is_org_descendent( $parent, $child );
+                       $logger->debug("script_builder: ord desc = $val");
+                       $runner->insert($write_key, $val);
+                       return $val;
                }
        );
 }
@@ -279,3 +283,4 @@ sub is_org_descendent {
 1;
 
 
+