<?php 
echo $_REQUEST['purchorders_id'];
$purchorder_query = "select * from purchorders where id='".$_REQUEST['purchorders_id']."'";
$purchorder_query_res = DB_query($purchorder_query,$db) or die(DB_error());
$purchorder_query_result = DB_fetch_assoc($purchorder_query_res);
echo "<pre>";
print_r($purchorder_query_result);
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Purchase Order Approval</h1>	
<form action="" method="post">

<!-----------------GENERAL DETAILS------------------------------------------------------------------------------------>

<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr class="row1">
	<td class="tabledata1" colspan="4"><h3>General Details</h3></td>
</tr>
\
<tr class="row1">
	<td class="tabledata1"><strong>Branch</strong></td>
	<td><?php echo $sitename; ?><input type="hidden" name="site" id="site" value="<?php echo $site; ?>" /> 
	</td>
	<td class="tabledata1"><strong>PO No</strong></td>
	<td><?php echo 'Auto Generated'; ?></td>
</tr>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>PO Date</strong></td>
	<td><?php echo date('d/m/Y'); ?>
	<input type="hidden" name="po_date" id="po_date" value="<?php  echo date('Y-m-d');?>" /></td>
	<td class="tabledata1"><strong>Vendor Name</strong></td>
	<td><?php echo $vendorName; ?>
	<input type="hidden" name="vendor_id" id="vendor_id" value="<?php  echo $_REQUEST['SupplierId'];?>" />
	</td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Vendor Code</strong></td>
	<td><?php echo $vendorCode; ?></td>
	<td class="tabledata1"><strong>Vendor Category</strong></td>
	<td><?php echo $vendorCategoryName; ?></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Contact Person</strong></td>
	<td>
	<?php $sqlCon=DB_query("select * from contact_information_master where master_code='".$_REQUEST['SupplierId']."' AND master_prefix='S'",$db); ?></td>
	<td class="tabledata1"><strong>Mobile No</strong></td>
	<td>&nbsp;</td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Purchase Order Type</strong></td>
	<td>&nbsp;</td>
	<td class="tabledata1"><strong>Comparative No</strong></td>
	<td><?php echo $comparative_no; ?></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Comparative Date</strong></td>
	<td><?php echo ConvertSQLDate($comparative_date); ?></td>
	<td class="tabledata1"><strong>Compared By</strong></td>
	<td><?php echo $CompareBY; ?></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Indent/PR No</strong></td>
	<td><?php echo $s->GetFieldValue('materialrequisitions',"requisitionno='".$indentprno."'",'Reqno'); ?>
	<input type="hidden"  name="indentPRNo" id="indentPRNo" value="<?php echo $indentprno; ?>" />
	</td>
	<td class="tabledata1"><strong>Indent/PR Date</strong></td>
	<td><?php echo ConvertSQLDate($s->GetFieldValue('materialrequisitions',"requisitionno='".$indentprno."'",'prdate')); ?></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Indent/PR By</strong></td>
	<td><?php echo $IndentBY; ?></td>
	<td class="tabledata1"><strong>Quotation No</strong></td>
	<td><?php echo $quotationNo; ?>
	<input type="hidden" name="quotationId" id="quotationId" value="<?php echo $quotationId; ?>" />
	</td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Quotation Date</strong></td>
	<td colspan="3"><?php echo ConvertSQLDate($quotationDate); ?></td>
</tr>

<!-----------------GENERAL DETAILS------------------------------------------------------------------------------------>


<!-----------------ADDRESS DETAILS------------------------------------------------------------------------------------>
<?php $vendAddress=$SuppliersDetails['adrress1'].','.$SuppliersDetails['adrress2'].','.$SuppliersDetails['address3']; ?>
<tr class="row1">
	<td class="tabledata1" colspan="4"><h3>Address Details</h3></td>
