fixed bug in user editor which prevented the expire_date from getting set properly...
[Evergreen.git] / Evergreen / xul / staff_client / server / patron / ue_config.js
index 26abc4c..a071339 100644 (file)
@@ -16,6 +16,7 @@ const CHECK_BARCODE           = 'open-ils.actor:open-ils.actor.barcode.exists';
 const defaultState             = 'GA';
 const defaultCountry           = 'USA';
 const defaultNetAccess = 'None';
+const defaultNetLevel   = 1;
 const CSS_INVALID_DATA = 'invalid_value';
 const ADULT_AGE                        = 18;
 //const GUARDIAN_NOTE          = 'SYSTEM: Parent/Guardian';
@@ -39,14 +40,14 @@ var myPerms = [
 
 var dataFields;
 const numRegex         = /^\d+$/;
-const wordRegex        = /^\w+$/;
-const unameRegex       = /^[a-zA-Z][\.\w\@-]*$/;
+const wordRegex        = /^[\w-]+$/;
+const unameRegex       = /^\w[\.\w\@-]*$/;
 const ssnRegex         = /^\d{3}-\d{2}-\d{4}$/;
 const dlRegex          = /^[a-zA-Z]{2}-\w+/; /* driver's license */
 const phoneRegex       = /^\d{3}-\d{3}-\d{4}(| ex\d+)$/i;
 const nonumRegex       = /^[a-zA-Z]\D*$/; /* no numbers, no beginning whitespace */
 const dateRegex        = /^\d{4}-\d{2}-\d{2}/;
-const zipRegex         = /^\d{5}(-\d{4}|$)/; /* 12345 or 12345-6789 */
+const zipRegex         = /^\d{5}(-\d{4}|-?$)/; /* 12345 or 12345-6789 */
 
 var barredAlerted = false;
 
@@ -78,6 +79,7 @@ function uEditUsrnameBlur(field) {
 function uEditBarcodeBlur(field) {
        var barcode = uEditNodeVal(field);
        if(!barcode) return;
+       _debug("blurring card with new value " + barcode);
        var req = new Request(CHECK_BARCODE, SESSION, barcode);
        req.callback( 
                function(r) {
@@ -396,6 +398,8 @@ function uEditDefineData(patron) {
                                        exptime                 += intsecs * 1000;
                                        expdate.setTime(exptime);
 
+                                       _debug("profile change (interval= '"+interval+"', seconds="+intsecs+")\n\tgenerated a date of " + expdate);
+
                                        var year                        = expdate.getYear() + 1900;
                                        var month               = (expdate.getMonth() + 1) + '';
                                        var day                 = (expdate.getDate()) + '';
@@ -403,8 +407,12 @@ function uEditDefineData(patron) {
                                        if(!month.match(/\d{2}/)) month = '0' + month;
                                        if(!day.match(/\d{2}/)) day = '0' + day;
 
+
                                        var node = $('ue_expire');
                                        node.value = year+'-'+month+'-'+day;
+
+                                       _debug("profile change formatted date to "+ node.value);
+                                       node.onchange();
                                }
                        }
                },
@@ -886,6 +894,8 @@ function uEditBuildSCMField(statcat, row) {
                                        /* map does not exist in the map array but now has data */
                                        if(newval) { 
                                                map.isnew(1);
+                                               if(!patron.stat_cat_entries())
+                                                       patron.stat_cat_entries([]);
                                                patron.stat_cat_entries().push(map);
                                        }
                                }