use the org setting for juvenile age threshold if present. only hide the juvenile...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 9 Dec 2008 00:15:25 +0000 (00:15 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 9 Dec 2008 00:15:25 +0000 (00:15 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11458 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/ue.js
Open-ILS/xul/staff_client/server/patron/ue_config.js

index a9499ee..79963fc 100644 (file)
@@ -10,6 +10,7 @@ var surveyAnswersCache                = {};
 var userCache                                  = {};
 var groupsCache                                = {};
 var netLevelsCache                     = {};
+var orgSettings             = [];
 //var guardianNote                             = null;
 
 if(!window.xulG) var xulG = null;
@@ -140,6 +141,8 @@ function uEditBuild() {
        if (xulG) if (xulG.params) if (xulG.params.usr) usr = xulG.params.usr;
        patron = fetchFleshedUser(usr);
        if(!patron) patron = uEditNewPatron(); 
+
+    orgSettings = fetchBatchOrgSetting(USER.ws_ou(), ['global.juvenile_age_threshold']);
        
        uEditDraw( 
                uEditFetchIdentTypes(),
index 8bb5005..ac8f7fe 100644 (file)
@@ -19,8 +19,8 @@ const defaultNetAccess        = 'None';
 const defaultNetLevel   = 1;
 const CSS_INVALID_DATA = 'invalid_value';
 
-// XXX Should become an org unit setting XXX
-const ADULT_AGE                        = 18;
+// if no org setting exists
+const DEFAULT_ADULT_AGE                        = '18 years';
 
 //const GUARDIAN_NOTE          = 'SYSTEM: Parent/Guardian';
 
@@ -1060,21 +1060,21 @@ function uEditCheckDOB(field) {
        }
 
        var base = new Date();
-       base.setYear( today.getYear() + 1900 - ADULT_AGE );
-
-       /* patron is at least 18 */
+    var age = orgSettings['global.juvenile_age_threshold'].value || DEFAULT_ADULT_AGE;
+    base.setTime(base.getTime() - Number(interval_to_seconds(age) + '000'));
 
        var f = uEditFindFieldByKey('ident_value2');
+       unHideMe(f.widget.node.parentNode.parentNode.parentNode);
 
        if( dob < base ) { /* patron is of age */
                f.required = false;
-               hideMe(f.widget.node.parentNode.parentNode.parentNode);
+        if(!uEditNodeVal(f))
+                   hideMe(f.widget.node.parentNode.parentNode.parentNode);
                return;
        }
 
        uEditFindFieldByKey('juvenile').widget.node.checked = true;
 
-       unHideMe(f.widget.node.parentNode.parentNode.parentNode);
        f.required = true;
        uEditCheckErrors();
 }