</tr>
<tr class="row1">
	<td style="text-align:;" colspan="2" class="tabledata1">
	<strong>Ckeck If Billing & Shipping Address Are Same</strong></td>
	<td style="text-align:left;" colspan="2" class="tabledata1"><input type="checkbox" name="shipping_data" id="shipping_data" onclick="ship_data()"></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Billing Address</strong></td>
	<td width="25%" >&nbsp;</td>
	<td class="tabledata1"><strong>Shipping Address</strong></td>
	<td width="25%" id="CODE">&nbsp;</td>
	</tr>
	<tr class="row1">
	<td class="tabledata1"><strong>Billing city</strong></td>
	<td>&nbsp;</td>
	<td class="tabledata1"><strong>Shipping City</strong></td>
	<td>&nbsp;</td>
	</tr>
	<tr class="row1">
	<td class="tabledata1"><strong>Billing State</strong></td>
	<td><input type="hidden" name="billing_state" id="billing_state" value="<?php echo $SuppliersDetails['state']; ?>" style="width:150px;" />
		  <?php $STname=$s->GetFieldValue('state_master',"id='".$SuppliersDetails['state']."'",'state'); ?></td>
	<td class="tabledata1"><strong>Shipping State</strong></td>
	<td><input type="hidden" name="shipping_state" id="shipping_state" value="<?php echo $state; ?>" style="width:150px;" />
		  <?php $STname=$s->GetFieldValue('state_master',"id='".$state."'",'state'); ?></td>
	</tr>
	<tr class="row1">
	<td class="tabledata1"><strong>Billing Country</strong></td>
	<td><input type="hidden" name="billing_country" id="billing_country" value="<?php echo $SuppliersDetails['country']; ?>" style="width:150px;" />
		  <?php $Conname=$s->GetFieldValue('country_master',"id='".$SuppliersDetails['country']."'",'country'); ?></td>
	<td class="tabledata1"><strong>Shipping Country</strong></td>
	<td><input type="hidden" name="shipping_country" id="shipping_country" value="<?php echo $country; ?>" style="width:150px;" />
		  <?php $Conname=$s->GetFieldValue('country_master',"id='".$country."'",'country'); ?></td>
	</tr>
	<tr class="row1">
	<td class="tabledata1"><strong>Billing Postal Code</strong></td>
	<td >&nbsp;</td>
	<td class="tabledata1"><strong>Shipping Postal Code</strong></td>
	<td>&nbsp;</td>
	</tr>


<!-----------------ADDRESS DETAILS------------------------------------------------------------------------------------>


<!-----------------OTHER DETAILS------------------------------------------------------------------------------------>


<tr class="row1">
	<td class="tabledata1" colspan="4"><h3>Other Details</h3></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Delivery Place</strong></td>
	<td>&nbsp;</td>
	<td class="tabledata1"><strong>Mod Of Transport</strong></td>
	<td>&nbsp;</td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Freight</strong></td>
	<td>&nbsp;</td>
	<td class="tabledata1"><strong>Delivery Date</strong></td>
	<td>&nbsp;</td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Delivery Time</strong></td>
	<td>&nbsp;</td>
	<td class="tabledata1"><strong>Valid Till</strong></td>
	<td>&nbsp;</td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Payment Terms</strong></td>
	<td>&nbsp;</td>
	<td class="tabledata1"><strong>Payment Mode</strong></td>
	<td>&nbsp;</td>
</tr>
<tr class="row1">
<td class="tabledata1"><strong>Remarks</strong> </td>
<td colspan="3">&nbsp;</td>
</tr>
</table>

<!-----------------OTHER DETAILS------------------------------------------------------------------------------------>

<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr class="row1">
	<td class="tabledata1" colspan="6"><h3>Items Details</h3></td>
</tr>
<tr class="row1">
	<td class="tabledata1" colspan="6">
		<div style="width:100%; overflow:auto;">
			<table border="1" cellpadding="3" cellspacing="0" width="100%" style="border:1px #333333 solid;">
				<tr bgcolor="#d4d4d4">
					<td class="tabledata">SrNo.</td>
					<td class="tabledata">Item Name</td>
					<td class="tabledata">UOM</td>
					<td class="tabledata">Qty</td>
					<td class="tabledata">Quoted Rate </td>
					<td class="tabledata">Total Price</td>
					<td class="tabledata">Discount Type</td>
					<td class="tabledata">Discount Amt</td>
					<td class="tabledata">Discounted Amount</td>
					<td class="tabledata">Sub Total</td>
					<!--<td class="tabledata">Special Discount Type</td>
					<td class="tabledata">Special Discount Amt</td>
					<td class="tabledata">Special Discounted Amt</td>-->
					<td class="tabledata">Basic Amount</td>
					<td class="tabledata">Excise flag</td>
					<td class="tabledata">Excise</td>
					<td class="tabledata">E-Cess</td>
					<td class="tabledata">SAH-E Cess</td>
					<td class="tabledata">Excise<br />Amt.</td>
					<td class="tabledata">Total<br /> Amt.</td>
				</tr>
