details:   https://code.openbravo.com/erp/devel/pi/rev/380fb64679e9
changeset: 21641:380fb64679e9
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Tue Dec 17 23:48:04 2013 +0100
summary:   Related to issue 25244: Now an error is shown in non-existing dates
like 30-02-2013 or 32-08-2013 in 2.50 based windows

details:   https://code.openbravo.com/erp/devel/pi/rev/5a49c922ecdd
changeset: 21642:5a49c922ecdd
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Tue Dec 17 23:49:52 2013 +0100
summary:   Fixed issue 25244: Now 'Trial Balance' report cannot be generated if
there is an invalid date

diffstat:

 src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html |   10 +-
 src/org/openbravo/erpCommon/security/Login.html                |    2 +-
 src/org/openbravo/erpCommon/security/Login_F1.html             |    2 +-
 web/js/default/DateTextBox.js                                  |   37 ++-
 web/js/dojo/dojo.js                                            |  122 
+++++-----
 web/js/utils.js                                                |    4 +-
 6 files changed, 101 insertions(+), 76 deletions(-)

diffs (279 lines):

diff -r 754999c5e3bc -r 5a49c922ecdd 
src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html    Tue Dec 
17 16:31:40 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html    Tue Dec 
17 23:49:52 2013 +0100
@@ -13,7 +13,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2012 Openbravo SLU
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -115,6 +115,14 @@
       setWindowElementFocus(frm.inpcAcctSchemaId);
       showJSMessage(7);
       return false;
+    }  else if (!dojo.widget.byId(frm.inpDateFrom.id).isValid()) {
+      setWindowElementFocus(frm.inpDateFrom);
+      showJSMessage(5);
+      return false;
+    }  else if (!dojo.widget.byId(frm.inpDateTo.id).isValid()) {
+      setWindowElementFocus(frm.inpDateTo);
+      showJSMessage(5);
+      return false;
     }
     markCheckedAllElements(frm.inpcBPartnerId_IN);
     markCheckedAllElements(frm.inpcProjectId_IN);
diff -r 754999c5e3bc -r 5a49c922ecdd 
src/org/openbravo/erpCommon/security/Login.html
--- a/src/org/openbravo/erpCommon/security/Login.html   Tue Dec 17 16:31:40 
2013 +0100
+++ b/src/org/openbravo/erpCommon/security/Login.html   Tue Dec 17 23:49:52 
2013 +0100
@@ -406,7 +406,7 @@
     }
     catch (e) { }
 
-    if ((!revisionControl('18119')) || (isOpsInstance() != 
isOpsInstanceCached())) {
+    if ((!revisionControl('21641')) || (isOpsInstance() != 
isOpsInstanceCached())) {
       maskLoginWindow(cacheMsg);
       setLoginMessage('Warning', '', cacheMsg);
     }
diff -r 754999c5e3bc -r 5a49c922ecdd 
src/org/openbravo/erpCommon/security/Login_F1.html
--- a/src/org/openbravo/erpCommon/security/Login_F1.html        Tue Dec 17 
16:31:40 2013 +0100
+++ b/src/org/openbravo/erpCommon/security/Login_F1.html        Tue Dec 17 
23:49:52 2013 +0100
@@ -126,7 +126,7 @@
       clearForm();
     } catch (e) {}
     setWindowElementFocus('firstElement');
-    if ((!revisionControl('18119')) || (isOpsInstance() != 
isOpsInstanceCached())) {
+    if ((!revisionControl('21641')) || (isOpsInstance() != 
isOpsInstanceCached())) {
       alert(cacheMsg);
     }
 
diff -r 754999c5e3bc -r 5a49c922ecdd web/js/default/DateTextBox.js
--- a/web/js/default/DateTextBox.js     Tue Dec 17 16:31:40 2013 +0100
+++ b/web/js/default/DateTextBox.js     Tue Dec 17 23:49:52 2013 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2007 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -202,6 +202,23 @@
     return false;
   }
 
