<?php ob_start();?>
<script>
var xmlHttp
function changestorename(str)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="Store_Name.php";
	url=url+"?store_code="+str;
	xmlHttp.onreadystatechange=NumberChanged1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function NumberChanged1()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("txtid").innerHTML=xmlHttp.responseText;
	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
  
  
function openPopupProfile(i)
{
  	window.open("Search_item_MRN.php?rowcount="+i,"profiles_popup_window","height=425,width=640,toolbar=no,menubar=no,dependent=yes,resizable =no");
}
 $(function() {
$(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' ,changeMonth: true,
		changeYear: true,
		yearRange: '-80:+20'});
});
function Completetotal(id)
{
 	var  Item_Amount = document.getElementById('total_Item_Amount').value;
 	var  Charge_Amount = document.getElementById('Charge_Amount').value;
	var inclusive=document.getElementById('tax_suroct_value').value;
	var total_tax=document.getElementById('tax_chargeamount').value;
 	var Grand_Total = parseFloat(Item_Amount) + parseFloat(Charge_Amount)+parseFloat(total_tax)+parseFloat(inclusive);
  	document.getElementById('grandtotal').value =Grand_Total;
}

function calculate_short(id)
{
	var x = document.getElementById('reciveqty_'+id).value;
	var poqty = document.getElementById('poqty_'+id).value;
	var reject = document.getElementById('rejectqty_'+id).value;
	var rate = document.getElementById('itemrate_'+id).value;
	//var tot = document.getElementById('totalrate_'+id).value;
	//alert("total rate is : "+tot);

	if(x != '')
	{
		if(poqty >= x)
		{
			//alert(rate);
			if(reject >0){
				document.getElementById('rejectqty_'+id).disabled =false;
			}
			else{
				document.getElementById('short_accessid_'+id).value = parseInt(poqty)- parseInt(x);
				document.getElementById('rejectqty_'+id).disabled =true;
				document.getElementById('totalrate_'+id).value = parseInt(rate) * parseInt(x);
				//alert(document.getElementById('totalrate_'+id).value);
			}

		}
		else
		{
			alert("Received Quantity can not be greater than PO Quantity");
			return false;
		}
		return true;
	}
	else
	{
		document.getElementById('short_accessid_'+id).value = '0';
	}
}


//--------------  ADD Sub charges----------------------------------
function cal_surcharges(id)
{
	 
	   document.getElementById("hidden_percent_inclusivecharge").value=id;
}
 
function cal_surcharges1()
{
  
   var surcharge=document.getElementById("percent_inclusivecharge").value;
   var per=document.getElementById('percent_inclusive').value;
   var amount=document.getElementById('tax_chargeamount').value;
  var total=document.getElementById('total_Item_Amount').value;
  var   total_tax=document.getElementById('tax_chargeamount').value;
   	if(surcharge=="SUR"){  
		totals=(parseInt(per)*parseFloat(amount))/100;
 		var	 final=totals;
 	 }
	else if(surcharge=="OCT"){
 	   	totals=parseFloat(total)+parseFloat(total_tax);
	 	var 	final=(parseFloat(totals)*  parseFloat(per))/100;
		 }	
 
		document.getElementById('tax_suroct_value').value=final;
	  
}

 


function update_amount(id)
{
document.getElementById("item_total_rate_"+id).value= (document.getElementById("reciveqty_"+id).value) * (document.getElementById("itemprice_"+id).value);
 }
 function update_basic()
{
var  itemamount = 0;
   var table = document.getElementById("totalrow").value;
   for(i=1; i<=table; i++)
	{
 		var totalrate = document.getElementById('itemprice_'+i).value;
 			itemamount  =parseInt(itemamount)+  parseInt(totalrate);
			 
			document.getElementById('total_Item_Amount').value = itemamount;
 	}
	
}
 
function showitem_details(str)
{
if (str=="")
  {
  document.getElementById("txt_item_details").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txt_item_details").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getitem_details.php?addmrn="+str,true);
xmlhttp.send();
}



function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function get_mrn_details(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	var data=xmlhttp.responseText.split("__");	
	document.getElementById("mrnDate").value=data[0];
	document.getElementById("poNO").value=data[1];
    document.getElementById("po_date").value=data[2];
	document.getElementById("poType").innerHTML=data[3];
	document.getElementById("doc_type_data").innerHTML=data[4];
	document.getElementById("billAdd").innerHTML=data[5];
	$("#bill_date").datepicker();
 	$("#challan_date").datepicker();
	
	
    }
  }

xmlhttp.open("GET","mrn_order_details2.php?mrnno="+str,true);
xmlhttp.send();
}


function showmrn(str)
{
var site= document.getElementById('site').value;
if (str=="")
  {
  document.getElementById("getmrn").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("getmrn").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_mrn.php?vendor="+str+"&site="+site,true);
xmlhttp.send();
}

function calc_basicamt()
{
	var total_basic=0;
	var cnt=document.getElementById("count").value;
	
	for(var j=1;j<cnt;j++)
	{
		var netrate=document.getElementById("basic_"+j).value;
		if(netrate==''){netrate=0;}
		total_basic=parseFloat(total_basic)+parseFloat(netrate);
	}
	document.getElementById("basic_amount").value=total_basic.toFixed(2);
}

function calc_total_excise_amount()
{
	var total_basic=0;
	var cnt=document.getElementById("count").value;
	
	for(var j=1;j<cnt;j++)
	{
		var netrate=document.getElementById("exciseValue_"+j).value;
		if(netrate==''){netrate=0;}
		total_basic=parseFloat(total_basic)+parseFloat(netrate);
	}
	document.getElementById("exciseValue").value=total_basic.toFixed(2);
}
function calc_total_ecess_amount()
{
	var total_basic=0;
	var cnt=document.getElementById("count").value;
	
	for(var j=1;j<cnt;j++)
	{
		var netrate=document.getElementById("ECessValue_"+j).value;
		if(netrate==''){netrate=0;}
		total_basic=parseFloat(total_basic)+parseFloat(netrate);
	}
	document.getElementById("ECessValue").value=total_basic.toFixed(2);
}
function calc_total_sah_amount()
{
	var total_basic=0;
	var cnt=document.getElementById("count").value;
	
	for(var j=1;j<cnt;j++)
	{
		var netrate=document.getElementById("SAHCessValue_"+j).value;
		if(netrate==''){netrate=0;}
		total_basic=parseFloat(total_basic)+parseFloat(netrate);
	}
	document.getElementById("SAHCessValue").value=total_basic.toFixed(2);
}
function calc_total_taxable_amount()
{
	var total_basic=0;
	var cnt=document.getElementById("count").value;
	
	for(var j=1;j<cnt;j++)
	{
		var netrate=document.getElementById("taxable_amt_"+j).value;
		if(netrate==''){netrate=0;}
		total_basic=parseFloat(total_basic)+parseFloat(netrate);
	}
	document.getElementById("taxable_amt").value=total_basic.toFixed(2);
}
function calc_total_tax_amount()
{
	var total_basic=0;
	var cnt=document.getElementById("count").value;
	
	for(var j=1;j<cnt;j++)
	{
		var netrate=document.getElementById("taxvalue_"+j).value;
		if(netrate==''){netrate=0;}
		total_basic=parseFloat(total_basic)+parseFloat(netrate);
	}
	document.getElementById("taxvalue").value=total_basic.toFixed(2);
}
function calc_total_total_amount()
{
	var total_basic=0;
	var cnt=document.getElementById("count").value;
	
	for(var j=1;j<cnt;j++)
	{
		var netrate=document.getElementById("TotalSpecial_"+j).value;
		if(netrate==''){netrate=0;}
		total_basic=parseFloat(total_basic)+parseFloat(netrate);
	}
	document.getElementById("total_item_amount").value=total_basic.toFixed(2);
}
function claculateExcise(i,str)
{
	if(str=='')
	{
    document.getElementById("exciseId_"+i).innerHTML='';
	}
	else
	{
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
  		}
		else
  		{// code for IE6, IE5
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  			
  			if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    		var data=xmlhttp.responseText.split("__");
    			    		
    		if(data[0]==1)
    		{    			
    	document.getElementById("ECessPercentage_"+i).disabled=true;
		document.getElementById("ECessValue_"+i).disabled=true;
		document.getElementById("SAHCessPercentage_"+i).disabled=true;
		document.getElementById("SAHCessValue_"+i).disabled=true;
		//document.getElementById("ECessPercentage_"+i).value='';
		document.getElementById("ECessValue_"+i).value='';
		//document.getElementById("SAHCessPercentage_"+i).value='';
		document.getElementById("SAHCessValue_"+i).value='';
		document.getElementById("exciseId_"+i).innerHTML=data[1];
		var data2=calculateExciseDuty(i);
    		}	
    		else 
    		{
         document.getElementById("ECessPercentage_"+i).disabled=false;
		document.getElementById("ECessValue_"+i).disabled=false;
		document.getElementById("SAHCessPercentage_"+i).disabled=false;
		document.getElementById("SAHCessValue_"+i).disabled=false;
		document.getElementById("exciseId_"+i).innerHTML=data[1];
		var data2=calculateExciseDuty(i);
    		}
    		}
  		}
		xmlhttp.open("GET","checkdata.php?quotTaxId="+str+"&data="+i,true);
		xmlhttp.send();	
	}	
	
	
	
}






function claculateExcise1(str)
{
	var discounted=document.getElementById("basic_amount").value;
	if (str.length==0)
  		{
  			document.getElementById("exciseId").innerHTML="";
  			return;
  		}
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
  		}
		else
  		{// code for IE6, IE5
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  			if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById("exciseId").innerHTML=xmlhttp.responseText;
				
    		}
  		}
		xmlhttp.open("GET","calculateExcise.php?qid="+str+"&discounted="+discounted,true);
		xmlhttp.send();
}

function calamt(i)
{
var amt=parseFloat(document.getElementById('rate_'+i).value);
var qty=parseFloat(document.getElementById('reciveqty_'+i).value);
var amount=amt*qty;
document.getElementById('valuedata_'+i).value=amount.toFixed(2);	
}
function calculateExciseDuty(i)
{
	
	var basic=document.getElementById("basic_"+i).value;
	
	var ExcisePercentage=document.getElementById("ExcisePercentage_"+i).value;
	
	var exciseVal=basic*(ExcisePercentage/100);
	document.getElementById("exciseValue_"+i).value=exciseVal.toFixed(2);
	var data2=calculateECess(i);
	var data3=calculateSAHCess(i);
	var data4=calculateTaxable(i);
	}


function calculateExciseDuty1()
{
	var basic=document.getElementById("basic_amount").value;
	var ExcisePercentage=document.getElementById("ExcisePercentage").value;
	
	var exciseVal=basic*(ExcisePercentage/100);
	document.getElementById("exciseValue").value=exciseVal.toFixed(2);
}

function calculateECess(i)
{
	
	var exciseValue=document.getElementById("exciseValue_"+i).value;
	var ECessPercentage=document.getElementById("ECessPercentage_"+i).value;
	var total=exciseValue*(ECessPercentage/100);
	document.getElementById("ECessValue_"+i).value=total.toFixed(2);
}
function calculateECess1()
{
	var exciseValue=document.getElementById("exciseValue").value;
	var ECessPercentage=document.getElementById("ECessPercentage").value;
	var total=exciseValue*(ECessPercentage/100);
	document.getElementById("ECessValue").value=total.toFixed(2);
}

function calculateSAHCess(i)
{
	var exciseValue=document.getElementById("exciseValue_"+i).value;
	var SAHCessPercentage=document.getElementById("SAHCessPercentage_"+i).value;
	var total=exciseValue*(SAHCessPercentage/100);
	document.getElementById("SAHCessValue_"+i).value=total.toFixed(2);
}
function calculateSAHCess1()
{
	var exciseValue=document.getElementById("exciseValue").value;
	var SAHCessPercentage=document.getElementById("SAHCessPercentage").value;
	var total=exciseValue*(SAHCessPercentage/100);
	document.getElementById("SAHCessValue").value=total.toFixed(2);
}

function calculateTaxable(i)
{
	var totalDiscountedPrice=document.getElementById("basic_"+i).value;
	var exciseValue=document.getElementById("exciseValue_"+i).value;
	var ECessValue=document.getElementById("ECessValue_"+i).value;
	var SAHCessValue=document.getElementById("SAHCessValue_"+i).value;
	
	if(totalDiscountedPrice==''){totalDiscountedPrice=0;}
	if(exciseValue==''){exciseValue=0;}
	if(ECessValue==''){ECessValue=0;}
	if(SAHCessValue==''){SAHCessValue=0;}
	//var TOTAL=parseFloat(exciseValue)+parseFloat(ECessValue)+parseFloat(SAHCessValue);
	var TOTAL=parseFloat(totalDiscountedPrice)+parseFloat(exciseValue)+parseFloat(ECessValue)+parseFloat(SAHCessValue);
	document.getElementById("taxable_amt_"+i).value=TOTAL.toFixed(2);
}
function calculateTaxable1()
{
	var totalDiscountedPrice=document.getElementById("basic_amount").value;
	var exciseValue=document.getElementById("exciseValue").value;
	var ECessValue=document.getElementById("ECessValue").value;
	var SAHCessValue=document.getElementById("SAHCessValue").value;
	
	if(totalDiscountedPrice==''){totalDiscountedPrice=0;}
	if(exciseValue==''){exciseValue=0;}
	if(ECessValue==''){ECessValue=0;}
	if(SAHCessValue==''){SAHCessValue=0;}
	
	var TOTAL=parseFloat(totalDiscountedPrice)+parseFloat(exciseValue)+parseFloat(ECessValue)+parseFloat(SAHCessValue);
	document.getElementById("taxable_amt").value=TOTAL.toFixed(2);
}




