<?php 
$PageSecurity = 11;
include('includes/session.inc');
include('includes/function_lib.php');
$data1="";
$data2="";
if($_REQUEST['OrderType']=='DO'){
$data1.="<table width='100%' cellpadding='3' cellspacing='0' border='1' style='border:#333333 1px solid;'>";
					$data1.="<tr bgcolor='#d4d4d4'>";
						$data1.="<td class='tabledata'>Select</td>";
						$data1.="<td class='tabledata'>&nbsp;</td>";
						$data1.="<td class='tabledata'>Part Code</td>";
						$data1.="<td class='tabledata'>Part Name</td>";
						$data1.="<td class='tabledata'>Qty</td>";
						$data1.="<td class='tabledata'>Rate</td>";
						$data1.="<td class='tabledata'>Total Price</td>";
						$data1.="<td class='tabledata'>Discount Type</td>";
						$data1.="<td class='tabledata'>Discount Amt</td>";
						$data1.="<td class='tabledata'>Discounted Amount</td>";
						$data1.="<td class='tabledata'>Sub Total</td>";
						$data1.="<td class='tabledata'>Basic Amount</td>";
						$data1.="<td class='tabledata'>Excise flag</td>";
						$data1.="<td class='tabledata'>Excise</td>";
						$data1.="<td class='tabledata'>Excise Value</td>";
						$data1.="<td class='tabledata'>E-Cess</td>";
						$data1.="<td class='tabledata'>E-Cess Value</td>";
						$data1.="<td class='tabledata'>SAH-E Cess</td>";
						$data1.="<td class='tabledata'>SAH-E Value</td>";
						$data1.="<td class='tabledata'>Excise<br />Amt.</td>";
						$data1.="<td class='tabledata'>Total<br /> Amt.</td>";
					$data1.="</tr>";
					$data1.="<tbody id='dataTable'>";
					$data1.="<tr bgcolor='#c1c1c1'>";
					$data1.="<td><input type='checkbox'  /></td>";
					$data1.="<td><input type='hidden' name='mst_itemid[0]' id='itemid' /></td>";
					$data1.="<td><input type='text' name='itemcode[0]' id='itemcode' style='width:100%;' readonly='' /></td>";
					$data1.="<td><input type='text' name='itemcode[0]' id='itemname' style='width:100px;' readonly='' /></td>";
					$data1.="<td><input style='width:100%;'  type='text' name='Quantity[0]' id='Quantity'/></td>";
					$data1.="<td><input style='width:100%;'  type='text' name='Rate[0]' id='Rate' onKeyUp='calculateTotalPrice(this.id)'/></td>";
					$data1.="<td><input style='width:100%;' type='text' name='totalPrice[0]' id='totalValue' readonly='true'/></td>";
					$data1.="<td><select style='width:100%;' name='DiscountType[0]' id='PerAmo'>";
					$data1.="<option value='Amount'>Amount</option>";
					$data1.="<option value='PercentAmt'>Percent Amt</option>";
					$data1.="</select></td>";
					$data1.="<td><input type='text' style='width:100%;' name='Discount[0]' id='Discount' onblur='DiscountAmount(this.value,this.id)' /></td>";
					$data1.="<td><input type='text' name='discounted_amount[0]' id='perc'  readonly='true' style='width:100%;' onfocus='Check(this.value,this.id)'/></td>";
					$data1.="<td><input type='text'  id='NetRate' name='NetRate[0]' style='width:100%;' readonly/></td>";
					$data1.="<td><input type='text' style='width:100%;' id='basic' name='basic_Amt[0]' readonly/></td>";
					$data1.="<td><select name='Excise_type[0]' style='width:85px' id='hid_billing_type'  onchange='checkExcisable(this.value,this.id)'>";
					$data1.="<option value=''>Select</option>";
					$data1.="<option value='NonExcisable'>NonExcisable</option>";
					$data1.="<option value='Excisable'>Excisable</option>";
					$data1.="<option value='IncludeTax'>IncludeTax</option>";
					$data1.="</select></td>";
					$data1.="<td><select name='Excise_Duty[0]' id='exciseDuty' style='width:100%;' onchange='claculateExcise(this.id,this.value)' onfocus='checkexiseflag(this.id)'>";
					$data1.="<option value=''>Select</option>";
					$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))
					{
					$g='';
					if($Excise_Duty==$excise_row['id'])
					{$g='selected';}
					$data1.="<option value='".$excise_row['id']."'>".$excise_row['caption']."</option>";
					}
					
					$data1.="</select><input name='ExcisePercentage[0]' id='ExcisePercentage' type='hidden' style='width:100%;' readonly />";
					$data1.="</td>";
					$data1.="<td><input name='exciseValue[0]' id='exciseValue' type='text' style='width:100%;' onfocus='calculateExciseDuty(this.id)' readonly='' /></td>";
					$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++;
					} 	
					
					$cessLedgerSql1=DB_query("Select * from excise_tax where ledgertype='cess' LIMIT 0,1",$db);	 
					$cessLedgerSql2=DB_query("Select * from excise_tax where ledgertype='cess' LIMIT 1,1",$db);	 	 
					
					$data1.="<td><select name='Cess_ID[0]' id='cess_ID1' style='width:100%;' onchange='calEcessonchange(this.id,this.value)'>";
					$data1.="<option value=''>Select</option>";	
					while($cessLedger1=DB_fetch_array($cessLedgerSql1)){
					$data1.="<option value='".$cessLedger1['id']."'>".$cessLedger1['caption']."</option>";
					}
					$data1.="</select>";
					$data1.="<input name='ECessPercentage[0]' id='ECessPercentage' type='hidden' value='<?php echo $rate[1]; ?>' style='width:100%;' readonly />";
					$data1.="</td>";
					$data1.="<td><input name='ECessValue[0]' id='ECessValue' type='text' style='width:100%;'  onfocus='calculateECess(this.id)' readonly/></td>";
					$data1.="<td><select name='SHECess_ID[0]' id='cess_ID2' style='width:100%;' onchange='calSHEcessonchange(this.id,this.value)'>";
					$data1.="<option value=''>Select</option>";	
					while($cessLedger2=DB_fetch_array($cessLedgerSql2)){
					$data1.="<option value='".$cessLedger2['id']."'>".$cessLedger2['caption']."</option>";
					}
					$data1.="</select>";
					$data1.="<input name='SAHCessPercentage[0]' id='SAHCessPercentage' type='hidden' value='<?php echo $rate[2]; ?>' style='width:100%;' readonly/>";
					$data1.="</td>";
					$data1.="<td><input name='SAHCessValue[0]' id='SAHCessValue' type='text' style='width:100%;' readonly onfocus='calculateSAHCess(this.id)' /></td>";
					$data1.="<td><input type='text' name='taxable_amt[0]' id='taxable_amt' style='width:100%;' onfocus='calculateTaxable(this.id)' readonly/></td>";
					$data1.="<td><input type='text' id='TotalSpecial' name='TotalAmount[0]' style='width:100%;' readonly  onfocus='cal_grandtotal(this.id);' value='0'/></td>";
					$data1.="</tr>";
					$data1.="</tbody>";
				$data1.="</table>";
				
				
				
				
		$data2.="<table width='100%' border='0' cellspacing='0' cellpadding='3'>";
		$data2.="<tr class='row1'>";
		$data2.="<td class='tabledata1'><strong>Basic Amount</strong> </td>";
		$data2.="<td><input type='text'  name='basic_amt' id='total_item_amount' style='width:150px;' readonly onfocus='cal_totalamount()' /></td>";
		$data2.="</tr>";
		$data2.="<tr class='row1'>";
        $data2.="<td class='tabledata1'><strong>Pkg Charges</strong> </td>";
        $data2.="<td><input type='text' name='pkg_per' id='pkg_perc' style='width:50px' onkeyup='calcPackaging(this.value)' />													<input name='pkg_charges' id='pkg_charges1' style='width:100px' type='text'/></td>";
        $data2.="</tr>";
        $data2.="<tr class='row1'>";
        $data2.="<td class='tabledata1'><strong>Vat/Cst(discription) </strong> </td>";
		$Taxsql='SELECT salestax_id,tax_code, taxrate FROM sales_tax_master';
		$Taxresult=DB_query($Taxsql,$db);
        $data2.="<td><select id='taxname' name='vatcst' onchange='tax_rate1(this.value)' style='width:150px;'>";
	    $data2.="<option value='0'>---Select---</option>";
		while($Taxmyrow=DB_fetch_array($Taxresult)){
        $data2.="<option  value='".$Taxmyrow['salestax_id']."'>".$Taxmyrow['tax_code'].' --- '.$Taxmyrow['taxrate'].'%'."</option>";
        }
        $data2.="</select></td>";
        $data2.="</tr>";
        $data2.="<tr class='row1'>";
        $data2.="<td class='tabledata1'><strong>Tax Value</strong></td>";
        $data2.="<td><div id='taxval'><input type='text' name='taxvalue' id='taxvalue' style='width:150px;' value='' readonly='true'/>";
        $data2.="</div></td>";
        $data2.="</tr>";
     	$data2.="<tr class='row1'>";
        $data2.="<td class='tabledata1'><strong>Surcharge Amount</strong> </td>";
        $data2.="<td><input type='text' name='surcharge_per' id='sur_oct_per' style='width:50px;' onchange='calsuroctamt(this.value)'/><input name='surcharge_amt' type='text' id='sur_oct_amt' style='width:100px;' /></td>";
        $data2.="</tr>";
        $data2.="<tr class='row1'>";
        $data2.="<td class='tabledata1'><strong>Freight</strong></td>";
        $data2.="<td><input type='text' name='Freight' id='TotalCharge' style='width:150px;'/></td>";
        $data2.="</tr>";
        $data2.="<tr class='row1'>";
        $data2.="<td class='tabledata1'><strong>Additional Charges</strong> </td>";
        $data2.="<td><input name='add_charges' id='additionalCharges' type='text' style='width:150px;' /></td>";
        $data2.="</tr>";
				
        $data2.="<tr class='row1'>";
		$data2.="<td class='tabledata1'><strong>Grand Total</strong></td>";
        $data2.="<td><input type='text' name='GrandTotal' id='GrandTotal' onfocus='cal_grandamount()' style='width:150px;' /><input type='hidden'  id='orig_grand_tot' />&nbsp;<strong>Round Off</strong>&nbsp;";
		$data2.="<select name='round_off' id='round_off' style='width:50px; height:20px' onchange='calcRounded(this.value)'>";
				  $data2.="<option value=''>None</option>";
				  $data2.="<option value='+'>+</option>";
				  $data2.="<option value='-'>-</option>";
				  $data2.="</select></td>";
    	$data2.="</tr>";
		$data2.="</table>";
}






//**********************************************************************************************************************




if($_REQUEST['OrderType']=='IO'){
	$data1.="<table width='100%' cellpadding='3' cellspacing='0' border='1' style='border:#333333 1px solid;'>";
		$data1.="<tr bgcolor='#d4d4d4'>";
			$data1.="<td class='tabledata'>Sr. No.</td>";
			$data1.="<td class='tabledata'>&nbsp;</td>";
			$data1.="<td class='tabledata'>Part Code</td>";
			$data1.="<td class='tabledata'>Part Name</td>";
			$data1.="<td class='tabledata'>Qty</td>";
			$data1.="<td class='tabledata'>Rate</td>";
			$data1.="<td class='tabledata'>Total Price</td>";
			$data1.="<td class='tabledata'>Discount Type</td>";
			$data1.="<td class='tabledata'>Discount Amt</td>";
			$data1.="<td class='tabledata'>Discounted Amount</td>";
			$data1.="<td class='tabledata'>Sub Total</td>";
			$data1.="<td class='tabledata'>Basic Amount</td>";
			$data1.="<td class='tabledata'>Custom Duty flag</td>";
			$data1.="<td class='tabledata'>Custom Duty</td>";
			$data1.="<td class='tabledata'>Duty Amount</td>";
			$data1.="<td class='tabledata'>Total<br /> Amt.</td>";
		$data1.="</tr>"; 
		$data1.="<tbody id='dataTable'>";
			$data1.="<tr bgcolor='#c1c1c1'>";
					$data1.="<td><input type='checkbox'  /></td>";
					$data1.="<td><input type='hidden' name='mst_itemid[0]' id='itemid' /></td>";
					$data1.="<td><input type='text' name='itemcode[0]' id='itemcode' style='width:100%;' readonly='' /></td>";
					$data1.="<td><input type='text' name='itemcode[0]' id='itemname' style='width:100%;' readonly='' /></td>";
					$data1.="<td><input style='width:100%;'  type='text' name='Quantity[0]' id='Quantity'/></td>";
					$data1.="<td><input style='width:100%;'  type='text' name='Rate[0]' id='Rate' onKeyUp='calculateTotalPrice(this.id)'/></td>";
					$data1.="<td><input style='width:100%;' type='text' name='totalPrice[0]' id='totalValue' readonly='true'/></td>";
					$data1.="<td><select style='width:100%;' name='DiscountType[0]' id='PerAmo'>";
					$data1.="<option value='Amount'>Amount</option>";
					$data1.="<option value='PercentAmt'>Percent Amt</option>";
					$data1.="</select></td>";
					$data1.="<td><input type='text' style='width:100%;' name='Discount[0]' id='Discount' onblur='DiscountAmount(this.value,this.id)' /></td>";
					$data1.="<td><input type='text' name='discounted_amount[0]' id='perc'  readonly='true' style='width:100%;' onfocus='Check(this.value,this.id)'/></td>";
					$data1.="<td><input type='text'  id='NetRate' name='NetRate[0]' style='width:100%;' readonly/></td>";
					$data1.="<td><input type='text' style='width:100%;' id='basic' name='basic_Amt[0]' readonly/></td>";
				$data1.="<td class='tabledata'><select name='cuntomDuty_Flag[0]' style='width:85px' id='cuntomDuty_Flag'  onchange='CustomDutyType(this.value,this.id)'>";
			$data1.="<option value=''>Select</option>";
			$data1.="<option value='1'>Yes</option>";
			$data1.="<option value='2'>No</option>";
		$data1.="</select></td>";
			$data1.="<td class='tabledata'><select name='Custon_Duty[0]' id='Custon_Duty' style='width:100%;'    onchange='CalculateCustomDuty(this.id,this.value)' onFocus='checkCustomtype(this.id)'>";
					$data1.="<option value=''>Select</option>";
					
					$excise_sql=DB_query("Select * from custom_duty",$db);
					while($excise_row=DB_fetch_array($excise_sql)){
						$data1.="<option value='".$excise_row['id']."'>".$excise_row['caption']."</option>";}
				  $data1.="</select></td>";
				  $data1.="<td class='tabledata'><input type='text'  id='CustomDutyAmt'  onfocus='checkCustomDuty(this.id);' readonly='' name='CustomDutyAmt[0]' style='width:100%;'  /></td>";
				$data1.="<td class='tabledata'><input type='text' id='TotalSpecial' name='TotalAmount[0]' style='width:100%;'    onfocus='cal_grandtotalImp(this.id);' value='0'/></td>";
		$data1.="</tr>"; 
		$data1.="</tbody>";  
		$data1.="</table>";
		
		
		
		
		
	$data2.="<table width='100%' border='0' cellspacing='0' cellpadding='3'>";
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Basic Amount</strong></td>";
	$data2.="<td><input name='basic_amt' id='total_item_amount' style='width:100%;' readonly onfocus='cal_totalamount()'></td>";
	$data2.="</tr>";
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Custom Duty</strong></td>";
	$data2.="<td><select name='CustomDuty' id='CustomDuty' style='width:100%;' onChange='claculateExcisetotal(this.id,this.value)'>";
	$data2.="<option value='0'>Select</option>";
	$ServiceSql='select * from  custom_duty' ;
	$ServiceRes=DB_query($ServiceSql,$db);
	while($ServiceRow=DB_fetch_array($ServiceRes)){
	$data2.="<option value='".$ServiceRow['id']."'>".$ServiceRow['caption']."</option>";} 
	$data2.="</select><br/><input name='custondutyval' id='custondutyval' 
	type='text'  style='width:150px;' onFocus='cal_totalamountwithduty()' />
	<input type='hidden' id='rateval' />";
	$data2.="</td>";
	$data2.="</tr>";
	
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Insurance charges</strong></td>";
	$data2.="<td><input type='text' name='insurancecharges' id='insurancecharges' style='width:100%;'   onblur='calsuroctamtipm(this.value)'/>
	<input name='insurancecharges_amt' type='text'  onkeyup='reversecalsuroctamt(this.value);' id='insurancecharges_amt' value='' style='width:100px;' /></td>";
	$data2.="</tr>";
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Overseas Freight</strong></td>";
	$data2.="<td><input type='text' name='overseasfrieght' id='overseasfrieght'  style='width:100%;' onBlur='caloverfreight(this.value)'/>
	<input name='overseasfrieght_amt' type='text' onkeyup='reversecaloverfreight(this.value);' id='overseasfrieght_amt' value='' style='width:100px;' /></td>";
	$data2.="</tr>";
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Local Freight</strong></td>";
	$data2.="<td><input type='text' name='localfreight' id='localfreight'  style='width:100%;' onBlur='callocalfreight(this.value)'/>
	<input name='localfreight_amt' type='text'  onkeyup='reversecallocalfreight(this.value);'  id='localfreight_amt' style='width:100px;' /></td>";
	$data2.="</tr>";
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Clearing & Forwarding</strong> </td>";
	$data2.="<td><input type='text' name='clearingforwarding' id='clearingforwarding'  style='width:100%;' onBlur='calclearingforwarding(this.value)'/>
	<input name='calclearingforwarding_amt' type='text' onkeyup='reversecalclearingforwarding(this.value);' id='calclearingforwarding_amt' style='width:100px;' /></td>";
	$data2.="</tr>";
	
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Detetion Charges</strong> </td>";
	$data2.="<td><input type='text' name='detetioncharges' id='detetioncharges'  style='width:100%;' onBlur='caldetetioncharges(this.value)'/>
	<input name='detetioncharges_amt' type='text' onkeyup='reversecaldetetioncharges(this.value);' id='detetioncharges_amt'style='width:100px;' /></td>";
	$data2.="</tr>";
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Other charges</strong></td>";
	$data2.="<td><input type='text' name='othercharges' id='othercharges'  style='width:150px;' style='margin-left:18px;'/></td>";
	$data2.="</tr>";		
	
	$data2.="<tr class='row1'>";
	$data2.="<td class='tabledata1'><strong>Grand Total</strong></td>";
	$data2.="<td><input type='text' name='GrandTotal' id='GrandTotal' onFocus='cal_grandamountimp()'  style='width:100%;'/></td>";
	$data2.="</tr>";
	$data2.="</table>";
}
echo $data=$data1."__".$data2;