+  var checkProperDate = function(year, month, day) {
+    var tentativeDate;
+    year = parseFloat(year, 10);
+    month = parseFloat(month, 10);
+    day = parseFloat(day, 10);
+    if (day < 1 || day > 31) return false;
+    if (month < 1 || month > 12) return false;
+    if (year < 1 || year > 9999) return false;
+    tentativeDate = new Date(year, month - 1, day);
+    if (day !== tentativeDate.getDate()) {
+      // To avoid non-existing dates like 30-02-2013 or 32-08-2013
+      // Fixes issue: https://issues.openbravo.com/view.php?id=25244
+      return false;
+    }
+    return true;
+  }
+
   switch (str_dateFormat) { 
     case "MM-DD-YYYY": 
     case "YY-MM-DDDD": 
@@ -216,9 +233,9 @@
     case "MM-DD-YY": 
     case "%m-%d-%Y": 
     case "%m-%d-%y": 
-      if (dateBlock[2] < 1 || dateBlock[2] > 31) return false; 
-      if (dateBlock[1] < 1 || dateBlock[1] > 12) return false; 
-      if (dateBlock[3] < 1 || dateBlock[3] > 9999) return false; 
+      if (!checkProperDate(dateBlock[3], dateBlock[1], dateBlock[2])) {
+        return false;
+      }
       inputDate=new Date(parseFloat(dateBlock[3]), parseFloat(dateBlock[1])-1, 
parseFloat(dateBlock[2]), timeBlock[1], timeBlock[2], timeBlock[3]);
       if (fullYear) { inputDate.setFullYear(dateBlock[3]); }
       return inputDate; 
@@ -226,9 +243,9 @@
     case "YY-MM-DD": 
     case "%Y-%m-%d": 
     case "%y-%m-%d": 
-      if (dateBlock[3] < 1 || dateBlock[3] > 31) return false; 
-      if (dateBlock[2] < 1 || dateBlock[2] > 12) return false; 
-      if (dateBlock[1] < 1 || dateBlock[1] > 9999) return false; 
+      if (!checkProperDate(dateBlock[1], dateBlock[2], dateBlock[3])) {
+        return false;
+      }
       inputDate=new Date(parseFloat(dateBlock[1]), parseFloat(dateBlock[2])-1, 
parseFloat(dateBlock[3]), timeBlock[1], timeBlock[2], timeBlock[3]);
       if (fullYear) { inputDate.setFullYear(dateBlock[1]); }
       return inputDate; 
@@ -237,9 +254,9 @@
     case "%d-%m-%Y": 
     case "%d-%m-%y": 
     default: 
-      if (dateBlock[1] < 1 || dateBlock[1] > 31) return false; 
-      if (dateBlock[2] < 1 || dateBlock[2] > 12) return false; 
-      if (dateBlock[3] < 1 || dateBlock[3] > 9999) return false; 
+      if (!checkProperDate(dateBlock[3], dateBlock[2], dateBlock[1])) {
+        return false;
+      }
       inputDate=new Date(parseFloat(dateBlock[3]), parseFloat(dateBlock[2])-1, 
parseFloat(dateBlock[1]), timeBlock[1], timeBlock[2], timeBlock[3]);
       if (fullYear) { inputDate.setFullYear(dateBlock[3]); }
       return inputDate; 
diff -r 754999c5e3bc -r 5a49c922ecdd web/js/dojo/dojo.js
--- a/web/js/dojo/dojo.js       Tue Dec 17 16:31:40 2013 +0100
+++ b/web/js/dojo/dojo.js       Tue Dec 17 23:49:52 2013 +0100
@@ -12597,67 +12597,67 @@
 }else{
 return false;
 }