function calc_tax_amount()
{
	var taxable=document.getElementById("taxable_amt").value;
	var taxval=document.getElementById("taxvalue").value;
	var final=taxable*(taxval/100);
	document.getElementById("tot_tax_amount").value=final.toFixed(2);
}
function calculateVatCstValue()
{
	var taxable=document.getElementById("taxable_amt").value;
	var vatcstRate=document.getElementById("VatCstPerc").value;
	var VatCstAmount=taxable*(vatcstRate/100);
	document.getElementById("taxvalue").value=VatCstAmount.toFixed(2);
}
function tax_rate1(str)
{
var taxableAmount=document.getElementById("taxable_amt").value;
if (str.length==0)
  {
  document.getElementById("taxval").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("taxval").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_purchtax_val.php?taxid="+str+"&amt="+taxableAmount,true);
xmlhttp.send();


var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
}
function tax_rate(str,i)
{
var billing_type=document.getElementById("hid_billing_type_"+i).value;

if(billing_type=='NonExcisable')
{
var taxableAmount=document.getElementById("basic_"+i).value;}
else if(billing_type=='Excisable')
{
var taxableAmount=document.getElementById("taxable_amt_"+i).value;}
//alert(taxableAmount);
if (str.length==0)
  {
  document.getElementById("taxval_"+i).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("taxval_"+i).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_tax_val.php?taxid="+str+"&amt="+taxableAmount+"&data="+i,true);
xmlhttp.send();
}


function cal_suroct(str)
{
	var total_tax=document.getElementById("taxvalue").value;
	var final_sur=total_tax*(str/100);
	document.getElementById("sur_oct_amt").value=final_sur.toFixed(2);
}

function cal_grandtotal(i)
{
	var type_of_bill=document.getElementById("hid_billing_type_"+i).value;
	var basic=document.getElementById("basic_"+i).value;
	//alert(basic);
	var Totaltaxable=document.getElementById("taxable_amt_"+i).value;
	var vatcstAmt=document.getElementById("taxvalue_"+i).value;
	

	//var roundOffVal=document.getElementById("roundOff_").value;
	
	//if(roundOffVal==''){roundOffVal='-.0';}
	
	//var test=roundOffVal.split(".");
	
	//alert(test[0]);
	
	if(basic==''){basic=0;}
	if(Totaltaxable==''){Totaltaxable=0;}
	if(vatcstAmt==''){vatcstAmt=0;}
	
	
	
	
	if(document.getElementById("hid_billing_type_"+i).value=='NonExcisable')
	{
	
		var grand_tot1=parseFloat(basic)+parseFloat(vatcstAmt);
		var grand_tot=grand_tot1.toFixed(2);
		
	}	
	
	
else if(document.getElementById("hid_billing_type_"+i).value=='IncludeTax'){

var grand_tot1= parseFloat(basic) ;
var grand_tot=grand_tot1.toFixed(2);
}
	else{
	
		var grand_tot1=parseFloat(Totaltaxable)+parseFloat(vatcstAmt);
			var grand_tot=grand_tot1.toFixed(2);
		
		 }
	  //alert(	document.getElementById("TotalSpecial_"+i).value);
	 	//alert(grand_tot);
	 	document.getElementById("TotalSpecial_"+i).value=grand_tot ;	
		//alert(	document.getElementById("TotalSpecial_"+i).value);
	
}


function cal_grandtotal1()
{
	var basic=document.getElementById("basic_amount").value;
	var Totaltaxable=document.getElementById("taxable_amt").value;
	var vatcstAmt=document.getElementById("taxvalue").value;
	var suramt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var packagingCharges=document.getElementById("packagingCharges").value;
	var additionalCharges=document.getElementById("additionalCharges").value;
	//var entry_tax=document.getElementById("entry_tax").value;
	if(basic==''){basic=0;}
	if(Totaltaxable==''){Totaltaxable=0;}
	if(vatcstAmt==''){vatcstAmt=0;}
	if(suramt==''){suramt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(packagingCharges==''){packagingCharges=0;}
	if(additionalCharges==''){additionalCharges=0;}
	//if(entry_tax==''){entry_tax=0;}
	var grand_tot=parseFloat(Totaltaxable)+parseFloat(vatcstAmt)+parseFloat(suramt)+parseFloat(TotalCharge)+parseFloat(packagingCharges)+parseFloat(additionalCharges); 
	
	
	document.getElementById("grand_total").value=grand_tot.toFixed(2);
}

function calculateTotalPrice(i)
{
 if(document.getElementById("Rate_"+i).value=='')
 {
 	alert("Must Enter Rate");
 	document.getElementById("Rate_"+i).focus();
 }	
 else
 {
	var againstbill = document.getElementById("bill_id").checked;
	var againstreceived = document.getElementById("received_id").checked;
	
	if(againstbill==true){
	var Quantity=parseFloat(document.getElementById('qty_as_per_bill_'+i).value); }
	else if(againstreceived==true){
	var Quantity=parseFloat(document.getElementById('Quantity_'+i).value); }
	
	//Quantity = document.getElementById("Quantity_"+i).value;
	Rate= document.getElementById("Rate_"+i).value;
	var Total=Quantity*Rate;
	document.getElementById("totalValue_"+i).value=Total.toFixed(2);
}
}

function getreqitemdataNew(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	 var data=xmlhttp.responseText.split("__");	
	//document.getElementById("storedata").innerHTML=data[1];
	//document.getElementById("transporters").innerHTML=data[2];
	document.getElementById("vendor").innerHTML=data[3];
    }
  }
  xmlhttp.open("GET","getsitenamedata.php?site="+str,true);
xmlhttp.send();
}


function validateFrm()
{
	if(document.getElementById("site").value=='000')
	{
	    alert("Must Select Site");
		document.getElementById("site").focus();
		return false;
	}
	if(document.getElementById("voucher_date").value=='')
	{
	    alert("Must Enter Voucher Date");
		document.getElementById("voucher_date").focus();
		return false;
	}
	if(document.getElementById("doc_type").value=='Challan')
	{
		if(document.getElementById("bill_no").value=='')
		{
			alert("Must Enter Bill No");
			document.getElementById("bill_no").focus();
			return false;
		}
		if(document.getElementById("bill_date").value =='')
		{
			alert("Enter Bill Date");
			document.getElementById("bill_date").focus();
			return false;
		}
	}
	else
	{
		if(document.getElementById("bill_no").value=='')
		{
			alert("Must Enter Bill No");
			document.getElementById("bill_no").focus();
			return false;
		}
		if(document.getElementById("bill_date").value =='')
		{
			alert("Enter Bill Date");
			document.getElementById("bill_date").focus();
			return false;
		}
		
	}
}
function grnDisabled1(str)
 {
	var mrn_no=document.getElementById("mrn_no").value;
	var po_type=document.getElementById("poType").value;
	if (str==''){
  		document.getElementById("target_id").innerHTML="";
 	 	return;
  	}
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}else{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function(){
   	if(xmlhttp.readyState==4 && xmlhttp.status==200){
		var data=xmlhttp.responseText;
		//alert(data);
    	document.getElementById("target_id").innerHTML=xmlhttp.responseText;
   }
   }
   xmlhttp.open("GET","ajax_mrn_items.php?mrn="+mrn_no+"&type="+str+"&GrnType="+po_type,true);
xmlhttp.send();
 }
 
 
 
 function calculateAgainst(str)
 {
	var totAmount=0;
	var count =document.getElementById("count").value;
	if(str=='bill')
	{
		for(var h=0; h<count;h++)
		{
				if(billQty==''){billQty=0;}
				if(itemRate==''){itemRate=0;}
				var billQty=document.getElementById("qty_as_per_bill_"+h).value;
				var itemRate=document.getElementById("itemrate_"+h).value;
				var amtVal=parseFloat(billQty)*parseFloat(itemRate);
				document.getElementById("itemamount_"+h).value = amtVal;
				var discount = document.getElementById("Discount1_"+h).value;
				if(discount==''){discount=0;}
				var discount_type = document.getElementById("PerAmo_"+h).value;
				if(discount_type=='Amount')
				{
				var basicAmt = parseFloat(amtVal)-parseFloat(discount);
				document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
				var totAmount =  totAmount+parseFloat(basicAmt);
				}
				else 
				{
				var midRes= (discount*amtVal)/100;
				var basicAmt = parseFloat(amtVal)-parseFloat(midRes);
				document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
				var totAmount =  totAmount+parseFloat(basicAmt);
				}
			}
			document.getElementById("total_item_amount").value = totAmount.toFixed(2);
			if(totAmount==''){totAmount=0;}
			var conv_amt=document.getElementById("tot_conv_amt").value;
			if(conv_amt==''){conv_amt=0;}
			var cdis_amt=document.getElementById("pkg_charges").value;
			if(cdis_amt==''){cdis_amt=0;}
			var othercharges=document.getElementById("custom_duty_new").value;
			if(othercharges==''){othercharges=0;}
			var othercharges1=document.getElementById("cvd_total_new").value;
			if(othercharges1==''){othercharges1=0;}
			var othercharges2=document.getElementById("custom_ecess_new").value;
			if(othercharges2==''){othercharges2=0;}
			var othercharges3=document.getElementById("custom_sec_ecess_new").value;
			if(othercharges3==''){othercharges3=0;}
			var othercharges4=document.getElementById("add_charges_new").value;
			if(othercharges4==''){othercharges4=0;}
			var othercharges5=document.getElementById("TotalCharge2").value;
			if(othercharges5==''){othercharges5=0;}
			var othercharges6=document.getElementById("insurance").value;
			if(othercharges6==''){othercharges6=0;}
			var othercharges7=document.getElementById("clearing").value;
			if(othercharges7==''){othercharges7=0;}
			var othercharges8=document.getElementById("misCharge").value;
			if(othercharges8==''){othercharges8=0;}
			var othercharges9=document.getElementById("loading2").value;
			if(othercharges9==''){othercharges9=0;}
			var GrandTotalAmt = parseFloat(totAmount)+parseFloat(conv_amt)+parseFloat(cdis_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges4)+parseFloat(othercharges5)+parseFloat(othercharges6)+parseFloat(othercharges7)+parseFloat(othercharges8)+parseFloat(othercharges9);
			if(GrandTotalAmt==''){GrandTotalAmt=0;}
			document.getElementById("GrandTotal").value = GrandTotalAmt.toFixed(2);
			document.getElementById("orig_grand_tot").value = GrandTotalAmt.toFixed(2);
		}
			else
			{
				for(var h=0; h<count;h++)
				{
					var recQty=document.getElementById("reciveqty_"+h).value;
					var itemRate=document.getElementById("itemrate_"+h).value;
					var amtVal=parseFloat(recQty)*parseFloat(itemRate);
					document.getElementById("itemamount_"+h).value = amtVal;
					var discount = document.getElementById("Discount1_"+h).value;
					if(discount==''){discount=0;}
					var discount_type = document.getElementById("PerAmo_"+h).value;
					if(discount_type=='Amount')
					{
					var basicAmt = parseFloat(amtVal)-parseFloat(discount);
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totAmount =  totAmount+parseFloat(basicAmt);
					}
					else 
					{
					var midRes= (discount*amtVal)/100;
					var basicAmt = parseFloat(amtVal)-parseFloat(midRes);
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totAmount =  totAmount+parseFloat(basicAmt);
					}
				}
			
				document.getElementById("total_item_amount").value = totAmount.toFixed(2);
			if(totAmount==''){totAmount=0;}
			var conv_amt=document.getElementById("tot_conv_amt").value;
			if(conv_amt==''){conv_amt=0;}
			var cdis_amt=document.getElementById("pkg_charges").value;
			if(cdis_amt==''){cdis_amt=0;}
			var othercharges=document.getElementById("custom_duty_new").value;
			if(othercharges==''){othercharges=0;}
			var othercharges1=document.getElementById("cvd_total_new").value;
			if(othercharges1==''){othercharges1=0;}
			var othercharges2=document.getElementById("custom_ecess_new").value;
			if(othercharges2==''){othercharges2=0;}
			var othercharges3=document.getElementById("custom_sec_ecess_new").value;
			if(othercharges3==''){othercharges3=0;}
			var othercharges4=document.getElementById("add_charges_new").value;
			if(othercharges4==''){othercharges4=0;}
			var othercharges5=document.getElementById("TotalCharge2").value;
			if(othercharges5==''){othercharges5=0;}
			var othercharges6=document.getElementById("insurance").value;
			if(othercharges6==''){othercharges6=0;}
			var othercharges7=document.getElementById("clearing").value;
			if(othercharges7==''){othercharges7=0;}
			var othercharges8=document.getElementById("misCharge").value;
			if(othercharges8==''){othercharges8=0;}
			var othercharges9=document.getElementById("loading2").value;
			if(othercharges9==''){othercharges9=0;}
			var GrandTotalAmt = parseFloat(totAmount)+parseFloat(conv_amt)+parseFloat(cdis_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges4)+parseFloat(othercharges5)+parseFloat(othercharges6)+parseFloat(othercharges7)+parseFloat(othercharges8)+parseFloat(othercharges9);
			if(GrandTotalAmt==''){GrandTotalAmt=0;}
			document.getElementById("GrandTotal").value = GrandTotalAmt.toFixed(2);
			document.getElementById("orig_grand_tot").value= GrandTotalAmt.toFixed(2);
		}
 }
 
 function calculateAgainst3(str)
 {
	var totAmount=0;
	var count =document.getElementById("count").value;
	if(str=='bill')
	{
		for(var h=0; h<count;h++)
		{
				if(billQty==''){billQty=0;}
				if(itemRate==''){itemRate=0;}
				var billQty=document.getElementById("qty_as_per_bill_"+h).value;
				var itemRate=document.getElementById("itemrate_"+h).value;
				var amtVal=parseFloat(billQty)*parseFloat(itemRate);
				document.getElementById("itemamount_"+h).value = amtVal;
				var discount = document.getElementById("Discount1_"+h).value;
				if(discount==''){discount=0;}
				var discount_type = document.getElementById("PerAmo_"+h).value;
				if(discount_type=='Amount')
				{
				var basicAmt = parseFloat(amtVal)-parseFloat(discount);
				document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
				var totAmount =  totAmount+parseFloat(basicAmt);
				}
				else 
				{
				var midRes= (discount*amtVal)/100;
				var basicAmt = parseFloat(amtVal)-parseFloat(midRes);
				document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
				var totAmount =  totAmount+parseFloat(basicAmt);
				}
			}
				document.getElementById("total_item_amount").value = totAmount.toFixed(2);
				if(totAmount==''){totAmount=0;}
				
				var cdis_amt=document.getElementById("pkg_charges").value;
				if(cdis_amt==''){cdis_amt=0;}
				var othercharges=document.getElementById("tot_excise_amt").value;
				if(othercharges==''){othercharges=0;}
				var othercharges1=document.getElementById("tot_ecess_amt").value;
				if(othercharges1==''){othercharges1=0;}
				var othercharges2=document.getElementById("tot_sahecess_amt").value;
				if(othercharges2==''){othercharges2=0;}
				var othercharges3=document.getElementById("tot_excise_duty_amt").value;
				if(othercharges3==''){othercharges3=0;}
				var othercharges4=document.getElementById("tot_taxable_amt").value;
				if(othercharges4==''){othercharges4=0;}
				var othercharges5=document.getElementById("taxvalue2").value;
				if(othercharges5==''){othercharges5=0;}
				var othercharges6=document.getElementById("sur_oct_amt").value;
				if(othercharges6==''){othercharges6=0;}
				var othercharges7=document.getElementById("TotalCharge").value;
				if(othercharges7==''){othercharges7=0;}
				var othercharges8=document.getElementById("loading").value;
				if(othercharges8==''){othercharges8=0;}
				var othercharges9=document.getElementById("additionalCharges").value;
				if(othercharges9==''){othercharges9=0;}
				var GrandTotalAmt = parseFloat(totAmount)+parseFloat(cdis_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges4)+parseFloat(othercharges5)+parseFloat(othercharges6)+parseFloat(othercharges7)+parseFloat(othercharges8)+parseFloat(othercharges9);
				if(GrandTotalAmt==''){GrandTotalAmt=0;}
				document.getElementById("GrandTotal").value = GrandTotalAmt.toFixed(2);
				document.getElementById("orig_grand_tot").value = GrandTotalAmt.toFixed(2);
		}
			else
			{
				for(var h=0; h<count;h++)
				{
					var recQty=document.getElementById("reciveqty_"+h).value;
					var itemRate=document.getElementById("itemrate_"+h).value;
					var amtVal=parseFloat(recQty)*parseFloat(itemRate);
					document.getElementById("itemamount_"+h).value = amtVal;
					var discount = document.getElementById("Discount1_"+h).value;
					if(discount==''){discount=0;}
					var discount_type = document.getElementById("PerAmo_"+h).value;
					if(discount_type=='Amount')
					{
					var basicAmt = parseFloat(amtVal)-parseFloat(discount);
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totAmount =  totAmount+parseFloat(basicAmt);
					}
					else 
					{
					var midRes= (discount*amtVal)/100;
					var basicAmt = parseFloat(amtVal)-parseFloat(midRes);
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totAmount =  totAmount+parseFloat(basicAmt);
					}
				}
			
				document.getElementById("total_item_amount").value = totAmount.toFixed(2);
				if(totAmount==''){totAmount=0;}
				
				var cdis_amt=document.getElementById("pkg_charges").value;
				if(cdis_amt==''){cdis_amt=0;}
				var othercharges=document.getElementById("tot_excise_amt").value;
				if(othercharges==''){othercharges=0;}
				var othercharges1=document.getElementById("tot_ecess_amt").value;
				if(othercharges1==''){othercharges1=0;}
				var othercharges2=document.getElementById("tot_sahecess_amt").value;
				if(othercharges2==''){othercharges2=0;}
				var othercharges3=document.getElementById("tot_excise_duty_amt").value;
				if(othercharges3==''){othercharges3=0;}
				var othercharges4=document.getElementById("tot_taxable_amt").value;
				if(othercharges4==''){othercharges4=0;}
				var othercharges5=document.getElementById("taxvalue2").value;
				if(othercharges5==''){othercharges5=0;}
				var othercharges6=document.getElementById("sur_oct_amt").value;
				if(othercharges6==''){othercharges6=0;}
				var othercharges7=document.getElementById("TotalCharge").value;
				if(othercharges7==''){othercharges7=0;}
				var othercharges8=document.getElementById("loading").value;
				if(othercharges8==''){othercharges8=0;}
				var othercharges9=document.getElementById("additionalCharges").value;
				if(othercharges9==''){othercharges9=0;}
				var GrandTotalAmt = parseFloat(totAmount)+parseFloat(cdis_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges4)+parseFloat(othercharges5)+parseFloat(othercharges6)+parseFloat(othercharges7)+parseFloat(othercharges8)+parseFloat(othercharges9);
				if(GrandTotalAmt==''){GrandTotalAmt=0;}
				document.getElementById("GrandTotal").value = GrandTotalAmt.toFixed(2);
				document.getElementById("orig_grand_tot").value = GrandTotalAmt.toFixed(2);
		}
 }
 
 function calculateAgainst2(str)
 {
 	var totAmount2 = 0;
	var count =document.getElementById("count").value;
	if(str=='bill')
	{
		var totalAmt =0;
		for(var h=0; h<count;h++)
		{
				if(billQty==''){billQty=0;}
				if(itemRate==''){itemRate=0;}
				var billQty=document.getElementById("qty_as_per_bill_"+h).value;
				var itemRate=document.getElementById("itemrate_"+h).value;
				var amtVal=parseFloat(billQty)*parseFloat(itemRate);
				document.getElementById("itemamount_"+h).value = amtVal;
				var discount = document.getElementById("Discount1_"+h).value;
				if(discount==''){discount=0;}
				var discount_type = document.getElementById("PerAmo_"+h).value;
				var totAmount = 0;
				if(discount_type=='Amount')
				{
				var basicAmt = parseFloat(amtVal)-parseFloat(discount);
				document.getElementById("NetRate1_"+h).value = basicAmt.toFixed(2);
				var convRate = document.getElementById("conv_rate_"+h).value;
					if(convRate!='')
					{
					var convAmt = parseFloat(basicAmt)*parseFloat(convRate);
					document.getElementById("basic_"+h).value = convAmt.toFixed(2);
					var totalAmt =  totalAmt+parseFloat(convAmt);
					}
					else
					{
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totalAmt =  totalAmt+parseFloat(basicAmt);
					}
				}
				else 
				{
				var midRes= (discount*amtVal)/100;
				var basicAmt = parseFloat(amtVal)-parseFloat(midRes);
				document.getElementById("NetRate1_"+h).value = basicAmt;
					var convRate = document.getElementById("conv_rate_"+h).value;
					if(convRate!='')
					{
					var convAmt = parseFloat(basicAmt)*parseFloat(convRate);
					document.getElementById("basic_"+h).value = convAmt.toFixed(2);
					var totalAmt =  totalAmt+parseFloat(convAmt);
					}
					else
					{
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totalAmt =  totalAmt+parseFloat(basicAmt);
					}
				}
			}
			document.getElementById("total_item_amount").value = totalAmt.toFixed(2);
		if(totalAmt==''){totalAmt=0;}
		}
			else
			{
				var totalAmt =0;
				for(var h=0; h<count;h++)
				{
					var recQty=document.getElementById("reciveqty_"+h).value;
					var itemRate=document.getElementById("itemrate_"+h).value;
					var amtVal=parseFloat(recQty)*parseFloat(itemRate);
					document.getElementById("itemamount_"+h).value = amtVal;
					var discount = document.getElementById("Discount1_"+h).value;
					if(discount==''){discount=0;}
					var discount_type = document.getElementById("PerAmo_"+h).value;
					if(discount_type=='Amount')
					{
					var basicAmt = parseFloat(amtVal)-parseFloat(discount);
					document.getElementById("NetRate1_"+h).value = basicAmt.toFixed(2);
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totalAmt =  totalAmt+parseFloat(basicAmt);
					}
					else 
					{
					var midRes= (discount*amtVal)/100;
					var basicAmt = parseFloat(amtVal)-parseFloat(midRes);
					document.getElementById("NetRate1_"+h).value = basicAmt.toFixed(2);
					document.getElementById("basic_"+h).value = basicAmt.toFixed(2);
					var totalAmt =  totalAmt+parseFloat(basicAmt);
					}
				}
			
		document.getElementById("total_item_amount").value = totalAmt.toFixed(2);
		if(totalAmt==''){totalAmt=0;}
		
		var biling_type = document.getElementById("hid_billing_type_"+h).value;
		var excisePer = document.getElementById("exciseDuty_"+h).value;
		
		
		
		if(biling_type=='1')
		{
		var totDutyAmt= 0;
		var totAmountCvd = 0;
		var ecestot=0;
		var ecesectot=0;
		var adddutytot=0;
		var basicAmount= document.getElementById("basic_"+h).value;
		
		var dutyPer = document.getElementById("exciseDuty_"+h).value;
		var dutyamt = (parseFloat(dutyPer)*parseFloat(basicAmount))/100;
		document.getElementById("dutyamount_"+h).value = dutyamt.toFixed(2);
		if(dutyamt==''){dutyamt=0;}
		var totDutyAmt = totDutyAmt+parseFloat(dutyamt);
		
		var grand_tot1= parseFloat(basicAmount)+parseFloat(dutyamt); 
		var cvdPer = document.getElementById("cvd_percentage").value;
		var cvd = grand_tot1*(cvdPer/100);
		var grand_tot=cvd.toFixed(2);
	 	document.getElementById("TotalSpecial_"+h).value=grand_tot;
		if(grand_tot==''){grand_tot=0;}
		var totAmountCvd = totAmountCvd+parseFloat(grand_tot);
		
		var c = document.getElementById("TotalSpecial_"+h).value; 
		var tot1= parseFloat(dutyamt)+parseFloat(c);
		var ecessPer = document.getElementById("ecess_percentage").value;
		var tot = tot1*(ecessPer/100);
		var final_eces=tot.toFixed(2);
		document.getElementById("customecess_"+h).value=final_eces;
		if(final_eces==''){final_eces=0;}
		var ecestot = ecestot+parseFloat(final_eces);
		
		var tot1= parseFloat(dutyamt)+parseFloat(c);
		var secEcessPer = document.getElementById("secess_percentage").value; 
		var tot = tot1*(secEcessPer/100);
		var final_eces1=tot.toFixed(2);
		document.getElementById("customsececess_"+h).value=final_eces1;
		if(final_eces1==''){final_eces1=0;}
		var ecesectot = ecesectot+parseFloat(final_eces1);
		
		var d = document.getElementById("customecess_"+h).value; 
		var e = document.getElementById("customsececess_"+h).value; 
		var tot12= parseFloat(basicAmount)+parseFloat(dutyamt)+parseFloat(c)+parseFloat(d)+parseFloat(e);
		var addPer = document.getElementById("add_percentage").value; 
		var tot1 = tot12*(addPer/100);
		var final_eces2=tot1.toFixed(2);
		document.getElementById("adduty_"+h).value=final_eces2;
		if(final_eces2==''){final_eces2=0;}
		var adddutytot = adddutytot+parseFloat(final_eces2);	
		}
		else
		{
			document.getElementById("exciseDuty_"+i).disabled=true;
			document.getElementById("dutyamount_"+i).disabled=true;
			document.getElementById("TotalSpecial_"+i).disabled=true;
			document.getElementById("customecess_"+i).disabled=true;
			document.getElementById("customsececess_"+i).disabled=true;
			document.getElementById("adduty_"+i).disabled=true;
			document.getElementById("exciseDuty_"+i).value='';
			document.getElementById("dutyamount_"+i).value='';
			document.getElementById("TotalSpecial_"+i).value='';
			document.getElementById("customecess_"+i).value='';
			document.getElementById("customsececess_"+i).value='';
			document.getElementById("adduty_"+i).value='';
		}
	}
		document.getElementById("total_item_amount").value = totalAmt.toFixed(2);
		if(totalAmt==''){totalAmt=0;}
		
		document.getElementById("custom_duty").value = totDutyAmt.toFixed(2);
		if(totDutyAmt==''){totDutyAmt=0;}

		document.getElementById("cvd_total").value = totAmountCvd.toFixed(2);
		if(totAmountCvd==''){totAmountCvd=0;}
				
		document.getElementById("custom_ecess").value = ecestot.toFixed(2);
		if(ecestot==''){ecestot=0;}
		 
		document.getElementById("custom_sec_ecess").value = ecesectot.toFixed(2);
		if(ecesectot==''){ecesectot=0;}
		
		document.getElementById("additionalCharges").value = adddutytot.toFixed(2);
		if(adddutytot==''){adddutytot=0;}
		
		var cdis_amt=document.getElementById("pkg_charges").value;
		if(cdis_amt==''){cdis_amt=0;}
		
		var othercharges=document.getElementById("TotalCharge2").value;
		if(othercharges==''){othercharges=0;}
			
		var othercharges1=document.getElementById("loading2").value;
		if(othercharges1==''){othercharges1=0;}
			
		var othercharges2=document.getElementById("misCharge").value;
		if(othercharges2==''){othercharges2=0;}
			
		var othercharges3=document.getElementById("clearing").value;
		if(othercharges3==''){othercharges3=0;}
		
		var othercharges4=document.getElementById("misCharge").value;
		if(othercharges4==''){othercharges4=0;}
			
		var othercharges5=document.getElementById("insurance").value;
		if(othercharges5==''){othercharges5=0;}
	
		var GrandTotalAmt = parseFloat(totalAmt)+parseFloat(totDutyAmt)+parseFloat(totAmountCvd)+parseFloat(ecestot)+parseFloat(ecesectot)+parseFloat(adddutytot)+parseFloat(cdis_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges4)+parseFloat(othercharges5);
		if(GrandTotalAmt==''){GrandTotalAmt=0;}
		document.getElementById("GrandTotal").value = GrandTotalAmt.toFixed(2);
		document.getElementById("orig_grand_tot").value = GrandTotalAmt.toFixed(2);
		 }

 function calcConvAmt(val,i)
 {
	 var itemAmt = document.getElementById("NetRate1_"+i).value;
	 if(itemAmt==''){itemAmt=0;}
	 var finalRes = parseFloat(itemAmt)*val;
	 document.getElementById("basic_"+i).value = finalRes.toFixed(2);
	 
	 var count =document.getElementById("count").value;
	 var totAmount = 0;
		 for(var h=0; h<count;h++)
		{
		var bAmt = document.getElementById("basic_"+h).value;
		if(bAmt==''){bAmt=0;}
		var totAmount = totAmount+parseFloat(bAmt);
		}
document.getElementById("total_item_amount").value = totAmount.toFixed(2)



}

function checkExcisable1(str,i)
{	
	if(str=='NonExcisable')
	{
	document.getElementById("exciseDuty_"+i).disabled=true;
	document.getElementById("ExcisePercentage_"+i).disabled=true;
	document.getElementById("exciseValue_"+i).disabled=true;
	document.getElementById("ECessPercentage_"+i).disabled=true;
	document.getElementById("ECessValue_"+i).disabled=true;
	document.getElementById("SAHCessPercentage_"+i).disabled=true;
	document.getElementById("SAHCessValue_"+i).disabled=true;
	document.getElementById("taxableamount_"+i).disabled=true;
	}
	else if(str=='Excisable' || str==0)
	{
	document.getElementById("exciseDuty_"+i).disabled=false;
	document.getElementById("ExcisePercentage_"+i).disabled=false;
	document.getElementById("exciseValue_"+i).disabled=false;
	document.getElementById("ECessPercentage_"+i).disabled=false;
	document.getElementById("ECessValue_"+i).disabled=false;		
	document.getElementById("SAHCessPercentage_"+i).disabled=false;	
	document.getElementById("SAHCessValue_"+i).disabled=false;
	document.getElementById("taxableamount_"+i).disabled=false;
	}
	else
	{
	document.getElementById("exciseDuty_"+i).disabled=true;
	document.getElementById("ExcisePercentage_"+i).disabled=true;
	document.getElementById("exciseValue_"+i).disabled=true;
	document.getElementById("ECessPercentage_"+i).disabled=true;
	document.getElementById("ECessValue_"+i).disabled=true;
	document.getElementById("SAHCessPercentage_"+i).disabled=true;
	document.getElementById("SAHCessValue_"+i).disabled=true;
	document.getElementById("taxable_amt_"+i).disabled=true;
	//document.getElementById("taxname_"+i).disabled=true;
	//document.getElementById("taxvalue_"+i).disabled=true;
	//document.getElementById("sur_oct_perc_"+i).disabled=true;
	//document.getElementById("sur_oct_amt_"+i).disabled=true;
	//document.getElementById("TotalCharge_"+i).disabled=true;
	//document.getElementById("packagingCharges_"+i).disabled=true;
	//document.getElementById("additionalCharges_"+i).disabled=true;
	//document.getElementById("roundOff_"+i).disabled=true;
	document.getElementById("exciseDuty_"+i).value='';
	document.getElementById("exciseValue_"+i).value='';
	document.getElementById("ECessPercentage_"+i).value='';
	document.getElementById("ECessValue_"+i).value='';
	document.getElementById("SAHCessPercentage_"+i).value='';
	document.getElementById("SAHCessValue_"+i).value='';
	document.getElementById("taxable_amt_"+i).value='';
	document.getElementById("taxname_"+i).value='';
	document.getElementById("taxvalue_"+i).value='';
	document.getElementById("sur_oct_perc_"+i).value='';
	document.getElementById("sur_oct_amt_"+i).value='';
	document.getElementById("TotalCharge_"+i).value='';
	document.getElementById("packagingCharges_"+i).value='';
	document.getElementById("additionalCharges_"+i).value='';
	document.getElementById("roundOff_"+i).value='';
	}
	document.getElementById("hid_billing_type_"+i).value=str;
}


function checkexiseflag1(i)
{
	if(document.getElementById("billing_type_"+i).value=='')
	{
	alert("Select Tax Types");
	document.getElementById("billing_type_"+i).focus();
	}	
}

function calculateECess1(i)
{
	var exciseValue=document.getElementById("exciseValue_"+i).value;
	var ECessPercentage=document.getElementById("ECessPercentage_"+i).value;
	var total=exciseValue*(ECessPercentage/100);
	document.getElementById("ECessValue_"+i).value=total.toFixed(2);
}

function calculateSAHCess1(i)
{
	var exciseValue=document.getElementById("exciseValue_"+i).value;
	var SAHCessPercentage=document.getElementById("SAHCessPercentage_"+i).value;
	var total=exciseValue*(SAHCessPercentage/100);
	document.getElementById("SAHCessValue_"+i).value=total.toFixed(2);
}

function value_after_discount1(i)
{
	
	var basic = parseFloat(document.getElementById('basic_'+i).value);
	//alert(item_total_rate);
	if(document.getElementById('taxableamount_'+i).value=='')
	{
	var taxableamt = 0;	
	}
	else
	{
	var taxableamt = parseFloat(document.getElementById('taxableamount_'+i).value);
	}
	//alert(taxableamt);
 	var val_after_disc = parseFloat(basic+taxableamt);
 	//alert(val_after_disc);
	document.getElementById('total_'+i).value=val_after_disc.toFixed(2);	
	
	
}


function caltaxamout1(i)
				{
					
				var excise=parseFloat(document.getElementById("exciseDuty_"+i).value);
				
				if(excise!=0)
				{
				var basic_amount=document.getElementById("exciseValue_"+i).value;
				var ecessamt=document.getElementById("ECessValue_"+i).value;
				var sahamt=document.getElementById("SAHCessValue_"+i).value;
				var totaltax=parseFloat(basic_amount)+parseFloat(ecessamt)+parseFloat(sahamt);	
				document.getElementById('taxableamount_'+i).value=totaltax.toFixed(2);	
				}
				else
				{
				document.getElementById('taxableamount_'+i).value=0;		
				}	
					
				}

function claculateExcise1(i,str)
{
	var discounted1=document.getElementById("basic_"+i).value;
	if (str.length==0)
  		{
  			document.getElementById("exciseId_"+i).innerHTML="";
  			return;
  		}
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
  		}
		else
  		{// code for IE6, IE5
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  			if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById("exciseId_"+i).innerHTML=xmlhttp.responseText;
    		}
  		}
		xmlhttp.open("GET","calculateExcise_exo.php?mrnTaxId="+str+"&data="+i+"&discAmt="+discounted1,true);
		xmlhttp.send();

}

