[ 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/Help/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 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 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 28 * All Rights Reserved. 29 * Contributor(s): ______________________________________.. 30 */ 31 function get_validate_record_js () { 32 $the_script = <<<EOQ 33 34 <script type="text/javascript" language="Javascript"> 35 <!-- to hide script contents from old browsers 36 /** 37 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) 38 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 39 * All Rights Reserved. 40 * Contributor(s): ______________________________________.. 41 */ 42 // Declaring valid date character, minimum year and maximum year 43 var dtCh= "-"; 44 var minYear=1900; 45 var maxYear=2100; 46 47 function isInteger(s){ 48 var i; 49 for (i = 0; i < s.length; i++){ 50 // Check that current character is number. 51 var c = s.charAt(i); 52 if (((c < "0") || (c > "9"))) return false; 53 } 54 // All characters are numbers. 55 return true; 56 } 57 58 function stripCharsInBag(s, bag){ 59 var i; 60 var returnString = ""; 61 // Search through string's characters one by one. 62 // If character is not in bag, append to returnString. 63 for (i = 0; i < s.length; i++){ 64 var c = s.charAt(i); 65 if (bag.indexOf(c) == -1) returnString += c; 66 } 67 return returnString; 68 } 69 70 function daysInFebruary (year){ 71 // February has 29 days in any year evenly divisible by four, 72 // EXCEPT for centurial years which are not also divisible by 400. 73 return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); 74 } 75 function DaysArray(n) { 76 for (var i = 1; i <= n; i++) { 77 this[i] = 31 78 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} 79 if (i==2) {this[i] = 29} 80 } 81 return this 82 } 83 84 function isDate(dtStr){ 85 var daysInMonth = DaysArray(12) 86 var pos1=dtStr.indexOf(dtCh) 87 var pos2=dtStr.indexOf(dtCh,pos1+1) 88 var strYear=dtStr.substring(0,pos1) 89 var strMonth=dtStr.substring(pos1+1,pos2) 90 var strDay=dtStr.substring(pos2+1) 91 strYr=strYear 92 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) 93 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) 94 for (var i = 1; i <= 3; i++) { 95 if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) 96 } 97 month=parseInt(strMonth) 98 day=parseInt(strDay) 99 year=parseInt(strYr) 100 if (pos1==-1 || pos2==-1){ 101 alert("The date format should be : yyyy-mm-dd") 102 return false 103 } 104 if (strMonth.length<1 || month<1 || month>12){ 105 alert("Please enter a valid month") 106 return false 107 } 108 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ 109 alert("Please enter a valid day") 110 return false 111 } 112 if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){ 113 alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) 114 return false 115 } 116 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ 117 alert("Please enter a valid date") 118 return false 119 } 120 return true 121 } 122 123 function verify_data(form) { 124 var isError = false; 125 var errorMessage = ""; 126 if (trim(form.name.value) == "") { 127 isError = true; 128 errorMessage += "\\nAccount Name"; 129 } 130 // Here we decide whether to submit the form. 131 if (isError == true) { 132 alert("Missing required fields: " + errorMessage); 133 return false; 134 } 135 if (trim(form.email1.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email1.value)) { 136 alert('"' + form.email1.value + '" not a valid email address in Email field'); 137 return false; 138 } 139 if (trim(form.email2.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email1.value)) { 140 alert('"' + form.email2.value + '" not a valid email address in Other Email field'); 141 return false; 142 } 143 144 return true; 145 } 146 147 function ParseUSNumber(PhoneNumberInitialString) 148 { 149 var FmtStr=""; 150 var index = 0; 151 var LimitCheck; 152 153 LimitCheck = PhoneNumberInitialString.length; 154 while (index != LimitCheck) 155 { 156 if (isNaN(parseInt(PhoneNumberInitialString.charAt(index)))) 157 { } 158 else 159 { FmtStr = FmtStr + PhoneNumberInitialString.charAt(index); } 160 index = index + 1; 161 } 162 if (FmtStr.length == 10) 163 { 164 FmtStr = "(" + FmtStr.substring(0,3) + ") " + FmtStr.substring(3,6) + "-" + FmtStr.substring(6,10); 165 } 166 167 return FmtStr; 168 } 169 170 171 // end hiding contents from old browsers --> 172 </script> 173 174 EOQ; 175 176 return $the_script; 177 } 178 179 /** 180 * Create HTML form to enter a new record with the minimum necessary fields. 181 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 182 * All Rights Reserved. 183 * Contributor(s): ______________________________________.. 184 */ 185 function get_new_record_form () { 186 //TODO: To be implemented 187 } 188 189 ?>
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 |