-},getDate:function(_b1f,_b20){
-var _b21=new Date(0,0,0);
-if(_b1f.length==0){
-return _b21;
-}
-var _b22=/^(\d+)[\-|\/|/|:|.|\.](\d+)[\-|\/|/|:|.|\.](\d+)$/;
-if(!_b22.exec(_b1f)){
-return false;
-}
-if(!_b20){
-_b20=defaultDateFormat;
-}
-switch(_b20){
-case "%m-%d-%Y":
-case "%m/%d/%Y":
-case "%m.%d.%Y":
-case "%m:%d:%Y":
-if(RegExp.$2<1||RegExp.$2>31){
-return false;
-}
-if(RegExp.$1<1||RegExp.$1>12){
-return false;
-}
-if(RegExp.$3<1||RegExp.$3>9999){
-return false;
-}
-_b21=new 
Date(parseFloat(RegExp.$3),parseFloat(RegExp.$1)-1,parseFloat(RegExp.$2));
-return _b21;
-case "%Y-%m-%d":
-case "%Y/%m/%d":
-case "%Y.%m.%d":
-case "%Y:%m:%d":
-if(RegExp.$3<1||RegExp.$3>31){
-return false;
-}
-if(RegExp.$2<1||RegExp.$2>12){
-return false;
-}
-if(RegExp.$1<1||RegExp.$1>9999){
-return false;
-}
-_b21=new 
Date(parseFloat(RegExp.$1),parseFloat(RegExp.$2)-1,parseFloat(RegExp.$3));
-return _b21;
-case "%d-%m-%Y":
-case "%d/%m/%Y":
-case "%d.%m.%Y":
-case "%d:%m:%Y":
-default:
-if(RegExp.$1<1||RegExp.$1>31){
-return false;
-}
-if(RegExp.$2<1||RegExp.$2>12){
-return false;
-}
-if(RegExp.$3<1||RegExp.$3>9999){
-return false;
-}
-_b21=new 
Date(parseFloat(RegExp.$3),parseFloat(RegExp.$2)-1,parseFloat(RegExp.$1));
-return _b21;
-}
-return false;
+},getDate: function (str_date, str_dateFormat) {
+  var inputDate = new Date(0, 0, 0);
+  if (str_date.length == 0) {
+    return inputDate;
+  }
+  var datePattern = /^(\d+)[\-|\/|/|:|.|\.](\d+)[\-|\/|/|:|.|\.](\d+)$/;
+  if (!datePattern.exec(str_date)) {
+    return false;
+  }
+  if (!str_dateFormat) {
+    str_dateFormat = defaultDateFormat;
+  }
+
+  var checkProperDate = function(year, month, day) {
+    var tentativeDate;
+    year = parseFloat(year, 10);
+    month = parseFloat(month, 10);
+    day = parseFloat(day, 10);
+    if (day < 1 || day > 31) return false;
+    if (month < 1 || month > 12) return false;
+    if (year < 1 || year > 9999) return false;
+    tentativeDate = new Date(year, month - 1, day);
+    if (day !== tentativeDate.getDate()) {
+      // To avoid non-existing dates like 30-02-2013 or 32-08-2013
+      // Fixes issue: https://issues.openbravo.com/view.php?id=25244
+      return false;
+    }
+    return true;
+  }
+
+  switch (str_dateFormat) {
+  case "%m-%d-%Y":
+  case "%m/%d/%Y":
+  case "%m.%d.%Y":
+  case "%m:%d:%Y":
+    if (!checkProperDate(RegExp.$3, RegExp.$1, RegExp.$2)) {
+      return false;
+    }
+    inputDate = new Date(parseFloat(RegExp.$3), parseFloat(RegExp.$1) - 1, 
parseFloat(RegExp.$2));
+    return inputDate;
+  case "%Y-%m-%d":
+  case "%Y/%m/%d":
+  case "%Y.%m.%d":
+  case "%Y:%m:%d":
+    if (!checkProperDate(RegExp.$1, RegExp.$2, RegExp.$3)) {
+      return false;
+    }
+    inputDate = new Date(parseFloat(RegExp.$1), parseFloat(RegExp.$2) - 1, 
parseFloat(RegExp.$3));
+    return inputDate;
+  case "%d-%m-%Y":
+  case "%d/%m/%Y":
+  case "%d.%m.%Y":
+  case "%d:%m:%Y":
+  default:
+    if (!checkProperDate(RegExp.$3, RegExp.$2, RegExp.$1)) {
+      return false;
+    }
+    inputDate = new Date(parseFloat(RegExp.$3), parseFloat(RegExp.$2) - 1, 
parseFloat(RegExp.$1));
+    return inputDate;
+  }
+  return false;
 },isInRange:function(){
 
if((this.greaterThan==""||this.greaterThan==null)&&(this.lowerThan==""||this.lowerThan==null)){
 return true;
diff -r 754999c5e3bc -r 5a49c922ecdd web/js/utils.js
--- a/web/js/utils.js   Tue Dec 17 16:31:40 2013 +0100
+++ b/web/js/utils.js   Tue Dec 17 23:49:52 2013 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2012 Openbravo SLU
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -101,7 +101,7 @@
 * Return a number that would be checked at the Login screen to know if the 
file is cached with the correct version
 */
 function getCurrentRevision() {
-  var number = '18119';
+  var number = '21641';
   return number;
 }
 

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to