<?php $i=0; 
$SQLPoA=DB_query("SELECT * FROM comprative_detail where sppliersId='".$_REQUEST['SupplierId']."' AND parant_id='".$_REQUEST['CPID']."'",$db);
while($InPrDetails=DB_fetch_array($SQLPoA)){ 
$ItemName=$s->GetFieldValue('item_master',"id='".$InPrDetails['mst_itemid']."'",'item_name');
$UnitId=$s->GetFieldValue('item_master',"id='".$InPrDetails['mst_itemid']."'",'mst_unitid');
$UnitName=$s->GetFieldValue('unitsofmeasure',"unitid='".$UnitId."'",'unitname');

$SQLQuotation=DB_query("select * from vendorquotationdetails where id='".$InPrDetails['quotation_details_id']."'",$db);
$QuotaionDetails=DB_fetch_array($SQLQuotation);

$totalPrice=$InPrDetails['assign_qty']*$QuotaionDetails['Rate'];
if($QuotaionDetails['DiscountType']=='Amount')
{
	$discountedAmt=$QuotaionDetails['Discount'];
	
}
else if($QuotaionDetails['DiscountType']=='PercentAmt')
{
	$discountedAmt=($totalPrice*$QuotaionDetails['Discount'])/100;
}


$subtotal=$totalPrice-$discountedAmt;


if($QuotaionDetails['SpecialDicount_Type']=='Amount')
{
	$SpecialdiscountedAmt=$QuotaionDetails['SpecialDiscount'];
	
}
else if($QuotaionDetails['SpecialDicount_Type']=='PercentAmt')
{
	$SpecialdiscountedAmt=($subtotal*$QuotaionDetails['SpecialDiscount'])/100;
}

$basicAMt=$subtotal-$SpecialdiscountedAmt;


if($QuotaionDetails['Excise_type']=='Excisable')
{
	$Excise=$QuotaionDetails['Excise_Duty'];
	$Exicename=$s->GetFieldValue('excise_tax',"id='".$Excise."'",'caption');
	//$ExcisePerc=$QuotaionDetails['ExcisePercentage'];
	$ExciseVal=$QuotaionDetails['ExciseValue'];
	
	
	$Cess_ID=$QuotaionDetails['Cess_ID'];
	$CessName=$s->GetFieldValue('excise_tax',"id='".$Cess_ID."'",'caption');
	//$CessPerc=$QuotaionDetails['ECessPercentage'];
	$CessValue=$QuotaionDetails['ECessValue'];
	
	$SHECess_ID=$QuotaionDetails['SHECess_ID'];
	$SHECessName=$s->GetFieldValue('excise_tax',"id='".$SHECess_ID."'",'caption');
	//$SHECessPerc=$QuotaionDetails['SAHCessPercentage'];
	$SHECessValue=$QuotaionDetails['SAHCessValue'];
	
	$TaxableAmt=$ExciseVal+$CessValue+$SHECessValue;
}
else if($QuotaionDetails['Excise_type']=='NonExcisable' || $QuotaionDetails['Excise_type']=='IncludeTax')
{
	$Excise=0;
	$Exicename=0;
	$ExcisePerc=0;
	$ExciseVal=0;
	
	
	$Cess_ID=0;
	$CessName=0;
	$CessPerc=0;
	$CessValue=0;
	
	$SHECess_ID=0;
	$SHECessName=0;
	$SHECessPerc=0;
	$SHECessValue=0;
	
	$TaxableAmt=0;
}




$TotalAmout=$basicAMt+$TaxableAmt;

?>
<tr class="rowdata">
<td><?php echo $i+1; ?></td>
<td><?php echo $ItemName; ?><input type="hidden" name="mst_itemid[<?php echo $i;?>]"  value="<?php echo $InPrDetails['mst_itemid'];?>"></td>
<td><?php echo $UnitName; ?></td>
<td><?php echo $InPrDetails['assign_qty'];?>
<input type="hidden" name="Quantity[<?php echo $i;?>]"  value="<?php echo $InPrDetails['assign_qty'];?>"
/></td>
<td><?php echo $QuotaionDetails['Rate']; ?>
<input   type="hidden" name="Rate[<?php echo $i;?>]"  /></td>
<td>
<?php echo  $totalPrice;?>
<input  type="hidden" name="totalPrice[<?php echo $i;?>]"  value="<?php echo $totalPrice; ?>"/></td>
<td>
<?php  echo $QuotaionDetails['DiscountType']; ?>
<input type="hidden"  name="DiscountType[<?php echo $i;?>]" value="<?php echo $QuotaionDetails['DiscountType'];?>">

</td>
<td><?php echo $QuotaionDetails['Discount']; ?>
<input type="hidden" style="width:70px" name="Discount[<?php echo $i;?>]" value="<?php echo $QuotaionDetails['Discount']; ?>" /></td>
<td><?php echo $discountedAmt; ?>
<input type="hidden" name="discounted_amount[<?php echo $i;?>]" value="<?php echo $discountedAmt; ?>" /></td>
<td><?php echo $subtotal; ?>
<input type="hidden" name="NetRate[<?php echo $i;?>]" value="<?php echo $subtotal; ?>"  /></td>
<!--<td><?php echo $QuotaionDetails['SpecialDicount_Type']; ?>
<input type="hidden"  name="SpecialDicount_Type[<?php echo $i; ?>]" value="<?php echo $QuotaionDetails['SpecialDicount_Type']; ?>" />
</td>
<td><?php echo $QuotaionDetails['SpecialDiscount']; ?>
<input type="hidden" name="SpecialDiscount[<?php echo $i; ?>]" value="<?php echo $QuotaionDetails['SpecialDiscount']; ?>" /></td>
<td><?php echo $SpecialdiscountedAmt; ?>
<input type="hidden" name="SpecialDiscounted_Amt[<?php echo $i; ?>]" value="<?php echo $SpecialdiscountedAmt; ?>"/></td>-->
<td><?php echo $basicAMt; ?>
<input type="hidden" name="basic_Amt[<?php echo $i; ?>]" value="<?php echo $basicAMt; ?>" /></td>
<td><?php echo $QuotaionDetails['Excise_type']; ?>
<input type="hidden" name="Excise_type[<?php echo $i;?>]" value="<?php echo $QuotaionDetails['Excise_type']; ?>" />
</td>
<td><?php echo $Exicename.'<br>'.$ExcisePerc.'<br>'.$ExciseVal; ?>
<input type="hidden" name="Excise_Duty[<?php echo $i; ?>]" value="<?php echo $Excise; ?>">
<input name="ExcisePercentage[<?php echo $i; ?>]" type="hidden" value="<?php echo $ExcisePerc; ?>"  />
<input name="exciseValue[<?php echo $i; ?>]" type="hidden"  value="<?php echo $ExciseVal; ?>" />
</td>
<td><?php echo $CessName.'<br>'.$CessPerc.'<br>'.$CessValue; ?>
<input type="hidden" name="Cess_ID[<?php echo $i; ?>]" value="<?php echo $Cess_ID; ?>" >
<input name="ECessPercentage[<?php echo $i; ?>]"  type="hidden" value="<?php echo $CessPerc; ?>"   />
<input name="ECessValue[<?php echo $i; ?>]"  type="hidden" value="<?php echo $CessValue; ?>" /></td>
<td><?php echo $SHECessName.'<br>'.$SHECessPerc.'<br>'.$SHECessValue; ?>
<input type="hidden" name="SHECess_ID[<?php echo $i; ?>]" value="<?php echo $SHECess_ID; ?>" >
<input name="SAHCessPercentage[<?php echo $i; ?>]" type="hidden" value="<?php echo $SHECessPerc; ?>"  />
<input name="SAHCessValue[<?php echo $i; ?>]" type="hidden" value="<?php echo $SHECessValue; ?>"/></td>
<td><?php echo $TaxableAmt; ?>
<input type="hidden" name="taxable_amt[<?php echo $i; ?>]" value="<?php echo $TaxableAmt; ?>"/></td>
<td><?php echo $TotalAmout; ?>
<input type="hidden"  name="TotalAmount[<?php echo $i;?>]" id="total_amt_<?php echo $i; ?>" value="<?php echo $TotalAmout; ?>"/></td>
</tr>
<?php $i++;}?>