function checkExcisable11(str,i)
{
if(str=='2')
	{
	document.getElementById("exciseDuty_"+i).disabled=true;
	document.getElementById("dutyamount_"+i).disabled=true;
	document.getElementById("TotalSpecial_"+i).disabled=true;
	document.getElementById("customecess_"+i).disabled=true;
	document.getElementById("customsececess_"+i).disabled=true;
	document.getElementById("adduty_"+i).disabled=true;
	
	document.getElementById("exciseDuty_"+i).value='';
	document.getElementById("dutyamount_"+i).value='';
	document.getElementById("TotalSpecial_"+i).value='';
	document.getElementById("customecess_"+i).value='';
	document.getElementById("customsececess_"+i).value='';
	document.getElementById("adduty_"+i).value='';
	
	document.getElementById("custom_duty").disabled=true;
	document.getElementById("cvd_total").disabled=true;
	document.getElementById("custom_ecess").disabled=true;
	document.getElementById("custom_sec_ecess").disabled=true;
	document.getElementById("additionalCharges").disabled=true;
	
	
	document.getElementById("total_item_amount").value='';
	document.getElementById("pkg_perc").value='';
	document.getElementById("pkg_charges").value='';
	document.getElementById("cvd_total").value='';
	document.getElementById("custom_duty").value='';
	document.getElementById("custom_ecess").value='';
	document.getElementById("custom_sec_ecess").value='';
	document.getElementById("additionalCharges").value='';
	}
	else
	{
	document.getElementById("exciseDuty_"+i).disabled=false;
	document.getElementById("dutyamount_"+i).disabled=false;
	document.getElementById("TotalSpecial_"+i).disabled=false;
	document.getElementById("customecess_"+i).disabled=false;
	document.getElementById("customsececess_"+i).disabled=false;
	document.getElementById("adduty_"+i).disabled=false;
	document.getElementById("custom_duty").disabled=false;
	document.getElementById("cvd_total").disabled=false;
	document.getElementById("custom_ecess").disabled=false;
	document.getElementById("custom_sec_ecess").disabled=false;
	document.getElementById("additionalCharges").disabled=false;	
	}
}

function claculateExcise33(val,i)
 {
 var basicAmt = document.getElementById("basic_"+i).value;
 if(basicAmt==''){basicAmt=0;}
 var finalRes = parseFloat(basicAmt)*(val/100);
 document.getElementById("dutyamount_"+i).value = finalRes.toFixed(2);
 
  var Totaltaxable=document.getElementById("dutyamount_"+i).value; 
  if(Totaltaxable==''){Totaltaxable=0;}
  var grand_tot1= parseFloat(basicAmt)+parseFloat(Totaltaxable); 
  var cvdPer = document.getElementById("cvd_percentage").value;
	var cvd = grand_tot1*(cvdPer/100);
	var grand_tot=cvd.toFixed(2);
	 document.getElementById("TotalSpecial_"+i).value=grand_tot;
	 
	var c = document.getElementById("TotalSpecial_"+i).value; 
	var tot1= parseFloat(Totaltaxable)+parseFloat(c);
	var ecessPer = document.getElementById("ecess_percentage").value;
	var tot = tot1*(ecessPer/100);
	var final_eces=tot.toFixed(2);
	document.getElementById("customecess_"+i).value=final_eces;	
	
	var tot1= parseFloat(Totaltaxable)+parseFloat(c);
	var secEcessPer = document.getElementById("secess_percentage").value; 
	var tot = tot1*(secEcessPer/100);
	var final_eces1=tot.toFixed(2);
	 document.getElementById("customsececess_"+i).value=final_eces1;
	 
	var d = document.getElementById("customecess_"+i).value; 
	var e = document.getElementById("customsececess_"+i).value; 
	var tot12= parseFloat(basicAmt)+parseFloat(Totaltaxable)+parseFloat(c)+parseFloat(d)+parseFloat(e);
	var addPer = document.getElementById("add_percentage").value; 
	var tot1 = tot12*(addPer/100);
	var final_eces2=tot1.toFixed(2);
	 document.getElementById("adduty_"+i).value=final_eces2 ;
		 
 
  var count =document.getElementById("count").value;
	 var totAmount = 0;
	  var totAmountCvd = 0;
	  var ecestot=0;
	  var ecesectot=0;
	   var adddutytot=0;
		 for(var h=0; h<count;h++)
		{
		var dAmt = document.getElementById("dutyamount_"+h).value;
		if(dAmt==''){dAmt=0;}
		var totAmount = totAmount+parseFloat(dAmt);
		
		var cvd=document.getElementById("TotalSpecial_"+h).value;
		if(cvd==''){cvd=0;}
		totAmountCvd=parseFloat(totAmountCvd)+parseFloat(cvd);
		
		var eces=document.getElementById("customecess_"+h).value;
		if(eces==''){eces=0;}
		ecestot=parseFloat(ecestot)+parseFloat(eces);
		
		var ecess=document.getElementById("customsececess_"+h).value;
			if(ecess==''){ecess=0;}
			ecesectot=parseFloat(ecesectot)+parseFloat(ecess);
			
			var addduty=document.getElementById("adduty_"+i).value;
			if(addduty==''){addduty=0;}
			adddutytot=parseFloat(adddutytot)+parseFloat(addduty);
		}
document.getElementById("custom_duty").value = totAmount.toFixed(2);
if(totAmount==''){totAmount=0;}

document.getElementById("cvd_total").value = totAmountCvd.toFixed(2);
if(totAmountCvd==''){totAmountCvd=0;}

document.getElementById("custom_ecess").value = ecestot.toFixed(2);
if(ecestot==''){ecestot=0;}
 
document.getElementById("custom_sec_ecess").value = ecesectot.toFixed(2);
if(ecesectot==''){ecesectot=0;}

document.getElementById("additionalCharges").value = adddutytot.toFixed(2);
if(adddutytot==''){adddutytot=0;}

		
	var total=document.getElementById("total_item_amount").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges4=document.getElementById("misCharge").value;	
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges4==''){othercharges4=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(totAmount)+parseFloat(cdis_amt)+parseFloat(totAmountCvd)+parseFloat(ecestot)+parseFloat(ecesectot)+parseFloat(adddutytot)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges4)+parseFloat(othercharges5);
	if(grandtotal==''){grandtotal=0;}
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
		
		
		
		
		
 }

function calcPackaging2(str)
{
	if(str!='')
	{
	var tota_amt=document.getElementById("total_item_amount").value;
	var pckgng_val=(str/100)*tota_amt;
	document.getElementById("pkg_charges").value=pckgng_val.toFixed(2);
	}
	
	var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function cal_grandamounts2()
{
	var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}

}
function calcexcise2()
{	
var total=0;
var t=document.getElementById("count").value;
for(var i=0;i<t;i++)
	{
		var amt=parseFloat(document.getElementById("exciseValue_"+i).value);
		if(isNaN(amt)){amt=0;}
		total=parseFloat(total)+amt;	
	}	
document.getElementById("tot_excise_amt").value=total.toFixed(2);	

var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calsuroctamt2(str)
{

	var amt=parseFloat(document.getElementById("taxvalue2").value);

	var	suroctper=parseFloat(document.getElementById("sur_oct_per").value);

	var amount=(amt*suroctper)/100;

	document.getElementById("sur_oct_amt").value=amount.toFixed(2);	
	
	
	var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}	

}

function calcecess2()
{	
var total=0;
var t=document.getElementById("count").value;
for(var i=0;i<t;i++)
	{
		var amt=parseFloat(document.getElementById("ECessValue_"+i).value);
		if(isNaN(amt)){amt=0;}
		total=parseFloat(total)+amt;	
	}	
document.getElementById("tot_ecess_amt").value=total.toFixed(2);	

var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calcPackaging12(str)
{
	if(str!='')
	{
	var tota_amt=document.getElementById("total_item_amount").value;
	var pckgng_val=(str/100)*tota_amt;
	document.getElementById("pkg_charges").value=pckgng_val.toFixed(2);
	}
	
	
	var total=document.getElementById("total_item_amount").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty").value;
	var overseasfrieght_amt=document.getElementById("cvd_total").value;
	var localfreight_amt=document.getElementById("custom_ecess").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess").value;	
	var detetioncharges_amt=document.getElementById("additionalCharges").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);

var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}	
}


function calTotFreight(str)
{
	if(str!='')
	{
	var total=document.getElementById("total_item_amount").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty").value;
	var overseasfrieght_amt=document.getElementById("cvd_total").value;
	var localfreight_amt=document.getElementById("custom_ecess").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess").value;	
	var detetioncharges_amt=document.getElementById("additionalCharges").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);

var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
	}
}

function calTotHandling(str)
{
	if(str!='')
	{
	var total=document.getElementById("total_item_amount").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty").value;
	var overseasfrieght_amt=document.getElementById("cvd_total").value;
	var localfreight_amt=document.getElementById("custom_ecess").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess").value;	
	var detetioncharges_amt=document.getElementById("additionalCharges").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);

var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
	}
}function cal_grandamount4()
{

	var total=document.getElementById("total_item_amount").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty").value;
	var overseasfrieght_amt=document.getElementById("cvd_total").value;
	var localfreight_amt=document.getElementById("custom_ecess").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess").value;	
	var detetioncharges_amt=document.getElementById("additionalCharges").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);

var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}
 function calculateAmuunt(i)
 {
	if(document.getElementById("bill_id").checked==true)
	{
			if(billQty==''){billQty=0;}
			if(itemRate==''){itemRate=0;}
			var billQty=document.getElementById("qty_as_per_bill_"+i).value;
			var itemRate=document.getElementById("itemrate_"+i).value;
			var amtVal=parseFloat(billQty)*parseFloat(itemRate);
			document.getElementById("itemamount_"+i).value = amtVal.toFixed(2);
	}
	if(document.getElementById("received_id").checked==true)
	{
			var recQty=document.getElementById("reciveqty_"+i).value;
			var itemRate=document.getElementById("itemrate_"+i).value;
			var amtVal=parseFloat(recQty)*parseFloat(itemRate);
			document.getElementById("itemamount_"+i).value = amtVal.toFixed(2);
	}
 }
 
 function DiscountAmounts(val,i)
 {
	var itemAmt=document.getElementById("itemamount_"+i).value;
	if(val==''){val=0;}
	if(itemAmt==''){itemAmt=0;}
	var subTotal = parseFloat(itemAmt)-parseFloat(val);
	document.getElementById("basic_"+i).value = subTotal.toFixed(2);
	
	var count =document.getElementById("count").value;
	var totAmount=0;
	for(var h=0; h<count;h++)
	{
		var subTotal1 = document.getElementById("basic_"+h).value;
		totAmount=parseFloat(totAmount)+parseFloat(subTotal1);
	}
	document.getElementById("total_item_amount").value = totAmount.toFixed(2);
 }
 
 function DiscountAmountNew(val,i)
{
	var disAmt = document.getElementById("Discount_"+i).value;
	var itemAmt=document.getElementById("itemamount_"+i).value;
	var totAmount=0;
	if(disAmt==''){disAmt=0;}
	if(itemAmt==''){itemAmt=0;}
	if(val=='PercentAmt')
	{
		var percent = parseFloat(itemAmt) * parseFloat(disAmt)/100;
		var subTotal = parseFloat(itemAmt)-parseFloat(percent);
		document.getElementById("basic_"+i).value = subTotal.toFixed(2);
		var count =document.getElementById("count").value;
		for(var h=0; h<count;h++)
		{
			var subTotal1 = document.getElementById("basic_"+h).value;
			totAmount=parseFloat(totAmount)+parseFloat(subTotal1);
		}
		document.getElementById("total_item_amount").value = totAmount.toFixed(2);
	}
	else
	{
	var subTotal = parseFloat(itemAmt)-parseFloat(percent);
	document.getElementById("basic_"+i).value = subTotal.toFixed(2);
	for(var h=0; h<count;h++)
		{
			var subTotal1 = document.getElementById("basic_"+h).value;
			totAmount=parseFloat(totAmount)+parseFloat(subTotal1);
		}
		document.getElementById("total_item_amount").value = totAmount.toFixed(2);
	}
}

function calctotConvAmt(val)
 {
 var totAmt = document.getElementById("total_item_amount").value;
 if(totAmt==''){totAmt=0;}
 var convAmt = parseFloat(val)*parseFloat(totAmt);
 document.getElementById("tot_conv_amt").value = convAmt.toFixed(2);
 
 var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
 }
 
 function calcPackagingd(str)
{
	if(str!='')
	{
	var tota_amt=document.getElementById("tot_conv_amt").value;
	var pckgng_val=(str/100)*tota_amt;
	document.getElementById("pkg_charges").value=pckgng_val.toFixed(2);
	}
	
	var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
	
}

