426 lines
14 KiB
JavaScript
426 lines
14 KiB
JavaScript
//RowDelim="~R0W~";
|
|
//ColDelim="~C0L~";
|
|
var SameAddr=new Array(0);
|
|
var AddrElem=new Array(4);
|
|
var selectedAddr=-1;
|
|
var FocusAfter="CustomerName";
|
|
AddrElem[0]=["chksresi","ResiAdd1","ResiAdd2","ResiAdd3","ResiLandmark","ResiAdd3_hidden","ResiAdd3_citylist","ResiAdd3_Pincode","ResiPhone"];
|
|
AddrElem[1]=["chksoff","CompanyName","OffAdd1","OffAdd2","OffAdd3","OffLandmark","OffAdd3_hidden","OffAdd3_citylist","OffAdd3_Pincode","OffPhone","Extension"];
|
|
AddrElem[2]=["chksprop","PropAdd1","PropAdd2","PropAdd3","PropLandmark","PropAdd3_hidden","PropAdd3_citylist","PropAdd3_Pincode"];
|
|
AddrElem[3]=["BankCode","BankCode","branchlist","prodlist","LoanAmount","typelist","ContactPerson","splist"];
|
|
|
|
function SubmitPunching(pageURL,TargetWindow)
|
|
{
|
|
document.caseDetails.action=pageURL;
|
|
document.caseDetails.target=TargetWindow;
|
|
document.caseDetails.submit();
|
|
}
|
|
function FindSameDet(Elm,Visit,focAfter)
|
|
{
|
|
if($("#FormMode").val()=='2' && Visit=='A')
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
FocusAfter=focAfter;
|
|
var procFlag=true;
|
|
if(Elm.type=='checkbox')
|
|
{
|
|
procFlag=Elm.checked;
|
|
}
|
|
if(procFlag)
|
|
{
|
|
Applno=document.getElementById('ApplNo').value;
|
|
if(Applno.length==0)
|
|
{
|
|
if(Elm.type=='checkbox'){Elm.checked=false;}
|
|
CallMessage('VLFRM:error:Please enter application number.',3000,200,300);
|
|
document.getElementById('ApplNo').focus();
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
SameAddr=new Array(0); // Empty Address Array
|
|
oprId=(Visit=='R' ? 19:Visit=='O' ? 20:Visit=='P' ? 21:22);
|
|
QryStr="val="+Applno+"&val1="+$("#portlist").val()+"&val2="+oprId;
|
|
RunAjax("GET","findsdet",QryStr,oprId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function copyTelNo(isCopy,SourceElemId,TargetElemId)
|
|
{
|
|
if(isCopy)
|
|
{
|
|
var copyStr="/";
|
|
if(($("#"+TargetElemId).val().length) > 0)
|
|
{
|
|
|
|
copyStr=$("#"+TargetElemId).val()+"/"+$("#"+SourceElemId).val();
|
|
}
|
|
else
|
|
{
|
|
copyStr=$("#"+SourceElemId).val();
|
|
}
|
|
$("#"+TargetElemId).val(copyStr);
|
|
}
|
|
}
|
|
function SelectAddr(OprID)
|
|
{
|
|
if(SameAddr.length>1)
|
|
{
|
|
ShowAddrOptions(OprID);
|
|
}
|
|
else
|
|
{
|
|
FillSameDet(0,OprID);
|
|
}
|
|
}
|
|
function FillSameDet(AddrIndex,OprID)
|
|
{
|
|
if(!(AddrIndex < 0))
|
|
{
|
|
for(cindx=0;cindx<SameAddr[AddrIndex].length;cindx++)
|
|
{
|
|
$("#"+AddrElem[OprID][cindx+1]).val((SameAddr[AddrIndex][cindx]));
|
|
}
|
|
document.getElementById(FocusAfter).focus();
|
|
ToggleChks((document.getElementById('typelist').value.toUpperCase()!='APPLICANT' && document.getElementById('typelist').value.toUpperCase()!='-1'),'chksresi!C0L!chksoff!C0L!chksprop!C0L!','!C0L!');
|
|
}
|
|
else
|
|
{
|
|
document.getElementById(AddrElem[OprID][0]).focus();
|
|
if(document.getElementById(AddrElem[OprID][0]).type=='checkbox'){document.getElementById(AddrElem[OprID][0]).checked=false;}
|
|
}
|
|
}
|
|
function ShowAddrOptions(OprID)
|
|
{
|
|
var optDiv=document.createElement("div");
|
|
var Addr="";
|
|
optDiv.setAttribute("id","optDiv");
|
|
optDiv.setAttribute("class","FormPanel");
|
|
optDiv.setAttribute("style","font-family:Tahoma;overflow:visible");
|
|
var OptionPanel="<div id='TablePanel' class='tableContainer'><table border='0' cellspacing='0' width='100%' id='cutlist'><thead class='thead'><tr title='Row Title'><td colspan='2'>Available Addresses</td></tr></thead><tbody class='scrollContent'>";
|
|
for(indx=0;indx<SameAddr.length;indx++)
|
|
{
|
|
OptionPanel=OptionPanel+"<tr><td><input type='radio' name='rb1' id='rb"+indx+"' value='"+indx+"' onclick='selectedAddr=this.value;' /></td>";
|
|
OptionPanel=OptionPanel+"<td style='padding-right:5px'>";
|
|
for(cindx=0;cindx<4;cindx++)
|
|
{
|
|
Addr=Addr+" "+SameAddr[indx][cindx];
|
|
}
|
|
OptionPanel=OptionPanel+""+Addr+"</td></tr>";
|
|
Addr="";
|
|
}
|
|
OptionPanel=OptionPanel+"<tr><td colspan='2'><input type='button' class='button' name='btnok' style='margin-top:5px;float:right' value='OK' id='btnok' accesskey='K' onclick=\"AfterOptSelect(document.getElementById('inptDialog'),"+OprID+");\"";
|
|
OptionPanel=OptionPanel+"</tbody></table></div>";
|
|
optDiv.innerHTML=OptionPanel;
|
|
ShowInputDialog(optDiv,"Select Address","hint","inptDialog");
|
|
document.getElementById('rb0').focus();
|
|
}
|
|
function AfterOptSelect(ElemToRemove,OprID)
|
|
{
|
|
FillSameDet(selectedAddr, OprID);
|
|
selectedAddr=-1;
|
|
ElemToRemove.parentNode.removeChild(ElemToRemove);
|
|
}
|
|
function GatherRequirement(portID)
|
|
{
|
|
ClearDropDown("branch"+ColDelim+"product",ColDelim);
|
|
HideSections("section");
|
|
if(portID!=0)
|
|
{
|
|
QryStr="val0="+portID;
|
|
RunAjax("GET","filldds",QryStr,1);
|
|
}
|
|
}
|
|
function AfterResponse(AjaxResponse,OprID)
|
|
{
|
|
if(OprID==1)
|
|
{
|
|
ArrangePage(AjaxResponse);
|
|
}
|
|
else if(OprID==19 || OprID==20 || OprID==21 || OprID==22)
|
|
{
|
|
TabRows=AjaxResponse.split(RowDelim);
|
|
for(indx=0;indx<TabRows.length-1;indx++)
|
|
{
|
|
TabCols=TabRows[indx].split(ColDelim);
|
|
SameAddr[indx]=new Array(TabCols.length);
|
|
for(cindx=0;cindx<TabCols.length;cindx++)
|
|
{
|
|
SameAddr[indx][cindx]=TabCols[cindx];
|
|
}
|
|
}
|
|
SelectAddr(OprID-19);
|
|
}
|
|
}
|
|
function ArrangePage(AjaxResponse)
|
|
{
|
|
if(AjaxResponse!='')
|
|
{
|
|
var TempArr=AjaxResponse.split("#BRAN#");
|
|
var branch=TempArr[0];
|
|
|
|
TempArr=TempArr[1].split("#PROD#");
|
|
var product=TempArr[0];
|
|
var process=TempArr[1];
|
|
|
|
FillDD("branch",branch,RowDelim,ColDelim);
|
|
FillDD("product",product,RowDelim,ColDelim);
|
|
UnhideSections(process,ColDelim);
|
|
}
|
|
}
|
|
function ToggleChks(IsVisible,ChildElems,Delim)
|
|
{
|
|
if(IsVisible)
|
|
{
|
|
UnhideSections(ChildElems,Delim);
|
|
}
|
|
else
|
|
{
|
|
var Childs=ChildElems.split(Delim);
|
|
for(indx=0;indx<Childs.length-1;indx++)
|
|
{
|
|
HideSections(Childs[indx]);
|
|
document.getElementById(Childs[indx]).checked=false;
|
|
}
|
|
}
|
|
}
|
|
function setFormValidation(Elem,FormPanel,ChildElems,IsRequired,Validation,CounterPartElem)
|
|
{
|
|
if(Elem.checked && !CounterPartElem)
|
|
{
|
|
hideForm(Elem.id, FormPanel);
|
|
}
|
|
if(!Elem.checked)
|
|
{
|
|
CheckForm(Elem,ChildElems,IsRequired,Validation);
|
|
if(!CounterPartElem)
|
|
{
|
|
hideForm(Elem.id, FormPanel);
|
|
}
|
|
}
|
|
ToggleChks((document.getElementById('chkresi').checked && document.getElementById('chkoffice').checked),'chkrco'+ColDelim,ColDelim);
|
|
ToggleChks((document.getElementById('chkresi').checked),'chkrcp'+ColDelim,ColDelim);
|
|
ToggleChks((document.getElementById('chkoffice').checked),'chkocp'+ColDelim,ColDelim);
|
|
}
|
|
function AutoFill(Opt,FillMode)
|
|
{
|
|
var SourceFields="";
|
|
var TargetFields="";
|
|
var isSameAdd=false;
|
|
if(Opt=='chkrco')
|
|
{
|
|
SourceFields="ResiAdd1"+ColDelim+"ResiAdd2"+ColDelim+"ResiAdd3"+ColDelim+"ResiAdd3_hidden"+ColDelim+"ResiAdd3_citylist"+ColDelim+"ResiLandmark"+ColDelim+"ResiAdd3_Pincode"+ColDelim+"ResiPhone";
|
|
TargetFields="OffAdd1"+ColDelim+"OffAdd2"+ColDelim+"OffAdd3"+ColDelim+"OffAdd3_hidden"+ColDelim+"OffAdd3_citylist"+ColDelim+"OffLandmark"+ColDelim+"OffAdd3_Pincode"+ColDelim+"OffPhone";
|
|
if(document.getElementById('ResiAdd3_hidden').value==document.getElementById('OffAdd3_hidden').value)
|
|
{
|
|
isSameAdd=true;
|
|
}
|
|
}
|
|
else if(Opt=='chkrcp')
|
|
{
|
|
SourceFields="ResiAdd1"+ColDelim+"ResiAdd2"+ColDelim+"ResiAdd3"+ColDelim+"ResiAdd3_hidden"+ColDelim+"ResiAdd3_citylist"+ColDelim+"ResiLandmark"+ColDelim+"ResiAdd3_Pincode";
|
|
TargetFields="PropAdd1"+ColDelim+"PropAdd2"+ColDelim+"PropAdd3"+ColDelim+"PropAdd3_hidden"+ColDelim+"PropAdd3_citylist"+ColDelim+"PropLandmark"+ColDelim+"PropAdd3_Pincode";
|
|
if(document.getElementById('ResiAdd3_hidden').value==document.getElementById('PropAdd3_hidden').value)
|
|
{
|
|
isSameAdd=true;
|
|
}
|
|
}
|
|
else if(Opt=='chkocp')
|
|
{
|
|
SourceFields="OffAdd1"+ColDelim+"OffAdd2"+ColDelim+"OffAdd3"+ColDelim+"OffAdd3_hidden"+ColDelim+"OffAdd3_citylist"+ColDelim+"OffLandmark"+ColDelim+"OffAdd3_Pincode";
|
|
TargetFields="PropAdd1"+ColDelim+"PropAdd2"+ColDelim+"PropAdd3"+ColDelim+"PropAdd3_hidden"+ColDelim+"PropAdd3_citylist"+ColDelim+"PropLandmark"+ColDelim+"PropAdd3_Pincode";
|
|
if(document.getElementById('OffAdd3_hidden').value==document.getElementById('PropAdd3_hidden').value)
|
|
{
|
|
isSameAdd=true;
|
|
}
|
|
}
|
|
if(FillMode==1)
|
|
{
|
|
CopyDetails(SourceFields,TargetFields);
|
|
}
|
|
else if(FillMode==0 && isSameAdd)
|
|
{
|
|
ClearDetails(TargetFields);
|
|
}
|
|
}
|
|
function ClearDetails(TargetFields)
|
|
{
|
|
if(TargetFields.length!=0)
|
|
{
|
|
var TargetList=TargetFields.split(ColDelim);
|
|
if(TargetList.length==TargetList.length)
|
|
{
|
|
for(pos=0;pos<TargetList.length;pos++)
|
|
{
|
|
$("#"+TargetList[pos]).val("");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function CopyDetails(SourceFields,TargetFields)
|
|
{
|
|
if(SourceFields.length!=0 && TargetFields.length!=0)
|
|
{
|
|
var SourceList=SourceFields.split(ColDelim);
|
|
var TargetList=TargetFields.split(ColDelim);
|
|
if(SourceList.length==TargetList.length)
|
|
{
|
|
for(pos=0;pos<SourceList.length;pos++)
|
|
{
|
|
$("#"+TargetList[pos]).val($("#"+SourceList[pos]).val());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function CheckForm(Elem,ChildElems,IsRequired,Validation)
|
|
{
|
|
var Childs=ChildElems.split(",");
|
|
var IsChildReq=IsRequired.split(",");
|
|
var ValidString=Validation.split(",");
|
|
for(Indx=0;Indx<Childs.length;Indx++)
|
|
{
|
|
validate(document.getElementById(Childs[Indx]),Elem.checked ? IsChildReq[Indx]:'f',ValidString[Indx]);
|
|
}
|
|
}
|
|
function onLocalityBlur(el,IsRequired)
|
|
{
|
|
if(el.value=='')
|
|
{
|
|
document.getElementById(el.id+'_hidden').value='';
|
|
}
|
|
if(document.getElementById(el.id+'_hidden').value=='')
|
|
{
|
|
el.value='';
|
|
}
|
|
validate(el,IsRequired,'SplInstruction');
|
|
}
|
|
function ValidateSubmitForm(FormName)
|
|
{
|
|
var Chkresi=document.getElementById('chkresi');
|
|
var Chkoff=document.getElementById('chkoffice');
|
|
var Chkprop=document.getElementById('chkprop');
|
|
if(Chkresi.checked || Chkoff.checked || Chkprop.checked || document.getElementById('chkteler').checked || document.getElementById('chkteleo').checked || document.getElementById('chkref').checked || document.getElementById('chkdoc').checked)
|
|
{
|
|
validate(document.getElementById('ApplNo'),'t','AlphaNumeric');
|
|
validate(document.getElementById('branchlist'),'t','');
|
|
validate(document.getElementById('prodlist'),'t','');
|
|
validate(document.getElementById('CustomerName'),'t','AlphaSpace');
|
|
validate(document.getElementById('typelist'),'t','');
|
|
if(Chkresi.checked)
|
|
{
|
|
CheckForm(Chkresi,'ResiAdd1,ResiAdd2,ResiAdd3,ResiLandmark,ResiAdd3_citylist,ResiAdd3_Pincode','t,f,t,f,t,t','SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode');
|
|
if(document.getElementById('ResiAdd3_hidden').value=='' || document.getElementById('ResiAdd3_hidden').value=='0')
|
|
{
|
|
highlightField(document.getElementById('ResiAdd3'));
|
|
}
|
|
}
|
|
if(Chkoff.checked)
|
|
{
|
|
CheckForm(Chkoff,'CompanyName,OffAdd1,OffAdd2,OffAdd3,OffLandmark,OffAdd3_citylist,OffAdd3_Pincode,Department,Designation','f,t,f,t,f,t,t,f,f,t','SplInstruction,SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode,SplInstruction,SplInstruction');
|
|
if(document.getElementById('OffAdd3_hidden').value=='' || document.getElementById('OffAdd3_hidden').value=='0')
|
|
{
|
|
highlightField(document.getElementById('OffAdd3'));
|
|
}
|
|
}
|
|
if(document.getElementById('chkteler').checked)
|
|
{
|
|
CheckForm(document.getElementById('chkteler'),'ResiPhone','t','Phone');
|
|
}
|
|
if(document.getElementById('chkteleo').checked)
|
|
{
|
|
CheckForm(document.getElementById('chkteleo'),'OffPhone','t','Phone');
|
|
}
|
|
if(Chkprop.checked)
|
|
{
|
|
CheckForm(Chkprop,'PropAdd1,PropAdd2,PropAdd3,PropLandmark,PropAdd3_citylist,PropAdd3_Pincode','t,f,t,f,t,t','SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode');
|
|
if(document.getElementById('PropAdd3_hidden').value=='' || document.getElementById('PropAdd3_hidden').value=='0')
|
|
{
|
|
highlightField(document.getElementById('PropAdd3'));
|
|
}
|
|
}
|
|
if(document.getElementById('chkref').checked)
|
|
{
|
|
CheckForm(document.getElementById('chkref'),'Ref1Name,Ref1Address,Ref1Contactno','t,f,t','AlphaSpace,SplInstruction,Phone');
|
|
}
|
|
if (invalidFields>0)
|
|
{
|
|
CallMessage('VLFRM:error:There are one or more error(s) in form. Please correct them and try again.',3000,200,300);
|
|
}
|
|
else
|
|
{
|
|
SubmitForm('casesave','_parent',FormName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CallMessage('VLFRM:error:Atleast one address verification is mandatory.',3000,200,300);
|
|
}
|
|
}
|
|
function HandleClick(el)
|
|
{
|
|
if(el.id=='chkresi')
|
|
{
|
|
setFormValidation(el,'FormPanel2','ResiAdd1,ResiAdd2,ResiAdd3,ResiLandmark,ResiAdd3_citylist,ResiAdd3_Pincode','t,f,t,f,t,t,f','SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode',document.getElementById('chkteler').checked);
|
|
EnableDisableFields(el.checked,'ResiAdd1,ResiAdd2,ResiAdd3,ResiLandmark,ResiAdd3_Pincode',',');
|
|
}
|
|
if(el.id=='chkteler')
|
|
{
|
|
setFormValidation(el,'FormPanel2','ResiPhone','t','Phone',document.getElementById('chkresi').checked);
|
|
}
|
|
if(el.id=='chkoffice')
|
|
{
|
|
setFormValidation(el,'FormPanel3','CompanyName,OffAdd1,OffAdd2,OffAdd3,OffLandmark,OffAdd3_citylist,OffAdd3_Pincode,Department,Designation','f,t,f,t,f,t,t,f,f,t','SplInstruction,SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode,SplInstruction,SplInstruction',document.getElementById('chkteleo').checked);
|
|
EnableDisableFields(el.checked,'OffAdd1,OffAdd2,OffAdd3,OffLandmark,OffAdd3_Pincode',',');
|
|
}
|
|
if(el.id=='chkrco')
|
|
{
|
|
if(el.checked)
|
|
{
|
|
AutoFill('chkrco',1);
|
|
}
|
|
else
|
|
{AutoFill('chkrco',0);}
|
|
}
|
|
if(el.id=='chkteleo')
|
|
{
|
|
setFormValidation(el,'FormPanel3','OffPhone','t','Phone',document.getElementById('chkoffice').checked);
|
|
}
|
|
if(el.id=='chkprop')
|
|
{
|
|
setFormValidation(el,'FormPanel4','PropAdd1,PropAdd2,PropAdd3,PropLandmark,PropAdd3_citylist,PropAdd3_Pincode','t,f,t,f,t,t','SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode',false);
|
|
EnableDisableFields(el.checked,'PropAdd1,PropAdd2,PropAdd3,PropLandmark,PropAdd3_Pincode',',');
|
|
}
|
|
if(el.id=='chkrcp')
|
|
{
|
|
if(el.checked)
|
|
{
|
|
AutoFill('chkrcp',1);
|
|
chkocp=document.getElementById('chkocp');
|
|
chkocp.checked=false;
|
|
chkprop=document.getElementById('chkprop');
|
|
chkprop.checked=true;
|
|
HandleClick(chkprop);
|
|
}
|
|
else
|
|
{AutoFill('chkrcp',0);}
|
|
}
|
|
if(el.id=='chkocp')
|
|
{
|
|
if(el.checked)
|
|
{
|
|
AutoFill('chkocp',1);
|
|
chkrcp=document.getElementById('chkrcp');
|
|
chkrcp.checked=false;
|
|
chkprop=document.getElementById('chkprop');
|
|
chkprop.checked=true;
|
|
HandleClick(chkprop);
|
|
}
|
|
else
|
|
{AutoFill('chkocp',0);}
|
|
}
|
|
}
|