<input type="hidden" name="count" id="count" value="<?php echo $i;?>" style="width:70px" /> 
			</table>
		</div>
	</td>
</tr>


<tr class="row1">
<td class="tabledata1" colspan="6">
	<table border="0" width="100%" cellpadding="3" cellspacing="0">
	<tr class="row1">
		<td width="50%"></td>
		<td width="50%">
		<table width="100%" border="0" cellspacing="0" cellpadding="3">
		<tr class="row1">
		<td class="tabledata1"><strong>TOTAL AMOUNT</strong> </td>
		<td><input type="text" name="total_amount" id="total_item_amount" onfocus="caltotalAmt()" readonly="" style="width:150px;"/></td>
		</tr>
		<tr class="row1">
		<?php $pkg_charges=($totalamount*$pkg_per)/100; ?>	
		<td class="tabledata1"><strong>Pkg Charges</strong> </td>
		<td><input type="text" name="pkg_per" id="pkg_per" value="<?php echo $pkg_per; ?>" style="width:75px;" />
		<input name="pkg_charges" id="packagingCharges" type="text" onfocus="calcPackaging()" style="width:75px;" readonly=""/></td>
		</tr>
		<tr class="row1">
		<td class="tabledata1"><strong>Vat(description)</strong></td>		
		<td>
		<?php $val1=$s->getField('sales_tax_master','salestax_id',$vatcst,'tax_code');
		$val2= $s->getField('sales_tax_master','salestax_id',$vatcst,'taxrate');
		$dataval= $val1 ."---".$val2."%"; ?>	
		<input type="hidden" name="vatcst" value="<?php echo $vatcst; ?>"  />
		<input type="hidden" name="vat_cst_per" id="vat_cst_per" value="<?php echo $val2; ?>" />
		<input type="text" name="" id="" value="<?php echo $val1; ?>" style="width:150px;"/>
		</td>
		</tr>
		<tr class="row1">
		<td class="tabledata1"><strong>Vat/Cst Amount</strong></td>
		<td><input type="text" name="vatcstvalue" id="VatcstVal" value="" style="width:150px;" onfocus="calvatcst();"/> </td>	
		</tr>	
		<tr class="row1">
          <td class="tabledata1"><strong>Surcharge Amount</strong> </td>
                  <td><input type="text" name="surcharge_per" id="sur_oct_per" style="width:50px;" value="<?php echo $surcharge_per; ?>" />
				  <input name="surcharge_amt" onfocus="calsurchrg()" type="text" id="sur_oct_amt" style="width:100px;" /></td>
                </tr>
       <tr class="row1">
              <td class="tabledata1"><strong>Freight</strong> </td>
                  <td><input type="text" name="Freight" id="TotalCharge" value="<?php echo $Freight; ?>" style="width:150px;"/></td>
       </tr>
       <tr class="row1">
            <td class="tabledata1"><strong>Additional Charges</strong> </td>
             <td><input name="add_charges" id="additionalCharges" value="<?php echo $add_charges; ?>" type="text" style="width:150px;" /></td>
      </tr>
		<?php  $grand_total=$totalamount+$sur_oct_amt+$totalcharge+$pkg_charges+$add_charges+$vat_cst_amount; ?> 			
		<tr class="row1">
		<td class="tabledata1"><strong>GrandTotal</strong></td>
		<td><input type="text" name="GrandTotal" id="GrandTotal" onfocus="calgrandTotal()" style="width:150px;" readonly="" /></td>
		</tr>
		</table>		</td>
	</tr>
	</table>