function calcPackagingdDC(str)
{
	if(str!='')
	{
	var tota_amt=document.getElementById("total_item_amount").value;
	var pckgng_val=(str/100)*tota_amt;
	document.getElementById("pkg_charges").value=pckgng_val.toFixed(2);
	}
	
	var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function claculateExcise2(i,str)

{
	var param1 = document.getElementById("total_item_amount").value;
	var param2 = document.getElementById("pkg_charges").value;
	
	var discounted=parseFloat(param1)+parseFloat(param2);

	if (str.length==0)

  		{

  			document.getElementById("exciseIdTot").innerHTML="";

  			return;

  		}

		if (window.XMLHttpRequest)

  		{// code for IE7+, Firefox, Chrome, Opera, Safari

  			xmlhttp=new XMLHttpRequest();

  		}

		else

  		{// code for IE6, IE5

  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  		}

		xmlhttp.onreadystatechange=function()

  		{

  			if (xmlhttp.readyState==4 && xmlhttp.status==200)

    		{
			
			

    			document.getElementById("exciseIdTot").innerHTML=xmlhttp.responseText;

    		}

  		}

		xmlhttp.open("GET","ajax_calcExciseValue.php?taxId="+str+"&discounted="+discounted,true);

		xmlhttp.send();
		
		
		
		var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}

}

