[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 /********************************************************************************* 2 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 ********************************************************************************/ 10 11 //Utility Functions 12 13 if (document.all) 14 15 var browser_ie=true 16 17 else if (document.layers) 18 19 var browser_nn4=true 20 21 else if (document.layers || (!document.all && document.getElementById)) 22 23 var browser_nn6=true 24 25 26 27 function getObj(n,d) { 28 29 var p,i,x; 30 31 if(!d) 32 33 d=document; 34 35 36 if(n != undefined) 37 { 38 if((p=n.indexOf("?"))>0&&parent.frames.length) { 39 40 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); 41 42 } 43 } 44 45 46 47 if(!(x=d[n])&&d.all) 48 49 x=d.all[n]; 50 51 52 53 for(i=0;!x&&i<d.forms.length;i++) 54 55 x=d.forms[i][n]; 56 57 58 59 for(i=0;!x&&d.layers&&i<d.layers.length;i++) 60 61 x=getObj(n,d.layers[i].document); 62 63 64 65 if(!x && d.getElementById) 66 67 x=d.getElementById(n); 68 69 70 71 return x; 72 73 } 74 75 76 77 function getOpenerObj(n) { 78 79 return getObj(n,opener.document) 80 81 } 82 83 84 85 function findPosX(obj) { 86 87 var curleft = 0; 88 89 if (document.getElementById || document.all) { 90 91 while (obj.offsetParent) { 92 93 curleft += obj.offsetLeft 94 95 obj = obj.offsetParent; 96 97 } 98 99 } else if (document.layers) { 100 101 curleft += obj.x; 102 103 } 104 105 106 107 return curleft; 108 109 } 110 111 112 113 function findPosY(obj) { 114 115 var curtop = 0; 116 117 118 119 if (document.getElementById || document.all) { 120 121 while (obj.offsetParent) { 122 123 curtop += obj.offsetTop 124 125 obj = obj.offsetParent; 126 127 } 128 129 } else if (document.layers) { 130 131 curtop += obj.y; 132 133 } 134 135 136 137 return curtop; 138 139 } 140 141 142 143 function clearTextSelection() { 144 145 if (browser_ie) document.selection.empty(); 146 147 else if (browser_nn4 || browser_nn6) window.getSelection().removeAllRanges(); 148 149 } 150 151 // Setting cookies 152 function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) 153 { 154 var cookie_string = name + "=" + escape ( value ); 155 156 if (exp_y) //delete_cookie(name) 157 { 158 var expires = new Date ( exp_y, exp_m, exp_d ); 159 cookie_string += "; expires=" + expires.toGMTString(); 160 } 161 162 if (path) cookie_string += "; path=" + escape ( path ); 163 if (domain) cookie_string += "; domain=" + escape ( domain ); 164 if (secure) cookie_string += "; secure"; 165 166 document.cookie = cookie_string; 167 } 168 169 // Retrieving cookies 170 function get_cookie(cookie_name) 171 { 172 var results = document.cookie.match(cookie_name + '=(.*?)(;|$)'); 173 if (results) return (unescape(results[1])); 174 else return null; 175 } 176 177 // Delete cookies 178 function delete_cookie( cookie_name ) 179 { 180 var cookie_date = new Date ( ); // current date & time 181 cookie_date.setTime ( cookie_date.getTime() - 1 ); 182 document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString(); 183 } 184 //End of Utility Functions 185 186 187 188 function emptyCheck(fldName,fldLabel, fldType) { 189 var currObj=getObj(fldName) 190 191 192 if (fldType=="text") { 193 if (currObj.value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) { 194 195 alert(fldLabel+" cannot be empty") 196 197 currObj.focus() 198 199 return false 200 201 } 202 203 else 204 205 return true 206 } else { 207 if (currObj.value == "" ) { 208 209 alert(fldLabel+" cannot be none") 210 211 return false 212 213 } else return true 214 215 } 216 217 } 218 219 220 221 function patternValidate(fldName,fldLabel,type) { 222 var currObj=getObj(fldName) 223 if (type.toUpperCase()=="EMAIL") //Email ID validation 224 var re=new RegExp(/^.+@.+\..+$/) 225 226 if (type.toUpperCase()=="DATE") {//DATE validation 227 //YMD 228 //var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/ //2 digit year 229 //var re = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/ //4 digit year 230 231 //MYD 232 //var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/ 233 //var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/ 234 235 //DMY 236 //var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/ 237 //var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/ 238 239 switch (userDateFormat) { 240 case "yyyy-mm-dd" : 241 var re = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/ 242 break; 243 case "mm-dd-yyyy" : 244 case "dd-mm-yyyy" : 245 var re = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/ 246 } 247 } 248 249 if (type.toUpperCase()=="TIME") {//TIME validation 250 var re = /^\d{1,2}\:\d{1,2}$/ 251 } 252 253 if (!re.test(currObj.value)) { 254 alert("Please enter a valid "+fldLabel) 255 currObj.focus() 256 return false 257 } 258 else return true 259 } 260 261 function splitDateVal(dateval) { 262 var datesep; 263 var dateelements = new Array(3); 264 265 if (dateval.indexOf("-")>=0) datesep="-" 266 else if (dateval.indexOf(".")>=0) datesep="." 267 else if (dateval.indexOf("/")>=0) datesep="/" 268 269 switch (userDateFormat) { 270 case "yyyy-mm-dd" : 271 dateelements[0]=dateval.substr(dateval.lastIndexOf(datesep)+1,dateval.length) //dd 272 dateelements[1]=dateval.substring(dateval.indexOf(datesep)+1,dateval.lastIndexOf(datesep)) //mm 273 dateelements[2]=dateval.substring(0,dateval.indexOf(datesep)) //yyyyy 274 break; 275 case "mm-dd-yyyy" : 276 dateelements[0]=dateval.substring(dateval.indexOf(datesep)+1,dateval.lastIndexOf(datesep)) 277 dateelements[1]=dateval.substring(0,dateval.indexOf(datesep)) 278 dateelements[2]=dateval.substr(dateval.lastIndexOf(datesep)+1,dateval.length) 279 break; 280 case "dd-mm-yyyy" : 281 dateelements[0]=dateval.substring(0,dateval.indexOf(datesep)) 282 dateelements[1]=dateval.substring(dateval.indexOf(datesep)+1,dateval.lastIndexOf(datesep)) 283 dateelements[2]=dateval.substr(dateval.lastIndexOf(datesep)+1,dateval.length) 284 } 285 286 return dateelements; 287 } 288 289 function compareDates(date1,fldLabel1,date2,fldLabel2,type) { 290 var ret=true 291 switch (type) { 292 case 'L' : if (date1>=date2) {//DATE1 VALUE LESS THAN DATE2 293 alert(fldLabel1+" should be less than "+fldLabel2) 294 ret=false 295 } 296 break; 297 case 'LE' : if (date1>date2) {//DATE1 VALUE LESS THAN OR EQUAL TO DATE2 298 alert(fldLabel1+" should be less than or equal to "+fldLabel2) 299 ret=false 300 } 301 break; 302 case 'E' : if (date1!=date2) {//DATE1 VALUE EQUAL TO DATE 303 alert(fldLabel1+" should be equal to "+fldLabel2) 304 ret=false 305 } 306 break; 307 case 'G' : if (date1<=date2) {//DATE1 VALUE GREATER THAN DATE2 308 alert(fldLabel1+" should be greater than "+fldLabel2) 309 ret=false 310 } 311 break; 312 case 'GE' : if (date1<date2) {//DATE1 VALUE GREATER THAN OR EQUAL TO DATE2 313 alert(fldLabel1+" should be greater than or equal to "+fldLabel2) 314 ret=false 315 } 316 break; 317 } 318 319 if (ret==false) return false 320 else return true 321 } 322 323 function dateTimeValidate(dateFldName,timeFldName,fldLabel,type) { 324 if(patternValidate(dateFldName,fldLabel,"DATE")==false) 325 return false; 326 dateval=getObj(dateFldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 327 328 var dateelements=splitDateVal(dateval) 329 330 dd=dateelements[0] 331 mm=dateelements[1] 332 yyyy=dateelements[2] 333 334 if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) { 335 alert("Please enter a valid "+fldLabel) 336 getObj(dateFldName).focus() 337 return false 338 } 339 340 if ((mm==2) && (dd>29)) {//checking of no. of days in february month 341 alert("Please enter a valid "+fldLabel) 342 getObj(dateFldName).focus() 343 return false 344 } 345 346 if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking 347 alert("Please enter a valid "+fldLabel) 348 getObj(dateFldName).focus() 349 return false 350 } 351 352 switch (parseInt(mm)) { 353 case 2 : 354 case 4 : 355 case 6 : 356 case 9 : 357 case 11 : if (dd>30) { 358 alert("Please enter a valid "+fldLabel) 359 getObj(dateFldName).focus() 360 return false 361 } 362 } 363 364 if (patternValidate(timeFldName,fldLabel,"TIME")==false) 365 return false 366 367 var timeval=getObj(timeFldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 368 var hourval=parseInt(timeval.substring(0,timeval.indexOf(":"))) 369 var minval=parseInt(timeval.substring(timeval.indexOf(":")+1,timeval.length)) 370 var currObj=getObj(timeFldName) 371 372 if (hourval>23 || minval>59) { 373 alert("Please enter a valid "+fldLabel) 374 currObj.focus() 375 return false 376 } 377 378 var currdate=new Date() 379 var chkdate=new Date() 380 381 chkdate.setYear(yyyy) 382 chkdate.setMonth(mm-1) 383 chkdate.setDate(dd) 384 chkdate.setHours(hourval) 385 chkdate.setMinutes(minval) 386 387 if (type!="OTH") { 388 if (!compareDates(chkdate,fldLabel,currdate,"current date & time",type)) { 389 getObj(dateFldName).focus() 390 return false 391 } else return true; 392 } else return true; 393 } 394 395 function dateTimeComparison(dateFldName1,timeFldName1,fldLabel1,dateFldName2,timeFldName2,fldLabel2,type) { 396 var dateval1=getObj(dateFldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 397 var dateval2=getObj(dateFldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 398 399 var dateelements1=splitDateVal(dateval1) 400 var dateelements2=splitDateVal(dateval2) 401 402 dd1=dateelements1[0] 403 mm1=dateelements1[1] 404 yyyy1=dateelements1[2] 405 406 dd2=dateelements2[0] 407 mm2=dateelements2[1] 408 yyyy2=dateelements2[2] 409 410 var timeval1=getObj(timeFldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 411 var timeval2=getObj(timeFldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 412 413 var hh1=timeval1.substring(0,timeval1.indexOf(":")) 414 var min1=timeval1.substring(timeval1.indexOf(":")+1,timeval1.length) 415 416 var hh2=timeval2.substring(0,timeval2.indexOf(":")) 417 var min2=timeval2.substring(timeval2.indexOf(":")+1,timeval2.length) 418 419 var date1=new Date() 420 var date2=new Date() 421 422 date1.setYear(yyyy1) 423 date1.setMonth(mm1-1) 424 date1.setDate(dd1) 425 date1.setHours(hh1) 426 date1.setMinutes(min1) 427 428 date2.setYear(yyyy2) 429 date2.setMonth(mm2-1) 430 date2.setDate(dd2) 431 date2.setHours(hh2) 432 date2.setMinutes(min2) 433 434 if (type!="OTH") { 435 if (!compareDates(date1,fldLabel1,date2,fldLabel2,type)) { 436 getObj(dateFldName1).focus() 437 return false 438 } else return true; 439 } else return true; 440 } 441 442 function dateValidate(fldName,fldLabel,type) { 443 if(patternValidate(fldName,fldLabel,"DATE")==false) 444 return false; 445 dateval=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 446 447 var dateelements=splitDateVal(dateval) 448 449 dd=dateelements[0] 450 mm=dateelements[1] 451 yyyy=dateelements[2] 452 453 if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) { 454 alert("Please enter a valid "+fldLabel) 455 getObj(fldName).focus() 456 return false 457 } 458 459 if ((mm==2) && (dd>29)) {//checking of no. of days in february month 460 alert("Please enter a valid "+fldLabel) 461 getObj(fldName).focus() 462 return false 463 } 464 465 if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking 466 alert("Please enter a valid "+fldLabel) 467 getObj(fldName).focus() 468 return false 469 } 470 471 switch (parseInt(mm)) { 472 case 2 : 473 case 4 : 474 case 6 : 475 case 9 : 476 case 11 : if (dd>30) { 477 alert("Please enter a valid "+fldLabel) 478 getObj(fldName).focus() 479 return false 480 } 481 } 482 483 var currdate=new Date() 484 var chkdate=new Date() 485 486 chkdate.setYear(yyyy) 487 chkdate.setMonth(mm-1) 488 chkdate.setDate(dd) 489 490 if (type!="OTH") { 491 if (!compareDates(chkdate,fldLabel,currdate,"current date",type)) { 492 getObj(fldName).focus() 493 return false 494 } else return true; 495 } else return true; 496 } 497 498 function dateComparison(fldName1,fldLabel1,fldName2,fldLabel2,type) { 499 var dateval1=getObj(fldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 500 var dateval2=getObj(fldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 501 502 var dateelements1=splitDateVal(dateval1) 503 var dateelements2=splitDateVal(dateval2) 504 505 dd1=dateelements1[0] 506 mm1=dateelements1[1] 507 yyyy1=dateelements1[2] 508 509 dd2=dateelements2[0] 510 mm2=dateelements2[1] 511 yyyy2=dateelements2[2] 512 513 var date1=new Date() 514 var date2=new Date() 515 516 date1.setYear(yyyy1) 517 date1.setMonth(mm1-1) 518 date1.setDate(dd1) 519 520 date2.setYear(yyyy2) 521 date2.setMonth(mm2-1) 522 date2.setDate(dd2) 523 524 if (type!="OTH") { 525 if (!compareDates(date1,fldLabel1,date2,fldLabel2,type)) { 526 getObj(fldName1).focus() 527 return false 528 } else return true; 529 } else return true 530 } 531 532 function timeValidate(fldName,fldLabel,type) { 533 if (patternValidate(fldName,fldLabel,"TIME")==false) 534 return false 535 536 var timeval=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 537 var hourval=parseInt(timeval.substring(0,timeval.indexOf(":"))) 538 var minval=parseInt(timeval.substring(timeval.indexOf(":")+1,timeval.length)) 539 var currObj=getObj(fldName) 540 541 if (hourval>23 || minval>59) { 542 alert("Please enter a valid "+fldLabel) 543 currObj.focus() 544 return false 545 } 546 547 var currtime=new Date() 548 var chktime=new Date() 549 550 chktime.setHours(hourval) 551 chktime.setMinutes(minval) 552 553 if (type!="OTH") { 554 if (!compareDates(chktime,fldLabel1,currtime,"current time",type)) { 555 getObj(fldName).focus() 556 return false 557 } else return true; 558 } else return true 559 } 560 561 function timeComparison(fldName1,fldLabel1,fldName2,fldLabel2,type) { 562 var timeval1=getObj(fldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 563 var timeval2=getObj(fldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 564 565 var hh1=timeval1.substring(0,timeval1.indexOf(":")) 566 var min1=timeval1.substring(timeval1.indexOf(":")+1,timeval1.length) 567 568 var hh2=timeval2.substring(0,timeval2.indexOf(":")) 569 var min2=timeval2.substring(timeval2.indexOf(":")+1,timeval2.length) 570 571 var time1=new Date() 572 var time2=new Date() 573 574 time1.setHours(hh1) 575 time1.setMinutes(min1) 576 577 time2.setHours(hh2) 578 time2.setMinutes(min2) 579 580 if (type!="OTH") { 581 if (!compareDates(time1,fldLabel1,time2,fldLabel2,type)) { 582 getObj(fldName1).focus() 583 return false 584 } else return true; 585 } else return true; 586 } 587 588 function numValidate(fldName,fldLabel,format,neg) { 589 var val=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 590 if (format!="any") { 591 if (isNaN(val)) { 592 var invalid=true 593 } else { 594 var format=format.split(",") 595 var splitval=val.split(".") 596 if (neg==true) { 597 if (splitval[0].indexOf("-")>=0) { 598 if (splitval[0].length-1>format[0]) 599 invalid=true 600 } else { 601 if (splitval[0].length>format[0]) 602 invalid=true 603 } 604 } else { 605 if (val<0) 606 invalid=true 607 else if (splitval[0].length>format[0]) 608 invalid=true 609 } 610 if (splitval[1]) 611 if (splitval[1].length>format[1]) 612 invalid=true 613 } 614 if (invalid==true) { 615 alert("Invalid "+fldLabel) 616 getObj(fldName).focus() 617 return false 618 } else return true 619 } else { 620 621 var splitval=val.split(".") 622 623 if(splitval[0]>2147483647) 624 { 625 alert( fldLabel + " exceeds the maximum limit "); 626 return false; 627 } 628 629 630 if (neg==true) 631 var re=/^(-|)\d+(\.\d\d*)*$/ 632 else 633 var re=/^\d+(\.\d\d*)*$/ 634 } 635 if (!re.test(val)) { 636 alert("Invalid "+fldLabel) 637 getObj(fldName).focus() 638 return false 639 } else return true 640 } 641 642 643 function intValidate(fldName,fldLabel) { 644 var val=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 645 if (isNaN(val) || (val.indexOf(".")!=-1 && fldName != 'potential_amount')) 646 { 647 alert("Invalid "+fldLabel) 648 getObj(fldName).focus() 649 return false 650 } 651 else if( val < -2147483648 || val > 2147483647) 652 { 653 alert(fldLabel +" is out of range"); 654 return false; 655 } 656 657 else 658 { 659 return true 660 } 661 } 662 663 function numConstComp(fldName,fldLabel,type,constval) { 664 var val=parseFloat(getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '')) 665 constval=parseFloat(constval) 666 667 var ret=true 668 switch (type) { 669 case "L" : if (val>=constval) { 670 alert(fldLabel+" should be less than "+constval) 671 ret=false 672 } 673 break; 674 case "LE" : if (val>constval) { 675 alert(fldLabel+" should be less than or equal to "+constval) 676 ret=false 677 } 678 break; 679 case "E" : if (val!=constval) { 680 alert(fldLabel+" should be equal to "+constval) 681 ret=false 682 } 683 break; 684 case "NE" : if (val==constval) { 685 alert(fldLabel+" should not be equal to "+constval) 686 ret=false 687 } 688 break; 689 case "G" : if (val<=constval) { 690 alert(fldLabel+" should be greater than "+constval) 691 ret=false 692 } 693 break; 694 case "GE" : if (val<constval) { 695 alert(fldLabel+" should be greater than or equal to "+constval) 696 ret=false 697 } 698 break; 699 } 700 701 if (ret==false) { 702 getObj(fldName).focus() 703 return false 704 } else return true; 705 } 706 707 function formValidate() { 708 for (var i=0; i<fieldname.length; i++) { 709 if(getObj(fieldname[i]) != null) 710 { 711 var type=fielddatatype[i].split("~") 712 if (type[1]=="M") { 713 if (!emptyCheck(fieldname[i],fieldlabel[i],getObj(fieldname[i]).type)) 714 return false 715 } 716 717 switch (type[0]) { 718 case "O" : break; 719 case "V" : break; 720 case "C" : break; 721 case "DT" : 722 if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0) 723 { 724 if (type[1]=="M") 725 if (!emptyCheck(type[2],fieldlabel[i],getObj(type[2]).type)) 726 return false 727 728 if(typeof(type[3])=="undefined") var currdatechk="OTH" 729 else var currdatechk=type[3] 730 731 if (!dateTimeValidate(fieldname[i],type[2],fieldlabel[i],currdatechk)) 732 return false 733 if (type[4]) { 734 if (!dateTimeComparison(fieldname[i],type[2],fieldlabel[i],type[5],type[6],type[4])) 735 return false 736 737 } 738 } 739 break; 740 case "D" : 741 if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0) 742 { 743 if(typeof(type[2])=="undefined") var currdatechk="OTH" 744 else var currdatechk=type[2] 745 746 if (!dateValidate(fieldname[i],fieldlabel[i],currdatechk)) 747 return false 748 if (type[3]) { 749 if (!dateComparison(fieldname[i],fieldlabel[i],type[4],type[5],type[3])) 750 return false 751 } 752 } 753 break; 754 case "T" : 755 if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0) 756 { 757 if(typeof(type[2])=="undefined") var currtimechk="OTH" 758 else var currtimechk=type[2] 759 760 if (!timeValidate(fieldname[i],fieldlabel[i],currtimechk)) 761 return false 762 if (type[3]) { 763 if (!timeComparison(fieldname[i],fieldlabel[i],type[4],type[5],type[3])) 764 return false 765 } 766 } 767 break; 768 case "I" : 769 if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0) 770 { 771 if (getObj(fieldname[i]).value.length!=0) 772 { 773 if (!intValidate(fieldname[i],fieldlabel[i])) 774 return false 775 if (type[2]) { 776 if (!numConstComp(fieldname[i],fieldlabel[i],type[2],type[3])) 777 return false 778 } 779 } 780 } 781 break; 782 case "N" : 783 case "NN" : 784 if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0) 785 { 786 if (getObj(fieldname[i]).value.length!=0) 787 { 788 if (typeof(type[2])=="undefined") var numformat="any" 789 else var numformat=type[2] 790 791 if (type[0]=="NN") { 792 793 if (!numValidate(fieldname[i],fieldlabel[i],numformat,true)) 794 return false 795 } else { 796 if (!numValidate(fieldname[i],fieldlabel[i],numformat)) 797 return false 798 } 799 if (type[3]) { 800 if (!numConstComp(fieldname[i],fieldlabel[i],type[3],type[4])) 801 return false 802 } 803 } 804 } 805 break; 806 case "E" : 807 if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0) 808 { 809 if (getObj(fieldname[i]).value.length!=0) 810 { 811 var etype = "EMAIL" 812 if (!patternValidate(fieldname[i],fieldlabel[i],etype)) 813 return false 814 } 815 } 816 break; 817 } 818 } 819 } 820 //added to check Start Date & Time,if Activity Status is Planned.//start 821 822 for (var j=0; j<fieldname.length; j++) 823 { 824 825 if(getObj(fieldname[j]) != null) 826 { 827 if(fieldname[j] == "date_start") 828 { 829 var datelabel = fieldlabel[j] 830 var datefield = fieldname[j] 831 var startdatevalue = getObj(datefield).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 832 } 833 if(fieldname[j] == "time_start") 834 { 835 var timelabel = fieldlabel[j] 836 var timefield = fieldname[j] 837 var timeval=getObj(timefield).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 838 } 839 if(fieldname[j] == "eventstatus" || fieldname[j] == "taskstatus") 840 { 841 var statusvalue = getObj(fieldname[j]).value.replace(/^\s+/g, '').replace(/\s+$/g, '') 842 var statuslabel = fieldlabel[j++] 843 } 844 }else 845 { 846 return true; 847 } 848 } 849 if(statusvalue == "Planned") 850 { 851 var dateelements=splitDateVal(startdatevalue) 852 853 var hourval=parseInt(timeval.substring(0,timeval.indexOf(":"))) 854 var minval=parseInt(timeval.substring(timeval.indexOf(":")+1,timeval.length)) 855 856 857 dd=dateelements[0] 858 mm=dateelements[1] 859 yyyy=dateelements[2] 860 861 var currdate=new Date() 862 var chkdate=new Date() 863 chkdate.setYear(yyyy) 864 chkdate.setMonth(mm-1) 865 chkdate.setDate(dd) 866 867 chktime = new Date() 868 869 chktime.setYear(yyyy) 870 chktime.setMonth(mm-1) 871 chktime.setDate(dd) 872 chktime.setHours(hourval) 873 chktime.setMinutes(minval) 874 if (!compareDates(chkdate,datelabel,currdate,"Current date & time for Activities with status as Planned","GE")) { 875 getObj(datefield).focus() 876 return false 877 } 878 else if(!compareDates(chktime,timelabel,currdate,"Current Time for Activities with status as Planned","GE")) 879 { 880 getObj(timefield).focus() 881 return false 882 } 883 else return true 884 885 }//end 886 887 return true 888 } 889 890 function clearId(fldName) { 891 892 var currObj=getObj(fldName) 893 894 currObj.value="" 895 896 } 897 898 function showCalc(fldName) { 899 var currObj=getObj(fldName) 900 openPopUp("calcWin",currObj,"/crm/Calc.do?currFld="+fldName,"Calc",170,220,"menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=yes") 901 } 902 903 function showLookUp(fldName,fldId,fldLabel,searchmodule,hostName,serverPort,username) { 904 var currObj=getObj(fldName) 905 906 //var fldValue=currObj.value.replace(/^\s+/g, '').replace(/\s+$/g, '') 907 908 //need to pass the name of the system in which the server is running so that even when the search is invoked from another system, the url will remain the same 909 910 openPopUp("lookUpWin",currObj,"/crm/Search.do?searchmodule="+searchmodule+"&fldName="+fldName+"&fldId="+fldId+"&fldLabel="+fldLabel+"&fldValue=&user="+username,"LookUp",500,400,"menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes") 911 } 912 913 function openPopUp(winInst,currObj,baseURL,winName,width,height,features) { 914 var left=parseInt(findPosX(currObj)) 915 var top=parseInt(findPosY(currObj)) 916 917 if (window.navigator.appName!="Opera") top+=parseInt(currObj.offsetHeight) 918 else top+=(parseInt(currObj.offsetHeight)*2)+10 919 920 if (browser_ie) { 921 top+=window.screenTop-document.body.scrollTop 922 left-=document.body.scrollLeft 923 if (top+height+30>window.screen.height) 924 top=findPosY(currObj)+window.screenTop-height-30 //30 is a constant to avoid positioning issue 925 if (left+width>window.screen.width) 926 left=findPosX(currObj)+window.screenLeft-width 927 } else if (browser_nn4 || browser_nn6) { 928 top+=(scrY-pgeY) 929 left+=(scrX-pgeX) 930 if (top+height+30>window.screen.height) 931 top=findPosY(currObj)+(scrY-pgeY)-height-30 932 if (left+width>window.screen.width) 933 left=findPosX(currObj)+(scrX-pgeX)-width 934 } 935 936 features="width="+width+",height="+height+",top="+top+",left="+left+";"+features 937 eval(winInst+'=window.open("'+baseURL+'","'+winName+'","'+features+'")') 938 } 939 940 var scrX=0,scrY=0,pgeX=0,pgeY=0; 941 942 if (browser_nn4 || browser_nn6) { 943 document.addEventListener("click",popUpListener,true) 944 } 945 946 function popUpListener(ev) { 947 if (browser_nn4 || browser_nn6) { 948 scrX=ev.screenX 949 scrY=ev.screenY 950 pgeX=ev.pageX 951 pgeY=ev.pageY 952 } 953 } 954 955 function toggleSelect(state,relCheckName) { 956 if (getObj(relCheckName)) { 957 if (typeof(getObj(relCheckName).length)=="undefined") { 958 getObj(relCheckName).checked=state 959 } else { 960 for (var i=0;i<getObj(relCheckName).length;i++) 961 getObj(relCheckName)[i].checked=state 962 } 963 } 964 } 965 966 function toggleSelectAll(relCheckName,selectAllName) { 967 if (typeof(getObj(relCheckName).length)=="undefined") { 968 getObj(selectAllName).checked=getObj(relCheckName).checked 969 } else { 970 var atleastOneFalse=false; 971 for (var i=0;i<getObj(relCheckName).length;i++) { 972 if (getObj(relCheckName)[i].checked==false) { 973 atleastOneFalse=true 974 break; 975 } 976 } 977 getObj(selectAllName).checked=!atleastOneFalse 978 } 979 } 980 //added for show/hide 10July 981 function expandCont(bn) 982 { 983 var leftTab = document.getElementById(bn); 984 leftTab.style.display = (leftTab.style.display == "block")?"none":"block"; 985 img = document.getElementById("img_"+bn); 986 img.src=(img.src.indexOf("images/toggle1.gif")!=-1)?"themes/images/toggle2.gif":"themes/images/toggle1.gif"; 987 set_cookie_gen(bn,leftTab.style.display) 988 989 } 990 991 function setExpandCollapse_gen() 992 { 993 var x = leftpanelistarray.length; 994 for (i = 0 ; i < x ; i++) 995 { 996 var listObj=getObj(leftpanelistarray[i]) 997 var tgImageObj=getObj("img_"+leftpanelistarray[i]) 998 var status = get_cookie_gen(leftpanelistarray[i]) 999 1000 if (status == "block") { 1001 listObj.style.display="block"; 1002 tgImageObj.src="themes/images/toggle2.gif"; 1003 } else if(status == "none") { 1004 listObj.style.display="none"; 1005 tgImageObj.src="themes/images/toggle1.gif"; 1006 } 1007 } 1008 } 1009 1010 function toggleDiv(id) { 1011 1012 var listTableObj=getObj(id) 1013 1014 if (listTableObj.style.display=="block") 1015 { 1016 listTableObj.style.display="none" 1017 }else{ 1018 listTableObj.style.display="block" 1019 } 1020 //set_cookie(id,listTableObj.style.display) 1021 } 1022 1023 //Setting cookies 1024 function set_cookie_gen ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) 1025 { 1026 var cookie_string = name + "=" + escape ( value ); 1027 1028 if ( exp_y ) 1029 { 1030 var expires = new Date ( exp_y, exp_m, exp_d ); 1031 cookie_string += "; expires=" + expires.toGMTString(); 1032 } 1033 1034 if ( path ) 1035 cookie_string += "; path=" + escape ( path ); 1036 1037 if ( domain ) 1038 cookie_string += "; domain=" + escape ( domain ); 1039 1040 if ( secure ) 1041 cookie_string += "; secure"; 1042 1043 document.cookie = cookie_string; 1044 } 1045 1046 // Retrieving cookies 1047 function get_cookie_gen ( cookie_name ) 1048 { 1049 var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' ); 1050 1051 if ( results ) 1052 return ( unescape ( results[1] ) ); 1053 else 1054 return null; 1055 } 1056 1057 // Delete cookies 1058 function delete_cookie_gen ( cookie_name ) 1059 { 1060 var cookie_date = new Date ( ); // current date & time 1061 cookie_date.setTime ( cookie_date.getTime() - 1 ); 1062 document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString(); 1063 } 1064 //end added for show/hide 10July 1065 1066 /** This is Javascript Function which is used to toogle between 1067 * assigntype user and group/team select options while assigning owner to entity. 1068 */ 1069 function toggleAssignType(currType) 1070 { 1071 if (currType=="U") 1072 { 1073 getObj("assign_user").style.display="block" 1074 getObj("assign_team").style.display="none" 1075 } 1076 else 1077 { 1078 getObj("assign_user").style.display="none" 1079 getObj("assign_team").style.display="block" 1080 } 1081 } 1082 //to display type of address for google map 1083 function showLocateMapMenu() 1084 { 1085 getObj("dropDownMenu").style.display="block" 1086 getObj("dropDownMenu").style.left=findPosX(getObj("locateMap")) 1087 getObj("dropDownMenu").style.top=findPosY(getObj("locateMap"))+getObj("locateMap").offsetHeight 1088 } 1089 1090 1091 function hideLocateMapMenu(ev) 1092 { 1093 if (browser_ie) 1094 currElement=window.event.srcElement 1095 else if (browser_nn4 || browser_nn6) 1096 currElement=ev.target 1097 1098 if (currElement.id!="locateMap") 1099 if (getObj("dropDownMenu").style.display=="block") 1100 getObj("dropDownMenu").style.display="none" 1101 } 1102 /* 1103 * javascript function to display the div tag 1104 * @param divId :: div tag ID 1105 */ 1106 function show(divId) 1107 1108 { 1109 1110 var id = document.getElementById(divId); 1111 1112 id.style.display = 'inline'; 1113 1114 } 1115 1116 /* 1117 * javascript function to display the div tag 1118 * @param divId :: div tag ID 1119 */ 1120 function showBlock(divId) 1121 { 1122 var id = document.getElementById(divId); 1123 id.style.display = 'block'; 1124 } 1125 1126 1127 /* 1128 * javascript function to hide the div tag 1129 * @param divId :: div tag ID 1130 */ 1131 function hide(divId) 1132 { 1133 1134 var id = document.getElementById(divId); 1135 1136 id.style.display = 'none'; 1137 1138 } 1139 function fnhide(divId) 1140 { 1141 1142 var id = document.getElementById(divId); 1143 1144 id.style.display = 'none'; 1145 } 1146 1147 function fnLoadValues(obj1,obj2,SelTab,unSelTab,moduletype,module){ 1148 1149 var oform = document.forms['EditView']; 1150 oform.action.value='Save'; 1151 if((moduletype == 'inventory' && validateInventory(module)) ||(moduletype == 'normal') && formValidate()) 1152 if(formValidate()) 1153 { 1154 var tabName1 = document.getElementById(obj1); 1155 1156 var tabName2 = document.getElementById(obj2); 1157 1158 var tagName1 = document.getElementById(SelTab); 1159 1160 var tagName2 = document.getElementById(unSelTab); 1161 1162 if(tabName1.className == "dvtUnSelectedCell") 1163 1164 tabName1.className = "dvtSelectedCell"; 1165 1166 if(tabName2.className == "dvtSelectedCell") 1167 1168 tabName2.className = "dvtUnSelectedCell"; 1169 tagName1.style.display='block'; 1170 1171 tagName2.style.display='none'; 1172 } 1173 } 1174 1175 function fnCopy(source,design){ 1176 1177 document.getElementById(source).value=document.getElementById(design).value; 1178 1179 document.getElementById(source).disabled=true; 1180 1181 } 1182 1183 function fnClear(source){ 1184 1185 document.getElementById(source).value=" "; 1186 1187 document.getElementById(source).disabled=false; 1188 1189 } 1190 1191 function fnCpy(){ 1192 1193 var tagName=document.getElementById("cpy"); 1194 1195 if(tagName.checked==true){ 1196 fnCopy("shipaddress","address"); 1197 1198 fnCopy("shippobox","pobox"); 1199 1200 fnCopy("shipcity","city"); 1201 1202 fnCopy("shipcode","code"); 1203 1204 fnCopy("shipstate","state"); 1205 1206 fnCopy("shipcountry","country"); 1207 1208 } 1209 1210 else{ 1211 1212 fnClear("shipaddress"); 1213 1214 fnClear("shippobox"); 1215 1216 fnClear("shipcity"); 1217 1218 fnClear("shipcode"); 1219 1220 fnClear("shipstate"); 1221 1222 fnClear("shipcountry"); 1223 1224 } 1225 1226 } 1227 function fnDown(obj){ 1228 var tagName = document.getElementById(obj); 1229 var tabName = document.getElementById("one"); 1230 if(tagName.style.display == 'none'){ 1231 tagName.style.display = 'block'; 1232 tabName.style.display = 'block'; 1233 } 1234 else{ 1235 tabName.style.display = 'none'; 1236 tagName.style.display = 'none'; 1237 } 1238 } 1239 1240 /* 1241 * javascript function to add field rows 1242 * @param option_values :: List of Field names 1243 */ 1244 var count = 0; 1245 var rowCnt = 1; 1246 function fnAddSrch(option_values,criteria_values){ 1247 1248 var tableName = document.getElementById('adSrc'); 1249 1250 var prev = tableName.rows.length; 1251 1252 var count = prev; 1253 1254 var row = tableName.insertRow(prev); 1255 1256 if(count%2) 1257 1258 row.className = "dvtCellLabel"; 1259 1260 else 1261 1262 row.className = "dvtCellInfo"; 1263 1264 var colone = row.insertCell(0); 1265 1266 var coltwo = row.insertCell(1); 1267 1268 var colthree = row.insertCell(2); 1269 1270 colone.innerHTML="<select id='Fields"+count+"' name='Fields"+count+"' class='detailedViewTextBox'>"+option_values+"</select>"; 1271 1272 coltwo.innerHTML="<select id='Condition"+count+"' name='Condition"+count+"' class='detailedViewTextBox'>"+criteria_values+"</select> "; 1273 1274 colthree.innerHTML="<input type='text' id='Srch_value"+count+"' name='Srch_value"+count+"' class='detailedViewTextBox'>"; 1275 1276 } 1277 1278 function totalnoofrows() 1279 { 1280 var tableName = document.getElementById('adSrc'); 1281 document.basicSearch.search_cnt.value = tableName.rows.length; 1282 } 1283 1284 /* 1285 * javascript function to delete field rows in advance search 1286 * @param void :: void 1287 */ 1288 function delRow() 1289 { 1290 1291 var tableName = document.getElementById('adSrc'); 1292 1293 var prev = tableName.rows.length; 1294 1295 if(prev > 1) 1296 1297 document.getElementById('adSrc').deleteRow(prev-1); 1298 1299 } 1300 1301 function fnVis(obj){ 1302 1303 var profTag = document.getElementById("prof"); 1304 1305 var moreTag = document.getElementById("more"); 1306 1307 var addrTag = document.getElementById("addr"); 1308 1309 1310 if(obj == 'prof'){ 1311 1312 document.getElementById('mnuTab').style.display = 'block'; 1313 1314 document.getElementById('mnuTab1').style.display = 'none'; 1315 1316 document.getElementById('mnuTab2').style.display = 'none'; 1317 1318 profTag.className = 'dvtSelectedCell'; 1319 1320 moreTag.className = 'dvtUnSelectedCell'; 1321 1322 addrTag.className = 'dvtUnSelectedCell'; 1323 1324 } 1325 1326 1327 else if(obj == 'more'){ 1328 1329 document.getElementById('mnuTab1').style.display = 'block'; 1330 1331 document.getElementById('mnuTab').style.display = 'none'; 1332 1333 document.getElementById('mnuTab2').style.display = 'none'; 1334 1335 moreTag.className = 'dvtSelectedCell'; 1336 1337 profTag.className = 'dvtUnSelectedCell'; 1338 1339 addrTag.className = 'dvtUnSelectedCell'; 1340 1341 } 1342 1343 1344 else if(obj == 'addr'){ 1345 1346 document.getElementById('mnuTab2').style.display = 'block'; 1347 1348 document.getElementById('mnuTab').style.display = 'none'; 1349 1350 document.getElementById('mnuTab1').style.display = 'none'; 1351 1352 addrTag.className = 'dvtSelectedCell'; 1353 1354 profTag.className = 'dvtUnSelectedCell'; 1355 1356 moreTag.className = 'dvtUnSelectedCell'; 1357 1358 } 1359 1360 } 1361 1362 function fnvsh(obj,Lay){ 1363 var tagName = document.getElementById(Lay); 1364 var leftSide = findPosX(obj); 1365 var topSide = findPosY(obj); 1366 tagName.style.left= leftSide + 175 + 'px'; 1367 tagName.style.top= topSide + 'px'; 1368 tagName.style.visibility = 'visible'; 1369 } 1370 1371 function fnvshobj(obj,Lay){ 1372 var tagName = document.getElementById(Lay); 1373 var leftSide = findPosX(obj); 1374 var topSide = findPosY(obj); 1375 var maxW = tagName.style.width; 1376 var widthM = maxW.substring(0,maxW.length-2); 1377 var getVal = eval(leftSide) + eval(widthM); 1378 if(getVal > document.body.clientWidth ){ 1379 leftSide = eval(leftSide) - eval(widthM); 1380 tagName.style.left = leftSide + 34 + 'px'; 1381 } 1382 else 1383 tagName.style.left= leftSide + 'px'; 1384 tagName.style.top= topSide + 'px'; 1385 tagName.style.display = 'block'; 1386 tagName.style.visibility = "visible"; 1387 } 1388 1389 function posLay(obj,Lay){ 1390 var tagName = document.getElementById(Lay); 1391 var leftSide = findPosX(obj); 1392 var topSide = findPosY(obj); 1393 var maxW = tagName.style.width; 1394 var widthM = maxW.substring(0,maxW.length-2); 1395 var getVal = eval(leftSide) + eval(widthM); 1396 if(getVal > document.body.clientWidth ){ 1397 leftSide = eval(leftSide) - eval(widthM); 1398 tagName.style.left = leftSide + 'px'; 1399 } 1400 else 1401 tagName.style.left= leftSide + 'px'; 1402 tagName.style.top= topSide + 'px'; 1403 } 1404 1405 function fninvsh(Lay){ 1406 var tagName = document.getElementById(Lay); 1407 tagName.style.visibility = 'hidden'; 1408 tagName.style.display = 'none'; 1409 } 1410 1411 function fnvshNrm(Lay){ 1412 var tagName = document.getElementById(Lay); 1413 tagName.style.visibility = 'visible'; 1414 tagName.style.display = 'block'; 1415 } 1416 1417 function cancelForm(frm) 1418 { 1419 window.history.back(); 1420 } 1421 1422 function trim(s) 1423 { 1424 while (s.substring(0,1) == " " || s.substring(0,1) == "\n") 1425 { 1426 s = s.substring(1, s.length); 1427 } 1428 while (s.substring(s.length-1, s.length) == " " || s.substring(s.length-1,s.length) == "\n") { 1429 s = s.substring(0,s.length-1); 1430 } 1431 return s; 1432 } 1433 1434 function clear_form(form) 1435 { 1436 for (j = 0; j < form.elements.length; j++) 1437 { 1438 if (form.elements[j].type == 'text' || form.elements[j].type == 'select-one') 1439 { 1440 form.elements[j].value = ''; 1441 } 1442 } 1443 } 1444 1445 function ActivateCheckBox() 1446 { 1447 var map = document.getElementById("saved_map_checkbox"); 1448 var source = document.getElementById("saved_source"); 1449 1450 if(map.checked == true) 1451 { 1452 source.disabled = false; 1453 } 1454 else 1455 { 1456 source.disabled = true; 1457 } 1458 } 1459 1460 //wipe for Convert Lead 1461 1462 function fnSlide2(obj,inner) 1463 { 1464 var buff = document.getElementById(obj).height; 1465 closeLimit = buff.substring(0,buff.length); 1466 menu_max = eval(closeLimit); 1467 var tagName = document.getElementById(inner); 1468 document.getElementById(obj).style.height=0 + "px"; menu_i=0; 1469 if (tagName.style.display == 'none') 1470 fnexpanLay2(obj,inner); 1471 else 1472 fncloseLay2(obj,inner); 1473 } 1474 1475 function fnexpanLay2(obj,inner) 1476 { 1477 // document.getElementById(obj).style.display = 'run-in'; 1478 var setText = eval(closeLimit) - 1; 1479 if (menu_i<=eval(closeLimit)) 1480 { 1481 if (menu_i>setText){document.getElementById(inner).style.display='block';} 1482 document.getElementById(obj).style.height=menu_i + "px"; 1483 setTimeout(function() { fnexpanLay2(obj,inner); },5); 1484 menu_i=menu_i+5; 1485 } 1486 } 1487 1488 function fncloseLay2(obj,inner) 1489 { 1490 if (menu_max >= eval(openLimit)) 1491 { 1492 if (menu_max<eval(closeLimit)){document.getElementById(inner).style.display='none';} 1493 document.getElementById(obj).style.height=menu_max +"px"; 1494 setTimeout(function() { fncloseLay2(obj,inner); }, 5); 1495 menu_max = menu_max -5; 1496 } 1497 } 1498 1499 function addOnloadEvent(fnc){ 1500 if ( typeof window.addEventListener != "undefined" ) 1501 window.addEventListener( "load", fnc, false ); 1502 else if ( typeof window.attachEvent != "undefined" ) { 1503 window.attachEvent( "onload", fnc ); 1504 } 1505 else { 1506 if ( window.onload != null ) { 1507 var oldOnload = window.onload; 1508 window.onload = function ( e ) { 1509 oldOnload( e ); 1510 window[fnc](); 1511 }; 1512 } 1513 else 1514 window.onload = fnc; 1515 } 1516 } 1517 function InternalMailer(record_id,type) { 1518 var url; 1519 switch(type) { 1520 case 'record_id': 1521 url = 'index.php?module=Emails&action=EmailsAjax&internal_mailer=true&type='+type+'&record=&rec_id='+record_id+'&file=EditView'; 1522 break; 1523 case 'email_addy': 1524 url = 'index.php?module=Emails&action=EmailsAjax&internal_mailer=true&type='+type+'&record=&email_addy='+record_id+'&file=EditView'; 1525 break; 1526 1527 } 1528 1529 var opts = "menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes"; 1530 openPopUp('xComposeEmail',this,url,'createemailWin',830,662,opts); 1531 } 1532 1533 function fnHide_Event(obj){ 1534 document.getElementById(obj).style.visibility = 'hidden'; 1535 } 1536 1537 function OpenCompose(id,mode) 1538 { 1539 switch(mode) 1540 { 1541 case 'edit': 1542 url = 'index.php?module=Emails&action=EmailsAjax&file=EditView&record='+id; 1543 break; 1544 case 'create': 1545 url = 'index.php?module=Emails&action=EmailsAjax&file=EditView'; 1546 break; 1547 case 'forward': 1548 url = 'index.php?module=Emails&action=EmailsAjax&file=EditView&record='+id+'&forward=true'; 1549 break; 1550 } 1551 openPopUp('xComposeEmail',this,url,'createemailWin',820,689,'menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=yes'); 1552 } 1553 1554 //Function added for Mass select in Popup - Philip 1555 function SelectAll(mod,parmod) 1556 { 1557 1558 x = document.selectall.selected_id.length; 1559 var y=0; 1560 if(parmod != 'Calendar') 1561 { 1562 var module = window.opener.document.getElementById('return_module').value 1563 var entity_id = window.opener.document.getElementById('parent_id').value 1564 } 1565 idstring = ""; 1566 namestr = ""; 1567 1568 if ( x == undefined) 1569 { 1570 1571 if (document.selectall.selected_id.checked) 1572 { 1573 idstring = document.selectall.selected_id.value; 1574 if(parmod == 'Calendar') 1575 namestr = document.getElementById('calendarCont'+idstring).innerHTML; 1576 y=1; 1577 } 1578 else 1579 { 1580 alert("Please select at least one entity"); 1581 return false; 1582 } 1583 } 1584 else 1585 { 1586 y=0; 1587 for(i = 0; i < x ; i++) 1588 { 1589 if(document.selectall.selected_id[i].checked) 1590 { 1591 idstring = document.selectall.selected_id[i].value +";"+idstring; 1592 if(parmod == 'Calendar') 1593 { 1594 idval = document.selectall.selected_id[i].value; 1595 namestr = document.getElementById('calendarCont'+idval).innerHTML+"\n"+namestr; 1596 } 1597 y=y+1; 1598 } 1599 } 1600 } 1601 if (y != 0) 1602 { 1603 document.selectall.idlist.value=idstring; 1604 } 1605 else 1606 { 1607 alert("Please select at least one entity"); 1608 return false; 1609 } 1610 if(confirm("Are you sure you want to add the selected "+y+" records ?")) 1611 { 1612 if(parmod == 'Calendar') 1613 { 1614 window.opener.document.EditView.contactidlist.value = idstring; 1615 window.opener.document.EditView.contactlist.value = namestr; 1616 } 1617 else 1618 { 1619 opener.document.location.href="index.php?module="+module+"&parentid="+entity_id+"&action=updateRelations&destination_module="+mod+"&idlist="+idstring; 1620 } 1621 self.close(); 1622 } 1623 else 1624 { 1625 return false; 1626 } 1627 } 1628 function ShowEmail(id) 1629 { 1630 url = 'index.php?module=Emails&action=EmailsAjax&file=DetailView&record='+id; 1631 openPopUp('xComposeEmail',this,url,'createemailWin',820,695,'menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=yes'); 1632 } 1633 1634 var bSaf = (navigator.userAgent.indexOf('Safari') != -1); 1635 var bOpera = (navigator.userAgent.indexOf('Opera') != -1); 1636 var bMoz = (navigator.appName == 'Netscape'); 1637 function execJS(node) { 1638 var st = node.getElementsByTagName('SCRIPT'); 1639 var strExec; 1640 for(var i=0;i<st.length; i++) { 1641 if (bSaf) { 1642 strExec = st[i].innerHTML; 1643 } 1644 else if (bOpera) { 1645 strExec = st[i].text; 1646 } 1647 else if (bMoz) { 1648 strExec = st[i].textContent; 1649 } 1650 else { 1651 strExec = st[i].text; 1652 } 1653 try { 1654 eval(strExec); 1655 } catch(e) { 1656 alert(e); 1657 } 1658 } 1659 } 1660 1661 //Function added for getting the Tab Selected Values (Standard/Advanced Filters) for Custom View - Ahmed 1662 function fnLoadCvValues(obj1,obj2,SelTab,unSelTab){ 1663 1664 var tabName1 = document.getElementById(obj1); 1665 1666 var tabName2 = document.getElementById(obj2); 1667 1668 var tagName1 = document.getElementById(SelTab); 1669 1670 var tagName2 = document.getElementById(unSelTab); 1671 1672 if(tabName1.className == "dvtUnSelectedCell") 1673 1674 tabName1.className = "dvtSelectedCell"; 1675 1676 if(tabName2.className == "dvtSelectedCell") 1677 1678 tabName2.className = "dvtUnSelectedCell"; 1679 tagName1.style.display='block'; 1680 1681 tagName2.style.display='none'; 1682 1683 } 1684 1685 1686 // Drop Dwon Menu 1687 1688 1689 function fnDropDown(obj,Lay){ 1690 var tagName = document.getElementById(Lay); 1691 var leftSide = findPosX(obj); 1692 var topSide = findPosY(obj); 1693 var maxW = tagName.style.width; 1694 var widthM = maxW.substring(0,maxW.length-2); 1695 var getVal = eval(leftSide) + eval(widthM); 1696 if(getVal > document.body.clientWidth ){ 1697 leftSide = eval(leftSide) - eval(widthM); 1698 tagName.style.left = leftSide + 34 + 'px'; 1699 } 1700 else 1701 tagName.style.left= leftSide + 'px'; 1702 tagName.style.top= topSide + 28 +'px'; 1703 tagName.style.display = 'block'; 1704 } 1705 1706 function fnShowDrop(obj){ 1707 document.getElementById(obj).style.display = 'block'; 1708 } 1709 1710 function fnHideDrop(obj){ 1711 document.getElementById(obj).style.display = 'none'; 1712 } 1713 1714 function getCalendarPopup(imageid,fieldid,dateformat) 1715 { 1716 Calendar.setup ({ 1717 inputField : fieldid, ifFormat : dateformat, showsTime : false, button : imageid, singleClick : true, step : 1 1718 }); 1719 } 1720
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 |