[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 * The contents of this file are subject to the SugarCRM Public License Version 1.1.2 4 * ("License"); You may not use this file except in compliance with the 5 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL 6 * Software distributed under the License is distributed on an "AS IS" basis, 7 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 8 * the specific language governing rights and limitations under the License. 9 * The Original Code is: SugarCRM Open Source 10 * The Initial Developer of the Original Code is SugarCRM, Inc. 11 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; 12 * All Rights Reserved. 13 * Contributor(s): ______________________________________. 14 ********************************************************************************/ 15 /********************************************************************************* 16 * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Dashboard/Forms.php,v 1.2 2004/10/06 09:02:05 jack Exp $ 17 * Description: Contains a variety of utility functions used to display UI 18 * components such as form vtiger_headers and footers. Intended to be modified on a per 19 * theme basis. 20 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 21 * All Rights Reserved. 22 * Contributor(s): ______________________________________.. 23 ********************************************************************************/ 24 25 /** 26 * Create javascript to validate the data entered into a record. 27 */ 28 function get_validate_chart_js () { 29 global $mod_strings; 30 global $app_strings; 31 32 $err_invalid_date_format = $app_strings['ERR_INVALID_DATE_FORMAT']; 33 $err_invalid_month = $app_strings['ERR_INVALID_MONTH']; 34 $err_invalid_day = $app_strings['ERR_INVALID_DAY']; 35 $err_invalid_year = $app_strings['ERR_INVALID_YEAR']; 36 $err_invalid_date = $app_strings['ERR_INVALID_DATE']; 37 38 $the_script = <<<EOQ 39 40 <script type="text/javascript" language="Javascript"> 41 <!-- to hide script contents from old browsers 42 /** 43 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) 44 */ 45 // Declaring valid date character, minimum year and maximum year 46 var dtCh= "-"; 47 var minYear=1900; 48 var maxYear=2100; 49 50 function isInteger(s){ 51 var i; 52 for (i = 0; i < s.length; i++){ 53 // Check that current character is number. 54 var c = s.charAt(i); 55 if (((c < "0") || (c > "9"))) return false; 56 } 57 // All characters are numbers. 58 return true; 59 } 60 61 function stripCharsInBag(s, bag){ 62 var i; 63 var returnString = ""; 64 // Search through string's characters one by one. 65 // If character is not in bag, append to returnString. 66 for (i = 0; i < s.length; i++){ 67 var c = s.charAt(i); 68 if (bag.indexOf(c) == -1) returnString += c; 69 } 70 return returnString; 71 } 72 73 function daysInFebruary (year){ 74 // February has 29 days in any year evenly divisible by four, 75 // EXCEPT for centurial years which are not also divisible by 400. 76 return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); 77 } 78 function DaysArray(n) { 79 for (var i = 1; i <= n; i++) { 80 this[i] = 31 81 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} 82 if (i==2) {this[i] = 29} 83 } 84 return this 85 } 86 87 function isDate(dtStr){ 88 var daysInMonth = DaysArray(12) 89 var pos1=dtStr.indexOf(dtCh) 90 var pos2=dtStr.indexOf(dtCh,pos1+1) 91 var strYear=dtStr.substring(0,pos1) 92 var strMonth=dtStr.substring(pos1+1,pos2) 93 var strDay=dtStr.substring(pos2+1) 94 strYr=strYear 95 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) 96 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) 97 for (var i = 1; i <= 3; i++) { 98 if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) 99 } 100 month=parseInt(strMonth) 101 day=parseInt(strDay) 102 year=parseInt(strYr) 103 if (pos1==-1 || pos2==-1){ 104 alert("$err_invalid_date_format") 105 return false 106 } 107 if (strMonth.length<1 || month<1 || month>12){ 108 alert("$err_invalid_month") 109 return false 110 } 111 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ 112 alert("$err_invalid_day") 113 return false 114 } 115 if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){ 116 alert("$err_invalid_year") 117 return false 118 } 119 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ 120 alert("$err_invalid_date") 121 return false 122 } 123 return true 124 } 125 126 127 function verify_chart_data(form) { 128 var isError = false; 129 var errorMessage = ""; 130 if (form.date_start.value != '' && isDate(form.date_start.value)==false) { 131 return false; 132 } 133 if (form.date_end.value != '' && isDate(form.date_end.value)==false) { 134 return false; 135 } 136 return true; 137 } 138 // end hiding contents from old browsers --> 139 </script> 140 141 EOQ; 142 143 return $the_script; 144 } 145 146 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |