$(document).ready(function(){
$("#showCashFlow").click(function(){
$("#montlyCashFlow").show();
$("#totalCashFlow").hide();
});
$("#showTotalCashFlow").click(function(){
$("#montlyCashFlow").hide();
$("#totalCashFlow").show();
});
});
function loadXml()
{
with(document.forms[0])
{
xmlDoc=getXMLParser();
if(Mode.value=="C"){
xmlDoc=loadXMLCommon("");
penaltyXml=loadXMLCommon("");
}
else
{
var urlOc ='GetEquipmentLeaseQuotXML&Arguments=-A'+QuotationNo.value+',-A1';
var QuotXml=getXMLParser();
xmlDoc=loadDefXml(urlOc);
var urlOc ='GetEquipmentLeaseQuotXML&Arguments=-A'+QuotationNo.value+',-A2';
//var QuotXml=getXMLParser();
penaltyXml=loadDefXml(urlOc);
//xmlDoc=loadXMLCommon(QuotXml);
//alert(getXMLStringFromObject(xmlDoc));
fillItemHdr();
FillItemDtl();
FillCalculatonDetails();
}
}
}
function fillItemHdr()
{
with(document.forms[0])
{
var headerNodeList = getJQXMLElementsArray(xmlDoc,"EquipmentQuot/EquipmentDtl/Equipment");
for (i=0;i').attr({
type: "text", id: id, name: id
});
alert(textInputBox);
// create a new textInputBox using supplied parameters
var inputTypeLable = $('').append(textInputBox).append(labelText);
// append the new radio button and label
$('#EquipmentTbl').append(inputTypeLable).append('
');
}
function test()
{
with(document.forms[0])
{
alert();
// var textInputBox = $('');
//alert(textInputBox);
}
}
function addEquipmentDetails()
{
with(document.forms[0])
{
addEqpDetail("","","","","","","","","","","","","","","");
}
}
function addEqpDetail(a_SrNo,a_LGCode,a_LGDesc,a_MGCode,a_MGDesc,a_EqpType,a_EqpTypeDesc,a_Discription,a_Quantity,a_RatePerQty,a_TotalCost,a_Discount,a_TotalAfterDisc,a_Supplier,a_SupName)
{
with(document.forms[0])
{
var tbl = document.getElementById('EquipmentTbl');
var lastRow = tbl.tBodies[0].rows.length;
rows=tbl.tBodies[0].rows;
var iteration;
//if(lastRow==0)
iteration = lastRow+1;
// else
// iteration=lastRow;
var row = tbl.tBodies[0].insertRow(lastRow);
row.setAttribute('vAlign',"top");
row.setAttribute('id', iteration);
var cellLeft = row.insertCell();
var el = document.createElement('img');
el.setAttribute('src','/English/Images94/QuickAccess/row_icon.jpg');
cellLeft.setAttribute('vAlign',"top");
cellLeft.appendChild(el);
var cellLeft = row.insertCell();
var textInput=Input('rowId',iteration,iteration,"50",'F','','tran_textInputFieldNr');
textInput.readOnly=true;
cellLeft.appendChild(textInput);
var cellLeft = row.insertCell();
var textInput =Input('LGcode',iteration,a_LGCode,"50",'F','','textInputFieldNr');
var textInput1 =Input('LGDesc',iteration,a_LGDesc,"150",'F','','readOnly_textInputFieldNr');
textInput1.style.width="100px"
textInput1.readOnly=true;
textInput1.tabIndex=-1;
callOnChangeCode(textInput,'LG',iteration);
cellLeft.appendChild(textInput);
cellLeft.appendChild(textInput1);
var cellLeft = row.insertCell();
var textInput =Input('MGcode',iteration,a_MGCode,"50",'F','','textInputFieldNr');
var textInput1 =Input('MGDesc',iteration,a_MGDesc,"150",'F','','readOnly_textInputFieldNr');
textInput1.style.width="100px"
textInput1.readOnly=true;
textInput1.tabIndex=-1;
callOnChangeCode(textInput,'MG',iteration);
cellLeft.appendChild(textInput);
cellLeft.appendChild(textInput1);
var cellLeft = row.insertCell();
var textInput =Input('Typecode',iteration,a_EqpType,"50",'F','','textInputFieldNr');
var srcButton=document.createElement("Button");
srcButton.id="TypeSrch"+iteration;
srcButton.className="zbutton";
srcButton.value="..";
callOnclickOfButton(srcButton,iteration);
var textInput1 =Input('TypeDesc',iteration,a_EqpTypeDesc,"150",'F','','readOnly_textInputFieldNr');
textInput.style.width="60px"
textInput1.style.width="100px"
textInput1.readOnly=true;
textInput1.tabIndex=-1;
callOnChangeCode(textInput,'TD',iteration);
cellLeft.appendChild(textInput);
cellLeft.appendChild(srcButton);
cellLeft.appendChild(textInput1);
var cellLeft = row.insertCell();
var textInput =Input('Description',iteration,a_Discription,"50",'F','','textInputFieldNr');
textInput.style.width="100px";
cellLeft.style.display="none";
textInput.readOnly=true;
cellLeft.appendChild(textInput);
var cellLeft = row.insertCell();
var dtlButton =Button('..','',iteration,"",'buttonNrTp1');
dtlButton.style.width="20px";
callOnClickDescription(dtlButton,"PeriodTbl",iteration);
cellLeft.align="center";
cellLeft.appendChild(dtlButton)
var cellLeft = row.insertCell();
var textInput =Input('Qty',iteration,a_Quantity,"50",'F','','textInputFieldNr');
textInput.style.width="30px";
callOnChangeOfAmount(textInput,iteration);
cellLeft.appendChild(textInput);
var cellLeft = row.insertCell();
var textInput =Input('Rate',iteration,a_RatePerQty,"50",'F','','textInputField_AmtNr');
textInput.style.width="80px";
callOnChangeOfAmount(textInput,iteration);
cellLeft.appendChild(textInput);
var cellLeft = row.insertCell();
var textInput =Input('Total',iteration,a_TotalCost,"50",'T','','readOnly_textInputField_AmtNr');
textInput.tabIndex=-1;
textInput.style.width="80px";
cellLeft.appendChild(textInput);
var cellLeft = row.insertCell();
var textInput =Input('Discount',iteration,a_Discount,"50",'F','','textInputField_AmtNr');
textInput.style.width="80px";
callOnChangeOfAmount(textInput,iteration);
cellLeft.appendChild(textInput);
var cellLeft = row.insertCell();
var textInput =Input('TotalAfterDisc',iteration,a_TotalAfterDisc,"50",'T','','readOnly_textInputField_AmtNr');
textInput.style.width="80px";
textInput.tabIndex=-1;
cellLeft.appendChild(textInput);
var cellLeft = row.insertCell();
var textInput =Input('Supplier',iteration,a_Supplier,"50",'T','','readOnly_textInputField_AmtNr');
var srcButton=document.createElement("Button");
srcButton.id="SupSrch"+iteration;
srcButton.className="zbutton";
srcButton.value="..";
SupplierZoom(srcButton,iteration);
var textInput1 =Input('SupplierName',iteration,a_Supplier,"50",'T','','readOnly_textInputField_AmtNr');
textInput1.value=a_SupName;
textInput.style.width="50px";
cellLeft.appendChild(textInput);
cellLeft.appendChild(srcButton);
cellLeft.appendChild(textInput1);
var cellLeft = row.insertCell();
var el = document.createElement('img');
el.setAttribute('src', '/English/Images94/QuickAccess/delete.gif');
el.setAttribute('name', 'EqpDel' + iteration);
el.setAttribute('id', 'EqpDel' + iteration);
el.setAttribute('alt', 'Delete');
cellLeft.align="center";
cellLeft.vAlign="center";
callOnClickDel(el,"EquipmentTbl",iteration);
cellLeft.appendChild(el);
}
//tableDecorate(document.getElementById('KmPmtab'));
}
function callOnclickOfButton(elm,rowCount)
{
with(document.forms[0])
{
elm.onclick=function(){
eqpRowCounter=rowCount;
NewWin('/Magic94Scripts/mgrqispi94.dll?appname=RentProWeb&prgName=EQUIPMENT_TYPE_DEFINITION_QA&Arguments=-A,-A,-A,-A,-A2','eqpQuotation','eqpQuotation','height=550,WIDTH=870,top=70,LEFT=160,scrollbars=1,resizable=1');
}
}
}
function SupplierZoom(elm,rowCount)
{
with(document.forms[0])
{
elm.onclick=function(){
eqpRowCounter=rowCount;
NewWin('/Magic94Scripts/mgrqispi94.dll?appname=RentProWeb&prgName=SupplierQA&Arguments=-A1,-A','eqpQuotation','eqpQuotation','left=120,top=20,height=690,WIDTH=870,scrollbars=1');
}
}
}
function hideDivDtl()
{
with(document.forms[0])
{
document.getElementById('equipmentDespDiv').style.display="none";
document.getElementById("Description"+currentRowId).value=eqpDescp.value;
}
}
function callOnClickDescription(elem,tbl,cntr)
{
with(document.forms[0])
{
eqpDescp.value="";
currentRowId=cntr;
elem.onclick=function(){
var e = window.event;
var posx11 = 0;
var posy11 = 0;
posx11 = e.clientX;
posy11 = e.clientY;
document.getElementById('equipmentDespDiv').style.display="";
//document.getElementById('spclRemarks').focus();
document.getElementById('equipmentDespDiv').focus();
var d=document.getElementById('equipmentDespDiv');
d.style.position = "absolute";
d.style.left=posx11+40;
d.style.top=posy11-10;
eqpDescp.value=document.getElementById("Description"+cntr).value;
}
}
}
function callOnChangeCode(elem,cllFrm,elemIdCntr)
{
with(document.forms[0])
{
elem.onchange=function(){
var elemCodeVal;
var elemCodeObj;
var elemCodeDescp;
var CalledFromParm;
if(cllFrm=='LG'){
elemCodeVal=document.getElementById("LGcode"+elemIdCntr).value;
CalledFromParm=332;
elemCodeObj=document.getElementById("LGcode"+elemIdCntr);
elemCodeDescp=document.getElementById("LGDesc"+elemIdCntr);
}
if(cllFrm=='MG'){
elemCodeVal=document.getElementById("MGcode"+elemIdCntr).value;
CalledFromParm=333;
elemCodeObj=document.getElementById("MGcode"+elemIdCntr);
elemCodeDescp=document.getElementById("MGDesc"+elemIdCntr);
}
if(cllFrm=='TD'){
elemCodeVal=document.getElementById("Typecode"+elemIdCntr).value;
CalledFromParm=334;
elemCodeObj=document.getElementById("Typecode"+elemIdCntr);
elemCodeDescp=document.getElementById("TypeDesc"+elemIdCntr);
}
// document.getElementById("Description"+elemIdCntr).value=trim(document.getElementById("LGDesc"+elemIdCntr).value)+' '+trim(document.getElementById("MGDesc"+elemIdCntr).value)+' '+trim(document.getElementById("TypeDesc"+elemIdCntr).value);
if(elemCodeVal!=0 && elemCodeVal!='')
{
var ValidateXML;
var urlOc = 'CommonXMLValidation&Arguments=-A'+parseInt(CalledFromParm)+',-A'+elemCodeVal;
ValidateXML=loadDefXml(urlOc);
var CodeDescpXmlRoot = ValidateXML.getElementsByTagName("Root")[0];
var RecordExistsYN=CodeDescpXmlRoot.getElementsByTagName("RecordExists")[0].text;
if(RecordExistsYN == "N")
{
alert("Invalid Code")
elemCodeObj.value=""
elemCodeDescp.value=""
elemCodeObj.focus()
return false;
}
else
{
elemCodeDescp.value=CodeDescpXmlRoot.getElementsByTagName("Description")[0].text;
}
}
}
}
}
function callOnChangeOfAmount(elmObj,cntr)
{
with(document.forms[0])
{
elmObj.onchange=function(){
var temp_Qty= parseInt(isNaN(parseFloat(document.getElementById("Qty"+cntr).value))?0:document.getElementById("Qty"+cntr).value);
var temp_Rate= parseFloat(isNaN(parseFloat(document.getElementById("Rate"+cntr).value))?0:document.getElementById("Rate"+cntr).value);
var temp_Total=parseFloat(isNaN(parseFloat(document.getElementById("Total"+cntr).value))?0:document.getElementById("Total"+cntr).value);
var temp_Discount=parseFloat(isNaN(parseFloat(document.getElementById("Discount"+cntr).value))?0:document.getElementById("Discount"+cntr).value);
document.getElementById("Total"+cntr).value=parseFloat(parseInt(temp_Qty)*parseFloat(temp_Rate));
temp_Total=parseFloat(isNaN(parseFloat(document.getElementById("Total"+cntr).value))?0:document.getElementById("Total"+cntr).value);
document.getElementById("TotalAfterDisc"+cntr).value=parseFloat(parseFloat(temp_Total)-parseFloat(temp_Discount));
}
}
}
function callOnClickDel(elem,TableId,dr)
{
with(document.forms[0])
{
elem.onclick=function(){
var tbl = document.getElementById(TableId);
var rows = tbl.tBodies[0].rows;
for(i=0;i0){
var TargetRetNode=TargetReturnNodeList[0];
temp_TargetRetRerc=TargetRetNode.getAttribute("Perc");
temp_TargetRetPerMonth=parseFloat(parseFloat(temp_TargetRetRerc)/parseInt(12)).toFixed(3);
targetReturnMonthCal=parseFloat(parseFloat(temp_TargetRetRerc)/parseInt(12));
}
node.setAttribute("TargatedReturnPerc",temp_TargetRetRerc);
node.setAttribute("TargatedReturnPerMonth",temp_TargetRetPerMonth);
appendNodeToParent(root_node,node);
/*----------------------------------------*/
/*---- Get Residual value from Defaults and Create XML ----*/
var ResidaulNodeList;
ResidaulNodeList=getResidualXml(rowId,document.getElementById("LGcode"+eqpRow).value,document.getElementById("MGcode"+eqpRow).value,parseFloat(document.getElementById("TotalAfterDisc"+eqpRow).value),document.getElementById("Typecode"+eqpRow).value);
if(ResidaulNodeList.length>0){
var ResidaulNode=ResidaulNodeList[0];
temp_ResidualPerc=ResidaulNode.getAttribute("Perc");
}
node.setAttribute("ResidualPercent",temp_ResidualPerc);
temp_ResidualValue=parseFloat(parseFloat(DtlNodeList[0].getAttribute("EquipmentCost"))*(parseFloat(temp_ResidualPerc)/parseFloat(100))*parseInt(DtlNodeList[0].getAttribute("NoOfUnits")));
node.setAttribute("ResidualValue",temp_ResidualValue);
var residualValForIRR=parseFloat(temp_ResidualValue);
var tempTargetRet=parseFloat(targetReturnMonthCal)/parseInt(100);
var tempPrd=parseInt(EqpPeriod);
temp_ResidualValue=parseFloat(temp_ResidualValue)*parseInt(-1);
var temp_PVRV=pv(tempTargetRet,tempPrd,0,temp_ResidualValue);
node.setAttribute("PVofRV",temp_PVRV);
appendNodeToParent(root_node,node);
/*----------------------------------------*/
/*------Create Invoice Schedule Based On Period Break--------------*/
removeFromDetails('InvSchedule',rowId);
CreateInvoiceShcedule(rowId);
var tempTRBeforRV = IRRCalc(IRRArry, 0.001);
tempTRBeforRV=(parseFloat(tempTRBeforRV)*parseInt(12)).toFixed(4);
node.setAttribute("TRBeforeRv",tempTRBeforRV);
IRRArry.push(residualValForIRR);
var tempTRAfterRV = IRRCalc(IRRArry, 0.001);
tempTRAfterRV=(parseFloat(tempTRAfterRV)*parseInt(12)).toFixed(4);
node.setAttribute("TRAfterRv",tempTRAfterRV);
/*-----------------------------------------------------------------*/
/*-------------Create PV and FV XML----------------------------*/
var temp_RtlPV_FirstPrd=0,temp_RtlPV_SecondPrd=0,temp_RtlPeriod=0,temp_RtlPeriodSecond=0,pvfvRowId=0,temp_FV_scndRTL=0;
removeFromDetails('PVFV',rowId);
var tbl = document.getElementById('PaymentSched');
var rowCount = tbl.tBodies[0].rows.length;
var tblRows =tbl.tBodies[0].rows;
for (i=0;i0){
var IRRNode=IRRNodeList[0];
var IRRpercent=parseFloat(IRRNode.getAttribute("Value"));
}
node.setAttribute("IRRValue",parseFloat(IRRpercent)*parseFloat(12));
appendNodeToParent(root_node,node);
/*------Update Calculation Tab From XML------------*/
UpdateCalculationDetail(rowId,eqpRow);
/*-------------------------------------------------*/
//alert(getXMLStringFromObject(xmlDoc));
}
}
//alert(pv(0.00725,36,0,-20405.53))
//alert(pv(0.00725,21,-11136,0))
//alert(fv(0.00725,21,0,-18769.26))
// Parameters are rate, total number of periods, payment made each period and future value
function pv(rate, nper, pmt, fv) {
rate = parseFloat(rate);
nper = parseFloat(nper);
pmt = parseFloat(pmt);
fv = parseFloat(fv);
if ( nper == 0 ) {
alert("Why do you want to test me with zeros?");
return(0);
}
if ( rate == 0 ) { // Interest rate is 0
pv_value = -(fv + (pmt * nper));
} else {
x = Math.pow(1 + rate, -nper);
y = Math.pow(1 + rate, nper);
pv_value = - ( x * ( fv * rate - pmt + y * pmt )) / rate;
}
pv_value = conv_number(pv_value,2);
return (pv_value);
}
function conv_number(expr, decplaces) {
var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
while (str.length <= decplaces) {
str = "0" + str;
}
var decpoint = str.length - decplaces;
return (str.substring(0,decpoint) + "." + str.substring(decpoint,str.length));
}
function fv(rate, nper, pmt, pv) {
rate = parseFloat(rate);
nper = parseFloat(nper);
pmt = parseFloat(pmt);
pv = parseFloat(pv);
if ( nper == 0 ) {
alert("Why do you want to test me with zeros?");
return(0);
}
if ( rate == 0 ) { // Interest rate is 0
fv_value = -(pv + (pmt * nper));
} else {
x = Math.pow(1 + rate, nper);
fv_value = - ( -pmt + x * pmt + rate * x * pv ) /rate;
}
fv_value = conv_number(fv_value,2);
return (fv_value);
}
function pmt(rate, nper, pv, fv, type) {
if (!fv) fv = 0;
if (!type) type = 0;
if (rate == 0) return -(pv + fv)/nper;
var pvif = Math.pow(1 + rate, nper);
var pmt_value = rate / (pvif - 1) * -(pv * pvif + fv);
if (type == 1) {
pmt_value /= (1 + rate);
}
return pmt_value;
}
function IRRCalc(CArray, guest) {
inc = 0.0000001;
do {
guest += inc;
NPV = 0;
for (var j=0; j < CArray.length; j++) {
NPV += CArray[j] / Math.pow((1 + guest), j);
}
} while (NPV > 0);
return guest * 100;
}
function updateSummaryXml(eqpRow)
{
with(document.forms[0])
{
EqpMnthCombo.value="";
rowId=EqpPeriod+eqpRow;
var node,totalInsuranceCost=0,temp_recoveryAmt=0,temp_TargetRetPerc=0,temp_TargetRetPerMonth=0,temp_ResidualPerc=0,temp_ResidualValue=0;
var root_node=xmlDoc.getElementsByTagName('EquipmentQuot')[0];
var NodeList =getJQXMLElementsArray(xmlDoc,"EquipmentQuot/Details[Tenure="+EqpPeriod+"]");// ***use finde function rather and try
var SummaryNodeList=getJQXMLElementsArray(xmlDoc,"EquipmentQuot/Summary[ID="+EqpPeriod+"]");
if(SummaryNodeList.length==0)
node=createElementCommon(xmlDoc,xmlDoc,'Summary');
else
node=SummaryNodeList[0];
var sum_EquipmentCost=0,sum_TotalCost=0,sum_DiscountAmt=0,sum_TotAfterDisc=0,sum_TotInsurance=0,sum_TotalOutFlow=0;
var sum_ResidualCost=0,tempTargetRet=0;
//0.00633333
for (i=0;i0){
CostPerEqp.value=detailNodeList[0].getAttribute("EquipmentCost");
NoOfUnits.value=detailNodeList[0].getAttribute("NoOfUnits");
TotalCostEqp.value=detailNodeList[0].getAttribute("TotalCost");
BlindDiscount.value=detailNodeList[0].getAttribute("DiscountAmt");
CostAfterDisc.value=detailNodeList[0].getAttribute("TotAfterDisc");
EqpInsuranceCost.value=detailNodeList[0].getAttribute("TotalInsuranceLocal");
TotalOutflow.value=detailNodeList[0].getAttribute("TotalOutFlow");
/* Delete Previous Insurance Lines and Create Fresh Rows from XMl*/
delTableRows('insuCalTable');
createInsuranceTable(rowId);
/* -----------------------------------*/
tenureInMnths.value=detailNodeList[0].getAttribute("Tenure");
prePaidMnthsDtl.value=detailNodeList[0].getAttribute("PrepaidMonths");
recoveryAmt.value=detailNodeList[0].getAttribute("RecoveryAmount");
recoveryRate.value=detailNodeList[0].getAttribute("RecoveryRate");
fltInterestRate.value=detailNodeList[0].getAttribute("FlatInterestRate");
TargateReturnEqp.value=detailNodeList[0].getAttribute("TargatedReturnPerc");
ResidualValueDtl.value=detailNodeList[0].getAttribute("ResidualValue");
TRBeforRVEqp.value=detailNodeList[0].getAttribute("TRBeforeRv");
TRAfterRVEqp.value=detailNodeList[0].getAttribute("TRAfterRv");
TargetRVPerMonthEqp.value=detailNodeList[0].getAttribute("TargatedReturnPerMonth");
PeriodOfRV.value=detailNodeList[0].getAttribute("Tenure");
InsuRate.value=detailNodeList[0].getAttribute("InsuranceRate");
PVforResidual.value=detailNodeList[0].getAttribute("PVofRV");
/* Delete Previous Invoice Schedule Lines and Create Fresh Rows from XMl*/
delTableRows('eqpInvoiceSch');
updateInvSchTable(rowId,eqpRow);
/* -----------------------------------*/
/*Delete Previous PV and FV table Lines and Create Fresh Rows from XMl*/
delTableRows('PVandFvDtl');
createPVFVTable(rowId);
/* -----------------------------------*/
}
}
}
function UpdateCalculationDetailSummary(rowId,eqpRow)
{
with(document.forms[0])
{
var detailNodeList = getJQXMLElementsArray(xmlDoc,"EquipmentQuot/Summary[ID="+EqpPeriod+"]");
if(detailNodeList.length>0){
CostPerEqp.value=detailNodeList[0].getAttribute("EquipmentCost");
NoOfUnits.value=detailNodeList[0].getAttribute("NoOfUnits");
TotalCostEqp.value=detailNodeList[0].getAttribute("TotalCost");
BlindDiscount.value=detailNodeList[0].getAttribute("DiscountAmt");
CostAfterDisc.value=detailNodeList[0].getAttribute("TotAfterDisc");
EqpInsuranceCost.value=detailNodeList[0].getAttribute("TotalInsuranceLocal");
TotalOutflow.value=detailNodeList[0].getAttribute("TotalOutFlow");
/* Delete Previous Insurance Lines and Create Fresh Rows from XMl*/
delTableRows('insuCalTable');
createInsuranceTableSummary(EqpPeriod);
/* -----------------------------------*/
tenureInMnths.value=detailNodeList[0].getAttribute("Tenure");
prePaidMnthsDtl.value=detailNodeList[0].getAttribute("PrepaidMonths");
recoveryAmt.value=detailNodeList[0].getAttribute("RecoveryAmount");
recoveryRate.value=detailNodeList[0].getAttribute("RecoveryRate");
fltInterestRate.value=detailNodeList[0].getAttribute("FlatInterestRate");
TargateReturnEqp.value=detailNodeList[0].getAttribute("TargatedReturnPerc");
ResidualValueDtl.value=detailNodeList[0].getAttribute("ResidualValue");
TRBeforRVEqp.value=detailNodeList[0].getAttribute("TRBeforeRv");
TRAfterRVEqp.value=detailNodeList[0].getAttribute("TRAfterRv");
TargetRVPerMonthEqp.value=detailNodeList[0].getAttribute("TargatedReturnPerMonth");
PeriodOfRV.value=detailNodeList[0].getAttribute("Tenure");
InsuRate.value="";
PVforResidual.value=detailNodeList[0].getAttribute("PVofRV");
var tbl = document.getElementById('PeriodTbl');
var lastRow = tbl.tBodies[0].rows.length;
rows=tbl.tBodies[0].rows;
for(i=0;i 0){
EqDtl_node = EqDtl_nodeList[0];
EqDtl_node.parentNode.removeChild(EqDtl_node);
}
var Eqptnode=createElementCommon(xmlDoc,xmlDoc,'EquipmentDtl');
appendNodeToParent(root_node,Eqptnode);
for(var i=0;i
LinkTo.options[0] = new Option('None','N');
LinkTo.options[1] = new Option('Index Rate','I');
LinkTo.value='N';
if(LinkTo.value=='')
LinkTo.value='N';
else
LinkTo.value=Lnkto
}
LinkCI();*/
}
}
function ShowDet(Cfrom)
{
with(document.forms[0])
{
if(Cfrom==1)
{
divchk("","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none")
}
else if(Cfrom==2)
{
divchk("","none","none","none")
if(ChkUpdTabAllowance!=1)
{
UpdTables(1,LineNO.value); //For Allowances
ChkUpdTabAllowance=1;
}
}
else if(Cfrom==3)
{
divchk("none","","none","none")
if(ChkUpdTabOtherChrg!=1)
{
UpdTables(2,LineNO.value); //For Other Charges
ChkUpdTabOtherChrg=1;
}
}
else if(Cfrom==4)
{
divchk("none","none","","none")
managmentFeePerEdit.value=MangmentFeePer.value;
managmentFeeFlatEdit.value=MangmentFeeFltAmt.value;
}
else if(Cfrom==5)
{
divchk("none","none","none","")
reductionAmtEdit.value=RedPerMonthCost.value;
}
else
{
divchk("none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none")
//document.all.DetailCalValue.style.display="";
}
}
}
function UpdTables(CallFrom,EId)
{
with(document.forms[0])
{
if(CallFrom==1)
{
var cal = "Quotation/Details[@ID="+EId+"]/Allowances"; // to display Penalties For that Details
var DET=xmlDoc.getElementsByTagName(cal);
var count = DET.length;
for(var i=1,j=count;i<=count;count--)
{
j=parseInt(j)-1;
cal = "Quotation/Details[@ID="+EId+"]/Allowances["+j+"]";
DET=xmlDoc.getElementsByTagName(cal);
addRowToAllowance(j+1,DET.item(0).getAttribute("ID"),DET.item(0).getAttribute("Amount"),0);
}
}
if(CallFrom==2)
{
var cal = "Quotation/Details[@ID="+EId+"]/OtherChrage"; // to display Penalties For that Details
var DET=xmlDoc.getElementsByTagName(cal);
var count = DET.length;
for(var i=1,j=count;i<=count;count--)
{
j=parseInt(j)-1;
cal = "Quotation/Details[@ID="+EId+"]/OtherChrage["+j+"]";
DET=xmlDoc.getElementsByTagName(cal);
addRowToOtherCharges(j+1,DET.item(0).getAttribute("Code"),DET.item(0).getAttribute("Amount"),0);
}
}
}
}
function addRowToAllowance(AccId,AlwncCode,Amount,CalledFrom1)
{
var tbl = document.getElementById('CAllwnceTabl');
if(CalledFrom1==1)
{
if(UpLdAllowances!=1)
{
ChkloadAllowances(); // load acc 7 gr acc on demand
UpLdAllowances=1;
}
var chk = ChkCombo(0,'CAllwnceTabl',AllwnceArrayCode,'AllwncCode');
if(!chk)
return false;
//1.fROM sCREEEN 0.oN SELECT.
var lastRow = tbl.tBodies[0].rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
//get the cnt from the last cellof the row to increment
if(lastRow==0)
{
var iteration = lastRow+1;
}
else
{
rows=tbl.tBodies[0].rows;
cells = rows[lastRow-1].cells;
var iteration = parseInt(cells[0].innerHTML)+1;
}
}
else
{
iteration=AccId;
}
if(UpLdAllowances!=1)
{
ChkloadAllowances(); // load acc 7 gr acc on demand
UpLdAllowances=1;
}
// if there's no header row in the table, then iteration = lastRow + 1
var row = tbl.tBodies[0].insertRow(lastRow);
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(1);
var el = document.createElement('select');
el.setAttribute('name', 'AllwncCode'+ iteration);
el.setAttribute('id', 'AllwncCode'+ iteration );
var addAllwnc=0;
for(var i=0,k=0;i0){
var EId=tempLineNo.value;
var st = 'Quotation/Details[@ID='+EId+']';
var srch=xmlDoc.getElementsByTagName(st);
cal = 'Details[@GroupCode='+srch.item(0).getAttribute("GroupCode")+']';
var Grpnode=xmlDoc.getElementsByTagName(cal);
if(Grpnode){
//var MontlyAmt=Grpnode[0].getAttribute("MonthlyLeaseAmt");
var MontlyAmt=srch.item(0).getAttribute("MonthlyLeaseAmt");
var ReductedAmount1=0;
ReductedAmount1=parseFloat(isNaN(parseFloat(MontlyAmt))?0:parseFloat(MontlyAmt))-parseFloat(isNaN(parseFloat(NegotiatedAmount.value))?0:parseFloat(NegotiatedAmount.value))
var ReductedAmount2=0;
ReductedAmount2=parseFloat(isNaN(parseFloat(LDefMangmntFeePerc.value))?0:parseFloat(LDefMangmntFeePerc.value))/100;
var ReductedAmount3=0;
ReductedAmount3=parseFloat(isNaN(parseFloat(ReductedAmount1))?0:parseFloat(ReductedAmount1))/(1+((parseFloat(isNaN(parseFloat(ReductedAmount2))?0:parseFloat(ReductedAmount2)))+(parseFloat(isNaN(parseFloat(LDefMarkupPerc.value))?0:parseFloat(LDefMarkupPerc.value))*parseFloat(isNaN(parseFloat(ReductedAmount2))?0:parseFloat(ReductedAmount2))/100)));
tempRedAmt.value=parseFloat(ReductedAmount3).toFixed(2);
}
NegotiatedAmount.value=0;
mainChanged=1;ChecktempReduction();UpdLineDetALL(0);
}
}
}
function HideVal(CallFrom)
{
if(CallFrom==0 && showCalOth==1)
{
document.all.chksize.style.width="100%";
}
else
{
document.all.chksize.style.width="100%";
}
}
function UpdtCurrTab(No)
{
with(document.forms[0])
{
selCTabV1=No;
if(No==1)
{
tabview_switch('TabView1',1);
tabName.value="Vehicle";
document.getElementById("CalTab").disabled=true;
}
else if(No==2)
{
tabview_switch('TabView1',2);
tabName.value="Calculate";
}
else if(No==3)
{
tabview_switch('TabView1',3);
tabName.value="Other";
}
else if(No==4)
{
if(ShowCalculation.value=='Y')
{
tabview_switch('TabView1',4);
tabName.value="Ratio";
}
}
}
}
function divchk(a,b,c,d)
{
document.all.CAllowanceZm.style.display=a;
document.all.COthrZm.style.display=b;
document.all.CMangementFeeZm.style.display=c;
document.all.CReductAmtZm.style.display=d;
}
function debprospimg()
{
with(document.forms[0])
{
if(CustomerType.value=='D')
NewWin('/Magic94Scripts/mgrqispi94.dll?appname=RentProWeb&prgName=DebitorsQuickAccess&Arguments=-A3,-AC,-A,-A,-A,-A,-A,-A,-A,-A,-A,-AY','EqpLeaseQuotation','EqpLeaseQuotation','left=120,top=20,height=500,WIDTH=750,scrollbars=1');
else
NewWin('/Magic94Scripts/mgrqispi94.dll?appname=RentProWeb&prgName=LeaseProspectPickList&Arguments=-A1,-A,-A,-A,-A,-A99','EqpLeaseQuotation','EqpLeaseQuotation','left=120,top=20,height=500,WIDTH=750,scrollbars=1');
}
}
function makeClone()
{
with(document.forms[0])
{
if((parseInt(LineNO.value))>1 && Mode.value=="C")
{
var toAddChild = xmlDoc.getElementsByTagName("Quotation")[0];
var tag =xmlDoc.getElementsByTagName("Quotation/Details")[0];
var clone = tag.cloneNode(false);
clone.setAttribute("ID",LineNO.value);
clone.setAttribute("GroupCode",'');
clone.setAttribute("LineMode",'C');
toAddChild.appendChild(clone);
}
}
}
function UpadateFromCalc(EId)
{
with(document.forms[0])
{
var st = 'Quotation/Details[@ID='+EId+']';
var srch=xmlDoc.getElementsByTagName(st);
srch.item(0).setAttribute("TotalBasicSal",BaicSalaryCost.value);
srch.item(0).setAttribute("AllowanceAmt",AllowanceCost.value);
srch.item(0).setAttribute("OthersCostAmt",OhterCost.value);
srch.item(0).setAttribute("TotalChfCost",TotalCost.value);
srch.item(0).setAttribute("TotalChfCostPerMont",CostPerMonth.value);
srch.item(0).setAttribute("ReductionAmt",RedPerMonthCost.value);
srch.item(0).setAttribute("NetCostPerMonth",NetPerMonthCost.value);
srch.item(0).setAttribute("LTManagementFeeAmt",MangmentFeeFltAmt.value);
srch.item(0).setAttribute("LTManagementFeePer",MangmentFeePer.value);
srch.item(0).setAttribute("LTManagementFeeTotal",TotMangmentFeeCost.value);
srch.item(0).setAttribute("VatPer",VatPer.value);
srch.item(0).setAttribute("VatAmt",VatAmount.value);
srch.item(0).setAttribute("TotalMonthlyCharge",TotMonthChrgCost.value);
}
}
function saveform(progname)
{
xmldoc2 = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.save(xmldoc2);
document.forms[0].Xmlblob.value=xmldoc2.xml;
document.forms[0].PRGNAME.value=progname;
document.forms[0].submit();
disableForm();
}
function disableForm()
{
if (document.all )
{
for (i = 0; i < document.forms[0].length; i++)
{
var formElement = document.forms[0].elements[i];
if (true)
{
formElement.disabled = true;
}
}
}
}
function SaveAllowanceToXml()
{
//var chk = ChkCombo(1,'CAccTabl',AccArrayCode,'AccName');
//if(!chk)
//{return false;}
var tbl = document.getElementById('CAllwnceTabl');
var rows = tbl.tBodies[0].rows;
for(var i=0;i=1)
OnSelect(LineNO.value);
else if(callFrom1122==1)
OnSelect(Grpnode[0].getAttribute("ID"));
}
}
function subMen(calFrm11)
{
var tbl = document.getElementById('test');
var rows1 = tbl.rows;
var cells = rows1[0].cells;
if(calFrm11==0)
{
cells[0].style.display='none';
}
else
{
cells[0].style.display='';
}
}
function delAlowanceOtherstable(TableId)
{
var tbl = document.getElementById(TableId);
var lastRow = tbl.tBodies[0].rows.length;
for(var dr=1;dr<=lastRow;--lastRow)
{
tbl.tBodies[0].deleteRow(0);
}
}
function getMaxLineNo()
{
var MaxLineNo=0;
MaxGrp = 'Details';
var Grpnode=xmlDoc.getElementsByTagName(MaxGrp);
for(i=0;i1)
{
for(i=0;count>i;i++)
{
MaxLineNo1++;
DET[i].setAttribute("ID",MaxLineNo1);
}
var ElmId = DET[0].getAttribute("ID");
Mode.value='M';
if(ElmId==1)
{
LineNO.value=1;
}
else
{
LineNO.value=ElmId;
}
}
else
{
Mode.value='C';
LineNO.value=1;
}
//document.forms[0].ErrorFlag.value=0;
saveform("ChauffeurLTQout");
}
}
}
function updateMangementFee(cllfrom)
{
with(document.forms[0])
{
if(cllfrom==1)
{
if(managmentFeePerEdit.value!="" && managmentFeePerEdit.value!=0)
{
managmentFeeFlatEdit.value="";
managmentFeeFlatEdit.readOnly=true;
managmentFeeFlatEdit.className="readOnly_textInputField_AmtLG";
}
else
{
managmentFeeFlatEdit.readOnly=false;
managmentFeeFlatEdit.className="textInputField_AmtLG";
managmentFeePerEdit.readOnly=true;
managmentFeePerEdit.className="readOnly_textInputField_AmtLG";
}
}
if(cllfrom==2)
{
if(managmentFeeFlatEdit.value!="" && managmentFeeFlatEdit.value!=0)
{
managmentFeePerEdit.value="";
managmentFeePerEdit.readOnly=true;
managmentFeePerEdit.className="readOnly_textInputField_AmtLG";
}
else
{
managmentFeePerEdit.readOnly=false;
managmentFeePerEdit.className="textInputField_AmtLG";
managmentFeeFlatEdit.readOnly=true;
managmentFeeFlatEdit.className="readOnly_textInputField_AmtLG";
}
}
MangmentFeePer.value=managmentFeePerEdit.value;
MangmentFeeFltAmt.value=managmentFeeFlatEdit.value;
}
}
function basicparameterschange(callFrom)
{
with(document.forms[0])
{
var Id=LineNO.value
var basicparameters = 'Details[@ID='+Id+']';
var srch=xmlDoc.getElementsByTagName(basicparameters);
var ChkAtGrpLevel=0;
var BasicParChanged=false;
if(ChfGradeCode.value != srch.item(0).getAttribute("ChfGrade"))
BasicParChanged=true;
if(CityCode.value != srch.item(0).getAttribute("City"))
BasicParChanged=true;
// Check For group Level
if(BasicParChanged)
ChkAtGrpLevel=1;
var ChkPMonths;
// If multiple Period Specified then
var tbl = document.getElementById('Pmtab');
var rows = tbl.tBodies[0].rows;
for(var i=0;i0)
{
with(document.forms[0])
{
if((BaicSalaryEWN.value == 'E' || BaicSalaryEWN.value == 'W') && (srch.item(0).getAttribute("ChfMonthlyCost")==0 || srch.item(0).getAttribute("ChfMonthlyCost")==""))
{
document.getElementById("CErrWarBasicSal").style.display='';
if(BaicSalaryEWN.value=='E')
{
Err='E';
document.getElementById("CErrWarBasicSal").src='/English/Images94/QuickAccess/MessageBoxStop.ico';
}
else
{
War='W';
document.getElementById("CErrWarBasicSal").src='/English/Images94/QuickAccess/MessageBoxExclamation.ico';
}
}
else
{
document.getElementById("CErrWarBasicSal").style.display='none';
}
if(Err=='E')
{
return Err;
}
else if(War=='W')
{
return War;
}
else
{
return Nan;
}
}
}
}
function ShowDetailsTab(LinErr)//For Showing Details
{
delAlowanceOtherstable('errTan2');
createTable(LinErr);
win = window.createPopup();
winBody = win.document.body;
winBody.innerHTML = document.getElementById('DetailsShow').innerHTML;
winBody.style.border = "solid black 1px";
win.show(250,250, 500,310, document.body);
}
function HideDetailsTab()
{
}
function ClosePopUp()
{
if(win.isOpen)
win.hide();
}
function createTable(ElmId)
{
var i=0;
var st = 'Quotation/Details[@ID='+ElmId+']';
var srch=xmlDoc.getElementsByTagName(st);
with(document.forms[0])
{
if((BaicSalaryEWN.value == 'E' || BaicSalaryEWN.value == 'W') && (parseFloat(srch.item(0).getAttribute("ChfMonthlyCost"))==0 || srch.item(0).getAttribute("ChfMonthlyCost") == ""))
{
CreateRow(BaicSalaryEWN.value,++i,'Chauffuer Basic Salary Not Found');
}
if(ErrorFlag.value== 1)
{
Proceed.disabled=true;
NewVehicle.disabled=true;
}
}
}
function CreateRow(EWFlag,EWNo,Desc) // EWFlag =E , W EWNo = Error Warinig No Desc= value not found
{
var newEl12 = document.getElementById('tbody12');
if(EWFlag =='E')
document.forms[0].ErrorFlag.value = 1;
var row = document.createElement('TR');
if(EWFlag=='E')
EWFlag="Error";
if(EWFlag=='W')
EWFlag="Warning";
var container = document.createElement('TD');
var theData = document.createTextNode(EWNo);
container.appendChild(theData);
row.appendChild(container);
var container = document.createElement('TD');
var theData = document.createTextNode(EWFlag);
container.appendChild(theData);
row.appendChild(container);
var container = document.createElement('TD');
var theData = document.createTextNode(Desc);
container.appendChild(theData);
row.appendChild(container);
newEl12.appendChild(row);
//ShowDetailsTab();
}
function updateReductionAmt()
{
with(document.forms[0])
{
RedPerMonthCost.value=reductionAmtEdit.value;
}
}
function savexml()
{
var CheckbAsicparm=basicparameterschange(0)
if(!CheckbAsicparm )
return false
//UpdateWithoutCalculate(5); // To update Delivery and Penalty to current Line in any case....
var y=xmlDoc.getElementsByTagName("Quotation");
// y.item(0).setAttribute("TotalValueQt",document.forms[0].TotalValSysCurr.value);
y.item(0).setAttribute("TotalValueQt",document.forms[0].total.value);
saveform("ChfLeaseQuotationSave");
document.forms[0].Proceed.disabled=true;
document.forms[0].Calculate_BT.disabled=true;
document.forms[0].Clear1.disabled=true;
document.forms[0].NewVehicle.disabled=true;
}
function UpdLineDetALL(callfrom22)
{
with(document.forms[0])
{
var tbl = document.getElementById('Pmtab');
var rows = tbl.tBodies[0].rows;
for(var i=0;i0)
{
alert("Duplicate Months Specified");
return false;
}
return true;
}
}
function BranchFound()
{
with(document.forms[0])
{
var ValidBranch;
var urlOc = '/Magic94Scripts/mgrqispi94.dll?appname=RentProWeb&prgName=VerifyBranchesWeb&Arguments=-A'+OutBranch.value+',-Aout,-A,-A,-AY';
var xmltemp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
xmltemp.open("GET", urlOc, false);
xmltemp.send();
ValidBranch = xmltemp.responseXML;
resultNode = ValidBranch.getElementsByTagName('root').item(0);
if(resultNode)
{
if (resultNode.getAttribute('InvalidBranch')=='Y')
{
if(OutBranch.value>9999)
alert('Branch Does Not Belong To Master Contract Company');
else
alert('Invalid Branch');
OutBranch.value='';
BranchName.value='';
OutBranch.focus();
}
else
{
BranchName.value=resultNode.getAttribute('BranchName');
}
}
}
}
function DelLineFrmXml()
{
with(document.forms[0])
{
var delLine=0;
calGrp = 'Details[@GroupCode='+CurrGroupCode.value+']';
var GetGrp=xmlDoc.getElementsByTagName(calGrp);
for(j=0;j1)
{
delQtline.removeAll();
}
else
{
var num = getline.item(0).getAttribute('ID');
cells = rows[0].cells;
var rowNum=rows[0].id;
var toAddChild = xmlDoc.getElementsByTagName("Quotation")[0];
var tag =xmlDoc.getElementsByTagName("Quotation/Details")[0];
var clone = tag.cloneNode(false);
clone.setAttribute("ID",document.getElementById("rowId"+rowNum).value);
delQtline.removeAll();
toAddChild.appendChild(clone);
}
var tbl = document.getElementById('Pmtab');
var rows = tbl.tBodies[0].rows;
for(var i=0;i