/********************************************************************************* ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 * ("License"); You may not use this file except in compliance with the License * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. ********************************************************************************/ //Utility Functions function c_toggleAssignType(currType){ if (currType=="U") { document.getElementById("c_assign_user").style.display="block"; document.getElementById("c_assign_team").style.display="none"; } else { document.getElementById("c_assign_user").style.display="none"; document.getElementById("c_assign_team").style.display="block"; } } var gValidationCall=''; if (document.all) var browser_ie=true else if (document.layers) var browser_nn4=true else if (document.layers || (!document.all && document.getElementById)) var browser_nn6=true var gBrowserAgent = navigator.userAgent.toLowerCase(); function hideSelect() { var oselect_array = document.getElementsByTagName('SELECT'); for(var i=0;i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); } } if(d.getElementById) { x=d.getElementById(n); // IE7 was returning form element with name = n (if there was multiple instance) // But not firefox, so we are making a double check if(x && x.id != n) x = false; } for(i=0;!x && i') { alert(fldLabel+alert_arr.CANNOT_BE_NONE); return false; } else{ return true; } } else{ if (trim(currObj.value) == '') { alert(fldLabel+alert_arr.CANNOT_BE_NONE) return false } else return true } } function patternValidate(fldName,fldLabel,type) { var currObj=getObj(fldName); if (type.toUpperCase()=="EMAIL") //Email ID validation { /*changes made to fix -- ticket#3278 & ticket#3461 var re=new RegExp(/^.+@.+\..+$/)*/ //Changes made to fix tickets #4633, #5111 to accomodate all possible email formats var re=new RegExp(/^[a-zA-Z0-9]+([!"#$%&'()*+,./:;<=>?@\^_`{|}~-]?[a-zA-Z0-9])*@[a-zA-Z0-9]+([\_\-\.]?[a-zA-Z0-9]+)*\.([\-\_]?[a-zA-Z0-9])+(\.?[a-zA-Z0-9]+)?$/); } if (type.toUpperCase()=="DATE") {//DATE validation //YMD //var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/ //2 digit year //var re = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/ //4 digit year //MYD //var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/ //var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/ //DMY //var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/ //var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/ switch (userDateFormat) { case "yyyy-mm-dd" : var re = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/ break; case "mm-dd-yyyy" : case "dd-mm-yyyy" : var re = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/ } } if (type.toUpperCase()=="TIME") {//TIME validation var re = /^\d{1,2}\:\d{2}:\d{2}$|^\d{1,2}\:\d{2}$/ } //Asha: Remove spaces on either side of a Email id before validating if (type.toUpperCase()=="EMAIL" || type.toUpperCase() == "DATE") currObj.value = trim(currObj.value); if (!re.test(currObj.value)) { alert(alert_arr.ENTER_VALID + fldLabel + " ("+type+")"); try { currObj.focus() } catch(error) { // Fix for IE: If element or its wrapper around it is hidden, setting focus will fail // So using the try { } catch(error) { } } return false } else return true } function splitDateVal(dateval) { var datesep; var dateelements = new Array(3); if (dateval.indexOf("-")>=0) datesep="-" else if (dateval.indexOf(".")>=0) datesep="." else if (dateval.indexOf("/")>=0) datesep="/" switch (userDateFormat) { case "yyyy-mm-dd" : dateelements[0]=dateval.substr(dateval.lastIndexOf(datesep)+1,dateval.length) //dd dateelements[1]=dateval.substring(dateval.indexOf(datesep)+1,dateval.lastIndexOf(datesep)) //mm dateelements[2]=dateval.substring(0,dateval.indexOf(datesep)) //yyyyy break; case "mm-dd-yyyy" : dateelements[0]=dateval.substring(dateval.indexOf(datesep)+1,dateval.lastIndexOf(datesep)) dateelements[1]=dateval.substring(0,dateval.indexOf(datesep)) dateelements[2]=dateval.substr(dateval.lastIndexOf(datesep)+1,dateval.length) break; case "dd-mm-yyyy" : dateelements[0]=dateval.substring(0,dateval.indexOf(datesep)) dateelements[1]=dateval.substring(dateval.indexOf(datesep)+1,dateval.lastIndexOf(datesep)) dateelements[2]=dateval.substr(dateval.lastIndexOf(datesep)+1,dateval.length) } return dateelements; } function compareDates(date1,fldLabel1,date2,fldLabel2,type) { var ret=true switch (type) { case 'L' : if (date1>=date2) {//DATE1 VALUE LESS THAN DATE2 alert(fldLabel1+ alert_arr.SHOULDBE_LESS +fldLabel2) ret=false } break; case 'LE' : if (date1>date2) {//DATE1 VALUE LESS THAN OR EQUAL TO DATE2 alert(fldLabel1+alert_arr.SHOULDBE_LESS_EQUAL+fldLabel2) ret=false } break; case 'E' : if (date1!=date2) {//DATE1 VALUE EQUAL TO DATE alert(fldLabel1+alert_arr.SHOULDBE_EQUAL+fldLabel2) ret=false } break; case 'G' : if (date1<=date2) {//DATE1 VALUE GREATER THAN DATE2 alert(fldLabel1+alert_arr.SHOULDBE_GREATER+fldLabel2) ret=false } break; case 'GE' : if (date131 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) { alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(dateFldName).focus() } catch(error) { } return false } if ((mm==2) && (dd>29)) {//checking of no. of days in february month alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(dateFldName).focus() } catch(error) { } return false } if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(dateFldName).focus() } catch(error) { } return false } switch (parseInt(mm)) { case 2 : case 4 : case 6 : case 9 : case 11 : if (dd>30) { alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(dateFldName).focus() } catch(error) { } return false } } if (patternValidate(timeFldName,fldLabel,"TIME")==false) return false var timeval=getObj(timeFldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var hourval=parseInt(timeval.substring(0,timeval.indexOf(":"))) var minval=parseInt(timeval.substring(timeval.indexOf(":")+1,timeval.length)) var currObj=getObj(timeFldName) if (hourval>23 || minval>59) { alert(alert_arr.ENTER_VALID+fldLabel) try { currObj.focus() } catch(error) { } return false } var currdate=new Date() var chkdate=new Date() chkdate.setYear(yyyy) chkdate.setMonth(mm-1) chkdate.setDate(dd) chkdate.setHours(hourval) chkdate.setMinutes(minval) if (type!="OTH") { if (!compareDates(chkdate,fldLabel,currdate,"current date & time",type)) { try { getObj(dateFldName).focus() } catch(error) { } return false } else return true; } else return true; } function dateTimeComparison(dateFldName1,timeFldName1,fldLabel1,dateFldName2,timeFldName2,fldLabel2,type) { var dateval1=getObj(dateFldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var dateval2=getObj(dateFldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var dateelements1=splitDateVal(dateval1) var dateelements2=splitDateVal(dateval2) dd1=dateelements1[0] mm1=dateelements1[1] yyyy1=dateelements1[2] dd2=dateelements2[0] mm2=dateelements2[1] yyyy2=dateelements2[2] var timeval1=getObj(timeFldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var timeval2=getObj(timeFldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var hh1=timeval1.substring(0,timeval1.indexOf(":")) var min1=timeval1.substring(timeval1.indexOf(":")+1,timeval1.length) var hh2=timeval2.substring(0,timeval2.indexOf(":")) var min2=timeval2.substring(timeval2.indexOf(":")+1,timeval2.length) var date1=new Date() var date2=new Date() date1.setYear(yyyy1) date1.setMonth(mm1-1) date1.setDate(dd1) date1.setHours(hh1) date1.setMinutes(min1) date2.setYear(yyyy2) date2.setMonth(mm2-1) date2.setDate(dd2) date2.setHours(hh2) date2.setMinutes(min2) if (type!="OTH") { if (!compareDates(date1,fldLabel1,date2,fldLabel2,type)) { try { getObj(dateFldName1).focus() } catch(error) { } return false } else return true; } else return true; } function dateValidate(fldName,fldLabel,type) { if(patternValidate(fldName,fldLabel,"DATE")==false) return false; dateval=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var dateelements=splitDateVal(dateval) dd=dateelements[0] mm=dateelements[1] yyyy=dateelements[2] if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) { alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(fldName).focus() } catch(error) { } return false } if ((mm==2) && (dd>29)) {//checking of no. of days in february month alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(fldName).focus() } catch(error) { } return false } if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(fldName).focus() } catch(error) { } return false } switch (parseInt(mm)) { case 2 : case 4 : case 6 : case 9 : case 11 : if (dd>30) { alert(alert_arr.ENTER_VALID+fldLabel) try { getObj(fldName).focus() } catch(error) { } return false } } var currdate=new Date() var chkdate=new Date() chkdate.setYear(yyyy) chkdate.setMonth(mm-1) chkdate.setDate(dd) if (type!="OTH") { if (!compareDates(chkdate,fldLabel,currdate,"current date",type)) { try { getObj(fldName).focus() } catch(error) { } return false } else return true; } else return true; } function dateComparison(fldName1,fldLabel1,fldName2,fldLabel2,type) { var dateval1=getObj(fldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var dateval2=getObj(fldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var dateelements1=splitDateVal(dateval1) var dateelements2=splitDateVal(dateval2) dd1=dateelements1[0] mm1=dateelements1[1] yyyy1=dateelements1[2] dd2=dateelements2[0] mm2=dateelements2[1] yyyy2=dateelements2[2] var date1=new Date() var date2=new Date() date1.setYear(yyyy1) date1.setMonth(mm1-1) date1.setDate(dd1) date2.setYear(yyyy2) date2.setMonth(mm2-1) date2.setDate(dd2) if (type!="OTH") { if (!compareDates(date1,fldLabel1,date2,fldLabel2,type)) { try { getObj(fldName1).focus() } catch(error) { } return false } else return true; } else return true } function timeValidate(fldName,fldLabel,type) { if (patternValidate(fldName,fldLabel,"TIME")==false) return false var timeval=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var hourval=parseInt(timeval.substring(0,timeval.indexOf(":"))) var minval=parseInt(timeval.substring(timeval.indexOf(":")+1,timeval.length)) var secval=parseInt(timeval.substring(timeval.indexOf(":")+4,timeval.length)) var currObj=getObj(fldName) if (hourval>23 || minval>59 || secval>59) { alert(alert_arr.ENTER_VALID+fldLabel) try { currObj.focus() } catch(error) { } return false } var currtime=new Date() var chktime=new Date() chktime.setHours(hourval) chktime.setMinutes(minval) chktime.setSeconds(secval) if (type!="OTH") { if (!compareDates(chktime,fldLabel,currtime,"current time",type)) { try { getObj(fldName).focus() } catch(error) { } return false } else return true; } else return true } function timeComparison(fldName1,fldLabel1,fldName2,fldLabel2,type) { var timeval1=getObj(fldName1).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var timeval2=getObj(fldName2).value.replace(/^\s+/g, '').replace(/\s+$/g, '') var hh1=timeval1.substring(0,timeval1.indexOf(":")) var min1=timeval1.substring(timeval1.indexOf(":")+1,timeval1.length) var hh2=timeval2.substring(0,timeval2.indexOf(":")) var min2=timeval2.substring(timeval2.indexOf(":")+1,timeval2.length) var time1=new Date() var time2=new Date() //added to fix the ticket #5028 if(fldName1 == "time_end" && (getObj("due_date") && getObj("date_start"))) { var due_date=getObj("due_date").value.replace(/^\s+/g, '').replace(/\s+$/g, '') var start_date=getObj("date_start").value.replace(/^\s+/g, '').replace(/\s+$/g, '') dateval1 = splitDateVal(due_date); dateval2 = splitDateVal(start_date); dd1 = dateval1[0]; mm1 = dateval1[1]; yyyy1 = dateval1[2]; dd2 = dateval2[0]; mm2 = dateval2[1]; yyyy2 = dateval2[2]; time1.setYear(yyyy1) time1.setMonth(mm1-1) time1.setDate(dd1) time2.setYear(yyyy2) time2.setMonth(mm2-1) time2.setDate(dd2) } //end time1.setHours(hh1) time1.setMinutes(min1) time2.setHours(hh2) time2.setMinutes(min2) if (type!="OTH") { if (!compareDates(time1,fldLabel1,time2,fldLabel2,type)) { try { getObj(fldName1).focus() } catch(error) { } return false } else return true; } else return true; } function numValidate(fldName,fldLabel,format,neg) { var val=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, ''); if(typeof userCurrencySeparator != 'undefined' && userCurrencySeparator != '') { while(val.indexOf(userCurrencySeparator) != -1) { val = val.replace(userCurrencySeparator,''); } } if(typeof userDecimalSeparator != 'undefined' && userDecimalSeparator != '') { if(val.indexOf(userDecimalSeparator) != -1) { val = val.replace(userDecimalSeparator,'.'); } } if (format!="any") { if (isNaN(val)) { var invalid=true } else { var format=format.split(",") var splitval=val.split(".") if (neg==true) { if (splitval[0].indexOf("-")>=0) { if (splitval[0].length-1>format[0]) invalid=true } else { if (splitval[0].length>format[0]) invalid=true } } else { if (val<0) invalid=true else if (format[0]==2 && splitval[0]==100 && (!splitval[1] || splitval[1]==0)) invalid=false else if (splitval[0].length>format[0]) invalid=true } if (splitval[1]) if (splitval[1].length>format[1]) invalid=true } if (invalid==true) { alert(alert_arr.INVALID+fldLabel) try { getObj(fldName).focus() } catch(error) { } return false }else return true } else { // changes made -- to fix the ticket#3272 if(fldName == "probability" || fldName == "commissionrate") { var val=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, ''); var splitval=val.split(".") var arr_len = splitval.length; var len = 0; if(arr_len > 1) len = splitval[1].length; if(isNaN(val)) { alert(alert_arr.INVALID+fldLabel) try { getObj(fldName).focus() }catch(error) { } return false } else if(splitval[0] > 100 || len > 3 || (splitval[0] >= 100 && splitval[1] > 0)) { alert( fldLabel + alert_arr.EXCEEDS_MAX); return false; } } else { var splitval=val.split(".") if(splitval[0]>18446744073709551615) { alert( fldLabel + alert_arr.EXCEEDS_MAX); return false; } } if (neg==true) var re=/^(-|)(\d)*(\.)?\d+(\.\d\d*)*$/ else var re=/^(\d)*(\.)?\d+(\.\d\d*)*$/ } //for precision check. ie.number must contains only one "." var dotcount=0; for (var i = 0; i < val.length; i++) { if (val.charAt(i) == ".") dotcount++; } if(dotcount>1) { alert(alert_arr.INVALID+fldLabel) try { getObj(fldName).focus() }catch(error) { } return false; } if (!re.test(val)) { alert(alert_arr.INVALID+fldLabel) try { getObj(fldName).focus() } catch(error) { } return false } else return true } function intValidate(fldName,fldLabel) { var val=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, ''); if(typeof userCurrencySeparator != 'undefined' && userCurrencySeparator != '') { while(val.indexOf(userCurrencySeparator) != -1) { val = val.replace(userCurrencySeparator,''); } } if (isNaN(val) || (val.indexOf(".")!=-1 && fldName != 'potential_amount' && fldName != 'list_price')) { alert(alert_arr.INVALID+fldLabel) try { getObj(fldName).focus() } catch(error) { } return false } else if((fldName != 'employees' || fldName != 'noofemployees') && (val < -2147483648 || val > 2147483647)) { alert(fldLabel +alert_arr.OUT_OF_RANGE); return false; } else if((fldName == 'employees' || fldName != 'noofemployees') && (val < 0 || val > 2147483647)) { alert(fldLabel +alert_arr.OUT_OF_RANGE); return false; } else { return true } } function numConstComp(fldName,fldLabel,type,constval) { var val=parseFloat(getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '')) constval=parseFloat(constval) var ret=true switch (type) { case "L" : if (val>=constval) { alert(fldLabel+alert_arr.SHOULDBE_LESS+constval) ret=false } break; case "LE" : if (val>constval) { alert(fldLabel+alert_arr.SHOULDBE_LESS_EQUAL+constval) ret=false } break; case "E" : if (val!=constval) { alert(fldLabel+alert_arr.SHOULDBE_EQUAL+constval) ret=false } break; case "NE" : if (val==constval) { alert(fldLabel+alert_arr.SHOULDNOTBE_EQUAL+constval) ret=false } break; case "G" : if (val<=constval) { alert(fldLabel+alert_arr.SHOULDBE_GREATER+constval) ret=false } break; case "GE" : if (val 255) { alert(alert_arr.LBL_FILENAME_LENGTH_EXCEED_ERR); valid = false; } if (!valid) { form_ele.style.backgroundColor = err_bg_color; return false; } form_ele.style.backgroundColor = form_ele.bgcolor; form_ele.form[form_ele.name + '_hidden'].value = value; displayFileSize(form_ele); return true; } /* Function to validate the filsize */ function validateFileSize(form_ele,uploadSize) { if (form_ele.value == '') return true; var fileSize = form_ele.files[0].size; if(fileSize > uploadSize) { alert(alert_arr.LBL_SIZE_SHOULDNOTBE_GREATER + uploadSize/1000000+alert_arr.LBL_FILESIZEIN_MB); form_ele.value = ''; document.getElementById('displaySize').innerHTML= ''; } else { displayFileSize(form_ele); } } /* Function to Display FileSize while uploading */ function displayFileSize(form_ele) { var fileSize = form_ele.files[0].size; if (fileSize < 1024) document.getElementById('displaySize').innerHTML = fileSize + alert_arr.LBL_FILESIZEIN_B; else if (fileSize > 1024 && fileSize < 1048576) document.getElementById('displaySize').innerHTML = Math.round(fileSize / 1024, 2) + alert_arr.LBL_FILESIZEIN_KB; else if (fileSize > 1048576) document.getElementById('displaySize').innerHTML = Math.round(fileSize / (1024 * 1024), 2) + alert_arr.LBL_FILESIZEIN_MB; } function formValidate(){ return doformValidation(''); } function massEditFormValidate(){ return doformValidation('mass_edit'); } function doformValidation(edit_type) { //Validation for Portal User if(gVTModule == 'Contacts' && gValidationCall != 'tabchange') { //if existing portal value = 0, portal checkbox = checked, ( email field is not available OR email is empty ) then we should not allow -- OR -- //if existing portal value = 1, portal checkbox = checked, ( email field is available AND email is empty ) then we should not allow if(edit_type=='') { if(getObj('existing_portal') != null && ((getObj('existing_portal').value == 0 && getObj('portal').checked && (getObj('email') == null || trim(getObj('email').value) == '')) || (getObj('existing_portal').value == 1 && getObj('portal').checked && getObj('email') != null && trim(getObj('email').value) == ''))) { alert(alert_arr.PORTAL_PROVIDE_EMAILID); return false; } } else { if(getObj('portal') != null && getObj('portal').checked && getObj('portal_mass_edit_check').checked && (getObj('email') == null || trim(getObj('email').value) == '' || getObj('email_mass_edit_check').checked==false)) { alert(alert_arr.PORTAL_PROVIDE_EMAILID); return false; } if((getObj('email') != null && trim(getObj('email').value) == '' && getObj('email_mass_edit_check').checked) && !(getObj('portal').checked==false && getObj('portal_mass_edit_check').checked)) { alert(alert_arr.EMAIL_CHECK_MSG); return false; } } } if(gVTModule == 'SalesOrder') { if(edit_type == 'mass_edit') { if (getObj('enable_recurring_mass_edit_check') != null && getObj('enable_recurring_mass_edit_check').checked && getObj('enable_recurring') != null) { if(getObj('enable_recurring').checked && (getObj('recurring_frequency') == null || trim(getObj('recurring_frequency').value) == '--None--' || getObj('recurring_frequency_mass_edit_check').checked==false)) { alert(alert_arr.RECURRING_FREQUENCY_NOT_PROVIDED); return false; } if(getObj('enable_recurring').checked == false && getObj('recurring_frequency_mass_edit_check').checked && getObj('recurring_frequency') != null && trim(getObj('recurring_frequency').value) != '--None--') { alert(alert_arr.RECURRING_FREQNECY_NOT_ENABLED); return false; } } } else if(getObj('enable_recurring') != null && getObj('enable_recurring').checked) { if(getObj('recurring_frequency') == null || getObj('recurring_frequency').value == '--None--') { alert(alert_arr.RECURRING_FREQUENCY_NOT_PROVIDED); return false; } var start_period = getObj('start_period'); var end_period = getObj('end_period'); if (trim(start_period.value) == '' || trim(end_period.value) == '') { alert(alert_arr.START_PERIOD_END_PERIOD_CANNOT_BE_EMPTY); return false; } } } for (var i=0; iwindow.screen.height) top=findPosY(currObj)+window.screenTop-height-30 //30 is a constant to avoid positioning issue if (left+width>window.screen.width) left=findPosX(currObj)+window.screenLeft-width } else if (browser_nn4 || browser_nn6) { top+=(scrY-pgeY) left+=(scrX-pgeX) if (top+height+30>window.screen.height) top=findPosY(currObj)+(scrY-pgeY)-height-30 if (left+width>window.screen.width) left=findPosX(currObj)+(scrX-pgeX)-width } features="width="+width+",height="+height+",top="+top+",left="+left+";"+features eval(winInst+'=window.open("'+baseURL+'","'+winName+'","'+features+'")') } var scrX=0,scrY=0,pgeX=0,pgeY=0; if (browser_nn4 || browser_nn6) { document.addEventListener("click",popUpListener,true) } function popUpListener(ev) { if (browser_nn4 || browser_nn6) { scrX=ev.screenX scrY=ev.screenY pgeX=ev.pageX pgeY=ev.pageY } } function toggleSelect(state,relCheckName) { if (getObj(relCheckName)) { if (typeof(getObj(relCheckName).length)=="undefined") { getObj(relCheckName).checked=state } else { for (var i=0;i 1) document.getElementById('adSrc').deleteRow(prev-1); } function fnVis(obj){ var profTag = document.getElementById("prof"); var moreTag = document.getElementById("more"); var addrTag = document.getElementById("addr"); if(obj == 'prof'){ document.getElementById('mnuTab').style.display = 'block'; document.getElementById('mnuTab1').style.display = 'none'; document.getElementById('mnuTab2').style.display = 'none'; profTag.className = 'dvtSelectedCell'; moreTag.className = 'dvtUnSelectedCell'; addrTag.className = 'dvtUnSelectedCell'; } else if(obj == 'more'){ document.getElementById('mnuTab1').style.display = 'block'; document.getElementById('mnuTab').style.display = 'none'; document.getElementById('mnuTab2').style.display = 'none'; moreTag.className = 'dvtSelectedCell'; profTag.className = 'dvtUnSelectedCell'; addrTag.className = 'dvtUnSelectedCell'; } else if(obj == 'addr'){ document.getElementById('mnuTab2').style.display = 'block'; document.getElementById('mnuTab').style.display = 'none'; document.getElementById('mnuTab1').style.display = 'none'; addrTag.className = 'dvtSelectedCell'; profTag.className = 'dvtUnSelectedCell'; moreTag.className = 'dvtUnSelectedCell'; } } function fnvsh(obj,Lay){ var tagName = document.getElementById(Lay); var leftSide = findPosX(obj); var topSide = findPosY(obj); tagName.style.left= leftSide + 175 + 'px'; tagName.style.top= topSide + 'px'; tagName.style.visibility = 'visible'; } function fnvshobj(obj,Lay){ var tagName = document.getElementById(Lay); var leftSide = findPosX(obj); var topSide = findPosY(obj); var maxW = tagName.style.width; var widthM = maxW.substring(0,maxW.length-2); if(Lay == 'editdiv') { leftSide = leftSide - 225; topSide = topSide - 125; }else if(Lay == 'transferdiv') { leftSide = leftSide - 10; topSide = topSide; } var IE = document.all?true:false; if(IE) { if($("repposition1")) { if(topSide > 1200) { topSide = topSide-250; } } } var getVal = eval(leftSide) + eval(widthM); if(getVal > document.body.clientWidth ){ leftSide = eval(leftSide) - eval(widthM); tagName.style.left = leftSide + 34 + 'px'; } else tagName.style.left= leftSide + 'px'; tagName.style.top= topSide + 'px'; tagName.style.display = 'block'; tagName.style.visibility = "visible"; } function posLay(obj,Lay){ var tagName = document.getElementById(Lay); var leftSide = findPosX(obj); var topSide = findPosY(obj); var maxW = tagName.style.width; var widthM = maxW.substring(0,maxW.length-2); var getVal = eval(leftSide) + eval(widthM); if(getVal > document.body.clientWidth ){ leftSide = eval(leftSide) - eval(widthM); tagName.style.left = leftSide + 'px'; } else tagName.style.left= leftSide + 'px'; tagName.style.top= topSide + 'px'; } function fninvsh(Lay){ var tagName = document.getElementById(Lay); tagName.style.visibility = 'hidden'; tagName.style.display = 'none'; } function fnvshNrm(Lay){ var tagName = document.getElementById(Lay); tagName.style.visibility = 'visible'; tagName.style.display = 'block'; } function cancelForm(frm) { window.history.back(); } function trim(str) { var s = str.replace(/\s+$/,''); s = s.replace(/^\s+/,''); return s; } function clear_form(form) { for (j = 0; j < form.elements.length; j++) { if (form.elements[j].type == 'text' || form.elements[j].type == 'select-one') { form.elements[j].value = ''; } } } function ActivateCheckBox() { var map = document.getElementById("saved_map_checkbox"); var source = document.getElementById("saved_source"); if(map.checked == true) { source.disabled = false; } else { source.disabled = true; } } //wipe for Convert Lead function fnSlide2(obj,inner) { var buff = document.getElementById(obj).height; closeLimit = buff.substring(0,buff.length); menu_max = eval(closeLimit); var tagName = document.getElementById(inner); document.getElementById(obj).style.height=0 + "px"; menu_i=0; if (tagName.style.display == 'none') fnexpanLay2(obj,inner); else fncloseLay2(obj,inner); } function fnexpanLay2(obj,inner) { // document.getElementById(obj).style.display = 'run-in'; var setText = eval(closeLimit) - 1; if (menu_i<=eval(closeLimit)) { if (menu_i>setText){ document.getElementById(inner).style.display='block'; } document.getElementById(obj).style.height=menu_i + "px"; setTimeout(function() { fnexpanLay2(obj,inner); },5); menu_i=menu_i+5; } } function fncloseLay2(obj,inner) { if (menu_max >= eval(openLimit)) { if (menu_max document.body.clientWidth ){ leftSide = eval(leftSide) - eval(widthM); tagName.style.left = leftSide + 34 + 'px'; } else tagName.style.left= leftSide + 'px'; tagName.style.top= topSide + 28 +'px'; tagName.style.display = 'block'; } function fnShowDrop(obj){ document.getElementById(obj).style.display = 'block'; } function fnHideDrop(obj){ document.getElementById(obj).style.display = 'none'; } function getCalendarPopup(imageid,fieldid,dateformat) { Calendar.setup ({ inputField : fieldid, ifFormat : dateformat, showsTime : false, button : imageid, singleClick : true, step : 1 }); } //Added to check duplicate account creation function AjaxDuplicateValidate(module,fieldname,oform) { var fieldvalue = encodeURIComponent(trim(getObj(fieldname).value)); var recordid = getObj('record').value; if(fieldvalue == '') { alert(alert_arr.ACCOUNTNAME_CANNOT_EMPTY); return false; } VtigerJS_DialogBox.block(); var url = "module="+module+"&action="+module+"Ajax&file=Save&"+fieldname+"="+fieldvalue+"&dup_check=true&record="+recordid; new Ajax.Request( 'index.php', { queue: { position: 'end', scope: 'command' }, method: 'post', postBody:url, onComplete: function(response) { var str = response.responseText if(str.indexOf('SUCCESS') > -1) { oform.submit(); }else { VtigerJS_DialogBox.unblock(); alert(str); return false; } } } ); } /**to get SelectContacts Popup check->to check select options enable or disable *type->to differentiate from task *frmName->form name*/ function selectContact(check,type,frmName) { var record = document.getElementsByName("record")[0].value; if($("single_accountid")) { var potential_id = ''; if($("potential_id")) potential_id = frmName.potential_id.value; account_id = frmName.account_id.value; if(potential_id != '') { record_id = potential_id; module_string = "&parent_module=Potentials"; } else { record_id = account_id; module_string = "&parent_module=Accounts"; } if(record_id != '') window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView"+module_string+"&relmod_id="+record_id,"test","width=640,height=602,resizable=0,scrollbars=0"); else window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0"); } else if(($("parentid")) && type != 'task') { if(getObj("parent_type")){ rel_parent_module = frmName.parent_type.value; record_id = frmName.parent_id.value; module = rel_parent_module.split("&"); if(record_id != '' && module[0] == "Leads") { alert(alert_arr.CANT_SELECT_CONTACTS); } else { if(check == 'true') search_string = "&return_module=Calendar&select=enable&popuptype=detailview&form_submit=false"; else search_string="&popuptype=specific"; if(record_id != '') window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&form=EditView"+search_string+"&relmod_id="+record_id+"&parent_module="+module[0],"test","width=640,height=602,resizable=0,scrollbars=0"); else window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&form=EditView"+search_string,"test","width=640,height=602,resizable=0,scrollbars=0"); } }else{ window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&return_module=Calendar&select=enable&popuptype=detailview&form=EditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0"); } } else if(($("contact_name")) && type == 'task') { var formName = frmName.name; var task_recordid = ''; if(formName == 'EditView') { if($("parent_type")) { task_parent_module = frmName.parent_type.value; task_recordid = frmName.parent_id.value; task_module = task_parent_module.split("&"); popuptype="&popuptype=specific"; } } else { if($("task_parent_type")) { task_parent_module = frmName.task_parent_type.value; task_recordid = frmName.task_parent_id.value; task_module = task_parent_module.split("&"); popuptype="&popuptype=toDospecific"; } } if(task_recordid != '' && task_module[0] == "Leads" ) { alert(alert_arr.CANT_SELECT_CONTACTS); } else { if(task_recordid != '') window.open("index.php?module=Contacts&action=Popup&html=Popup_picker"+popuptype+"&form="+formName+"&task_relmod_id="+task_recordid+"&task_parent_module="+task_module[0],"test","width=640,height=602,resizable=0,scrollbars=0"); else window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form="+formName,"test","width=640,height=602,resizable=0,scrollbars=0"); } } else { window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&recordid="+record,"test","width=640,height=602,resizable=0,scrollbars=0"); } } //to get Select Potential Popup function selectPotential() { // To support both B2B and B2C model var record_id = ''; var parent_module = ''; var acc_element = document.EditView.account_id; var cnt_element = document.EditView.contact_id; if (acc_element != null) { record_id= acc_element.value; parent_module = 'Accounts'; } else if (cnt_element != null) { record_id= cnt_element.value; parent_module = 'Contacts'; } if(record_id != '') window.open("index.php?module=Potentials&action=Popup&html=Popup_picker&popuptype=specific_potential_account_address&form=EditView&relmod_id="+record_id+"&parent_module="+parent_module,"test","width=640,height=602,resizable=0,scrollbars=0"); else window.open("index.php?module=Potentials&action=Popup&html=Popup_picker&popuptype=specific_potential_account_address&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0"); } //to select Quote Popup function selectQuote() { // To support both B2B and B2C model var record_id = ''; var parent_module = ''; var acc_element = document.EditView.account_id; var cnt_element = document.EditView.contact_id; if (acc_element != null) { record_id= acc_element.value; parent_module = 'Accounts'; } else if (cnt_element != null) { record_id= cnt_element.value; parent_module = 'Contacts'; } if(record_id != '') window.open("index.php?module=Quotes&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&relmod_id="+record_id+"&parent_module="+parent_module,"test","width=640,height=602,resizable=0,scrollbars=0"); else window.open("index.php?module=Quotes&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0"); } //to get select SalesOrder Popup function selectSalesOrder() { // To support both B2B and B2C model var record_id = ''; var parent_module = ''; var acc_element = document.EditView.account_id; var cnt_element = document.EditView.contact_id; if (acc_element != null) { record_id= acc_element.value; parent_module = 'Accounts'; } else if (cnt_element != null) { record_id= cnt_element.value; parent_module = 'Contacts'; } if(record_id != '') window.open("index.php?module=SalesOrder&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&relmod_id="+record_id+"&parent_module="+parent_module,"test","width=640,height=602,resizable=0,scrollbars=0"); else window.open("index.php?module=SalesOrder&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0"); } function checkEmailid(parent_module,emailid,secondaryemail) { var check = true; if(emailid == '' && secondaryemail == '') { alert(alert_arr.LBL_THIS+parent_module+alert_arr.DOESNOT_HAVE_MAILIDS); check=false; } return check; } function calQCduedatetime() { var datefmt = document.QcEditView.dateFormat.value; var type = document.QcEditView.activitytype.value; var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, ''); var dateelements1=splitDateVal(dateval1); dd1=parseInt(dateelements1[0],10); mm1=dateelements1[1]; yyyy1=dateelements1[2]; var date1=new Date(); date1.setYear(yyyy1); date1.setMonth(mm1-1,dd1+1); var yy = date1.getFullYear(); var mm = date1.getMonth() + 1; var dd = date1.getDate(); var date = document.QcEditView.date_start.value; var starttime = document.QcEditView.time_start.value; if (!timeValidate('time_start',' Start Date & Time','OTH')) return false; var timearr = starttime.split(":"); var hour = parseInt(timearr[0],10); var min = parseInt(timearr[1],10); dd = _2digit(dd); mm = _2digit(mm); var tempdate = yy+'-'+mm+'-'+dd; if(datefmt == '%d-%m-%Y') var tempdate = dd+'-'+mm+'-'+yy; else if(datefmt == '%m-%d-%Y') var tempdate = mm+'-'+dd+'-'+yy; if(type == 'Meeting') { hour = hour + 1; if(hour == 24) { hour = 0; date = tempdate; } hour = _2digit(hour); min = _2digit(min); document.QcEditView.due_date.value = date; document.QcEditView.time_end.value = hour+':'+min; } if(type == 'Call') { if(min >= 55) { min = min%55; hour = hour + 1; }else min = min + 5; if(hour == 24) { hour = 0; date = tempdate; } hour = _2digit(hour); min = _2digit(min); document.QcEditView.due_date.value = date; document.QcEditView.time_end.value = hour+':'+min; } } function _2digit( no ){ if(no < 10) return "0" + no; else return "" + no; } function confirmdelete(url) { if(confirm(alert_arr.ARE_YOU_SURE)) { document.location.href=url; } } //function modified to apply the patch ref : Ticket #4065 function valid(c,type) { if(type == 'name') { return (((c >= 'a') && (c <= 'z')) ||((c >= 'A') && (c <= 'Z')) ||((c >= '0') && (c <= '9')) || (c == '.') || (c == '_') || (c == '-') || (c == '@') ); } else if(type == 'namespace') { return (((c >= 'a') && (c <= 'z')) ||((c >= 'A') && (c <= 'Z')) ||((c >= '0') && (c <= '9')) || (c == '.')||(c==' ') || (c == '_') || (c == '-') ); } } //end function CharValidation(s,type) { for (var i = 0; i < s.length; i++) { if (!valid(s.charAt(i),type)) { return false; } } return true; } /** Check Upload file is in specified format(extension). * @param fldName -- name of the file field * @param filter -- List of file extensions to allow. each extension must be seperated with a | sybmol. * Example: upload_filter("imagename","Image", "jpg|gif|bmp|png") * @returns true -- if the extension is IN specified extension. * @returns false -- if the extension is NOT IN specified extension. * * NOTE: If this field is mandatory, please call emptyCheck() function before calling this function. */ function upload_filter(fldName, filter) { var currObj=getObj(fldName) if(currObj.value !="") { var file=currObj.value; var type=file.toLowerCase().split("."); var valid_extn=filter.toLowerCase().split("|"); if(valid_extn.indexOf(type[type.length-1]) == -1) { alert(alert_arr.PLS_SELECT_VALID_FILE+valid_extn) try { currObj.focus() } catch(error) { // Fix for IE: If element or its wrapper around it is hidden, setting focus will fail // So using the try { } catch(error) { } } return false; } } return true } function validateUrl(name) { var Url = getObj(name); var wProtocol; var oRegex = new Object(); oRegex.UriProtocol = new RegExp(''); oRegex.UriProtocol.compile( '^(((http):\/\/)|mailto:)', 'gi' ); oRegex.UrlOnChangeProtocol = new RegExp('') ; oRegex.UrlOnChangeProtocol.compile( '^(http)://(?=.)', 'gi' ); wUrl = Url.value; wProtocol=oRegex.UrlOnChangeProtocol.exec( wUrl ) ; if ( wProtocol ) { wUrl = wUrl.substr( wProtocol[0].length ); Url.value = wUrl; } } function LTrim( value ) { var re = /\s*((\S+\s*)*)/; return value.replace(re, "$1"); } function selectedRecords(module,category) { var allselectedboxes = document.getElementById("allselectedboxes"); var idstring = (allselectedboxes == null)? '' : allselectedboxes.value; var viewid = getviewId(); var url = '&viewname='+viewid; if(document.getElementById('excludedRecords') != null && typeof(document.getElementById('excludedRecords')) != 'undefined') { var excludedRecords = $('excludedRecords').value; var searchurl = document.getElementById('search_url').value; url = url+searchurl+'&excludedRecords='+excludedRecords; } if(idstring != '') window.location.href="index.php?module="+module+"&action=ExportRecords&parenttab="+category+"&idstring="+idstring+url; else window.location.href="index.php?module="+module+"&action=ExportRecords&parenttab="+category; return false; } function record_export(module,category,exform,idstring) { var searchType = document.getElementsByName('search_type'); var exportData = document.getElementsByName('export_data'); for(i=0;i<2;i++){ if(searchType[i].checked == true) var sel_type = searchType[i].value; } for(i=0;i<3;i++){ if(exportData[i].checked == true) var exp_type = exportData[i].value; } new Ajax.Request( 'index.php', { queue: { position: 'end', scope: 'command' }, method: 'post', postBody: "module="+module+"&action=ExportAjax&export_record=true&search_type="+sel_type+"&export_data="+exp_type+"&idstring="+idstring, onComplete: function(response) { if(response.responseText == 'NOT_SEARCH_WITHSEARCH_ALL') { $('not_search').style.display = 'block'; $('not_search').innerHTML=""+alert_arr.LBL_NOTSEARCH_WITHSEARCH_ALL+" "+module+""; setTimeout(hideErrorMsg1,6000); exform.submit(); } else if(response.responseText == 'NOT_SEARCH_WITHSEARCH_CURRENTPAGE') { $('not_search').style.display = 'block'; $('not_search').innerHTML=""+alert_arr.LBL_NOTSEARCH_WITHSEARCH_CURRENTPAGE+" "+module+""; setTimeout(hideErrorMsg1,7000); exform.submit(); } else if(response.responseText == 'NO_DATA_SELECTED') { $('not_search').style.display = 'block'; $('not_search').innerHTML=""+alert_arr.LBL_NO_DATA_SELECTED+""; setTimeout(hideErrorMsg1,3000); } else if(response.responseText == 'SEARCH_WITHOUTSEARCH_ALL') { if(confirm(alert_arr.LBL_SEARCH_WITHOUTSEARCH_ALL)) { exform.submit(); } } else if(response.responseText == 'SEARCH_WITHOUTSEARCH_CURRENTPAGE') { if(confirm(alert_arr.LBL_SEARCH_WITHOUTSEARCH_CURRENTPAGE)) { exform.submit(); } } else { exform.submit(); } } } ); } function hideErrorMsg1() { $('not_search').style.display = 'none'; } // Replace the % sign with %25 to make sure the AJAX url is going wel. function escapeAll(tagValue) { //return escape(tagValue.replace(/%/g, '%25')); if(default_charset.toLowerCase() == 'utf-8') return encodeURIComponent(tagValue.replace(/%/g, '%25')); else return escape(tagValue.replace(/%/g, '%25')); } function removeHTMLFormatting(str) { str = str.replace(/<([^<>]*)>/g, " "); str = str.replace(/ /g, " "); return str; } function get_converted_html(str) { var temp = str.toLowerCase(); if(temp.indexOf('<') != '-1' || temp.indexOf('>') != '-1') { str = str.replace(//g,'>'); } if( temp.match(/(script).*(\/script)/)) { str = str.replace(/&/g,'&'); } else if(temp.indexOf('&') != '-1') { str = str.replace(/&/g,'&'); } return str; } //To select the select all check box(if all the items are selected) when the form loads. function default_togglestate(obj_id,elementId) { var all_state=true; var groupElements = document.getElementsByName(obj_id); for (var i=0;i=0;i--) { if(trim(select_global[i])!='') result=select_global[i]+";"+result; } getObj(module+"_selectall").checked=false; } set_cookie(module+"_all",result); } //Function to select all the items in the current page for Campaigns related list:. function rel_toggleSelect(state,relCheckName,module) { var obj = document.getElementsByName(relCheckName); if (obj) { for (var i=0;i-1) $("replaceimage").innerHTML=alert_arr.LBL_IMAGE_DELETED; else alert(alert_arr.ERROR_WHILE_EDITING); } } ); } function delUserImage(id) { new Ajax.Request( 'index.php', { queue: { position: 'end', scope: 'command' }, method: 'post', postBody: 'module=Users&action=UsersAjax&file=Save&deleteImage=true&recordid='+id, onComplete: function(response) { if(response.responseText.indexOf("SUCCESS")>-1) $("replaceimage").innerHTML=alert_arr.LBL_IMAGE_DELETED; else alert(alert_arr.ERROR_WHILE_EDITING); } } ); } // Function to enable/disable related elements based on whether the current object is checked or not function fnenableDisable(currObj,enableId) { var disable_flag = true; if(currObj.checked == true) disable_flag = false; document.getElementById('curname'+enableId).disabled = disable_flag; document.getElementById('cur_reset'+enableId).disabled = disable_flag; document.getElementById('base_currency'+enableId).disabled = disable_flag; } // Update current value with current value of base currency and the conversion rate function updateCurrencyValue(currObj,txtObj,base_curid,conv_rate) { var unit_price = $(base_curid).value; if(typeof userCurrencySeparator != 'undefined') { while(unit_price.indexOf(userCurrencySeparator) != -1) { unit_price = unit_price.replace(userCurrencySeparator,''); } } if(typeof userDecimalSeparator != 'undefined') { if(unit_price.indexOf(userDecimalSeparator) != -1) { unit_price = unit_price.replace(userDecimalSeparator,'.'); } } document.getElementById(txtObj).value = unit_price * conv_rate; } // Synchronize between Unit price and Base currency value. function updateUnitPrice(from_cur_id, to_cur_id) { var from_ele = document.getElementById(from_cur_id); if (from_ele == null) return; var to_ele = document.getElementById(to_cur_id); if (to_ele == null) return; to_ele.value = from_ele.value; } // Update hidden base currency value, everytime the base currency value is changed in multi-currency UI function updateBaseCurrencyValue() { var cur_list = document.getElementsByName('base_currency_input'); if (cur_list == null) return; var base_currency_ele = document.getElementById('base_currency'); if (base_currency_ele == null) return; for(var i=0; i 0) { ActivityReminder_callback_delay = ActivityReminder_Newdelay_response_value; } // We don't need the no any longer, it will be sent from server for next Popup $(ActivityReminder_Newdelay_response_node).remove(); } if(message == '' || trim(message).indexOf(' z) { ActivityReminder_callback_win.style.height = parseInt(ActivityReminder_callback_win.style.height) - ActivityReminder_progressive_height + "px"; ActivityReminder_timer = setTimeout("ActivityReminderCallbackRollin(" + z + ",'" + ActivityReminder_callback_win.id + "')", 1); } else { ActivityReminderCallbackReset(z, ActivityReminder_callback_win); } } function ActivityReminderCallbackReset(z, ActivityReminder_callback_win) { ActivityReminder_callback_win = $(ActivityReminder_callback_win); if(ActivityReminder_callback_win) { ActivityReminder_callback_win.style.height = z + "px"; ActivityReminder_callback_win.style.display = "none"; } if(ActivityReminder_timer) { window.clearTimeout(ActivityReminder_timer); ActivityReminder_timer = null; } ActivityReminderRegisterCallback(ActivityReminder_callback_delay); } function ActivityReminderRegisterCallback(timeout) { if(timeout == null) timeout = 1; if(ActivityReminder_regcallback_timer == null) { ActivityReminder_regcallback_timer = setTimeout("ActivityReminderCallback()", timeout); } } //added for finding duplicates function movefields() { availListObj=getObj("availlist") selectedColumnsObj=getObj("selectedCol") for (i=0;i4 ) { alert(alert_arr.MAX_RECORDS) return false } if (availListObj.options.selectedIndex > -1) { for (i=0;i -1) { for (i=0;i < selectedColumnsObj.options.length;i++) { if(selectedColumnsObj.options[i].selected == true) { if(selected_tab == 4) { if(selectedColumnsObj.options[i].innerHTML == "Last Name") { alert(alert_arr.DEL_MANDATORY); del = false; return false; } else del = true; } else if(selected_tab == 7) { if(selectedColumnsObj.options[i].innerHTML == "Last Name" || selectedColumnsObj.options[i].innerHTML == "Company") { alert(alert_arr.DEL_MANDATORY); del = false; return false; } else del = true; } else if(selected_tab == 6) { if(selectedColumnsObj.options[i].innerHTML == "Account Name") { alert(alert_arr.DEL_MANDATORY); del = false; return false; } else del = true; } else if(selected_tab == 14) { if(selectedColumnsObj.options[i].innerHTML == "Product Name") { alert(alert_arr.DEL_MANDATORY); del = false; return false; } else del = true; } if(del == true) { selectedColumnsObj.remove(i); delFields(); } } } } } function moveFieldUp() { selectedColumnsObj=getObj("selectedCol") var currpos=selectedColumnsObj.options.selectedIndex var tempdisabled= false; for (i=0;i0) { var prevpos=selectedColumnsObj.options.selectedIndex-1 if (browser_ie) { temp=selectedColumnsObj.options[prevpos].innerText tempdisabled = selectedColumnsObj.options[prevpos].disabled; selectedColumnsObj.options[prevpos].innerText=selectedColumnsObj.options[currpos].innerText selectedColumnsObj.options[prevpos].disabled = false; selectedColumnsObj.options[currpos].innerText=temp selectedColumnsObj.options[currpos].disabled = tempdisabled; } else if (browser_nn4 || browser_nn6) { temp=selectedColumnsObj.options[prevpos].text tempdisabled = selectedColumnsObj.options[prevpos].disabled; selectedColumnsObj.options[prevpos].text=selectedColumnsObj.options[currpos].text selectedColumnsObj.options[prevpos].disabled = false; selectedColumnsObj.options[currpos].text=temp selectedColumnsObj.options[currpos].disabled = tempdisabled; } temp=selectedColumnsObj.options[prevpos].value selectedColumnsObj.options[prevpos].value=selectedColumnsObj.options[currpos].value selectedColumnsObj.options[currpos].value=temp selectedColumnsObj.options[prevpos].selected=true selectedColumnsObj.options[currpos].selected=false } } function moveFieldDown() { selectedColumnsObj=getObj("selectedCol") var currpos=selectedColumnsObj.options.selectedIndex var tempdisabled= false; for (i=0;i 3) { alert(alert_arr.MAX_THREE) return false; } if(xx > 0) { for(j=0;j 0) tmp++; } if (tmp > 1) { alert(alert_arr.SAME_GROUPS) return false; } if(xx <2) { alert(alert_arr.ATLEAST_TWO) return false; } } window.open("index.php?module="+req_module+"&action=ProcessDuplicates&mergemode=mergefields&passurl="+pass_url+"&parenttab="+parent_tab,"Merge","width=750,height=602,menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=yes"); } else { alert(alert_arr.ATLEAST_TWO); return false; } } function delete_fields(module) { var select_options=document.getElementsByName('del'); var x=select_options.length; var xx=0; url_rec=""; for(var i=0;i document.body.clientWidth ){ leftSide = eval(leftSide) - eval(widthM); }else{ leftSide = eval(leftSide) + (eval(tooltipWidth)/2); } if(leftSide < 0) { leftSide = findPosX(obj) + tooltipWidth; } tooltip.style.left = leftSide + 'px'; var heightTooltip = dimensions.y; var bottomSide = eval(topSide) + eval(heightTooltip); if(bottomSide > document.body.clientHeight){ topSide = topSide - (bottomSide - document.body.clientHeight) - 10; if(topSide < 0 ){ topSide = 10; } }else{ topSide = eval(topSide) - eval(heightTooltip)/2; if(topSide<0){ topSide = 10; } } tooltip.style.top= topSide + 'px'; } return { tip:tip, untip:unTip, 'exists': exists, 'show': show, 'getDivId':getDivId }; } if(!tooltip){ var tooltip = ToolTipManager(); } //tooltip manager changes end function submitFormForActionWithConfirmation(formName, action, confirmationMsg) { if (confirm(confirmationMsg)) { return submitFormForAction(formName, action); } return false; } function submitFormForAction(formName, action) { var form = document.forms[formName]; if (!form) return false; form.action.value = action; form.submit(); return true; } /** Javascript dialog box utility functions **/ VtigerJS_DialogBox = { _olayer : function(toggle) { var olayerid = "__vtigerjs_dialogbox_olayer__"; VtigerJS_DialogBox._removebyid(olayerid); if(typeof(toggle) == 'undefined' || !toggle) return; var olayer = document.getElementById(olayerid); if(!olayer) { olayer = document.createElement("div"); olayer.id = olayerid; olayer.className = "small veil"; olayer.style.zIndex = (new Date()).getTime(); // Avoid zIndex going beyond integer max // http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7146#comment:1 olayer.style.zIndex = parseInt((new Date()).getTime() / 1000); // In case zIndex goes to negative side! if(olayer.style.zIndex < 0) olayer.style.zIndex *= -1; if (browser_ie) { olayer.style.height = document.body.offsetHeight + (document.body.scrollHeight - document.body.offsetHeight) + "px"; } else if (browser_nn4 || browser_nn6) { olayer.style.height = document.body.offsetHeight + "px"; } olayer.style.width = "100%"; document.body.appendChild(olayer); var closeimg = document.createElement("img"); closeimg.src = 'themes/images/popuplay_close.png'; closeimg.alt = 'X'; closeimg.style.right= '10px'; closeimg.style.top = '5px'; closeimg.style.position = 'absolute'; closeimg.style.cursor = 'pointer'; closeimg.onclick = VtigerJS_DialogBox.unblock; olayer.appendChild(closeimg); } if(olayer) { if(toggle) olayer.style.display = "block"; else olayer.style.display = "none"; } return olayer; }, _removebyid : function(id) { if($(id)) $(id).remove(); }, unblock : function() { VtigerJS_DialogBox._olayer(false); }, block : function(opacity) { if(typeof(opactiy)=='undefined') opacity = '0.3'; var olayernode = VtigerJS_DialogBox._olayer(true); olayernode.style.opacity = opacity; }, hideprogress : function() { VtigerJS_DialogBox._olayer(false); VtigerJS_DialogBox._removebyid('__vtigerjs_dialogbox_progress_id__'); }, progress : function(imgurl) { VtigerJS_DialogBox._olayer(true); if(typeof(imgurl) == 'undefined') imgurl = 'themes/images/plsWaitAnimated.gif'; var prgbxid = "__vtigerjs_dialogbox_progress_id__"; var prgnode = document.getElementById(prgbxid); if(!prgnode) { prgnode = document.createElement("div"); prgnode.id = prgbxid; prgnode.className = 'veil_new'; prgnode.style.position = 'absolute'; prgnode.style.width = '100%'; prgnode.style.top = '0'; prgnode.style.left = '0'; prgnode.style.display = 'block'; document.body.appendChild(prgnode); prgnode.innerHTML = '' + '
'; } if(prgnode) prgnode.style.display = 'block'; }, hideconfirm : function() { VtigerJS_DialogBox._olayer(false); VtigerJS_DialogBox._removebyid('__vtigerjs_dialogbox_alert_boxid__'); }, confirm : function(msg, onyescode) { VtigerJS_DialogBox._olayer(true); var dlgbxid = "__vtigerjs_dialogbox_alert_boxid__"; var dlgbxnode = document.getElementById(dlgbxid); if(!dlgbxnode) { dlgbxnode = document.createElement("div"); dlgbxnode.style.display = 'none'; dlgbxnode.className = 'veil_new small'; dlgbxnode.id = dlgbxid; dlgbxnode.innerHTML = '' + '' + '' + '' + '' + '' + ''+ '' + '' + '
' + ''+ msg + '
' + '' + '' + '
'; document.body.appendChild(dlgbxnode); } if(typeof(onyescode) == 'undefined') onyescode = ''; dlgbxnode._onyescode = onyescode; if(dlgbxnode) dlgbxnode.style.display = 'block'; }, _confirm_handler : function() { var dlgbxid = "__vtigerjs_dialogbox_alert_boxid__"; var dlgbxnode = document.getElementById(dlgbxid); if(dlgbxnode) { if(typeof(dlgbxnode._onyescode) != 'undefined' && dlgbxnode._onyescode != '') { eval(dlgbxnode._onyescode); } } } } function validateInputData(value, fieldLabel, typeofdata) { var typeinfo = typeofdata.split('~'); var type = typeinfo[0]; if(type == 'T') { if(!re_patternValidate(value,fieldLabel+" (Time)","TIMESECONDS")) return false; } else if(type == 'D' || type == 'DT') { if(!re_dateValidate(value,fieldLabel+" (Current User Date Format)","OTH")) return false } else if(type == 'I') { if(isNaN(value) || value.indexOf(".")!=-1) { alert(alert_arr.INVALID+fieldLabel); return false } } else if(type == 'N' || type == 'NN') { if(typeof(typeinfo[2]) == "undefined") { var numformat = "any"; } else { var numformat = typeinfo[2] } if(type == 'NN') { var negativeallowed = true; } else { var negativeallowed = false; } if(numformat != "any") { if (isNaN(value)) { var invalid=true } else { var format = numformat.split(",") var splitval = value.split(".") if (negativeallowed == true) { if (splitval[0].indexOf("-") >= 0) { if (splitval[0].length-1 > format[0]) { invalid=true } } else { if (splitval[0].length > format[0]) { invalid=true } } } else { if (value < 0) { invalid=true } else if (format[0] == 2 && splitval[0] == 100 && (!splitval[1] || splitval[1]==0)) { invalid=false } else if (splitval[0].length > format[0]) { invalid=true } } if (splitval[1]) { if (splitval[1].length > format[1]) { invalid=true } } } if (invalid==true) { alert(alert_arr.INVALID + fieldLabel) return false; } else { return true; } } else { var splitval = value.split(".") var arr_len = splitval.length; var len = 0; if(splitval[0] > 18446744073709551615) { alert( fieldLabel + alert_arr.EXCEEDS_MAX); return false; } if(negativeallowed == true) { var re=/^(-|)(\d)*(\.)?\d+(\.\d\d*)*$/ } else { var re=/^(\d)*(\.)?\d+(\.\d\d*)*$/ } } //for precision check. ie.number must contains only one "." var dotcount=0; for (var i = 0; i < value.length; i++) { if (value.charAt(i) == ".") dotcount++; } if(dotcount>1) { alert(alert_arr.INVALID+fieldLabel) return false; } if (!re.test(value)) { alert(alert_arr.INVALID+fieldLabel) return false } } else if(type == 'E') { if (!re_patternValidate(value,fieldLabel+" (Email Id)","EMAIL")) return false } return true; } function re_dateValidate(fldval,fldLabel,type) { if(re_patternValidate(fldval,fldLabel,"DATE")==false) return false; dateval=fldval.replace(/^\s+/g, '').replace(/\s+$/g, '') var dateelements=splitDateVal(dateval) dd=dateelements[0] mm=dateelements[1] yyyy=dateelements[2] if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) { alert(alert_arr.ENTER_VALID+fldLabel) return false } if ((mm==2) && (dd>29)) {//checking of no. of days in february month alert(alert_arr.ENTER_VALID+fldLabel) return false } if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking alert(alert_arr.ENTER_VALID+fldLabel) return false } switch (parseInt(mm)) { case 2 : case 4 : case 6 : case 9 : case 11 : if (dd>30) { alert(alert_arr.ENTER_VALID+fldLabel) return false } } var currdate=new Date() var chkdate=new Date() chkdate.setYear(yyyy) chkdate.setMonth(mm-1) chkdate.setDate(dd) if (type!="OTH") { if (!compareDates(chkdate,fldLabel,currdate,"current date",type)) { return false } else return true; } else return true; } //Copied from general.js and altered some lines. becos we cant send vales to function present in general.js. it accept only field names. function re_patternValidate(fldval,fldLabel,type) { if (type.toUpperCase()=="EMAIL") { /*changes made to fix -- ticket#3278 & ticket#3461 var re=new RegExp(/^.+@.+\..+$/)*/ //Changes made to fix tickets #4633, #5111 to accomodate all possible email formats var re=new RegExp(/^[a-zA-Z0-9]+([\_\-\.]*[a-zA-Z0-9]+[\_\-]?)*@[a-zA-Z0-9]+([\_\-]?[a-zA-Z0-9]+)*\.+([\-\_]?[a-zA-Z0-9])+(\.?[a-zA-Z0-9]+)*$/) } if (type.toUpperCase()=="DATE") {//DATE validation switch (userDateFormat) { case "yyyy-mm-dd" : var re = /^\d{4}(-)\d{1,2}\1\d{1,2}$/ break; case "mm-dd-yyyy" : case "dd-mm-yyyy" : var re = /^\d{1,2}(-)\d{1,2}\1\d{4}$/ } } if (type.toUpperCase()=="TIMESECONDS") {//TIME validation var re = new RegExp("^([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$|^([0-1][0-9]|[2][0-3]):([0-5][0-9])$"); } if (!re.test(fldval)) { alert(alert_arr.ENTER_VALID + fldLabel) return false } else return true } function getTranslatedString(key, alertArray){ if(alertArray != undefined) { if(alertArray[key] != undefined) { return alertArray[key]; } } if(alert_arr[key] != undefined) { return alert_arr[key]; } else { return key; } } function copySelectedOptions(source, destination) { var srcObj = $(source); var destObj = $(destination); if(typeof(srcObj) == 'undefined' || typeof(destObj) == 'undefined') return; for (i=0;i=0;i--) { if (obj.options[i].selected == true) { obj.options[i] = null; } } } function convertOptionsToJSONArray(objName,targetObjName) { var obj = $(objName); var arr = []; if(typeof(obj) != 'undefined') { for (i=0; i 1200) { topSide = topSide-250; } } } if((leftSide > 100) && (leftSide < 500)){ tagName.style.left= leftSide -50 + 'px'; } else if((leftSide >= 500) && (leftSide < 800)){ tagName.style.left= leftSide -150 + 'px'; } else if((leftSide >= 800) && (leftSide < 1400)){ if((widthM > 100) && (widthM < 250)) { tagName.style.left= leftSide- 100 + 'px'; } else if((widthM >= 250) && (widthM < 350)) { tagName.style.left= leftSide- 200 + 'px'; } else if((widthM >= 350) && (widthM < 500)) { console.log(widthM); tagName.style.left= leftSide- 300 + 'px'; } else { tagName.style.left= leftSide -550 + 'px'; } } else { tagName.style.left= leftSide + 5 +'px'; } if(announcement){ tagName.style.top = 110+'px'; }else{ tagName.style.top = 76+'px'; } tagName.style.display = 'block'; tagName.style.visibility = "visible"; } function fnvshobjsearch(obj,Lay){ var tagName = document.getElementById(Lay); var leftSide = findPosX(obj); var topSide = findPosY(obj); var maxW = tagName.style.width; var widthM = maxW.substring(0,maxW.length-2); if(Lay == 'editdiv') { leftSide = leftSide - 225; topSide = topSide - 125; }else if(Lay == 'transferdiv') { leftSide = leftSide - 10; topSide = topSide; } var IE = document.all?true:false; if(IE) { if($("repposition1")) { if(topSide > 1200) { topSide = topSide-250; } } } var getVal = eval(leftSide) + eval(widthM); if(getVal > document.body.clientWidth ) { leftSide = eval(leftSide) - eval(widthM); tagName.style.left = leftSide + 91 + 'px'; } else { tagName.style.left= leftSide - 324 + 'px'; } tagName.style.top= topSide + 33 + 'px'; tagName.style.display = 'block'; tagName.style.visibility = "visible"; } function fnDropDownUser(obj,Lay){ var tagName = document.getElementById(Lay); var leftSide = findPosX(obj); var topSide = findPosY(obj); var maxW = tagName.style.width; var widthM = maxW.substring(0,maxW.length-2); var getVal = eval(leftSide) + eval(widthM); if(getVal > document.body.clientWidth ){ leftSide = eval(leftSide) - eval(widthM); tagName.style.left = leftSide + 34 + 'px'; } else tagName.style.left= leftSide - 50 + 'px'; tagName.style.top= topSide + 28 +'px'; tagName.style.display = 'block'; } //select the records across the pages function toggleSelectAll_Records(module,state,relCheckName) { toggleSelect_ListView(state,relCheckName); if(state == true) { $('allselectedboxes').value = 'all'; $('selectAllRec').style.display = 'none'; $('deSelectAllRec').style.display = 'inline'; } else { $('allselectedboxes').value = ''; $('excludedRecords').value = ''; $('selectCurrentPageRec').checked = false; $('selectAllRec').style.display = 'inline'; $('deSelectAllRec').style.display = 'none'; $('linkForSelectAll').hide(); } } function toggleSelectDocumentRecords(module,state,relCheckName,parentEleId) { toggleSelect_ListView(state,relCheckName,parentEleId); if(state == true) { $('selectedboxes_'+parentEleId).value = 'all'; $('selectAllRec_'+parentEleId).style.display = 'none'; $('deSelectAllRec_'+parentEleId).style.display = 'inline'; } else { $('selectedboxes_'+parentEleId).value = ''; $('excludedRecords_'+parentEleId).value = ''; $('currentPageRec_'+parentEleId).checked = false; $('selectAllRec_'+parentEleId).style.display = 'inline'; $('deSelectAllRec_'+parentEleId).style.display = 'none'; $('linkForSelectAll_'+parentEleId).hide(); } } //Compute the number of rows in the current module function getNoOfRows(id){ var module = $('curmodule').value; var searchurl = $('search_url').value; var viewid = getviewId(); var url = "module="+module+"&action="+module+"Ajax&file=ListViewCount&viewname="+viewid+searchurl; if(module == 'Documents') { var folderid = $('folderid_'+id).value; url = url+"&folderidstring="+folderid; } new Ajax.Request( 'index.php', { queue: { position: 'end', scope: 'command' }, method: 'post', postBody:url, onComplete: function(response) { if(module != 'Documents') { $('numOfRows').value = response.responseText; $('count').innerHTML = response.responseText; if(parseInt($('maxrecords').value) < parseInt(response.responseText)){ $('linkForSelectAll').show(); } } else { $('numOfRows_'+id).value = response.responseText; $('count_'+id).innerHTML = response.responseText; if(parseInt($('maxrecords').value) < parseInt(response.responseText)){ $('linkForSelectAll_'+id).show(); } } } } ); } //select all function for related list of campaign module function rel_toggleSelectAll_Records(module,relmodule,state,relCheckName) { rel_toggleSelect(state,relCheckName,relmodule); if(state == true) { $(module+'_'+relmodule+'_selectallActivate').value = 'true'; $(module+'_'+relmodule+'_selectAllRec').style.display = 'none'; $(module+'_'+relmodule+'_deSelectAllRec').style.display = 'inline'; } else { $(module+'_'+relmodule+'_selectallActivate').value = 'false'; $(module+'_'+relmodule+'_excludedRecords').value = ''; $(module+'_'+relmodule+'_selectCurrentPageRec').checked = false; $(module+'_'+relmodule+'_selectAllRec').style.display = 'inline'; $(module+'_'+relmodule+'_deSelectAllRec').style.display = 'none'; $(module+'_'+relmodule+'_linkForSelectAll').hide(); } } // Compute the number of records related to capmaign record function getNoOfRelatedRows(current_module,related_module){ var recordid = document.getElementById('recordid').value; new Ajax.Request( 'index.php', { queue: { position: 'end', scope: 'command' }, method: 'post', postBody:"module="+current_module+"&related_module="+related_module+"&action="+current_module+"Ajax&idlist="+recordid+"&file=ListViewCount&mode=relatedlist", onComplete: function(response) { $(current_module+'_'+related_module+'_numOfRows').value = response.responseText; $(related_module+'_count').innerHTML = response.responseText; if(parseInt($('maxrecords').value) < parseInt(response.responseText)){ $(current_module+'_'+related_module+'_linkForSelectAll').show(); } } } ); } function updateParentCheckbox(obj,id){ var parentCheck=true; if (obj) { for (var i=0; i