no longer allowing hold updates when date is invalid or <= today
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 1 Apr 2008 15:29:21 +0000 (15:29 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 1 Apr 2008 15:29:21 +0000 (15:29 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@9176 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/skin/default/js/holds.js
Open-ILS/web/opac/skin/default/js/myopac.js

index 57b0426..b79e59d 100644 (file)
@@ -27,6 +27,8 @@ function holdsHandleStaff() {
     };
 }
 
+$('holds_frozen_thaw_input').onchange = 
+        function(){holdsVerifyThawDateUI('holds_frozen_thaw_input');}
 $('holds_frozen_thaw_input').onkeyup = 
         function(){holdsVerifyThawDateUI('holds_frozen_thaw_input');}
 
@@ -467,6 +469,10 @@ function __holdsDrawWindow() {
        if(holdArgs.type == 'M') hideMe($('hold_physical_desc_row'));
 
        holdsSetFormatSelector();
+
+    $('holds_frozen_chkbox').checked = false;
+    hideMe($('hold_frozen_thaw_row'));
+
 }
 
 function holdsParseMRFormats(str) {
@@ -711,11 +717,10 @@ function holdsBuildHoldFromWindow() {
         unHideMe($('hold_frozen_thaw_row'));
         thawDate = $('holds_frozen_thaw_input').value;
         if(thawDate) {
-            if(holdsVerifyThawDate(thawDate)) {
+            if(holdsVerifyThawDate(thawDate)) 
                 hold.thaw_date(thawDate);
-            } else {
-                /* XXX */
-            }
+            else
+                return;
         } else {
             hold.thaw_date(null);
         }
@@ -824,17 +829,20 @@ function holdsUpdate(hold, user) {
 
 
 /* verify that the thaw date is valid and after today */
-function holdsVerifyThawDate(thawDate) {
-    thawDate = Date.parseIso8601(thawDate);
-    if(thawDate) {
-        var today = new Date();
-        today = new Date(today.getFullYear(), today.getMonth(), today.getDate())
-        if(thawDate > today) 
-            return thawDate.iso8601Format('YMD', false, false, true);
-    }
+function holdsVerifyThawDate(dateString) {
+    if(Date.parseIso8601(dateString) && 
+            holdGreaterThanToday(dateString)) 
+        return dateString;
     return null;
 }
 
+function holdGreaterThanToday(dateString) {
+    thawDate = Date.parseIso8601(dateString);
+    var today = new Date();
+    today = new Date(today.getFullYear(), today.getMonth(), today.getDate())
+    return thawDate > today;
+}
+
 
 function holdsVerifyThawDateUI(element) {
     value = $(element).value;
index ec1c057..1aabe82 100644 (file)
@@ -22,6 +22,8 @@ function myOPACInit() {
 
     $('myopac_holds_thaw_date_input').onkeyup = 
         function(){holdsVerifyThawDateUI('myopac_holds_thaw_date_input'); }
+    $('myopac_holds_thaw_date_input').onchange = 
+        function(){holdsVerifyThawDateUI('myopac_holds_thaw_date_input'); }
 }
 
 function myopacReload() {
@@ -1434,12 +1436,11 @@ function myopacDrawHoldThawDateForm() {
 
 function myopacApplyThawDate() {
     var dateString = $('myopac_holds_thaw_date_input').value;
-    if(dateString) {
+    if(dateString) 
         dateString = holdsVerifyThawDate(dateString);
         if(!dateString) return;
-    } else {
+    else
         dateString = null;
-    }
     myopacProcessHolds('freeze', dateString);
 }