</td>
</tr>



<tr class="row1">
<td colspan="6"  style="text-align:center;" class="tabledata1"><input name="save" type="submit" value="Generate Process Order" class="search"  onclick="return validate();"/></td>
</tr>
</table>
 </form>
 </div>
 </div>
 
<script language="JavaScript">
	
function checkvalidate()
{
	
var curr_date2='';	
var curr_month2='';
var d = new Date();
//alert(d.format("m/dd/yy"));
var curr_date = d.getDate();
var curr_month1 = d.getMonth();
var curr_year = d.getFullYear();
var curr_month=curr_month1+1;
var t=curr_month;
var d=curr_date;
if(t!=10 || t!=11 ||t!=12 )
{
 curr_month2="0" + curr_month;	
}
else
{
 curr_month2=curr_month;	
}
if(d==1 || d==2 || d==3 || d==4 || d==5 || d==6 || d==7 || d==8 || d==9 )
{
 curr_date2="0" + curr_date;		
}
else
{
 curr_date2=curr_date;		
}


var datedat=(curr_date2 + "/" + curr_month2 
+ "/" + curr_year);
var del=document.getElementById("delivery_date").value;	
if(del<datedat)
{
alert("Delivery  Date Not less then current  Date");
//document.getElementById("delivery_date").value='';
document.getElementById("delivery_date").focus;	
return false;	
}


}
function checktilldate()
{
var curr_date2='';	
var curr_month2='';
var d = new Date();
//alert(d.format("m/dd/yy"));
var curr_date = d.getDate();
var curr_month1 = d.getMonth();
var curr_year = d.getFullYear();
var curr_month=curr_month1+1;
var t=curr_month;
var d=curr_date;
if(t!=10 || t!=11 ||t!=12 )
{
 curr_month2="0" + curr_month;	
}
else
{
 curr_month2=curr_month;	
}
if(d==1 || d==2 || d==3 || d==4 || d==5 || d==6 || d==7 || d==8 || d==9 )
{
 curr_date2="0" + curr_date;		
}
else
{
 curr_date2=curr_date;		
}	
var datedat=(curr_date2 + "/" + curr_month2 
+ "/" + curr_year);
var del1=document.getElementById("valid_till").value;	
if(del1<datedat)
{
alert("Valid Till Date Not less then current  Date");
//document.getElementById("valid_till").value='';
document.getElementById("valid_till").focus;	
return false;	
}	
	
	
}	
	
	
	
	
function validate()
{//
//var curr_date2='';	
//var curr_month2='';
//var d = new Date();
////alert(d.format("m/dd/yy"));
//var curr_date = d.getDate();
//var curr_month1 = d.getMonth();
//var curr_year = d.getFullYear();
//var curr_month=curr_month1+1;
//var t=curr_month;
//var d=curr_date;
//if(t!=10 || t!=11 ||t!=12 )
//{
// curr_month2="0" + curr_month;	
//}
//else
//{
// curr_month2=curr_month;	
//}
//if(d==1 || d==2 || d==3 || d==4 || d==5 || d==6 || d==7 || d==8 || d==9 )
//{
// curr_date2="0" + curr_date;		
//}
//else
//{
// curr_date2=curr_date;		
//}
//
//
//var datedat=(curr_date2 + "/" + curr_month2 
//+ "/" + curr_year);
//
//if(document.getElementById("delivery_place1").value=='')
//{
//alert("Must Enter Delivery Place");
//document.getElementById("delivery_place1").focus();
//return false;	
//}
//if(document.getElementById("delivery_date").value=='')
//{
//alert("Must Enter Delivery Date");
//document.getElementById("delivery_date").focus();
//return false;	
//}
//if(document.getElementById("delivery_date").value!='')
//{
//
//var del=document.getElementById("delivery_date").value;	
//}
//if(del<datedat)
//{
//alert("Delivery  Date Not less then current  Date");
//document.getElementById("delivery_date").focus();	
//return false;	
//}
//if(document.getElementById("delivery_time").value=='')
//{
//alert("Must Enter Delivery Time");
//document.getElementById("delivery_time").focus();
//return false;	
//}
//if(document.getElementById("contact_person").value=='')
//{
//alert("Must Enter Contact Person Name");
//document.getElementById("contact_person").focus();
//return false;	
//}
//var del1=document.getElementById("valid_till").value;	
//if(del1<datedat)
//{
//alert("Valid Till Date Not less then current  Date");
////document.getElementById("valid_till").value='';
//document.getElementById("valid_till").focus;	
//return false;	
//}	
//return true;		
}	
	
