404 lines
9.4 KiB
JavaScript
404 lines
9.4 KiB
JavaScript
var records=new Array(1);
|
|
var fields=new Array(1);
|
|
var recIndx = 0;
|
|
var recpos = 0;
|
|
var FocusAfter="customername";
|
|
ajax_list_externalFile = "listservprovider";
|
|
var validateHidden = false;
|
|
function InitPage(port)
|
|
{
|
|
centerDivBoth("formcontainer","H");
|
|
$("#portfolio_id").val(port);
|
|
ManageButtons(true);
|
|
$("#btnsave").hide();
|
|
if(port>0)
|
|
{
|
|
if(document.getElementById("ajaxmsg") !== null)
|
|
{
|
|
CallMessage('1001AJX:warning:Another operation is being processed, please wait..',3000,200,300);
|
|
return;
|
|
}
|
|
LoadingMsg("Fetching records, please wait...","ajaxmsg");
|
|
RunAjax("GET","puncheddocrecs","val0="+port+"&val1="+($("#dynamicfields").val()),1);
|
|
}
|
|
}
|
|
|
|
function PrepareQStr()
|
|
{
|
|
var val0='';
|
|
var val1='';
|
|
var indx=2;
|
|
autocut=0;
|
|
var lindx=fields[0].length-1;
|
|
var cid=$("#case_id").val();
|
|
var temp='';
|
|
|
|
for(indx;indx<lindx;indx++)
|
|
{
|
|
temp='';
|
|
if($("#"+fields[0][indx]).length > 0)
|
|
{
|
|
if(fields[0][indx]=='docv' || fields[0][indx]=='status')
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
temp="''"+$("#"+fields[0][indx]).val().replace(/,/g, ' ')+"''";
|
|
}
|
|
val0=val0+fields[0][indx]+',';
|
|
val1=val1+temp+",";
|
|
records[recpos][indx]=temp.replace(/\'/g,'');
|
|
}
|
|
else
|
|
{
|
|
val0=val0+fields[0][indx]+',';
|
|
val1=val1+"NULL,";
|
|
records[recpos][indx]=temp.replace(/\'/g,'');
|
|
}
|
|
}
|
|
val1=val1.replace(/&/g,'~AmP~');
|
|
return "val0="+val0+"&val1="+val1+"&val2="+cid+"&val3="+($("#uuid").val())+"&val4="+autocut+"&val5="+($("#usid").val())+"&val6="+($("#portfolio_id").val());
|
|
}
|
|
function GotoRecord(el)
|
|
{
|
|
recno=el.value;
|
|
if(recno!='')
|
|
{
|
|
if(recno > recIndx || recno <=0)
|
|
{
|
|
CallMessage('1001IRNG:error:Invalid input. Out of range',3000,200,300);
|
|
}
|
|
else
|
|
{
|
|
recpos=recno-1;
|
|
FillDetails(recpos);
|
|
}
|
|
}
|
|
}
|
|
function AddNewRecord()
|
|
{
|
|
if(recIndx== 0 || records[recIndx-1][0]!='0')
|
|
{
|
|
var cols=fields[0].length;
|
|
recIndx = recIndx+1;
|
|
recpos = recIndx-1;
|
|
records[recpos]=new Array(cols);
|
|
records[recpos][0]='0';
|
|
records[recpos][1]=$("#portfolio_id").val();
|
|
records[recpos][cols-4]='0';
|
|
records[recpos][cols-3]=$("#company_id").val();
|
|
records[recpos][cols-2]=$("#branch_id").val();
|
|
records[recpos][cols-1]='';
|
|
}
|
|
else
|
|
{
|
|
recpos=recIndx-1;
|
|
}
|
|
FillDetails(recpos);
|
|
}
|
|
function AfterResponse(response,oprID)
|
|
{
|
|
var rindx=0;
|
|
if(oprID==1)
|
|
{
|
|
$("#ajaxmsg").remove();
|
|
if(response.trim().search('Error')==-1)
|
|
{
|
|
var rows=response.split(RowDelim);
|
|
for(rindx=0;rindx<rows.length-1;rindx++)
|
|
{
|
|
var cindx=0;
|
|
var cols=rows[rindx].split(ColDelim);
|
|
if(rindx==0)
|
|
{
|
|
fields[rindx]=new Array(cols.length);
|
|
}
|
|
else
|
|
{
|
|
records[rindx-1]=new Array(cols.length);
|
|
}
|
|
for(cindx=0;cindx<cols.length;cindx++)
|
|
{
|
|
if(rindx==0)
|
|
{
|
|
fields[rindx][cindx]=cols[cindx];
|
|
}
|
|
else
|
|
{
|
|
records[rindx-1][cindx]=cols[cindx];
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
CallMessage(response,3000,200,300);
|
|
}
|
|
recIndx= rindx==0 ? rindx : rindx-1;
|
|
$("#recfound").html("<b>( 0 / "+(recIndx==0 ? "0" : recIndx)+" )</b>");
|
|
recpos=0;
|
|
FillDetails(recpos);
|
|
}
|
|
else if(oprID==2)
|
|
{
|
|
$("#ajaxmsg").remove();
|
|
collen=fields[0].length;
|
|
if(response.trim().search('Error')==-1)
|
|
{
|
|
if(autocut==1)
|
|
{
|
|
records[recpos][collen-4]='1';
|
|
}
|
|
if($("#case_id").val()!='0')
|
|
{
|
|
findRecord(3);
|
|
}
|
|
else
|
|
{
|
|
records[recpos][0]=response.split(ColDelim)[0];
|
|
records[recpos][collen-1]=response.split(ColDelim)[1];
|
|
AddNewRecord();
|
|
}
|
|
CallMessage('1001IRNG:info:Record updated successfully',3000,200,300);
|
|
}
|
|
else
|
|
{
|
|
records[recpos][collen-4]='-1';
|
|
CallMessage(response,3000,200,300);
|
|
}
|
|
}
|
|
else if(oprID==3)
|
|
{
|
|
$("#ajaxmsg").remove();
|
|
if(response.trim().search('Error')==-1)
|
|
{
|
|
CallMessage('1001IRNG:info:Record updated successfully',3000,200,300);
|
|
}
|
|
else
|
|
{
|
|
CallMessage(response,3000,200,300);
|
|
}
|
|
}
|
|
else if(oprID==4)
|
|
{
|
|
if(response.trim().search('Error')==-1)
|
|
{
|
|
FillDD("vendor_id",response,RowDelim,ColDelim);
|
|
if(currow != null)
|
|
{
|
|
$("#vendor_id").val($("#doclist tr:eq("+currow+")").find('td').eq(6).attr("id"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CallMessage(response,3000,200,300);
|
|
}
|
|
}
|
|
else if(oprID==5)
|
|
{
|
|
if(response.trim().search('Error')==-1)
|
|
{
|
|
alert(response);
|
|
}
|
|
else
|
|
{
|
|
CallMessage(response,3000,200,300);
|
|
}
|
|
}
|
|
}
|
|
function findRecord(arrOpr)
|
|
{
|
|
tempPos= recpos;
|
|
maxLen= recIndx-1;
|
|
if(arrOpr==1) tempPos=0;
|
|
if(arrOpr==2)
|
|
{
|
|
if(tempPos>0) tempPos=tempPos-1;
|
|
else return false;
|
|
}
|
|
if(arrOpr==3)
|
|
{
|
|
if(tempPos<maxLen) tempPos=tempPos+1;
|
|
else return false;
|
|
}
|
|
if(arrOpr==4) tempPos=maxLen;
|
|
recpos= tempPos;
|
|
FillDetails(recpos);
|
|
}
|
|
function SearchRecord(elm)
|
|
{
|
|
var found=false;
|
|
var skey=elm.value.trim().toLowerCase();
|
|
for(rindx=0;rindx<records.length;rindx++)
|
|
{
|
|
if(records[rindx][3].trim().toLowerCase().search(skey)>-1)
|
|
{
|
|
recpos=rindx;
|
|
found=true;
|
|
FillDetails(recpos);
|
|
break;
|
|
}
|
|
}
|
|
if(!found)
|
|
{
|
|
CallMessage('NOREC1001:error:No record found.',3000,200,300);
|
|
}
|
|
}
|
|
function FillDetails(indx)
|
|
{
|
|
if(recIndx > 0)
|
|
{
|
|
CancelEdit();
|
|
document.forms['casedetails'].reset();
|
|
$("#doclist").html('');
|
|
resetDocForm();
|
|
$("#recfound").html("<b>( "+(indx+1)+" / "+(recIndx==0 ? "0" : recIndx)+" )</b>");
|
|
var cols = fields[0].length;
|
|
var findx=0;
|
|
for(findx=0;findx < cols;findx++)
|
|
{
|
|
if($("#"+fields[0][findx]).length > 0)
|
|
{
|
|
$("#"+fields[0][findx]).val(records[indx][findx]);
|
|
}
|
|
}
|
|
var data = jQuery.parseJSON(records[indx][cols-5].replace('},]}','}]}'));
|
|
var tdocs = data.docs.length;
|
|
for(indx = 0;indx < tdocs; indx++)
|
|
{
|
|
var did = data.docs[indx].doc_id;
|
|
data.docs[indx].doc_id="0";
|
|
AddDocRow(data.docs[indx],did,data.docs[indx].docvendor);
|
|
}
|
|
document.getElementById("applno").focus();
|
|
}
|
|
else
|
|
{
|
|
CallMessage('5005MQRY:error:No records found',3000,200,300);
|
|
AddNewRecord();
|
|
}
|
|
}
|
|
function EditBasicDetails()
|
|
{
|
|
EnableDisableFields(false);
|
|
ManageButtons(false);
|
|
}
|
|
function SaveBasicDetails()
|
|
{
|
|
if(confirm("Are you sure to update the details?"))
|
|
{
|
|
var QStr=PrepareQStr();
|
|
QStr=QStr+"&val7=2";
|
|
if(document.getElementById("ajaxmsg") !== null)
|
|
{
|
|
CallMessage('1001AJX:warning:Another operation is being processed, please wait..',3000,200,300);
|
|
return;
|
|
}
|
|
LoadingMsg("Updating details, please wait...","ajaxmsg");
|
|
RunAjax("POST","updatebdetails",QStr,3);
|
|
EnableDisableFields(true);
|
|
ManageButtons(true);
|
|
|
|
}
|
|
}
|
|
function CancelEdit()
|
|
{
|
|
SetPrevValues();
|
|
EnableDisableFields(true);
|
|
ManageButtons(true);
|
|
}
|
|
function EnableDisableFields(isEnabled)
|
|
{
|
|
var indx=2;
|
|
if(typeof fields[0]!=='undefined')
|
|
{
|
|
var lindx=fields[0].length-1;
|
|
for(indx;indx<lindx;indx++)
|
|
{
|
|
$("#"+fields[0][indx]).prop("disabled",isEnabled);
|
|
}
|
|
}
|
|
indx=0;
|
|
/*$("#applno").prop("disabled",isEnabled);
|
|
$("#customername").prop("disabled",isEnabled);
|
|
$("#dob").prop("disabled",isEnabled);
|
|
$("#loanamount").prop("disabled",isEnabled);
|
|
$("#bank_branch_id").prop("disabled",isEnabled);
|
|
$("#product").prop("disabled",isEnabled);
|
|
$("#apptype").prop("disabled",isEnabled);
|
|
$("#category").prop("disabled",isEnabled);*/
|
|
}
|
|
function SetPrevValues()
|
|
{
|
|
$("#applno").val(records[recpos][3]);
|
|
$("#customername").val(records[recpos][6]);
|
|
$("#dob").val(records[recpos][9]);
|
|
$("#loanamount").val(records[recpos][5]);
|
|
$("#bank_branch_id").val(records[recpos][2]);
|
|
$("#product").val(records[recpos][4]);
|
|
$("#apptype").val(records[recpos][7]);
|
|
$("#category").val(records[recpos][8]);
|
|
}
|
|
function ManageButtons(bmode)
|
|
{
|
|
if(bmode)
|
|
{
|
|
if($("#applno").val().length > 0)
|
|
{
|
|
$("#btnbedit").show();
|
|
$("#btnsave").hide();
|
|
$("#section7").show();
|
|
}
|
|
else
|
|
{
|
|
$("#btnbedit").hide();
|
|
$("#btnsave").show();
|
|
$("#section7").hide();
|
|
EnableDisableFields(false);
|
|
}
|
|
$("#btnbsave").hide();
|
|
$("#btnbcancel").hide();
|
|
}
|
|
else
|
|
{
|
|
$("#btnbedit").hide();
|
|
$("#btnbsave").show();
|
|
$("#btnbcancel").show();
|
|
}
|
|
}
|
|
function changeLabel(el)
|
|
{
|
|
$("#uniqueidentifier").html($('option:selected',el).attr("uniqueidentifier"));
|
|
$("#sprovider").html($('option:selected',el).attr("sprovider"));
|
|
$("#serviceprovider").val($('option:selected',el).attr("defsprovider"));
|
|
$("#serviceprovider_hidden").val("0");
|
|
if($('option:selected',el).attr("genlist")>0)
|
|
{
|
|
$("#serviceprovider_citylist").val($('option:selected',el).attr("genlist"));
|
|
$("#serviceprovider").attr('onkeyup',"ajax_showOptions(this,event)");
|
|
validateHidden = true;
|
|
}
|
|
else
|
|
{
|
|
$("#serviceprovider_citylist").val("0");
|
|
$("#serviceprovider").removeAttr('onkeyup');
|
|
validateHidden = false;
|
|
}
|
|
$("#uniqueno").attr("onblur","validate(this,'t','"+$('option:selected',el).attr("validuno")+"')");
|
|
$("#yearmon").html($('option:selected',el).attr("ymon"));
|
|
$("#yearmonth").attr("onblur","validate(this,'f','"+$('option:selected',el).attr("validymon")+"')");
|
|
ValidateEntry('f');
|
|
GetVerifierList(el);
|
|
}
|
|
function GetVerifierList(el)
|
|
{
|
|
$("#vendor_id").empty().append('<option value="-1" selected>SELECT</option>');
|
|
if(el.value != '-1')
|
|
{
|
|
RunAjax("POST","getdocverlist","val0="+el.value,4);
|
|
}
|
|
}
|
|
|