function calculateECess2()
{
	var exciseValue=document.getElementById("exciseValueTot").value;
	var ECessPercentage=document.getElementById("ExcisePercentageTot").value;
	var total=exciseValue*(ECessPercentage/100);
	document.getElementById("ECessValueTot").value=total.toFixed(2);
	
	
	var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calculateSAHCess2(i)
{
	var exciseValue=document.getElementById("exciseValueTot").value;
	var SAHCessPercentage=document.getElementById("SAHCessPercentageTot").value;
	var total=exciseValue*(SAHCessPercentage/100);
	document.getElementById("SAHCessValueTot").value=total.toFixed(2);
	
	
	var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calcexciseduty3()
{	
var exiceAMt1 = document.getElementById("exciseValueTot").value;
var ecessAMt2 = document.getElementById("ECessValueTot").value;
var esahAMt = document.getElementById("SAHCessValueTot").value;
var addAmt = document.getElementById("additionalCharges1").value;

if(isNaN(exiceAMt1)){exiceAMt1=0;}
if(isNaN(ecessAMt2)){ecessAMt2=0;}
if(isNaN(esahAMt)){esahAMt=0;}
if(isNaN(addAmt)){addAmt=0;}
var total = parseFloat(exiceAMt1)+parseFloat(ecessAMt2)+parseFloat(esahAMt)+parseFloat(addAmt);
document.getElementById("tot_excise_duty_amt3").value=total.toFixed(2);	


var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calctaxamt3()
{	
var total=0;
var amt1=document.getElementById("tot_excise_duty_amt3").value;
if(isNaN(amt1)){amt1=0;}

var amt2=document.getElementById("total_item_amount").value;
if(isNaN(amt2)){amt2=0;}

var amt3=document.getElementById("pkg_charges").value;
if(isNaN(amt3)){amt3=0;}


total=parseFloat(amt1)+parseFloat(amt2)+parseFloat(amt3);	
		
document.getElementById("tot_taxable_amt3").value=total.toFixed(2);	

var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function cal_grandamountssur()
{
	var amt=parseFloat(document.getElementById("taxvalue2").value);
	if(amt==''){amt=0;}
	var	suroctper=parseFloat(document.getElementById("sur_oct_per3").value);
	if(suroctper==''){suroctper=0;}
	var amount=(amt*suroctper)/100;
	if(amount==''){amount=0;}
	document.getElementById("sur_oct_amt3").value=amount.toFixed(2);

	var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function cal_grandamounts3()
{
	var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
	
}

function tax_rate3(str)
{
var taxableAmount=document.getElementById("tot_taxable_amt3").value;
if(taxableAmount==''){taxableAmount=0;}
if (str.length==0)
  {
  document.getElementById("taxval3").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("taxval3").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("GET","get_tax_val2.php?taxid="+str+"&amt="+taxableAmount,true);

xmlhttp.send();

var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function tax_rate(str)
{
var taxableAmount=document.getElementById("tot_taxable_amt").value;
if(taxableAmount==''){taxableAmount=0;}
if (str.length==0)
  {
  document.getElementById("taxval").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("taxval").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("GET","get_tax_val2.php?taxid="+str+"&amt="+taxableAmount,true);

xmlhttp.send();

var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calctaxamt2()
{	
var total=0;
var amt1=document.getElementById("tot_excise_duty_amt").value;
if(isNaN(amt1)){amt1=0;}

var amt2=document.getElementById("total_item_amount").value;
if(isNaN(amt2)){amt2=0;}

var amt3=document.getElementById("pkg_charges").value;
if(isNaN(amt3)){amt3=0;}


total=parseFloat(amt1)+parseFloat(amt2)+parseFloat(amt3);	
		
document.getElementById("tot_taxable_amt").value=total.toFixed(2);	

var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calcexciseduty2()
{	
var total=0;
var adAmt=document.getElementById("additionalCharges").value;
if(adAmt==''){adAmt=0;}
var t=document.getElementById("count").value;
for(var i=0;i<t;i++)
	{
		var amt=parseFloat(document.getElementById("taxableamount_"+i).value);
		if(isNaN(amt)){amt=0;}
		total=parseFloat(total)+amt;	
	}
	var finalRes = 	parseFloat(total)+parseFloat(adAmt);
document.getElementById("tot_excise_duty_amt").value=finalRes.toFixed(2);	

var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function cal_totalamount3()
{	
var total=0;
var t=document.getElementById("count").value;
for(var i=0;i<t;i++)
	{
		var amt=parseFloat(document.getElementById("basic_"+i).value);
		if(isNaN(amt)){amt=0;}
		total=parseFloat(total)+amt;	
	}
document.getElementById("total_item_amount").value=total.toFixed(2);	
}

function calcsahecess2()
{	
var total=0;
var t=document.getElementById("count").value;
for(var i=0;i<t;i++)
	{
		var amt=parseFloat(document.getElementById("SAHCessValue_"+i).value);
		if(isNaN(amt)){amt=0;}
		total=parseFloat(total)+amt;	
	}	
document.getElementById("tot_sahecess_amt").value=total.toFixed(2);	

var totaltax=document.getElementById("tot_taxable_amt").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var loading=document.getElementById("loading").value;
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}

	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);

	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);	
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}


function calcCustomd(id)
{ 
var totalAmount = document.getElementById("tot_conv_amt").value;
	if(totalAmount==''){totalAmount=0;}	
		var result = totalAmount*(id/100);
		var final_result=result.toFixed(2);
		document.getElementById("custom_duty_new").value=final_result;
		
		
		var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
		
}

function calcCvdd(id)
{ 
		var a1 = document.getElementById("tot_conv_amt").value;
		var b1 = document.getElementById("custom_duty_new").value;
		 if(a1==''){a1=0;}
		  if(b1==''){b1=0;}	
		var summ = parseFloat(a1)+parseFloat(b1);
		var result = summ*(id/100);
		var final_result=result.toFixed(2);
		document.getElementById("cvd_total_new").value=final_result;
		
		
		var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
		
}

function calcCustmexcessd(id)
{ 
		var a2 = document.getElementById("custom_duty_new").value;
		var b2 = document.getElementById("cvd_total_new").value;
		 if(a2==''){a2=0;}
		  if(b2==''){b2=0;}		
		var percentage2 = document.getElementById("cstm_ecess_per").value;
		var summ2 = parseFloat(a2)+parseFloat(b2);
		var result2 = summ2*(id/100);
		var final_result2=result2.toFixed(2);
		document.getElementById("custom_ecess_new").value=final_result2;
		
		var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
		
}

function calcCustmexcessec(id)
{ 
		var a3 = document.getElementById("custom_duty_new").value;
		var b3 = document.getElementById("cvd_total_new").value;
		var summ3 = parseFloat(a3)+parseFloat(b3);
		var result3 = summ3*(id/100);
		var final_result3=result3.toFixed(2);
		document.getElementById("custom_sec_ecess_new").value=final_result3;
		
		var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
		
}

function calcadduty(id)
{ 
		var a4 = document.getElementById("tot_conv_amt").value;
		var b4 = document.getElementById("custom_duty_new").value;
		var c4 = document.getElementById("cvd_total_new").value;
		var d4 = document.getElementById("custom_ecess_new").value;
		var e4 = document.getElementById("custom_sec_ecess_new").value;
		var percentage4 = document.getElementById("cstm_add_per").value;
		var summ4= parseFloat(a4)+parseFloat(b4)+parseFloat(c4)+parseFloat(d4)+parseFloat(e4);
		var result4 = summ4*(id/100);
		document.getElementById("add_charges_new").value=result4.toFixed(2);	
		
		
		var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
	
}
function cal_grandamount5()
{
	var total=document.getElementById("tot_conv_amt").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty_new").value;
	var overseasfrieght_amt=document.getElementById("cvd_total_new").value;
	var localfreight_amt=document.getElementById("custom_ecess_new").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess_new").value;	
	var detetioncharges_amt=document.getElementById("add_charges_new").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);
var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
	
}

function cal_grandamount4()
{

	var total=document.getElementById("total_item_amount").value;
	var cdis_amt=document.getElementById("pkg_charges").value;
	var insurancecharges_amt=document.getElementById("custom_duty").value;
	var overseasfrieght_amt=document.getElementById("cvd_total").value;
	var localfreight_amt=document.getElementById("custom_ecess").value;
	var calclearingforwarding_amt=document.getElementById("custom_sec_ecess").value;	
	var detetioncharges_amt=document.getElementById("additionalCharges").value;	
	var othercharges=document.getElementById("TotalCharge2").value;	
	var othercharges1=document.getElementById("loading2").value;	
	var othercharges2=document.getElementById("misCharge").value;	
	var othercharges3=document.getElementById("clearing").value;
	var othercharges5=document.getElementById("insurance").value;	
	
	if(total==''){total=0;}
	if(cdis_amt==''){cdis_amt=0;}
	if(insurancecharges_amt==''){insurancecharges_amt=0;}
	if(overseasfrieght_amt==''){overseasfrieght_amt=0;}
	if(localfreight_amt==''){localfreight_amt=0;}
	if(calclearingforwarding_amt==''){calclearingforwarding_amt=0;}
	if(detetioncharges_amt==''){detetioncharges_amt=0;}	if(othercharges==''){othercharges=0;}
	if(othercharges1==''){othercharges1=0;}
	if(othercharges2==''){othercharges2=0;}
	if(othercharges3==''){othercharges3=0;}
	if(othercharges5==''){othercharges5=0;}
	 
	
	grandtotal=parseFloat(total)+parseFloat(cdis_amt)+parseFloat(insurancecharges_amt)+parseFloat(overseasfrieght_amt)+parseFloat(localfreight_amt)+parseFloat(calclearingforwarding_amt)+parseFloat(detetioncharges_amt)+parseFloat(othercharges)+parseFloat(othercharges1)+parseFloat(othercharges2)+parseFloat(othercharges3)+parseFloat(othercharges5);
document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);

var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function calcRounded(str)
{
	var gtotal=document.getElementById('GrandTotal').value;
	var origGtotal=document.getElementById('orig_grand_tot').value;
	var gtotal_brk=gtotal.split('.');
	if(str=='+')
	{ 
	var final=parseInt(gtotal_brk[0])+1;
	document.getElementById("roundVal1").value=(parseFloat(final)-parseFloat(origGtotal)).toFixed(2);
	}
	if(str=='-')
	{ 
	var final=parseInt(gtotal_brk[0]-1);
	document.getElementById("roundVal1").value=(parseFloat(origGtotal)-parseFloat(final)).toFixed(2);
	}
	if(str=='')
	{
	var final=origGtotal;
	document.getElementById("roundVal1").value=(parseFloat(origGtotal)-parseFloat(final)).toFixed(2);
	}
	document.getElementById('GrandTotal').value=final;
	
	
}


</script>
<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>
<?php 
$PageSecurity = 4;
$PageName = 'Purchase Bill Book';
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');

$Fin1ExpS1=explode("-",$_SESSION['financialYrStart']);
$_SESSION['YearStart']=$Fin1ExpS1[0];
$Fin1ExpE1=explode("-",$_SESSION['financialYrEnd']);
$_SESSION['YearEnd']=$Fin1ExpE1[0];
?>
<?php 
if($_REQUEST['Save']) 
{
	 	$data['bill_no'] = $_REQUEST['bill_no']; 
		$data['bill_date'] = FormatDateForSQL($_REQUEST['bill_date']);  
		$data['challan_no'] = $_REQUEST['challan_no']; 
		$data['challan_date'] = FormatDateForSQL($_REQUEST['challan_date']); 
		
		$data['total_item_amount'] = $_REQUEST['total_item_amount'];
		$data['oldCurrency'] = $_REQUEST['oldCurrency']; 
		$data['conv_currency'] = $_REQUEST['conv_currency'];
		$data['tot_conv_rate'] = $_REQUEST['tot_conv_rate'];
		$data['tot_conv_amt'] = $_REQUEST['tot_conv_amt'];
		$data['pkg_charges'] = $_REQUEST['pkg_charges'];
		$data['custom_duty_per'] = $_REQUEST['custom_duty_per'];
		$data['custom_duty'] = $_REQUEST['custom_duty'];
		$data['cvd_per'] = $_REQUEST['cvd_per'];
		$data['cvd_total'] = $_REQUEST['cvd_total'];
		$data['cstm_ecess_per'] = $_REQUEST['cstm_ecess_per'];
		$data['custom_ecess1'] = $_REQUEST['custom_ecess1'];
		$data['cstm_ecessec_per'] = $_REQUEST['cstm_ecessec_per'];
		$data['custom_sec_ecesss'] = $_REQUEST['custom_sec_ecesss'];
		$data['cstm_add_per'] = $_REQUEST['cstm_add_per'];
		$data['add_chargess'] = $_REQUEST['add_chargess'];
		$data['tot_freights'] = $_REQUEST['tot_freights'];
		$data['insurance'] = $_REQUEST['insurance'];
		$data['clearing'] = $_REQUEST['clearing'];
		$data['misCharge'] = $_REQUEST['misCharge'];
		$data['loadings'] = $_REQUEST['loadings'];
		$data['grandtotals'] = $_REQUEST['grandtotals'];
		$data['calc_total_against'] = $_REQUEST['calc_total_against'];
		$data['pkg_perc'] = $_REQUEST['pkg_perc'];
		$data['tot_excise_amt'] = $_REQUEST['tot_excise_amt'];
		$data['tot_ecess_amt'] = $_REQUEST['tot_ecess_amt'];
		$data['tot_sahecess_amt'] = $_REQUEST['tot_sahecess_amt'];
		$data['tot_excise_duty_amt'] = $_REQUEST['tot_excise_duty_amt'];
		$data['tot_taxable_amt'] = $_REQUEST['tot_taxable_amt'];
		$data['vat_cst'] = $_REQUEST['vat_cst'];
		$data['taxvalue'] = $_REQUEST['taxvalue'];
		$data['sur_oct_per'] = $_REQUEST['sur_oct_per'];
		$data['sur_oct_amt'] = $_REQUEST['sur_oct_amt'];
		$data['excise_perc'] = $_REQUEST['excise_perc'];
		$data['exciseValue'] = $_REQUEST['exciseValue'];
		
		$data['e_cess_perc'] = $_REQUEST['e_cess_perc'];
		$data['exciseValue'] = $_REQUEST['exciseValue'];
		$data['voucher_date'] = date('Y-m-d'); 
		$data['approval_status'] =0; 
		$data['bill_book_date'] = FormatDateForSQL($_REQUEST['bill_book_date']);
		$data['round_off'] = $_REQUEST['round_off'];
		$data['roundVal'] = $_REQUEST['roundVal'];
		$data['sahecess_per'] = $_REQUEST['sahecess_per'];
		$data['modifiedBy'] = $_SESSION['UserID'];
		$data['modifiedDate'] = date('Y-m-d'); 
		
		$conditionUpa="id='".$_REQUEST['mainId']."'"; 
		$s->RecordEdit('purchase_verification', $data, $conditionUpa);
		
		
		//$del1=DB_query("delete from purchase_verification_details where parent_id='".$_REQUEST['mainId']."'",$db);
	  	 $countvalue= count($_REQUEST['mst_itemid']);
	   	for($i=0;$i<$countvalue;$i++)
		{
				$data_arr['parent_id']= $Lastreq_id;
				$data_arr['mst_itemid']= $_POST['mst_itemid'][$i];				
				$data_arr['poqty']= $_POST['poqty'][$i];
				$data_arr['qty_as_per_bill']= $_POST['qty_as_per_bill'][$i];
				$data_arr['reciveqty']= $_REQUEST['reciveqty'][$i];
				$data_arr['short_accessid']= $_REQUEST['short_accessid'][$i];
				$data_arr['itemrate']= $_REQUEST['itemrate'][$i];	
				$data_arr['itemamount']= $_REQUEST['itemamount'][$i];	
				$data_arr['discount']= $_REQUEST['discount'][$i];
				$data_arr['DiscountType1']= $_REQUEST['DiscountType1'][$i];
				$data_arr['basic']= $_REQUEST['basic'][$i];
				$data_arr['itemCurrency']= $_REQUEST['itemCurrency'][$i];
				$data_arr['NetRate1']= $_REQUEST['NetRate1'][$i];
				$data_arr['con_curr']= $_REQUEST['con_curr'][$i];
				$data_arr['conv_rate']= $_REQUEST['conv_rate'][$i];
				$data_arr['Excise_type']= $_REQUEST['Excise_type'][$i];
				$data_arr['Excise_Duty1']= $_REQUEST['Excise_Duty1'][$i];
				$data_arr['duty_amount']= $_REQUEST['duty_amount'][$i];
				$data_arr['cvd_percentage']= $_REQUEST['cvd_percentage'][$i];
				$data_arr['TotalAmount1']= $_REQUEST['TotalAmount1'][$i];
				$data_arr['ecess_percentage']= $_REQUEST['ecess_percentage'][$i];
				$data_arr['custom_ecess1']= $_REQUEST['custom_ecess1'][$i];
				$data_arr['secess_percentage']= $_REQUEST['secess_percentage'][$i];
				$data_arr['custom_sec_ecess1']= $_REQUEST['custom_sec_ecess1'][$i];
				$data_arr['add_percentage']= $_REQUEST['add_percentage'][$i];
				$data_arr['adduty1']= $_REQUEST['adduty1'][$i];
				$data_arr['excise_perc']= $_REQUEST['excise_perc'][$i];
				$data_arr['excise_val']= $_REQUEST['excise_val'][$i];
				$data_arr['e_cess_perc']= $_REQUEST['e_cess_perc'][$i];
				$data_arr['e_cess_val']= $_REQUEST['e_cess_val'][$i];
				$data_arr['sah_perc']= $_REQUEST['sah_perc'][$i];
				$data_arr['sah_val']= $_REQUEST['sah_val'][$i];
				$data_arr['taxableamount']= $_REQUEST['taxableamount'][$i];
				$data_arr['val_after_disc']= $_REQUEST['val_after_disc'][$i];
				$data_arr['remarks']= $_REQUEST['remarks'][$i];
				$data_arr['tax_type']= $_REQUEST['billing_type'][$i];
				//echo "<pre>";
				//print_r($data_arr);exit();
				
				$insert_mrm=$s->insertRecord('purchase_verification_details', $data_arr);
				$ErrMsg = _('An error occurred Record Note Save') . '. ' . _('The error says');
					$insertResult1 = DB_query($insert_mrm,$db,$ErrMsg);
					
					
					
					echo "<script>location.href='index.php?route=purchaseBillIndex&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
prnMsg( _('Record Inserted Successfully!'),'success');
		
		}
}
		$mailsql = "select * from purchase_verification where id='".$_REQUEST['id']."'";
		$resultMain=DB_query($mailsql, $db);
		$rowData=DB_fetch_array($resultMain);

		//voucher no.
		$vnum=$rowData['voucher_no'];
		$vsite=$rowData['site'];
		$pcode=$s->getField('prefix_tbl','prefix_code','PV','prefix_code');
	    $vouchercode=$vsite."/".$pcode."/"."00".$vnum;
		$vendorData=$s->getField('suppliers','id',$rowData['vendor'],'vendor_name');
		$mrnNum=$s->getField('addmrn','id',$rowData['mrn_no'],'MRNNo');
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1 align="center">MRN Bill Verification</h1>
<form  name="purchase" action="" method="post" onsubmit="return validateFrm();">
<table width="100%" border="0"  cellspacing="0" cellpadding="3">
<tr class="row1">
<input name="mainId" type="hidden" value="<?php echo $rowData['id']; ?>" />
	<td class="tabledata1"><strong>Site <font color="#FF0000">*</font></strong></td>
	<td> 
	<?php 
  	$sql = "select loccode, locationname from locations where loccode='".$rowData['site']."'";
	$result=DB_query($sql, $db);
	$myrow=DB_fetch_array($result);
	?>
	<input name="site" type="text" value="<?php echo $myrow['locationname']; ?>"  style="width:200px;" id="site" readonly="true"/>
	</td>
	<td class="tabledata1"><strong>Voucher No</strong></td>
	<td><input name="voucher_no" type="text" value="<?php echo $vouchercode; ?>"  style="width:200px;" id="bill" readonly="true"/></td>
	<td class="tabledata1"><strong>Voucher Date <font color="#FF0000">*</font></strong></td>
	<td><input name="voucher_date" id="voucher_date" type="text" class="datepicker" style="width:200px;" value="<?php echo ConvertSQLDate($rowData['voucher_date']); ?>" /></td>
	
</tr>
<tr class="row1">
<td class="tabledata1"><strong>Vendor</strong></td>
	<td>
	<input name="vendor" type="text" value="<?php echo $vendorData; ?>"  style="width:200px;" id="vendor" readonly="true"/>
	</td>
	<td class="tabledata1"><strong>MRN No</strong></td>
	<td>
	<input name="mrn_no" type="text" value="<?php echo $mrnNum; ?>"  style="width:200px;" id="mrn_no" readonly="true"/>
	</td> 
	<td align="left" valign="top" class="tabledata1"><strong>MRN Date</strong></td>
	<td align="left" valign="top"><input type="text" name="mrn_date" id="mrnDate" style="width:200px;" value="<?php echo ConvertSQLDate($rowData['mrn_date']); ?>"/></td>
</tr>
<tr class="row1">
<td align="left" valign="top" class="tabledata1"><strong>PO NO</strong></td>
<td align="left" valign="top"><input name="po_no" id="poNO" type="text"  style="width:200px;" value="<?php echo $rowData['po_no']; ?>" readonly="true"/></td>
<td align="left" valign="top" class="tabledata1"><strong>PO Date</strong></td>
<td align="left" valign="top"><input type="text" name="po_date" id="po_date"  value="<?php echo ConvertSQLDate($rowData['po_date']); ?>" style="width:200px;"  readonly="true"/></td>
<td align="left" valign="top" class="tabledata1"><strong>PO Type</strong></td>
<td align="left" valign="top"><input name="po_type" id="po_type" type="text"  style="width:200px;" value="<?php if($rowData['po_type']=='1') {echo "Import Order";} elseif($rowData['po_type']=='2'){echo "Domestic Order";} elseif($rowData['po_type']=='3'){echo "Service Order";} elseif($rowData['po_type']=='4'){echo "Asset Order";}  ?>" readonly="true"/>
</td>
</tr>
<tr class="row1">
<td align="left" valign="top" class="tabledata1"><strong>Doc Type</strong></td>
<td align="left" valign="top" id="doc_type_data"><input name="doc_type" id="doc_type" type="text"  style="width:200px;" value="<?php echo $rowData['doc_type']; ?>" readonly="true"/></td>
<td align="left" valign="top" class="tabledata1"><strong>Due Date</strong></td>
<td align="left" valign="top"><input type="text" name="bill_book_date" id="bill_book_date" value="<?php echo ConvertSQLDate($rowData['bill_book_date']); ?>"  style="width:200px;"  readonly="true"/></td>
<td align="left" valign="top" class="tabledata1">&nbsp;</td>
<td align="left" valign="top">&nbsp;
</td>
</tr>

<tr class="row1">
<td align="left" valign="top" class="tabledata1"><strong>Bill No.</strong></td>
<td align="left" valign="top"><input name="bill_no" id="bill_no" type="text"  style="width:200px;" value="<?php echo $rowData['bill_no']; ?>" /></td>
<td align="left" valign="top" class="tabledata1"><strong>Bill Date</strong></td>
<td align="left" valign="top"><input name="bill_date" id="bill_date" class="datepicker" type="text"  style="width:200px;" value="<?php echo ConvertSQLDate($rowData['bill_date']); ?>" /></td>
<td align="left" valign="top" class="tabledata1"><strong>Duty Type</strong></td>
<td align="left" valign="top"><input name="duty_type" id="duty_type" type="text"  style="width:200px;" readonly="true" value="<?php echo $rowData['duty_type']; ?>" /></td>
</tr>

<tr class="row1" colspan="3">
<td align="left" valign="top" class="tabledata1"><strong>Challan No</strong></td>
<td align="left" valign="top"><input name="challan_no" id="challan_no" type="text"  style="width:200px;" value="<?php echo $rowData['challan_no']; ?>" /></td>
<td align="left" valign="top" class="tabledata1"><strong>Challan Date</strong></td>
<td align="left" valign="top"><input name="challan_date" id="challan_date" class="datepicker" type="text"  style="width:200px;" value="<?php echo ConvertSQLDate($rowData['challan_date']); ?>" /></td>
<td>
</td>
<td>
</td>
</tr>
</table>
<?php
if($rowData['po_type']==1 && $rowData['duty_type']=='Consolidated')
{ ?>
<div style="clear:both"></div>
<div align="right" id="charges1">
  <div id="importPo3" style="width:100%; margin:auto;">
    <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:1px solid #333333;">
      <tr class="row1">
        <td colspan="14" style="text-align:center;" class="tabledata1"><strong>Against :</strong>
            <input type="radio" name="calc_total_against" id="radio" value="bill" <?php if($rowData['calc_total_against']=='bill') { echo 'checked'; } else { echo ''; } ?> disabled="disabled" onclick="calculateAgainst(this.value)" />
            <strong>Bill Qty</strong>
            <input type="radio" name="calc_total_against" <?php if($rowData['calc_total_against']=='received') { echo 'checked'; } else { echo ''; } ?> id="radio2" value="received" disabled="disabled" onclick="calculateAgainst(this.value)"/>
            <strong>Received Qty</strong></td>
      </tr>
      <tr>
        <td class="tabledata"><strong>Sr.No.</strong></td>
        <td class="tabledata"><strong>Item Code</strong></td>
        <td class="tabledata"><strong>Description</strong></td>
        <td class="tabledata"><strong>UOM</strong></td>
        <td class="tabledata"><strong>PO QTY</strong></td>
        <td class="tabledata"><strong>Bill QTY</strong></td>
        <td class="tabledata"><strong>Recieved QTY</strong></td>
        <td class="tabledata"><strong>Short/Excess QTY</strong></td>
        <td class="tabledata"><strong>Rate</strong></td>
        <td class="tabledata"><strong>Amount</strong></td>
        <td class="tabledata" colspan="2" width="15%"><strong>Discount</strong></td>
        <td class="tabledata"><strong>Basic<br /> Amt.</strong></td>
        <td class="tabledata"><strong>Currency</strong></td>
      </tr>
      <?php 
$i=0;
$sql=DB_query("select * from purchase_verification_details where parent_id='".$rowData['id']."'",$db);
while($row=DB_fetch_array($sql))
{
	$itemcode=$s->getField('item_master','id',$row['mst_itemid'],'StockID');
	$itemname=$s->getField('item_master','id',$row['mst_itemid'],'item_name');
	$unit=$s->getField('item_master','id',$row['mst_itemid'],'mst_unitid');
	
$oldCur = $s->getField('direct_po_details','id',$row['details_id'],'currency');
?>
      <tr bgcolor="#c1c1c1">
        <td><?php echo $i+1;?></td>
        <td><?php echo $itemcode;?>
            <input type="hidden" name="convfac[]" id="convfac[]" value="<?php echo $confac; ?>" />
            <input type="hidden" readonly="" id="mst_itemid[]" name="mst_itemid[]" size="15" value="<?php echo $row['mst_itemid']; ?>" />
            <input type="hidden" readonly="" id="itemcode[]" name="itemcode[]" size="15"  value="<?php echo $itemcode; ?>" />
            <input type="hidden" readonly="" id="tolrancees[]" name="tolrancees[]" size="15"  value="<?php echo $tolerance; ?>" />
            <input type="hidden" readonly="" id="pending[]" name="pending[]" size="15"  value="<?php echo $pending_qty; ?>" />
        </td>
        <td><?php echo $itemname ?></td>
        <td><?php $unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
	echo $unitname;?></td>
        <td><?php   echo $poqty=$row['poqty']; ?>
            <input name="poqty[]" type="hidden" id="poqty[]" value="<?php echo $poqty;?>" size="10"/></td>
        <td><input name="qty_as_per_bill[]" type="text" id="qty_as_per_bill_<?php echo $i; ?>" value="<?php echo $row['qty_as_per_bill'];?>"  size="8" readonly onblur="check_bill_qty(this.value,<?php echo $i;?>)"/>
        </td>
        <td><input name="reciveqty[]" readonly type="text" id="reciveqty_<?php echo $i; ?>" value="<?php echo $row['reciveqty'];?>" style="width:100%;"/></td>
        <td><input name="short_accessid[]" type="text" id="short_accessid[]" value="<?php echo $row['short_accessid'];?>" size="8" readonly="true" onfocus="calculate_poshort(<?php echo $i ?>);"/></td>
        <td><input name="itemrate[]" type="text" id="itemrate_<?php echo $i; ?>" value="<?php echo $row['itemrate']; ?>"  size="8" readonly="true"/>
        </td>
        <td><input name="itemamount[]" readonly type="text" id="itemamount_<?php echo $i; ?>" value="<?php echo $row['itemamount']; ?>" onfocus="calculateAmuunt(<?php echo $i; ?>)"  size="8"/>
        </td> 
               <td class="tabledata"><input type="text" readonly value="<?php echo $row['discount']; 
		?>" name="discount[]" onkeyup="DiscountAmounts(this.value,<?php echo $i; ?>)" size="8" id="Discount1_<?php echo $i; ?>"/>
        </td>
        <td><input name="DiscountType1[]" type="hidden" id="PerAmo_<?php echo $i; ?>" value="<?php echo $row['DiscountType1']; 
		?>" size="8" readonly />
		<input  name="DiscountType[]" type="text"  id="PerAmo_<?php echo $i; ?>" value="<?php if($row['DiscountType1']=='Amount')
		{ echo 'Amt'; } else { echo '%'; }
		?>" size="8" readonly/>
	</td>
       <td class="tabledata"><input type="text" style="width:70px" id="basic_<?php echo $i; ?>" value="<?php echo $row['basic']; ?>" name="basic[]" readonly/></td>
       <td><input name="itemCurrency[]" type="hidden" id="itemCurrency_<?php echo $i; ?>" value="<?php echo $row['itemCurrency'];?>" size="8" readonly />
		<input name="itemCurrencyread[]" type="text" id="itemCurrencyname_<?php echo $i; ?>" value="<?php echo $s->getField('currency_master','id',$row['itemCurrency'],'abbreviation');
		?>" size="8" readonly/>
	</td>
      </tr>
      <?php $i++; }	 ?>
      <input type="hidden" name="countval" value="<?php echo $i; ?>"  id="count"/>
    </table>
  </div><br />
<br />
			
			<table width="40%">
			<tr><th>
		      <table width="100%" border="1" cellspacing="0" cellpadding="3">
                <tr>
                  <td><strong>TOTAL AMOUNT <font color="#FF0000">*</font></strong> </td>
                  <td >
				  <input type="text" name="total_item_amount" id="total_item_amount" style="width:100%;" onFocus="cal_totalamount()" value="<?php echo $rowData['total_item_amount']; ?>" />
				  </td>
               </tr>
			   <tr>
                  <td><strong>Currency Conversion<font color="#FF0000">*</font></strong> </td>
                  <td>
				  <input name="oldCurrency" type="hidden" id="oldCurrency" value="<?php echo $oldCur; 
		?>" size="8" />
				  <select style="width:38%;" name="conv_currency" id="tot_currency" onChange="ajax_cur_rate_tot(this.value);">
				  <option value="">--Select--</option>
			<?php $curr_sql=DB_query("Select * from currency_master",$db);
			while($curr_row=DB_fetch_array($curr_sql))
			{  ?>
            <option value="<?php echo $curr_row['id']; ?>"<?php echo ($rowData['conv_currency']==$curr_row['id'])?'selected':''?>><?php echo $curr_row['abbreviation']; ?></option>
			<?php } ?>
          </select>
		  <input name="tot_conv_rate" id="tot_conv_rate" type="text" value="<?php echo $rowData['tot_conv_rate']; ?>" style="width:60%;" onkeyup="calctotConvAmt(this.value)" />
				  </td>
               </tr>
			   <tr>
                  <td><strong>Conversion Amount</strong> </td>
                  <td><input type="text" name="tot_conv_amt" id="tot_conv_amt" value="<?php echo $rowData['tot_conv_amt']; ?>" style="width:100%;" /></td>
                </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_perc" id="pkg_perc" value="<?php echo $rowData['pkg_perc']; ?>" style="width:38%;"onkeyup="calcPackagingd(this.value)" />
				  
				  <input name="pkg_charges" id="pkg_charges" type="text" value="<?php echo $rowData['pkg_charges']; ?>" style="width:60%;" /></td>
                </tr>
                <tr>
                  <td><strong>Custom Duty</strong> </td>
              <td><select name="custom_duty_per" id="custom_duty_per" style="width:38%" onChange="calcCustomd(this.value)">
			  <option value="">--Select--</option>
		<?php 
		$accgroup_sql = "select * from custom_duty where type = 'Custom'";
		$accgroup_result = DB_query($accgroup_sql,$db);
		while($accgroup_row = DB_fetch_array($accgroup_result))
		{ 	
		?>
		<option value="<?php echo $accgroup_row['def_rate'];?>"<?php echo ($rowData['custom_duty_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
			  <input type="text" name="custom_duty" id="custom_duty_new" value="<?php echo $rowData['custom_duty']; ?>" style="width:60%;"/></td>
              </tr>
              <tr>
              	<td><strong>CVD</strong></td>
              <td><select name="cvd_per" id="cvd_per" style="width:38%" onChange="calcCvdd(this.value)">
			  <option value="">--Select--</option>
		<?php 
		$accgroup_sql = "select * from custom_duty where type = 'CVD'";
		$accgroup_result = DB_query($accgroup_sql,$db);
		while($accgroup_row = DB_fetch_array($accgroup_result))
		{ 	
		?>
		<option value="<?php echo $accgroup_row['def_rate'];?>"<?php echo ($rowData['cvd_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
                  <input type="text" name="cvd_total" id="cvd_total_new" value="<?php echo $rowData['cvd_total']; ?>" style="width:60%;"/></td>
                </tr>
                <tr>
                  <td><strong>Custom E.Cess</strong> </td>
                  <td>
				  <select name="cstm_ecess_per" id="cstm_ecess_per" style="width:38%" onChange="calcCustmexcessd(this.value)">
				   <option value="">--Select--</option>
		<?php 
		$accgroup_sql = "select * from custom_duty where type = 'ECESS'";
		$accgroup_result = DB_query($accgroup_sql,$db);
		while($accgroup_row = DB_fetch_array($accgroup_result))
		{ 	
		?>
		<option value="<?php echo $accgroup_row['def_rate'];?>"<?php echo ($rowData['cstm_ecess_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
		
		<input type="text" name="custom_ecess1" id="custom_ecess_new" value="<?php echo $rowData['custom_ecess1']; ?>" style="width:60%;"/></td>
                </tr>
				<tr>
                  <td><strong>Custom SE.Cess</strong> </td>
                  <td><select name="cstm_ecessec_per" id="cstm_ecessec_per" style="width:38%" onChange="calcCustmexcessec(this.value)">
				<option value="">--Select--</option>  
		<?php 
		$accgroup_sql = "select * from custom_duty where type = 'SHE-CESS'";
		$accgroup_result = DB_query($accgroup_sql,$db);
		while($accgroup_row = DB_fetch_array($accgroup_result))
		{ 	
		?>
		<option value="<?php echo $accgroup_row['def_rate'];?>"<?php echo ($rowData['cstm_ecessec_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
				<input type="text" name="custom_sec_ecesss" value="<?php echo $rowData['custom_sec_ecesss']; ?>" id="custom_sec_ecess_new" style="width:60%;"/></td>
                </tr>
				<tr>
                  <td><strong>Additional Duty </strong> </td>
                  <td><select name="cstm_add_per" id="cstm_add_per" value="<?php echo $rowData['cstm_add_per']; ?>" style="width: 38%" onChange="calcadduty(this.value)">
				  <option value="">--Select--</option>  
		<?php 
		$accgroup_sql = "select * from custom_duty where type = 'ADC'";
		$accgroup_result = DB_query($accgroup_sql,$db);
		while($accgroup_row = DB_fetch_array($accgroup_result))
		{ 	
		?>
		<option value="<?php echo $accgroup_row['def_rate'];?>"<?php echo ($rowData['cstm_add_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
				  <input name="add_chargess" id="add_charges_new" type="text" value="<?php echo $rowData['add_chargess']; ?>" style="width:60%;" /></td>
                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="tot_freights" value="<?php echo $rowData['tot_freights']; ?>" id="TotalCharge2" style="width:100%;" /></td>
                </tr>
				 <tr>
                  <td><strong>Insurance</strong> </td>
                  <td><input type="text" name="insurance" value="<?php echo $rowData['insurance']; ?>" id="insurance" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Clearing & Forwarding</strong> </td>
                  <td><input type="text" name="clearing" value="<?php echo $rowData['clearing']; ?>" id="clearing" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Misc. Charges</strong> </td>
                  <td><input type="text" name="misCharge" value="<?php echo $rowData['misCharge']; ?>" id="misCharge" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Handling Charges</strong> </td>
                  <td><input type="text" name="loadings" value="<?php echo $rowData['loadings']; ?>" id="loading2" style="width:100%;" /></td>
                </tr>
                <tr>
				<td><strong>Grand Total <font color="#FF0000">*</font></strong></td>
                  <td><input type="text" name="grandtotals" id="GrandTotal" value="<?php echo $rowData['grandtotals']; ?>" onFocus="cal_grandamount5()"  size="23"/><input type="hidden"  id="orig_grand_tot"  size="5"/>&nbsp;
				  <?php
				    $flagRound = $s->getField('roundoff_flag','company_id',$_SESSION['ACGCompanyId'],'round_flag');
				  if($flagRound=='1')
				  { ?>
				  <input type="text" name="round_off" value="<?php echo $rowData['round_off']; ?>" id="pluMin"  size="5"/><input type="text" name="roundVal" value="<?php echo $rowData['roundVal']; ?>" id="roundVal"  size="5" />&nbsp;
				 <?php  }
				 else
				 {
				  ?><strong>Round Off</strong>&nbsp;<select name="round_off" id="round_off" style="width:50px; height:20px" onChange="calcRounded(this.value)">
				  <option value="">None</option>
				  <option value="+"<?php echo ($rowData['round_off']=='+')?'selected':''?>>+</option>
				  <option value="-"<?php echo ($rowData['round_off']=='-')?'selected':''?>>-</option>
				  </select><input type="text" name="roundVal" id="roundVal1" value="<?php echo $rowData['roundVal']; ?>" size="5" /><?php } ?></td>
                </tr>
              </table>
		     </th>
		<td>		</td>
		</tr>
			</table>
</div>
 <?php } 
elseif($rowData['po_type']==1 && $rowData['duty_type']=='Itemwise')
{ ?>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td>
 <div id="importPo1" style="width:1200PX;overflow:auto;">
<table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:1px solid #333333;">
<tr class="row1">
        <td colspan="14" style="text-align:center;" class="tabledata1"><strong>Against :</strong>
            <input type="radio" name="calc_total_against" id="radio" value="bill" <?php if($rowData['calc_total_against']=='bill') { echo 'checked'; } else { echo ''; } ?> disabled="disabled" onclick="calculateAgainst2(this.value)" />
            <strong>Bill Qty</strong>
            <input type="radio" name="calc_total_against" id="radio2" <?php if($rowData['calc_total_against']=='received') { echo 'checked'; } else { echo ''; } ?> disabled="disabled" value="received" onclick="calculateAgainst2(this.value)"/>
            <strong>Received Qty</strong></td>
      </tr>
	<th class="tabledata"><strong>Sr.No.</strong></th>
	<th class="tabledata"><strong>Item Code</strong></th>
	<th class="tabledata"><strong>Description</strong></th>
	<th class="tabledata"><strong>UOM</strong></th>
	<th class="tabledata"><strong>PO QTY</strong></th>
	<th class="tabledata"><strong>Bill Qty</strong></th>
	<th class="tabledata"><strong>Recieved QTY</strong></th>
	<th class="tabledata"><strong>Short/Excess QTY</strong></th>
	<th class="tabledata"><strong>Rate</strong></th>
	<th class="tabledata"><strong>Amount</strong></th>
	<td class="tabledata" colspan="2"><strong>Discount</strong></td>
	<th class="tabledata"><strong>Basic Amount</strong></th>
	<td class="tabledata"><strong>Currency</strong></td>
	<td class="tabledata" ><strong>Conversion<br /> Curr.</strong></td>
	<td class="tabledata"><strong>Conversion<br /> Rate</strong></td>
	<th class="tabledata"><strong>Basic<br /> Amt.(Converted)</strong></th>
	<th class="tabledata"><strong>Custom Duty Flag</strong></th>
	<th class="tabledata"><strong>Custom Duty</strong></th>
	<th class="tabledata"><strong>Duty Amount</strong></th>
	<th class="tabledata"><div style="width:47px;"><strong>CVD</strong></div></th>
	<th class="tabledata"><strong>Custom E.Cess</strong></th>
	<th class="tabledata"><strong>Custom SE.Cess</strong></th>
	<th class="tabledata"><strong>Add. Duty</strong></th>
  </tr>
  <?php 
$i=0;
$sql=DB_query("select * from purchase_verification_details where parent_id='".$rowData['id']."'",$db);
while($row=DB_fetch_array($sql))
{
	$itemcode=$s->getField('item_master','id',$row['mst_itemid'],'StockID');
	$itemname=$s->getField('item_master','id',$row['mst_itemid'],'item_name');
	$tolerance=$s->getField('item_master','id',$row['mst_itemid'],'tolerance');
	$unit=$s->getField('item_master','id',$row['mst_itemid'],'mst_unitid');
?>
 
 <tr bgcolor="#c1c1c1">
        <td><?php echo $i+1;?></td>
        <td><?php echo $itemcode;?>
            <input type="hidden" readonly="" id="mst_itemid[]" name="mst_itemid[]" size="15" value="<?php echo $row['mst_itemid']; ?>" />
            <input type="hidden" readonly="" id="itemcode[]" name="itemcode[]" size="15"  value="<?php echo $itemcode; ?>" />
            <input type="hidden" readonly="" id="tolrancees[]" name="tolrancees[]" size="15"  value="<?php echo $tolerance; ?>" />
            <input type="hidden" readonly="" id="pending[]" name="pending[]" size="15"  value="<?php echo $pending_qty; ?>" />
        </td>
         <td><?php echo $itemname ?></td>
        <td><?php $unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
	echo $unitname;?></td>
        <td><?php   echo $poqty=$row['poqty']; ?>
            <input name="poqty[]" type="hidden" id="poqty[]" value="<?php echo $poqty;?>" size="10"/></td>
        <td><input name="qty_as_per_bill[]" type="text" id="qty_as_per_bill_<?php echo $i; ?>" value="<?php echo $row['qty_as_per_bill'];?>"  size="8" readonly onblur="check_bill_qty(this.value,<?php echo $i;?>)"/>
        </td>
        <td><input name="reciveqty[]" readonly type="text" id="reciveqty_<?php echo $i; ?>" value="<?php echo $row['reciveqty'];?>" style="width:100%;"/></td>
        <td><input name="short_accessid[]" type="text" id="short_accessid[]" value="<?php echo $row['short_accessid'];?>" size="8" readonly="true" onfocus="calculate_poshort(<?php echo $i ?>);"/></td>
        <td><input name="itemrate[]" type="text" id="itemrate_<?php echo $i; ?>" value="<?php echo $row['itemrate']; ?>"  size="8" readonly="true"/>
        </td>
        <td><input name="itemamount[]" readonly type="text" id="itemamount_<?php echo $i; ?>" value="<?php echo $row['itemamount']; ?>" onfocus="calculateAmuunt(<?php echo $i; ?>)"  size="8"/>
        </td> 
               <td class="tabledata"><input type="text" readonly value="<?php echo $row['discount']; 
		?>" name="discount[]" onkeyup="DiscountAmounts(this.value,<?php echo $i; ?>)" size="8" id="Discount1_<?php echo $i; ?>"/>
        </td>
        <td><input name="DiscountType1[]" type="hidden" id="PerAmo_<?php echo $i; ?>" value="<?php echo $row['DiscountType1']; 
		?>" size="8" readonly />
		<input  name="DiscountType[]" type="text"  id="PerAmo_<?php echo $i; ?>" value="<?php if($row['DiscountType1']=='Amount')
		{ echo 'Amt'; } else { echo '%'; }
		?>" size="8" readonly/>
	</td>
		 <td class="tabledata"><input type="text" style="width:70px" id="NetRate1_<?php echo $i; ?>" value="<?php echo $row['NetRate1']; ?>" name="NetRate1[]" readonly/></td>
		<td><input name="itemCurrency[]" type="hidden" id="itemCurrency_<?php echo $i; ?>" value="<?php echo $row['itemCurrency']; ?>" size="8" readonly />
		<input name="itemCurrencyread[]" type="text" id="itemCurrencyname_<?php echo $i; ?>" value="<?php echo $s->getField('currency_master','id',$row['itemCurrency'],'abbreviation');
		?>" size="8" readonly/>
	</td>
	 <td>
				  <select style="width:80px;" name="con_curr[]" id="con_curr">
				  <option value="">--Select--</option>
			<?php $curr_sql=DB_query("Select * from currency_master",$db);
			while($curr_row=DB_fetch_array($curr_sql))
			{  ?>
            <option value="<?php echo $curr_row['id']; ?>"<?php echo ($row['con_curr']==$curr_row['id'])?'selected':''?>><?php echo $curr_row['abbreviation']; ?></option>
			<?php } ?>
          </select>
				  </td>
		  <td>
		  <input name="conv_rate[]" type="text" id="conv_rate_<?php echo $i; ?>" value="<?php echo $row['conv_rate']; ?>"  size="8" onfocus="recieveValidate()" onkeyup="calcConvAmt(this.value,<?php echo $i; ?>)"/></td>
		<td class="tabledata"><input type="text" style="width:70px" readonly id="basic_<?php echo $i;?>" value="<?php echo $row['basic']; ?>" name="basic[]" onBlur="cal_basic_total(this.id)" onFocus="calConvertedAmount(this.value,<?php echo $i;?>);" /></td>
		<td class="tabledata"><select name="Excise_type[]" style="width:85px" id="hid_billing_type_<?php echo $i;?>"  onchange="checkExcisable11(this.value,<?php echo $i;?>)">
	<option value="">Select</option>
	<option value="1"<?php echo ($row['Excise_type']=='1')?'selected':''?>>Yes</option>
	<option value="2"<?php echo ($row['Excise_type']=='2')?'selected':''?>>No</option>
</select></td>

<?php if($row['Excise_type']=='1') { ?>

	<td class="tabledata"><select name="Excise_Duty1[]" id="exciseDuty_<?php echo $i;?>" style="width:120px;" onchange="claculateExcise33(this.value,<?php echo $i; ?>)" onBlur="checkexiseflag(this.id)">
    	    <option value="">Select</option>
    	    <?php 
    	    $excise_sql=DB_query("Select * from custom_duty where type='custom'",$db);
			while($excise_row=DB_fetch_array($excise_sql))
			{?>
				<option value="<?php echo $excise_row['def_rate'];?>"<?php echo ($row['Excise_Duty1']==$excise_row['def_rate'])?'selected':''?>><?php echo $excise_row['caption'];?></option>
			<?php 	
			}
    	    ?> 
  	      </select>
  	      <div id="exciseId_<?php echo $j;?>"></div>
      </td>
		  <td class="tabledata"><input type="text"  id="dutyamount_<?php echo $i;?>" onFocus="checkduty(this.id)" name="duty_amount[]" value="<?php echo $row['duty_amount']; ?>" style="width:70px;" onBlur="cal_custom_total(this.id)" readonly/></td><?php 
    	     $cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);
			 $k=1;
			 while($cessRow=DB_fetch_array($cessSql))
			 {
			 	$caption[$k]=$cessRow['caption']; 
				
				$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);
				while($rate_row=DB_fetch_array($rate_sql))
				{
					$rate[$k]=$rate_row['def_rate'];
				}
				$k++;
			 } 
    	     ?> 
		<td class="tabledata">
		<input type="text" id="cvd_percentage" name="cvd_percentage" size="5" readonly value="<?php echo $s->getField('custom_duty','type','CVD','def_rate');?>" /><input type="text" id="TotalSpecial_<?php echo $i;?>" name="TotalAmount1[]" style="width:70px;"  onBlur="cal_cvd_total(this.id);" value="<?php echo $row['TotalAmount1']; ?>"/></td>
		<td class="tabledata"><input type="text" id="ecess_percentage" name="ecess_percentage" readonly size="5" value="<?php echo $s->getField('custom_duty','type','ECESS','def_rate');?>" /><input type="text" id="customecess_<?php echo $i;?>" name="custom_ecess1[]" style="width:70px;" value="<?php echo $row['custom_ecess1']; ?>"/></td>
		<td class="tabledata"> <input type="text" readonly id="secess_percentage" name="secess_percentage" size="5" value="<?php echo $s->getField('custom_duty','type','SHE-CESS','def_rate');?>" /><input type="text" id="customsececess_<?php echo $i;?>" name="custom_sec_ecess1[]" style="width:70px;" onBlur="cal_ecess_sec_total(this.id);" value="<?php echo $row['custom_sec_ecess1']; ?>"/></td>
		<td class="tabledata"><input type="text" readonly id="add_percentage" name="add_percentage" size="5" value="<?php echo $s->getField('custom_duty','type','ADC','def_rate');?>" /><input type="text" id="adduty_<?php echo $i;?>" name="adduty1[]" style="width:70px;"  onFocus="cal_add_duty1(this.id);" value="<?php echo $row['adduty1']; ?>" onblur="cal_addcharg_total(this.id);"  / ></td>
	<?php } else { ?>
	
	<td class="tabledata"><select disabled name="Excise_Duty1[]" id="exciseDuty_<?php echo $i;?>" style="width:120px;" onchange="claculateExcise33(this.value,<?php echo $i; ?>)" onBlur="checkexiseflag(this.id)">
    	    <option value="">Select</option>
    	    <?php 
    	    $excise_sql=DB_query("Select * from custom_duty where type='custom'",$db);
			while($excise_row=DB_fetch_array($excise_sql))
			{?>
				<option value="<?php echo $excise_row['def_rate'];?>"<?php echo ($row['Excise_Duty1']==$excise_row['id'])?'selected':''?>><?php echo $excise_row['caption'];?></option>
			<?php 	
			}
    	    ?> 
  	      </select>
  	      <div id="exciseId_<?php echo $j;?>"></div>
      </td>
		  <td class="tabledata"><input disabled type="text"  id="dutyamount_<?php echo $i;?>" onFocus="checkduty(this.id)" name="duty_amount[]" style="width:70px;" onBlur="cal_custom_total(this.id)" readonly/></td><?php 
    	     $cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);
			 $k=1;
			 while($cessRow=DB_fetch_array($cessSql))
			 {
			 	$caption[$k]=$cessRow['caption']; 
				
				$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);
				while($rate_row=DB_fetch_array($rate_sql))
				{
					$rate[$k]=$rate_row['def_rate'];
				}
				$k++;
			 } 
    	     ?> 
		<td class="tabledata">
		<input type="text" id="cvd_percentage" disabled name="cvd_percentage" size="5" readonly value="<?php echo $s->getField('custom_duty','type','CVD','def_rate');?>" /><input type="text" disabled id="TotalSpecial_<?php echo $i;?>" name="TotalAmount1[]" style="width:70px;"  onBlur="cal_cvd_total(this.id);"/></td>
		<td class="tabledata"><input type="text" disabled id="ecess_percentage" name="ecess_percentage" readonly size="5" value="<?php echo $s->getField('custom_duty','type','ECESS','def_rate');?>" /><input type="text" disabled id="customecess_<?php echo $i;?>" name="custom_ecess1[]" style="width:70px;"/></td>
		<td class="tabledata"> <input type="text" disabled readonly id="secess_percentage" name="secess_percentage" size="5" value="<?php echo $s->getField('custom_duty','type','SHE-CESS','def_rate');?>" /><input type="text" disabled id="customsececess_<?php echo $i;?>" name="custom_sec_ecess1[]" style="width:70px;" onBlur="cal_ecess_sec_total(this.id);" /></td>
		<td class="tabledata"><input type="text" disabled readonly id="add_percentage" name="add_percentage" size="5" value="<?php echo $s->getField('custom_duty','type','ADC','def_rate');?>" /><input type="text" disabled id="adduty_<?php echo $i;?>" name="adduty1[]" style="width:70px;"  onFocus="cal_add_duty1(this.id);"  onblur="cal_addcharg_total(this.id);"  / ></td>
	<?php } ?>
</tr>
  <?php $i++; }	 ?>
  <input type="hidden" name="countval" value="<?php echo $i; ?>"  id="count"/>
</table>
 </div>
</td>
</tr>
</table>
<div style="clear:both"></div>
<div align="right" id="charges1">			
			<table width="40%">
			<tr><th>
		      <table width="100%" border="1" cellspacing="0" cellpadding="3">
                <tr>
                  <td><strong>BASIC AMOUNT<font color="#FF0000">*</font></strong> </td>
                  <td >
				 
				  <input type="text" name="total_item_amount" readonly id="total_item_amount" value="<?php echo $rowData['total_item_amount']; ?>" style="width:100%;" onFocus="cal_totalamount()" />
				  </td>
               </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_perc" id="pkg_perc" size="5" value="<?php echo $rowData['pkg_perc']; ?>" onKeyUp="calcPackaging12(this.value)" /><input name="pkg_charges" id="pkg_charges" value="<?php echo $rowData['pkg_charges']; ?>" readonly type="text" size="28"  
				 /></td>
                </tr>
                <tr>
                  <td><strong>Custom Duty</strong> </td>
              <td><input type="text" readonly name="custom_duty" value="<?php echo $rowData['custom_duty']; ?>" id="custom_duty" style="width:100%;" /></td>
              </tr>
              <tr>
              	<td><strong>CVD</strong></td>
              <td><div id="taxval">
                  <input type="text" readonly name="cvd_total" value="<?php echo $rowData['cvd_total']; ?>" id="cvd_total" style="width:100%;"/>
              </div>

	</td>
                </tr>
                <tr>
                  <td><strong>Custom E.Cess</strong> </td>
                  <td><input type="text" readonly name="custom_ecess1" value="<?php echo $rowData['custom_ecess1']; ?>" id="custom_ecess" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Custom SE.Cess</strong> </td>
                  <td><input type="text" name="custom_sec_ecesss" value="<?php echo $rowData['custom_sec_ecesss']; ?>" readonly id="custom_sec_ecess" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Additional Duty </strong> </td>
                  <td><input name="add_chargess" id="additionalCharges" value="<?php echo $rowData['add_chargess']; ?>" readonly type="text" size="25" style="width:100%;" /></td>
                </tr>
               <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="tot_freights" value="<?php echo $rowData['tot_freights']; ?>" onKeyUp="calTotFreight(this.value)"  id="TotalCharge2" style="width:100%;" /></td>
                </tr>
				 <tr>
                  <td><strong>Insurance</strong> </td>
                  <td><input type="text" name="insurance" value="<?php echo $rowData['insurance']; ?>" onKeyUp="calTotFreight(this.value)" id="insurance" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Clearing & Forwarding</strong> </td>
                  <td><input type="text" name="clearing" value="<?php echo $rowData['clearing']; ?>" onKeyUp="calTotFreight(this.value)" id="clearing" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Misc. Charges</strong> </td>
                  <td><input type="text" name="misCharge" value="<?php echo $rowData['misCharge']; ?>" onKeyUp="calTotFreight(this.value)" id="misCharge" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Handling Charges</strong> </td>
                  <td><input type="text" name="loadings" value="<?php echo $rowData['loadings']; ?>" onKeyUp="calTotHandling(this.value)" id="loading2" style="width:100%;"/></td>
                </tr>
                <tr>
				<td><strong>Grand Total <font color="#FF0000">*</font></strong></td>
                  <td><input type="text" name="grandtotals" value="<?php echo $rowData['grandtotals']; ?>" readonly id="GrandTotal" onFocus="cal_grandamount4()"  size="12"/><input type="hidden"  id="orig_grand_tot" />&nbsp;
				  <?php $flagRound = $s->getField('roundoff_flag','company_id',$_SESSION['ACGCompanyId'],'round_flag');

				  if($flagRound=='1')
				  { ?>
				  <input type="text" name="round_off" value="<?php echo $rowData['round_off']; ?>" id="pluMin"  size="5"/><input type="text" name="roundVal" id="roundVal" value="<?php echo $rowData['roundVal']; ?>" size="5" />&nbsp;
				 <?php  }
				 else
				 {
				  ?><strong>Round Off</strong>&nbsp;<select name="round_off" id="round_off" style="width:50px; height:20px" onChange="calcRounded(this.value)">
				  <option value="">None</option>
				  <option value="+"<?php echo ($rowData['round_off']=='+')?'selected':''?>>+</option>
				  <option value="-"<?php echo ($rowData['round_off']=='+')?'selected':''?>>-</option>
				  </select><input type="text" name="roundVal" value="<?php echo $rowData['roundVal']; ?>" id="roundVal1" size="5" /><?php } ?></td>
                </tr>
              </table>
		     </th>
		<td>		</td>
		</tr>
			</table>

</div>
<?php
}
elseif($rowData['po_type']==2 && $rowData['duty_type']=='Consolidated')
{ ?>
<div id="importPo4" style="width:950px;overflow:auto;">
<table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:1px solid #333333;">
      <tr class="row1">
        <td colspan="14" style="text-align:center;" class="tabledata1"><strong>Against :</strong>
            <input type="radio" name="calc_total_against" id="radio" value="bill" <?php if($rowData['calc_total_against']=='bill') { echo 'checked'; } else { echo ''; } ?> disabled="disabled" onclick="calculateAgainst3(this.value)" />
            <strong>Bill Qty</strong>
            <input type="radio" name="calc_total_against" id="radio2" <?php if($rowData['calc_total_against']=='received') { echo 'checked'; } else { echo ''; } ?> disabled="disabled" value="received" onclick="calculateAgainst3(this.value)"/>
            <strong>Received Qty</strong></td>
      </tr>
      <tr>
        <td class="tabledata"><strong>Sr.No.</strong></td>
        <td class="tabledata"><strong>Item Code</strong></td>
        <td class="tabledata"><strong>Description</strong></td>
        <td class="tabledata"><strong>UOM</strong></td>
        <td class="tabledata"><strong>PO QTY</strong></td>
        <td class="tabledata"><strong>Bill QTY</strong></td>
        <td class="tabledata"><strong>Recieved QTY</strong></td>
        <td class="tabledata"><strong>Short/Excess QTY</strong></td>
        <td class="tabledata"><strong>Rate</strong></td>
        <td class="tabledata"><strong>Amount</strong></td>
        <td class="tabledata" colspan="2" width="15%"><strong>Discount</strong></td>
        <td class="tabledata"><strong>Basic<br />
          Amt.</strong></td>
        <td class="tabledata"><strong>Currency</strong></td>
      </tr>
      <?php 
$i=0;
$sql=DB_query("select * from purchase_verification_details where parent_id='".$rowData['id']."'",$db);
while($row=DB_fetch_array($sql))
{
	$itemcode=$s->getField('item_master','id',$row['mst_itemid'],'StockID');
	$itemname=$s->getField('item_master','id',$row['mst_itemid'],'item_name');
	$unit=$s->getField('item_master','id',$row['mst_itemid'],'mst_unitid');
$oldCur = $s->getField('direct_po_details','id',$row['details_id'],'currency');
?>
      <tr bgcolor="#c1c1c1">
        <td><?php echo $i+1;?></td>
        <td><?php echo $itemcode;?>
            <input type="hidden" readonly="" id="mst_itemid[]" name="mst_itemid[]" size="15" value="<?php echo $row['mst_itemid']; ?>" />
            <input type="hidden" readonly="" id="itemcode[]" name="itemcode[]" size="15"  value="<?php echo $itemcode; ?>" />
            <input type="hidden" readonly="" id="tolrancees[]" name="tolrancees[]" size="15"  value="<?php echo $tolerance; ?>" />
            <input type="hidden" readonly="" id="pending[]" name="pending[]" size="15"  value="<?php echo $pending_qty; ?>" />
        </td>
         <td><?php echo $itemname ?></td>
        <td><?php $unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
	echo $unitname;?></td>
        <td><?php   echo $poqty=$row['poqty']; ?>
            <input name="poqty[]" type="hidden" id="poqty[]" value="<?php echo $poqty;?>" size="10"/></td>
        <td><input name="qty_as_per_bill[]" type="text" id="qty_as_per_bill_<?php echo $i; ?>" value="<?php echo $row['qty_as_per_bill'];?>"  size="8" readonly onblur="check_bill_qty(this.value,<?php echo $i;?>)"/>
        </td>
        <td><input name="reciveqty[]" readonly type="text" id="reciveqty_<?php echo $i; ?>" value="<?php echo $row['reciveqty'];?>" style="width:100%;"/></td>
        <td><input name="short_accessid[]" type="text" id="short_accessid[]" value="<?php echo $row['short_accessid'];?>" size="8" readonly="true" onfocus="calculate_poshort(<?php echo $i ?>);"/></td>
        <td><input name="itemrate[]" type="text" id="itemrate_<?php echo $i; ?>" value="<?php echo $row['itemrate']; ?>"  size="8" readonly="true"/>
        </td>
        <td><input name="itemamount[]" readonly type="text" id="itemamount_<?php echo $i; ?>" value="<?php echo $row['itemamount']; ?>" onfocus="calculateAmuunt(<?php echo $i; ?>)"  size="8"/>
        </td> 
               <td class="tabledata"><input type="text" readonly value="<?php echo $row['discount']; 
		?>" name="discount[]" onkeyup="DiscountAmounts(this.value,<?php echo $i; ?>)" size="8" id="Discount1_<?php echo $i; ?>"/>
        </td>
        <td><input name="DiscountType1[]" type="hidden" id="PerAmo_<?php echo $i; ?>" value="<?php echo $row['DiscountType1']; 
		?>" size="8" readonly />
		<input  name="DiscountType[]" type="text"  id="PerAmo_<?php echo $i; ?>" value="<?php if($row['DiscountType1']=='Amount')
		{ echo 'Amt'; } else { echo '%'; }
		?>" size="8" readonly/>
	</td>
       <td class="tabledata"><input type="text" style="width:70px" id="basic_<?php echo $i; ?>" value="<?php echo $row['basic']; ?>" name="basic[]" readonly/></td>
       <td><input name="itemCurrency[]" type="hidden" id="itemCurrency_<?php echo $i; ?>" value="<?php echo $row['itemCurrency'];?>" size="8" readonly />
		<input name="itemCurrencyread[]" type="text" id="itemCurrencyname_<?php echo $i; ?>" value="<?php echo $s->getField('currency_master','id',$row['itemCurrency'],'abbreviation');
		?>" size="8" readonly/>
	</td>
      </tr>
      <?php $i++; }	 ?>
      <input type="hidden" name="countval" value="<?php echo $i; ?>"  id="count"/>
    </table>
</div>
 <div align="right" id="charges4">	
		<table width="40%">
			<tr><th>
			  <table width="100%" border="0" cellspacing="2" cellpadding="2">

                <tr>
                  <td><strong>TOTAL BASIC AMOUNT</strong> </td>
                  <td ><input type="text" name="total_item_amount" id="total_item_amount" style="width:100%;" onFocus="cal_totalamount()" value="<?php echo $rowData['total_item_amount']; ?>"/></td>
               </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_perc" id="pkg_perc4"  size="5" value="<?php echo $rowData['pkg_perc']; ?>" onkeyup="calcPackagingdDC(this.value)" /><input name="pkg_charges" id="pkg_charges" value="<?php echo $rowData['pkg_charges']; ?>" type="text"  size="28" /></td>
                </tr>
				<tr>
                  <td><strong>Total Excise Amt</strong> </td>
                  <td><select name="tot_excise_amt" id="exciseDutyTot" style="width:120px;" onChange="claculateExcise2(<?php echo $i; ?>,this.value)" onFocus="checkexiseflag1(<?php echo $i; ?>)">
	<option value="">Select</option>
	<?php 
	$excise_sql=DB_query("Select * from excise_tax where caption like '%excise%' and form_type='Purchase'",$db);
	while($excise_row=DB_fetch_array($excise_sql))
	{
	$c='';
	if($rowData['tot_excise_amt']==$excise_row['id'])
	$c='selected';
	?>
	<option value="<?php echo $excise_row['id'];?>"<?php echo $c; ?>><?php echo $excise_row['caption'];?></option>
	<?php 	
	}
	?> 
	</select><div id="exciseIdTot">
	<input name="excise_perc" id="ExcisePercentageTot" type="text" value="<?php echo $rowData['excise_perc']; ?>"  style="width:35px;;"  /> 
	<input name="exciseValue" id="exciseValueTot" type="text"  style="width:70px;" value="<?php echo $rowData['exciseValue']; ?>" onFocus="calculateExciseDuty2(<?php echo $i; ?>)" />
	</div></td>
                </tr>
				<tr>
                  <td><strong>Total E.Cess Amt</strong> </td>
                  <?php 
	$cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);
	$k=1;
	while($cessRow=DB_fetch_array($cessSql))
	{
	$caption[$k]=$cessRow['caption']; 
	
	$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);
	while($rate_row=DB_fetch_array($rate_sql))
	{
	$rate[$k]=$rate_row['def_rate'];
	}
	$k++;
	} 
	?>
	<td><input name="e_cess_perc" id="ECessPercentageTot" type="text" value="<?php echo $rate[1];?>"  style="width:35px;" readonly   />
	<input name="tot_ecess_amt" id="ECessValueTot" type="text" value="<?php echo $rowData['tot_ecess_amt']; ?>"  style="width:70px;" readonly onFocus="calculateECess2()"/></td>
                </tr>
				<tr>
				<td><strong>Total SE.Cess Amt</strong> </td>
				<td><input name="sahecess_per" id="SAHCessPercentageTot" type="text" value="<?php echo $rate[2];?>" style="width:35px;" readonly/>
	<input name="tot_sahecess_amt" id="SAHCessValueTot" type="text" value="<?php echo $rowData['tot_sahecess_amt']; ?>"  style="width:65px;" onFocus="calculateSAHCess2()"/></td>
                </tr>
				 <tr>

                  <td><strong>Additional Charges</strong> </td>

                  <td><input name="add_chargess" id="additionalCharges1" value="<?php echo $rowData['add_chargess']; ?>" type="text"  size="25" style="width:100%;" /></td>

                </tr>
				<tr>
				<td><strong>Total Excise Duty Amt</strong> </td>

                  <td><input type="text" name="tot_excise_duty_amt" value="<?php echo $rowData['tot_excise_duty_amt']; ?>" id="tot_excise_duty_amt3" size="5" onFocus="calcexciseduty3(this.value)" /></td>

                </tr>
				
				<td><strong>Total Taxable Amt</strong> </td>

                  <td><input type="text" name="tot_taxable_amt" value="<?php echo $rowData['tot_taxable_amt']; ?>" id="tot_taxable_amt3" size="5" onFocus="calctaxamt3(this.value)" /></td>

                </tr>

                <tr>

                  <td><strong>Input Tax </strong> </td>

                  <?php

				$Taxsql='SELECT salestax_id,tax_code, taxrate FROM sales_tax_master';


				$Taxresult=DB_query($Taxsql,$db);

     	?>

              <td><select id="taxname1" name="vat_cst" onChange="tax_rate3(this.value)" style="width:100%;">

	          <option value="0">---Select---</option>

                  <?php 

			while($Taxmyrow=DB_fetch_array($Taxresult)){

			?>

                  <option  value="<?php echo $Taxmyrow['salestax_id']; ?>"<?php echo ($rowData['vat_cst']==$Taxmyrow['salestax_id']?'selected':'')?>><?php echo $Taxmyrow['tax_code']." --- ".$Taxmyrow['taxrate']."%"; ?></option>

                  <?php } ?>

              </select></td>

 

              </tr>
              <tr>
              	<td><strong>Tax Value</strong></td>
              <td><div id="taxval3">
                  <input type="text" name="taxvalue"  value="<?php echo $rowData['taxvalue']; ?>" id="taxvalue2" style="width:100%;"  readonly="true"/>
              </div>
	</td>
                </tr>
                <tr>
                  <td><strong>Surcharge Amount</strong> </td>
                  <td><input type="text" name="sur_oct_per" onkeyup="cal_grandamountssur()" value="<?php echo $rowData['sur_oct_per']; ?>" id="sur_oct_per3"  size="10" /><input name="sur_oct_amt" type="text" value="<?php echo $rowData['sur_oct_amt']; ?>" readonly id="sur_oct_amt3"   style="width:60%;" /></td>

                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="tot_freights" value="<?php echo $rowData['tot_freights']; ?>" onkeyup="cal_grandamounts3()" id="TotalCharge1" style="width:100%;" /></td>
                </tr>
				 <td><strong>Loading/Unloading</strong> </td>
                  <td><input type="text" name="loadings" value="<?php echo $rowData['loadings']; ?>" onkeyup="cal_grandamounts3()" id="loading1" style="width:100%;" /></td>
                </tr>
                <tr>
				<td><strong>Grand Total</strong></td>
                  <td>
				  <input type="text" name="grandtotals" value="<?php echo $rowData['grandtotals']; ?>" id="GrandTotal" readonly onFocus="cal_grandamounts3()"  size="12" />
				  <input type="hidden"  id="orig_grand_tot" value=""/>&nbsp;
				  <?php $flagRound = $s->getField('roundoff_flag','company_id',$_SESSION['ACGCompanyId'],'round_flag');

				  if($flagRound=='1')
				  { ?>
				  <input type="text" name="round_off" value="<?php echo $rowData['round_off']; ?>" id="pluMin"  size="5"/><input type="text" name="roundVal" value="<?php echo $rowData['roundVal']; ?>" id="roundVal" size="5" />&nbsp;
				 <?php  }
				 else
				 {
				  ?><strong>Round Off</strong>&nbsp;<select name="round_off" id="round_off" style="width:50px; height:20px" onChange="calcRounded(this.value)">
				  <option value="">None</option>
				  <option value="+"<?php echo ($rowData['round_off']=='+')?'selected':''?>>+</option>
				  <option value="-"<?php echo ($rowData['round_off']=='+')?'selected':''?>>-</option>
				  </select><input type="text" name="roundVal" value="<?php echo $rowData['roundVal']; ?>" id="roundVal1" size="5" /><?php } ?></td>
                </tr>
              </table>
		     </th>
		<td></td>
		</tr>
   </table>
</div>
<?php
}elseif($rowData['po_type']==2 && $rowData['duty_type']=='Itemwise')
{ ?>
<div id="importPo2" style="width:950px;overflow:auto; display:block;">
<table width="232%" border="1" cellspacing="0" cellpadding="3" style="border:1px solid #333333;">
<tr class="row1">
	<td colspan="4" style="text-align:center;" class="tabledata1">
	<strong>Against :</strong>
	<input type="radio" name="calc_total_against" id="radio" value="bill" <?php if($rowData['calc_total_against']=='bill') { echo 'checked'; } else { echo ''; } ?> disabled="disabled" onclick="calculateAgainst3('bill')" />
	<strong>Bill Qty</strong> 
	<input type="radio" name="calc_total_against" id="radio2" value="received" <?php if($rowData['calc_total_against']=='received') { echo 'checked'; } else { echo ''; } ?> disabled="disabled" onclick="calculateAgainst3('rec')"/>
	<strong>Received Qty</strong></td>
</tr>
<tr>
	<td class="tabledata"><strong>Sr.No.</strong></td>
	<td class="tabledata"><strong>Item Code</strong></td>
	<td class="tabledata"><strong>Description</strong></td>
	<td class="tabledata"><strong>UOM</strong></td>
	<td class="tabledata"><strong>PO QTY</strong></td>
	<td class="tabledata"><strong>Bill QTY</strong></td>
	<td class="tabledata"><strong>Recieved QTY</strong></td>
	<td class="tabledata"><strong>Short/Excess QTY</strong></td>
	<td class="tabledata"><strong>Rate</strong></td>
	<td class="tabledata"><strong>Amount</strong></td>
	<td class="tabledata" colspan="2" width="15%"><strong>Discount</strong></td>
	<td class="tabledata"><strong>Basic<br />
	  Amt.</strong></td>
	<th ><strong>EXCISE FLAG</strong></th>
	<th ><strong>EXCISE</strong></th>
	<th ><strong>E-CESS</strong></th>
	<th ><strong>SE-CESS</strong></th>
	<th ><strong>Excise Amount</strong></th>
	<th ><strong>Total Amount</strong></th>
	<th ><strong>REMARKS </strong></th>
  </tr>
  <?php 
$i=0;
$sql=DB_query("select * from purchase_verification_details where parent_id='".$rowData['id']."'",$db);
while($row=DB_fetch_array($sql))
{
	$itemcode=$s->getField('item_master','id',$row['mst_itemid'],'StockID');
	$itemname=$s->getField('item_master','id',$row['mst_itemid'],'item_name');
	$tolerance=$s->getField('item_master','id',$row['mst_itemid'],'tolerance');
	$unit=$s->getField('item_master','id',$row['mst_itemid'],'mst_unitid');
?>
<tr bgcolor="#c1c1c1">
        <td><?php echo $i+1;?></td>
        <td><?php echo $itemcode;?>
            <input type="hidden" readonly="" id="mst_itemid[]" name="mst_itemid[]" size="15" value="<?php echo $row['mst_itemid']; ?>" />
            <input type="hidden" readonly="" id="itemcode[]" name="itemcode[]" size="15"  value="<?php echo $itemcode; ?>" />
            <input type="hidden" readonly="" id="tolrancees[]" name="tolrancees[]" size="15"  value="<?php echo $tolerance; ?>" />
            <input type="hidden" readonly="" id="pending[]" name="pending[]" size="15"  value="<?php echo $pending_qty; ?>" />
        </td>
        <td><?php echo $itemname ?></td>
        <td><?php $unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
	echo $unitname;?></td>
        <td><?php   echo $poqty=$row['poqty']; ?>
            <input name="poqty[]" type="hidden" id="poqty[]" value="<?php echo $poqty;?>" size="10"/></td>
        <td><input name="qty_as_per_bill[]" type="text" id="qty_as_per_bill_<?php echo $i; ?>" value="<?php echo $row['qty_as_per_bill'];?>"  size="8" readonly onblur="check_bill_qty(this.value,<?php echo $i;?>)"/>
        </td>
        <td><input name="reciveqty[]" readonly type="text" id="reciveqty_<?php echo $i; ?>" value="<?php echo $row['reciveqty'];?>" style="width:100%;"/></td>
        <td><input name="short_accessid[]" type="text" id="short_accessid[]" value="<?php echo $row['short_accessid'];?>" size="8" readonly="true" onfocus="calculate_poshort(<?php echo $i ?>);"/></td>
        <td><input name="itemrate[]" type="text" id="itemrate_<?php echo $i; ?>" value="<?php echo $row['itemrate']; ?>"  size="8" readonly="true"/>
        </td>
        <td><input name="itemamount[]" readonly type="text" id="itemamount_<?php echo $i; ?>" value="<?php echo $row['itemamount']; ?>" onfocus="calculateAmuunt(<?php echo $i; ?>)"  size="8"/>
        </td> 
               <td class="tabledata"><input type="text" readonly value="<?php echo $row['discount']; 
		?>" name="discount[]" onkeyup="DiscountAmounts(this.value,<?php echo $i; ?>)" size="8" id="Discount1_<?php echo $i; ?>"/>
        </td>
        <td><input name="DiscountType1[]" type="hidden" id="PerAmo_<?php echo $i; ?>" value="<?php echo $row['DiscountType1']; 
		?>" size="8" readonly />
		<input  name="DiscountType[]" type="text"  id="PerAmo_<?php echo $i; ?>" value="<?php if($row['DiscountType1']=='Amount')
		{ echo 'Amt'; } else { echo '%'; }
		?>" size="8" readonly/>
	</td>
       <td class="tabledata"><input type="text" style="width:70px" id="basic_<?php echo $i; ?>" value="<?php echo $row['basic']; ?>" name="basic[]" readonly/></td>
	<td><select name="billing_type[]" style="width:85px" id="billing_type_<?php echo $i;?>"  onchange="checkExcisable1(this.value,<?php echo $i; ?>)">
	<option value="">Select</option>
	<option value="NonExcisable"<?php if($row['tax_type']=='NonExcisable') { ?> selected="selected" <?php } ?>>NonExcisable</option>
	<option value="Excisable" <?php if($row['tax_type']=='Excisable') { ?> selected="selected" <?php } ?>>Excisable</option>
	<option value="IncludeTax" <?php if($row['tax_type']=='IncludeTax') { ?> selected="selected" <?php } ?>>IncludeTax</option>
	</select></td>
	<td><select name="Excise_Duty1[]" id="exciseDuty_<?php echo $i;?>" style="width:120px;" onChange="claculateExcise1(<?php echo $i; ?>,this.value)" onFocus="checkexiseflag1(<?php echo $i; ?>)">
	<option value="">Select</option>
	<?php 
	$excise_sql=DB_query("Select * from excise_tax where caption like '%excise%' and form_type='Purchase'",$db);
	while($excise_row=DB_fetch_array($excise_sql))
	{
	$c='';
	if($row['Excise_Duty1']==$excise_row['id'])
	$c='selected';
	?>
	<option value="<?php echo $excise_row['id'];?>"<?php echo $c; ?>><?php echo $excise_row['caption'];?></option>
	<?php 	
	}
	?> 
	</select><div id="exciseId_<?php echo $i; ?>">
	<input name="excise_perc[]" id="ExcisePercentage_<?php echo $i; ?>" value="<?php echo $row['excise_perc']; ?>" type="text" style="width:35px;;"  /> 
	<input name="excise_val[]" id="exciseValue_<?php echo $i; ?>" type="text" value="<?php echo $row['excise_val']; ?>"  style="width:70px;" onFocus="calculateExciseDuty1(<?php echo $i; ?>)" />
	</div></td>
	<?php 
	$cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);
	$k=1;
	while($cessRow=DB_fetch_array($cessSql))
	{
	$caption[$k]=$cessRow['caption']; 
	
	$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);
	while($rate_row=DB_fetch_array($rate_sql))
	{
	$rate[$k]=$rate_row['def_rate'];
	}
	$k++;
	} 
	?>
	<td><input name="e_cess_perc[]" id="ECessPercentage_<?php echo $i;?>" type="text" value="<?php echo $rate[1];?>" style="width:35px;" readonly   />
	<input name="e_cess_val[]" id="ECessValue_<?php echo $i;?>" type="text" value="<?php echo $row['e_cess_val']; ?>"  style="width:70px;" readonly onFocus="calculateECess1(<?php echo $i; ?>)"/></td>
	<td><input name="sah_perc[]" id="SAHCessPercentage_<?php echo $i;?>" type="text" value="<?php echo $rate[2];?>" style="width:35px;" readonly/>
	<input name="sah_val[]" id="SAHCessValue_<?php echo $i;?>" type="text" value="<?php echo $row['sah_val']; ?>"  style="width:65px;" readonly onFocus="calculateSAHCess1(<?php echo $i; ?>)"/></td>
	
	<td><input name="taxableamount[]" type="text" id="taxableamount_<?php echo $i?>"  size="12" value="<?php echo $row['taxableamount']; ?>"  onfocus="caltaxamout1(<?php echo $i;?>)" /></td>
	
	<td><input name="val_after_disc[]" type="text" id="total_<?php echo $i?>" value="<?php echo $row['val_after_disc']; ?>" size="12" readonly="true" onFocus="value_after_discount1(<?php echo $i ?>);"/></td>
	
	
	<td><input type="text" name="remarks[]" id="remarks"  value="<?php echo $row['remarks']; ?>"/></td>
	
</tr>
  <?php $i++; }	 ?>
  <input type="hidden" name="countval" value="<?php echo $i; ?>"  id="count"/>

</table>
</div>
 <div align="right" id="charges2">			
			<table width="40%">
			<th>
			  <table width="100%" border="0" cellspacing="2" cellpadding="2">

                <tr>

                  <td><strong>TOTAL BASIC AMOUNT</strong> </td>

                  <td ><input type="text" name="total_item_amount" value="<?php echo $rowData['total_item_amount']; ?>" id="total_item_amount" style="width:100%;" onFocus="cal_totalamount()" /></td>

               </tr>

              <tr>

                  <td><strong>Pkg Charges</strong> </td>

                  <td><input type="text" name="pkg_perc" value="<?php echo $rowData['pkg_perc']; ?>" id="pkg_perc" size="5" onkeyup="calcPackaging2(this.value)" /><input name="pkg_charges" id="pkg_charges" type="text" value="<?php echo $rowData['pkg_charges']; ?>" size="28" /></td>

                </tr>
				
				<tr>

                  <td><strong>Total Excise Amt</strong> </td>

                  <td><input type="text" name="tot_excise_amt" id="tot_excise_amt" value="<?php echo $rowData['tot_excise_amt']; ?>" size="5" onFocus="calcexcise2(this.value)" /></td>

                </tr>
				<tr>

                  <td><strong>Total E.Cess Amt</strong> </td>

                  <td><input type="text" name="tot_ecess_amt" id="tot_ecess_amt" value="<?php echo $rowData['tot_ecess_amt']; ?>" size="5" onFocus="calcecess2(this.value)" /></td>

                </tr>
				<td><strong>Total SE.Cess Amt</strong> </td>

                  <td><input type="text" name="tot_sahecess_amt" id="tot_sahecess_amt" value="<?php echo $rowData['tot_sahecess_amt']; ?>" size="5" onFocus="calcsahecess2(this.value)" /></td>

                </tr>
				<tr>

                  <td><strong>Additional Charges</strong> </td>

                  <td><input name="add_chargess" id="additionalCharges" type="text" value="<?php echo $rowData['add_chargess']; ?>" size="25" style="width:100%;" /></td>

                </tr>
				</tr>
				<td><strong>Total Excise Duty Amt</strong> </td>

                  <td><input type="text" name="tot_excise_duty_amt" value="<?php echo $rowData['tot_excise_duty_amt']; ?>" id="tot_excise_duty_amt" size="5" onFocus="calcexciseduty2(this.value)" /></td>

                </tr>
				</tr>
				<td><strong>Total Taxable Amt</strong> </td>

                  <td><input type="text" name="tot_taxable_amt" value="<?php echo $rowData['tot_taxable_amt']; ?>" id="tot_taxable_amt" size="5" onFocus="calctaxamt2(this.value)" /></td>

                </tr>

                <tr>

                  <td><strong>Input Tax </strong> </td>

                  <?php

				$Taxsql='SELECT salestax_id,tax_code, taxrate FROM sales_tax_master';

				$Taxresult=DB_query($Taxsql,$db);

     	?>

              <td><select id="taxname" name="vat_cst" onChange="tax_rate(this.value)" style="width:100%;">

	          <option value="0">---Select---</option>

                  <?php 

			while($Taxmyrow=DB_fetch_array($Taxresult)){

			?>

                  <option  value="<?php echo $Taxmyrow['salestax_id']; ?>"<?php echo ($rowData['vat_cst']==$Taxmyrow['salestax_id']?'selected':'')?>><?php echo $Taxmyrow['tax_code']." --- ".$Taxmyrow['taxrate']."%"; ?></option>

                  <?php } ?>

              </select></td>

 

              </tr>

              <tr>

              	<td><strong>Tax Value</strong></td>

              <td><div id="taxval">

                  <input type="text" name="taxvalue" value="<?php echo $rowData['taxvalue']; ?>" id="taxvalue2" style="width:100%;" readonly="true"/>

              </div>



	</td>

                </tr>

                <tr>

                  <td><strong>Surcharge Amount</strong> </td>

                  <td><input type="text" name="sur_oct_per" id="sur_oct_per" value="<?php echo $rowData['sur_oct_per']; ?>" size="10" onkeyup="calsuroctamt2(this.value)" /><input name="sur_oct_amt" value="<?php echo $rowData['sur_oct_amt']; ?>" type="text" id="sur_oct_amt" style="width:60%;" /></td>

                </tr>

                <tr>

                  <td><strong>Freight</strong> </td>

                  <td><input type="text" name="tot_freights" value="<?php echo $rowData['tot_freights']; ?>" id="TotalCharge" onkeyup="cal_grandamounts2(this.value)" style="width:100%;" /></td>

                </tr>

				 <td><strong>Handling Charges</strong> </td>

                  <td><input type="text" name="loadings" value="<?php echo $rowData['loadings']; ?>" id="loading" onkeyup="cal_grandamounts2(this.value)" style="width:100%;" /></td>

                </tr>
                <tr>

				<td><strong>Grand Total</strong></td>

                  <td>
				  <input type="text" name="grandtotals" value="<?php echo $rowData['grandtotals']; ?>" id="GrandTotal" onFocus="cal_grandamounts2()"  size="12" />
				  <input type="hidden"  id="orig_grand_tot" value=""/>&nbsp;
				  <?php $flagRound = $s->getField('roundoff_flag','company_id',$_SESSION['ACGCompanyId'],'round_flag');

				  if($flagRound=='1')
				  { ?>
				  <input type="text" name="round_off" value="<?php echo $rowData['round_off']; ?>" id="pluMin"  size="5"/><input type="text" name="roundVal" value="<?php echo $rowData['roundVal']; ?>"  id="roundVal" size="5" />&nbsp;
				 <?php  }
				 else
				 {
				  ?><strong>Round Off</strong>&nbsp;<select name="round_off" id="round_off" style="width:50px; height:20px" onChange="calcRounded(this.value)">
				  <option value="">None</option>
				  <option value="+"<?php echo ($rowData['round_off']=='+')?'selected':''?>>+</option>
				  <option value="-"<?php echo ($rowData['round_off']=='-')?'selected':''?>>-</option>
				  </select><input type="text" name="roundVal" value="<?php echo $rowData['roundVal']; ?>" id="roundVal1" size="5" /><?php } ?></td>

                </tr>

              </table>
		     </th>
		<td></td>
		</tr>
			</table>
</div>
<?php 
}
?>
   <div align="center">
   <input type="submit" name="Save" class="search" value="Update"/>
   </div>
</form>
<script language="javascript" type="text/javascript">
	
function cal_totalbasicamount()
{
	var totalbas=0;
	var tt=document.getElementById("count").value;

	for(var i=1;i<tt;i++)
	{
		var basamt=parseFloat(document.getElementById("basic_"+i).value);
		if(isNaN(basamt)){basamt=0;}
		totalbas=parseFloat(totalbas)+basamt;	
	}	
	document.getElementById("total_basic_amount").value=totalbas.toFixed(2);	

}	


function showdata(str)
{

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	var data=xmlhttp.responseText.split("__");	
	//alert(data);
	document.getElementById("vender").innerHTML=data[0];
    document.getElementById("hid-Godown-div").innerHTML=data[1];
	
    }
  }

xmlhttp.open("GET","purchasebillnogenerate.php?site="+str,true);
xmlhttp.send();
}	
function DiscountAmount(DA,i)
{
	
	var discount_percent = document.getElementById("PerAmo_"+i).value;
	
	var rate = document.getElementById("Rate_"+i).value;
	var discount = document.getElementById("Discount_"+i).value;
	var quantity = document.getElementById("Quantity_"+i).value;
	//var totalPrice = quantity*rate;
	var totalPrice = document.getElementById("totalValue_"+i).value;
	
	if(discount_percent=='PercentAmt')
	{
		if(discount==''){discount=0;}
		var percent = parseFloat(totalPrice) * parseFloat(discount)/100;
		var subTotal = parseFloat(totalPrice)-parseFloat(percent);
	}
	else if(discount_percent=='Amount')
	{
		var percent = parseFloat(document.getElementById("Discount_"+i).value);
		if(isNaN(percent)){percent=0;}
		var subTotal = parseFloat(totalPrice)-parseFloat(percent);
	}
	document.getElementById("perc_"+i).value=percent.toFixed(2);
	document.getElementById("NetRate_"+i).value=subTotal.toFixed(2);
	
	/*Total=parseFloat(Total) + parseFloat(subTotal);
	document.getElementById("Total").value=Total;*/
	//return true;
}	

function checkamount(str,i)
{
	
var k=parseFloat(document.getElementById("totalValue_"+i).value);

var t=parseFloat(str);
if(t>k)
{
alert("Discount Amount Not Greater Then Rate");
document.getElementById("Discount_"+i).value='';
document.getElementById("NetRate_"+i).value='';
document.getElementById("perc_"+i).value='';
document.getElementById("Discount_"+i).focus();	
}	
}
function checkspecialamt(str,i)
{
var k=parseFloat(document.getElementById("NetRate_"+i).value);

var t=parseFloat(str);
if(t>k)
{
alert("Special Discount Amount Not Greater Then Sub Total");
document.getElementById("SpecialDiscount_"+i).value='';
document.getElementById("Specialperc_"+i).value='';
document.getElementById("basic_"+i).value='';
document.getElementById("SpecialDiscount_"+i).focus();	
}		
	
	
	
	
}	

function DiscountAmountspe(DA,i)
{
	
	
	var total1=document.getElementById("NetRate_"+i).value;
	
	var discount1 = document.getElementById("SpecialDiscount_"+i).value;
	var Specialperc=document.getElementById("Specialperc_"+i).value;
	
	if(discount1=='' && Specialperc=='')
	{
		var total1=document.getElementById("NetRate_"+i).value;
		
		document.getElementById("basic_"+i).value=total1;
	
	}
	else
	{
		if(discount1=='' && Specialperc!='')
		{
			var elx=document.getElementById("Specialperc_"+i).value;
			var total1=document.getElementById("NetRate_"+i).value;
			
			var TotalAmount2 = total1-parseFloat(elx);
			
			document.getElementById("basic_"+i).value=TotalAmount2.toFixed(2);
		}
		else
		{
			var percent1 = total1 * parseFloat(discount1)/100;
			var TotalAmount2 = total1-parseFloat(percent1);
	
			document.getElementById("Specialperc_"+i).value=percent1.toFixed(2);
			document.getElementById("basic_"+i).value=TotalAmount2.toFixed(2);
		}
	
	}
}

function checkExcisable(str,i)
{
 	
	if(str=='NonExcisable')
	{
		document.getElementById("ExcisePercentage_"+i).disabled=true;
		document.getElementById("exciseDuty_"+i).disabled=true;
		document.getElementById("exciseValue_"+i).disabled=true;
		document.getElementById("cess_ID1_"+i).disabled=true;
		document.getElementById("cess_ID2_"+i).disabled=true;
		document.getElementById("ECessPercentage_"+i).disabled=true;
		document.getElementById("ECessValue_"+i).disabled=true;
		document.getElementById("SAHCessPercentage_"+i).disabled=true;
		document.getElementById("SAHCessValue_"+i).disabled=true;
		document.getElementById("taxable_amt_"+i).disabled=true;
		
		document.getElementById("exciseDuty_"+i).value='';
		document.getElementById("exciseValue_"+i).value='';
		//document.getElementById("ECessPercentage_"+i).value='';
		document.getElementById("ECessValue_"+i).value='';
		//document.getElementById("SAHCessPercentage_"+i).value='';
		document.getElementById("SAHCessValue_"+i).value='';
		document.getElementById("taxable_amt_"+i).value='';
		document.getElementById("ExcisePercentage_"+i).value='';
	//	document.getElementById("taxvalue").disabled=true;
		//document.getElementById("sur_oct_perc").disabled=true;
		//document.getElementById("sur_oct_amt").disabled=true;
	}
	else if(str=='Excisable' || str==0)
	{
		document.getElementById("exciseDuty_"+i).disabled=false;
		document.getElementById("exciseValue_"+i).disabled=false;
		document.getElementById("ECessPercentage_"+i).disabled=false;
		document.getElementById("ECessValue_"+i).disabled=false;		
		document.getElementById("SAHCessPercentage_"+i).disabled=false;
		document.getElementById("cess_ID1_"+i).disabled=false;
		document.getElementById("cess_ID2_"+i).disabled=false;
	
		document.getElementById("SAHCessValue_"+i).disabled=false;
		document.getElementById("taxable_amt_"+i).disabled=false;
		document.getElementById("taxname_"+i).disabled=false;
		document.getElementById("taxvalue_"+i).disabled=false;
		document.getElementById("sur_oct_perc_"+i).disabled=false;
		document.getElementById("sur_oct_amt_"+i).disabled=false;
		
		document.getElementById("TotalCharge_"+i).disabled=false;
		document.getElementById("packagingCharges_"+i).disabled=false;
		document.getElementById("additionalCharges_"+i).disabled=false;
		document.getElementById("roundOff_"+i).disabled=false;	
		
		
	}
	else{
		document.getElementById("exciseDuty_"+i).disabled=true;
		document.getElementById("exciseValue_"+i).disabled=true;
		document.getElementById("ECessPercentage_"+i).disabled=true;
		document.getElementById("ECessValue_"+i).disabled=true;
		document.getElementById("SAHCessPercentage_"+i).disabled=true;
		document.getElementById("cess_ID1_"+i).disabled=true;
		document.getElementById("cess_ID2_"+i).disabled=true;
		document.getElementById("SAHCessValue_"+i).disabled=true;
		document.getElementById("taxable_amt_"+i).disabled=true;
		document.getElementById("taxname_"+i).disabled=true;
		document.getElementById("taxvalue_"+i).disabled=true;
		document.getElementById("sur_oct_perc_"+i).disabled=true;
		document.getElementById("sur_oct_amt_"+i).disabled=true;
		document.getElementById("TotalCharge_"+i).disabled=true;
		document.getElementById("packagingCharges_"+i).disabled=true;
		document.getElementById("additionalCharges_"+i).disabled=true;
		document.getElementById("roundOff_"+i).disabled=true;

		document.getElementById("exciseDuty_"+i).value='';
		document.getElementById("exciseValue_"+i).value='';
		document.getElementById("ECessPercentage_"+i).value='';
		document.getElementById("ECessValue_"+i).value='';
		document.getElementById("SAHCessPercentage_"+i).value='';
		document.getElementById("SAHCessValue_"+i).value='';
		document.getElementById("taxable_amt_"+i).value='';
		document.getElementById("taxname_"+i).value='';
		document.getElementById("taxvalue_"+i).value='';
		document.getElementById("sur_oct_perc_"+i).value='';
		document.getElementById("sur_oct_amt_"+i).value='';
		document.getElementById("TotalCharge_"+i).value='';
		document.getElementById("packagingCharges_"+i).value='';
		document.getElementById("additionalCharges_"+i).value='';
		document.getElementById("roundOff_"+i).value='';


	
	}
	document.getElementById("hid_billing_type_"+i).value=str;
}

function checkexiseflag(i)
{
	
if(document.getElementById("hid_billing_type_"+i).value=='')
	{
	alert("Must Select Tax Type");
	}	
	
}
function cal_totalamount()
{
	if ( ( document.getElementById("radio").checked == false ) && ( document.getElementById("radio2").checked == false ) )
{
alert ( "Please choose Recieved Against" );
return false;
}

var total=0;
var t=document.getElementById("count").value;
for(var i=0;i<t;i++)
{
var amt=parseFloat(document.getElementById("basic_"+i).value);
if(isNaN(amt)){amt=0;}
total=parseFloat(total)+amt;	
}	
document.getElementById("total_item_amount").value=total.toFixed(2);	

var totaltax=document.getElementById("tot_taxable_amt3").value;
	var taxamt=document.getElementById("taxvalue2").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt3").value;
	var TotalCharge=document.getElementById("TotalCharge1").value;
	var loading=document.getElementById("loading1").value;
	
	
	

	if(totaltax==''){totaltax=0;}
	if(taxamt==''){taxamt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(loading==''){loading=0;}
	
	

	var grandtotal=parseFloat(totaltax)+parseFloat(taxamt)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(loading);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
	
	var GrandTotAmt = document.getElementById("GrandTotal").value;
var gtotal_brk=GrandTotAmt.split('.');
	if(gtotal_brk[1]>=50)
	{
	var finalAmt=parseInt(gtotal_brk[0])+1;
	}
	else if(gtotal_brk[1]<50)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	else if(gtotal_brk[1]==00)
	{
	var finalAmt=parseInt(gtotal_brk[0]);
	}
	document.getElementById("GrandTotal").value=finalAmt.toFixed(2);
	
	var OrigGrandTotAmt = document.getElementById("orig_grand_tot").value;
	var NewGrandTotAmt = document.getElementById("GrandTotal").value;
	
	if(NewGrandTotAmt>OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(NewGrandTotAmt)-parseFloat(OrigGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='+';
	}
	else if(NewGrandTotAmt<OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='-';
	}
	else if(NewGrandTotAmt==OrigGrandTotAmt)
	{
	document.getElementById("roundVal").value=(parseFloat(OrigGrandTotAmt)-parseFloat(NewGrandTotAmt)).toFixed(2);
	document.getElementById("pluMin").value='No Round';
	}
}

function recieveValidate()
{
	if ( ( document.getElementById("radio").checked == false ) && ( document.getElementById("radio2").checked == false ) )
{
alert ( "Please choose Recieved Against" );
return false;
}
}

function cal_roundamt()
{
	var total=document.getElementById("total_item_amount").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var packagingCharges=document.getElementById("packagingCharges").value;
	var additionalCharges=document.getElementById("additionalCharges").value;	
	if(total==''){total=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(packagingCharges==''){packagingCharges=0;}
	if(additionalCharges==''){additionalCharges=0;}
	var roundOffVal=document.getElementById("round_off").value;
	var grand=document.getElementById("GrandTotal").value;
	
	grandtotal=parseFloat(total)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(packagingCharges)+parseFloat(additionalCharges);
	if(roundOffVal==''){roundOffVal='-.0';}
	else if(roundOffVal=='0'){roundOffVal='-.0';}
	
	var test=roundOffVal.split(".");
	
	 if(test[0]=='-')
	 {
		var dot=".";
		var roundval=dot + test[1];
		
		 document.getElementById("GrandTotal").value=parseFloat(grandtotal) - parseFloat(roundval);
	 }
	 else
	 {
	 	var dot=".";
		var roundval=dot + test[1];
	 	document.getElementById("GrandTotal").value=(parseFloat(grandtotal) + parseFloat(roundval)).toFixed(2);	
	 }
	
}

function cal_grandamount()
{
	
	var total=document.getElementById("basic_amount").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var TotalCharge=document.getElementById("TotalCharge").value;
	var packagingCharges=document.getElementById("packagingCharges").value;
	var additionalCharges=document.getElementById("additionalCharges").value;	
	if(total==''){total=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(TotalCharge==''){TotalCharge=0;}
	if(packagingCharges==''){packagingCharges=0;}
	if(additionalCharges==''){additionalCharges=0;}
	var roundOffVal=document.getElementById("round_off").value;
	var grand=document.getElementById("GrandTotal").value;
	
	grandtotal=parseFloat(total)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(packagingCharges)+parseFloat(additionalCharges);
	if(roundOffVal==''){roundOffVal='-.0';}
	
	var test=roundOffVal.split(".");
	
	 if(test[0]=='-')
	 {
		var dot=".";
		var roundval=dot + test[1];
		
		 document.getElementById("GrandTotal").value=parseFloat(grandtotal) - parseFloat(roundval);
	 }
	 else
	 {
	 	var dot=".";
		var roundval=dot + test[1];
	 	document.getElementById("GrandTotal").value=parseFloat(grandtotal) + parseFloat(roundval);	
	 }
	
	
	
//document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	

}

/*function calculateAgainst(type)
{
	var count=document.getElementById("count").value;
	for(var i=1; i<count; i++){
	if(type=='bill'){
	var qty=parseFloat(document.getElementById('qty_as_per_bill_'+i).value); }
	else if(type=='rec'){
	var qty=parseFloat(document.getElementById('Quantity_'+i).value); }
	}
}*/
</script>