function showdata(str)
{
if (str=='')
  {
  document.getElementById("divdata").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("divdata").style.display='block';
    document.getElementById("divdata").innerHTML=xmlhttp.responseText;
      }
  }
 
xmlhttp.open("GET","geteditdatapo.php?site="+str,true);
xmlhttp.send();
}	


function ship_data()
{

	if(document.getElementById("shipping_data").checked==true)
	{
		document.getElementById('Shipping_address').value = document.getElementById('billing_Address').value;
		document.getElementById('shipping_city').value = document.getElementById('billing_city').value;
		document.getElementById('shipping_state').value = document.getElementById('billing_state').value;
		document.getElementById('shipping_country').value = document.getElementById('billing_country').value;
		document.getElementById('shipping_state1').value = document.getElementById('billing_state1').value;
		document.getElementById('shipping_country1').value = document.getElementById('billing_country1').value;
		document.getElementById('Shipping_zipcode').value = document.getElementById('zipcode').value;
		
	}else{
		document.getElementById('Shipping_address').value = '';
		document.getElementById('shipping_city').value = '';
		document.getElementById('shipping_state').value = '';
		document.getElementById('shipping_country').value = '';
		document.getElementById('shipping_state1').value = '';
		document.getElementById('shipping_country1').value = '';
		document.getElementById('Shipping_zipcode').value='';
	}
}



function caltotalAmt()
{
	var count=document.getElementById("count").value;
	var total=0;
	for(var i=0;i<count;i++)
	{
		total=parseFloat(total)+parseFloat(document.getElementById("total_amt_"+i).value);
	}
	document.getElementById("total_item_amount").value=total.toFixed(2);
}

function calcPackaging()
{
		var tota_amt=document.getElementById("total_item_amount").value;
		var pkgper=document.getElementById("pkg_per").value;
		var pckgng_val=(pkgper/100)*tota_amt;
		document.getElementById("packagingCharges").value=pckgng_val.toFixed(2);
}

function calvatcst()
{
	var tota_amt=document.getElementById("total_item_amount").value;
	
	var vatperc=document.getElementById("vat_cst_per").value;
	
	var cal=(tota_amt*vatperc)/100;
	
	document.getElementById("VatcstVal").value=cal.toFixed(2);
	
}

function calsurchrg()
{
	var amt=parseFloat(document.getElementById("VatcstVal").value);
	var	suroctper=parseFloat(document.getElementById("sur_oct_per").value);
	var amount=(amt*suroctper)/100;
	document.getElementById("sur_oct_amt").value=amount.toFixed(2);	
}

function calgrandTotal()
{
	var total=document.getElementById("total_item_amount").value;
	var PkgChrg=document.getElementById("packagingCharges").value;
	var VatAmt=document.getElementById("VatcstVal").value;
	var sur_oct_amt=document.getElementById("sur_oct_amt").value;
	var freight=document.getElementById("TotalCharge").value;
	var additionalCharges=document.getElementById("additionalCharges").value;
		
	if(total==''){total=0;}
	if(PkgChrg==''){PkgChrg=0;}
	if(VatAmt==''){VatAmt=0;}
	if(sur_oct_amt==''){sur_oct_amt=0;}
	if(freight==''){freight=0;}
	if(additionalCharges==''){additionalCharges=0;}
	grandtotal=parseFloat(total)+parseFloat(PkgChrg)+parseFloat(VatAmt)+parseFloat(sur_oct_amt)+parseFloat(freight)+parseFloat(additionalCharges);
	document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	
}


function GetMobileNo(id)
{
	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("mobile_no").value=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","GetContactNo.php?contactId="+id,true);
	xmlhttp.send();
}




function GetSatateCountry(str)
{
	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("billing_state").value=data[0];
		document.getElementById("billing_country").value=data[1];
		document.getElementById("billing_state1").value=data[2];
		document.getElementById("billing_country1").value=data[3];
    }
  	}
	xmlhttp.open("GET","SateCountryName.php?CityId="+str,true);
	xmlhttp.send();
}


function GetSatateCountry1(str)
{
	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("shipping_state").value=data[0];
		document.getElementById("shipping_country").value=data[1];
		document.getElementById("shipping_state1").value=data[2];
		document.getElementById("shipping_country1").value=data[3];
    }
  	}
	xmlhttp.open("GET","SateCountryName.php?CityId="+str,true);
	xmlhttp.send();
}
</script>