<?php $PageSecurity = 11;
 //echo $_SERVER['QUERY_STRING'];exit;
 include('includes/SQL_CommonFunctions.inc');
 include('includes/function_lib.php');
 include('includes/session.inc');
 global $db;

echo $dutytype=$_GET['dutytype'];
echo $grntype=$_GET['grntype'];

 $orderOne = $_REQUEST['ord1'];
 $orderTwo = $_REQUEST['ord2'];

if($dutytype=="Itemwise" && $grntype=="1")
{ ?>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td>
 <div id="importPo1" style="width:900px;overflow:auto;">
<table width="232%" border="1" cellspacing="0" cellpadding="3" style="border:1px solid #333333;">
<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>Pending QTY</strong></th>
	<th class="tabledata"><strong>Batch No.</strong></th>
	<th class="tabledata"><strong>QTY AS PER BILL </strong></th>
	<th class="tabledata"><strong>QTY Recieved</strong></th>
	<th class="tabledata"><strong>Short Quantity</strong></th>
	<th class="tabledata"><strong>Rate</strong></th>
	<th class="tabledata"><strong>Amount</strong></th>
	<th class="tabledata"><strong>Dis. Type</strong></th> 
	<th class="tabledata"><strong>Dis. % <br />or amt</strong>.</th>
	<th class="tabledata"><strong>Final<br  />Dis. Amt.</strong></th>
	<th class="tabledata"><strong>Discounted 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.</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>
  <input type="hidden" id="cvd_percentage" value="<?php echo $s->getField('custom_duty','type','CVD','def_rate');?>" />
  <input type="hidden" id="ecess_percentage" value="<?php echo $s->getField('custom_duty','type','ECESS','def_rate');?>" />
  <input type="hidden" id="secess_percentage" value="<?php echo $s->getField('custom_duty','type','SHE-CESS','def_rate');?>" />
  <input type="hidden" id="add_percentage" value="<?php echo $s->getField('custom_duty','type','ADC','def_rate');?>" />
  <?php 
$i=0;
if($orderOne!="")
{
$sql=DB_query("select * from direct_po_details where parent_id='".$orderOne."' and status='Pending'",$db);
}
else
{
$sql=DB_query("select * from addmrnqty where issue_id='".$orderTwo."'",$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');
	$unit1=$s->getField('item_master','id',$row['mst_itemid'],'conv_unit');
	$confac=$s->getField('item_master','id',$row['mst_itemid'],'conv_factor');
	$discount_type=$row['dis_type'];
	$discount=$row['dis_per'];
	$discount_amount=$row['dis_price'];
	$specialdiscounttype=$row['spl_dis_type'];
	$specialdiscount=$row['spl_dis_per'];
	$specialdiscount_amount=$row['spl_dis_amt'];
	$tax_type=$row['excise_flag'];
	$Excise_Duty=$row['excise_duty'];
	$ExcisePercentage=$row['ExcisePercentage'];
	$Edu_Cess_perc=$row['ECessPercentage'];
	$SHE_Cess_perc=$row['SAHCessPercentage'];
	
	$check_last_mrn="Select POQty,sum(reciveqty) from addmrnqty 
	where order_no='".$orderNo."' and mst_itemid='".$row['mst_itemid']."'";
	$last_mrn_res=DB_query($check_last_mrn,$db);
	
	$last_mrn_row=DB_fetch_array($last_mrn_res);
	
	if($last_mrn_row['POQty']!='' && $last_mrn_row['sum(reciveqty)']!='' )
	{
		$pending_qty=$last_mrn_row['POQty']-($last_mrn_row['sum(reciveqty)']);
	}
	else
	{
		$pending_qty=$row['qty'];
	}	
	

?>
 
<tr bgcolor="#c1c1c1">
	<td><?php echo $i+1;?></td>
	<td><?php echo $itemcode;?>
	<input type="hidden" name="convfac[]" id="convfac_<?php echo $i; ?>" value="<?php echo $confac; ?>" />
	<input type="hidden" readonly="" id="mst_itemid_<?php echo $i; ?>" name="mst_itemid[]" size="15" value="<?php echo $row['mst_itemid']; ?>" />
	<input type="hidden" readonly="" id="itemcode_<?php echo $i; ?>" name="itemcode[]" size="15"  value="<?php echo $itemcode; ?>" />
	</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_<?php echo $i; ?>" value="<?php echo $poqty;?>" size="10"/></td>
	<td><?php   echo $pending_qty;?>
	<input type="hidden" name="pending_qty[]" id="pending_qty_<?php echo $i; ?>" value="<?php echo $pending_qty;?>" />
	</td>
	<td><input type="text" name="batch_no[]" id="batch_no_<?php echo $i; ?>" value="<?php echo $row['batch_no'];?>" /></td>
	<td><input name="qty_as_per_bill[]" type="text" id="qty_as_per_bill2_<?php echo $i; ?>" value="<?php echo $row['qty_as_per_bill'];?>"  size="8" onblur="check_bill_qty(this.value,<?php echo $i;?>)"/>
	</td>
	<td><input name="reciveqty[]" type="text" id="reciveqty2_<?php echo $i; ?>"  size="8"  onkeyup="check_po_qty1(<?php echo $i;?>)" value="<?php echo $row['reciveqty']; ?>"  /></td>
	<!--<td><input name="scecondarqty[]" type="text" id="scecondarqty_<?php echo $i; ?>"  size="8"   /></td>-->
	<td><input name="short_accessid[]" type="text" id="short_accessid2_<?php echo $i; ?>" value="<?php echo  $row['short_accessid'];?>" size="8" readonly="true" onfocus="calculate_poshort2(<?php echo $i ?>);"/></td>
	<td><?php //echo $row['rate'];?>
	<input name="itemrate[]" type="rext" id="itemrate2_<?php echo $i; ?>" readonly="true"  size="8" value="<?php echo  $row['rate'];?>"/>
	</td>
	<td>
	<input name="itemamount[]" type="text" id="itemamount2_<?php echo $i; ?>" onfocus="calculateTotalPrice2(this.id)"  size="8" readonly="true" value="<?php echo $row['itemamount'];?>"/>
	</td>
	<td class="tabledata" id ="hideArea1"><select style="width:80px;" name="DiscountType1[]" id="PerAmo2_<?php echo $i; ?>">
            <option value="Amount"<?php echo ($row['DiscountType1']=='Amount')?'selected':''?>>Amount</option>
            <option value="PercentAmt"<?php echo ($row['DiscountType1']=='PercentAmt')?'selected':''?>>Percent Amt</option>
          </select></td>
		  <td><input type="text" style="width:40px" name="discount[]" id="Discount2_<?php echo $i;?>" onblur="DiscountAmount3(this.value,this.id)" value="<?php echo $row['discount_1'];?>" /></td>
	<td class="tabledata"><input type="text" name="discounted_amount1[]" id="perc2_<?php echo $i; ?>"  readonly="true" style="width:100%;" onFocus="Check(this.value)" value="<?php echo $row['discounted_amount1'];?>"/></td> 
		<td class="tabledata" id ="hideArea3"><input type="text"  id="NetRate2_<?php echo $i;?>" name="NetRate1[]" style="width:70px;" value="<?php echo $row['NetRate1'];?>" readonly/></td>
		<td><input name="itemCurrency[]" type="text" id="itemCurrency_<?php echo $i; ?>" value="<?php echo $row['itemCurrency'];?>" size="8" readonly="true"/>
	</td>
	<td class="tabledata"><select style="width:80px;" name="conv_curr[]" id="conv_curr_<?php echo $i; ?>">
			<?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['conv_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; ?>" onblur="calcNewAmount(this.id,this.value)" size="8" value="<?php echo $row['conv_rate'];?>"/></td>
		<td class="tabledata"><input type="text" style="width:70px" id="basic_<?php echo $i;?>" name="basic[]" onblur="cal_basic_total(this.id)" value="<?php echo $row['basic'];?>" readonly/></td>
		<td class="tabledata"><select name="Excise_type1[]" style="width:85px" id="hid_billing_type_<?php echo $i;?>"  onchange="checkExcisable(this.value,this.id)">
	<option value="">Select</option>
	<option value="1"<?php echo ($row['Excise_type1']=='Amount')?'selected':''?>>Yes</option>
	<option value="2"<?php echo ($row['Excise_type1']=='Amount')?'selected':''?>>No</option>
</select></td>
	<td class="tabledata"><select name="Excise_Duty1[]" id="exciseDuty_<?php echo $i;?>" style="width:120px;"    onchange="claculateExcise(this.id,this.value)" 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['id'];?>"<?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 type="text"  id="dutyamount_<?php echo $i;?>" readonly="" onfocus="checkduty(this.id)" name="duty_amount[]" style="width:70px;" onblur="cal_custom_total(this.id)" value="<?php echo $row['duty_amount_1'];?>"/></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="TotalSpecial_<?php echo $i;?>" name="TotalAmount1[]" style="width:70px;" onfocus="cal_grandtotal(this.id);" value="<?php echo $row['TotalAmount1'];?>" onblur="cal_cvd_total(this.id);"/></td>
		<td class="tabledata"><input type="text" id="customecess_<?php echo $i;?>" name="custom_ecess[]" style="width:70px;" onblur="cal_ecess_total(this.id);" value="<?php echo $row['custom_ecess'];?>" onfocus="cal_e_cess1(this.id);" / ></td>
		<td class="tabledata"><input type="text" id="customsececess_<?php echo $i;?>" name="custom_sec_ecess[]" style="width:70px;" onblur="cal_ecess_sec_total(this.id);" value="<?php echo $row['custom_sec_ecess'];?>"  onfocus="cal_esec_cess1(this.id);" / ></td>
		<td class="tabledata"><input type="text" id="adduty_<?php echo $i;?>" name="adduty[]" style="width:70px;" value="<?php echo $row['adduty'];?>" onfocus="cal_add_duty1(this.id);"  onblur="cal_addcharg_total(this.id);"  / ></td>
</tr>
  <?php $i++; }	 ?>
  <input type="hidden" name="countval3" 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_amounts" id="total_item_amount12" style="width:100%;" onfocus="cal_totalamount12()" />
				
				  </td>
               </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_percs" id="pkg_perc" size="5" onkeyup="calcPackaging12(this.value)" /><input name="pkg_chargess" id="pkg_charges" type="text" size="28"  
				  onfocus="calcPackaging1()" /></td>
                </tr>
                <tr>
                  <td><strong>Custom Duty</strong> </td>
              <td><input type="text" name="custom_dutys" id="custom_duty" style="width:100%;" /></td>
              </tr>
              <tr>
              	<td><strong>CVD</strong></td>
              <td><div id="taxval">
                  <input type="text" name="cvd_totals" id="cvd_total" style="width:100%;"/>
              </div>

	</td>
                </tr>
                <tr>
                  <td><strong>Custom E.Cess</strong> </td>
                  <td><input type="text" name="custom_ecesss" id="custom_ecess" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Custom SE.Cess</strong> </td>
                  <td><input type="text" name="custom_sec_ecesss" id="custom_sec_ecess" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Additional Duty </strong> </td>
                  <td><input name="add_chargess" id="additionalCharges" type="text" size="25" style="width:100%;" /></td>
                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="tot_freights" id="TotalCharge" style="width:100%;"   /></td>
                </tr>
				<tr>
                  <td><strong>Loading /Unloading</strong> </td>
                  <td><input type="text" name="loadings" id="loading1" style="width:100%;" /></td>
                </tr>
				<!--<tr>
					<td><strong>Round Off</strong></td>
					<td><input type="text" name="round_off" id="round_off" style="width:100%;"/></td>
				</tr>-->
                <tr>
				<td><strong>Grand Total <font color="#FF0000">*</font></strong></td>
                  <td><input type="text" name="grandtotals" id="orig_grand_tot" onfocus="cal_grandamount1()"  size="12"/><input type="hidden"  id="orig_grand_tot" />&nbsp;<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="+">+</option>
				  <option value="-">-</option>
				  </select></td>
                </tr>
              </table>
		     </th>
		<td>		</td>
		</tr>
			</table>

</div>
<?php
}
elseif($dutytype=="Consolidated" && $grntype=="1")
{ ?>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>

 <div id="importPo3" style="width:900px;overflow:auto;">
<table width="232%" border="1" cellspacing="0" cellpadding="3" style="border:1px solid #333333;">
<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>Pending QTY</strong></td>
	<td class="tabledata"><strong>Batch No.</strong></td>
	<td class="tabledata"><strong>QTY AS PER BILL </strong></td>
	<td class="tabledata"><strong>QTY Recieved</strong></td>
	<td class="tabledata"><strong>Short Quantity</strong></td>
	<td class="tabledata"><strong>Rate</strong></td>
	<td class="tabledata"><strong>Amount</strong></td>
	<td class="tabledata" id ="hideArea16">Dis. Type</td>  
	<td class="tabledata" id ="hideArea15">Dis. % <br />or amt.</td>
	<td class="tabledata" id ="hideArea14">Final<br  />Dis. Amt.</td>
	<td class="tabledata" id ="hideArea13">Discounted Amount</td>
	<td class="tabledata" id ="hideArea12">Basic<br /> Amt.</td>
  </tr>
  <?php 
$i=0;
if($orderOne!="")
{
$sql=DB_query("select * from direct_po_details where parent_id='".$orderOne."' and status='Pending'",$db);
}
else
{
echo "select * from addmrnqty where issue_id='".$orderTwo."'";
$sql=DB_query("select * from addmrnqty where issue_id='".$orderTwo."'",$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');
	$unit1=$s->getField('item_master','id',$row['mst_itemid'],'conv_unit');
	$confac=$s->getField('item_master','id',$row['mst_itemid'],'conv_factor');
	$discount_type=$row['dis_type'];
	$discount=$row['dis_per'];
	$discount_amount=$row['dis_price'];
	$specialdiscounttype=$row['spl_dis_type'];
	$specialdiscount=$row['spl_dis_per'];
	$specialdiscount_amount=$row['spl_dis_amt'];
	$tax_type=$row['excise_flag'];
	$Excise_Duty=$row['excise_duty'];
	$ExcisePercentage=$row['ExcisePercentage'];
	$Edu_Cess_perc=$row['ECessPercentage'];
	$SHE_Cess_perc=$row['SAHCessPercentage'];
	
	$check_last_mrn="Select POQty,sum(reciveqty) from addmrnqty 
	where order_no='".$_GET['orderno']."' and mst_itemid='".$row['mst_itemid']."'";
	$last_mrn_res=DB_query($check_last_mrn,$db);
	
	$last_mrn_row=DB_fetch_array($last_mrn_res);
	
	if($last_mrn_row['POQty']!='' && $last_mrn_row['sum(reciveqty)']!='' )
	{
		$pending_qty=$last_mrn_row['POQty']-($last_mrn_row['sum(reciveqty)']);
	}
	else
	{
		$pending_qty=$row['qty'];
	}	
	

?>
 
<tr bgcolor="#c1c1c1">
	<td><?php echo $i+1;?></td>
	<td><?php echo $itemcode;?>
	<input type="hidden" name="convfac[]" id="convfac_<?php echo $i; ?>" value="<?php echo $confac; ?>" />
	<input type="hidden" readonly="" id="mst_itemid_<?php echo $i; ?>" name="mst_itemid[]" size="15" value="<?php echo $row['mst_itemid']; ?>" />
	<input type="hidden" readonly="" id="itemcode_<?php echo $i; ?>" name="itemcode[]" size="15"  value="<?php echo $itemcode; ?>" />
	
	</td>
	<td><?php echo $itemname ?></td>
	<td><?php $unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
	echo $unitname;?></td>
	<td><?php   echo $poqty=$row['qty']; ?>
	<input name="poqty[]" type="hidden" id="poqty_<?php echo $i; ?>" value="<?php echo $poqty;?>" size="10"/></td>
	<td><?php   echo $pending_qty;?>
	<input type="hidden" name="pending_qty[]" id="pending_qty_<?php echo $i; ?>" value="<?php echo $pending_qty;?>" />
	</td>
	<td><input type="text" name="batch_no[]" id="batch_no_<?php echo $i; ?>" value="" /></td>
	<td><input name="qty_as_per_bill[]" type="text" id="qty_as_per_bill1_<?php echo $i; ?>"  size="8" onblur="check_bill_qty(this.value,<?php echo $i;?>)"/>
	</td>
	<td><input name="reciveqty[]" type="text" id="reciveqty1_<?php echo $i; ?>"  size="8"  onkeyup="check_po_qty1(<?php echo $i;?>)"  /></td>
	<!--<td><input name="scecondarqty[]" type="text" id="scecondarqty_<?php echo $i; ?>"  size="8"   /></td>-->
	<td><input name="short_accessid[]" type="text" id="short_accessid1_<?php echo $i; ?>" value="<?php echo $_REQUEST['short_accessid'][$i];?>" size="8" readonly="true" onfocus="calculate_poshort1(<?php echo $i ?>);"/></td>
	<td><?php //echo $row['rate'];?>
	<input name="itemrate[]" type="text" id="itemrate1_<?php echo $i; ?>" value="<?php echo  $row['rate'];?>"  size="8" readonly="true"/>
	</td>
	<td><?php //echo $row['rate']*$poqty;?>
	<input name="itemamount[]" type="text" id="itemamount1_<?php echo $i; ?>" value="" onfocus="calculateTotalPrice1(this.id)"  size="8"/>
	</td>
	 <td class="tabledata" id ="hideArea1"><select style="width:80px;" name="DiscountType1[]" id="PerAmo1_<?php echo $i; ?>">
            <option value="Amount" <?php echo ($_POST['PerAmo']=='Amount')?'selected':''?>>Amount</option>
            <option value="PercentAmt"<?php echo ($_POST['PerAmo']=='PercentAmt')?'selected':''?>>Percent Amt</option>
          </select></td>
		  <td id ="hideArea2"><input type="text" style="width:40px" name="discount[]" id="Discount1_<?php echo $i;?>" onblur="DiscountAmount1(this.value,this.id)" value="<?php echo $discount;?>" /></td>
	<td class="tabledata"><input type="text" name="discounted_amount1[]" id="perc1_<?php echo $i; ?>"  readonly="true" style="width:100%;" /></td> <!--onFocus="Check(this.value)"-->
		<td class="tabledata" id ="hideArea3"><input type="text"  id="NetRate1_<?php echo $i;?>" name="NetRate1[]" style="width:70px;" readonly/></td>
		<td class="tabledata" id ="hideArea4"><input type="text" style="width:70px" id="basic1_<?php echo $i;?>" name="basic[]" readonly/></td>
</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="charges3">			
			<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_amount3" style="width:100%;" onfocus="cal_totalamount2()"/>
				  </td>
               </tr>
			   <tr>
                  <td><strong>Currency Conversion<font color="#FF0000">*</font></strong> </td>
                  <td >
				  <select style="width:80px;" name="tot_currency[]" id="tot_currency">
			<?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 ($_POST['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="" size="28"  
				  onblur="calctotConvAmt(this.value)" />
				  </td>
               </tr>
			   <tr>
                  <td><strong>Conversion Amount</strong> </td>
                  <td><input type="text" name="tot_conv_amt" id="tot_conv_amt"  size="28" /></td>
                </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_perc" id="pkg_perc" value="<?php echo $venddata['pkg_per']; ?>" size="5" onkeyup="calcPackaging3(this.value)" /><input name="pkg_charges" id="pkg_charges3" type="text" value="" size="28"  
				  onfocus="calcPackaging1()" /></td>
                </tr>
                <tr>
                  <td><strong>Custom Duty</strong> </td>
              <td><select name="custom_duty_per" id="custom_duty_per" style="width: 55%" onchange="calcCustom(this.value)">
		<?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 $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
			  <input type="text" name="custom_duty" id="custom_duty_new" style="width:100%;"/></td>
              </tr>
              <tr>
              	<td><strong>CVD</strong></td>
              <td><select name="cvd_per" id="cvd_per" style="width: 55%" onchange="calcCvd(this.value)">
		<?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 $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
                  <input type="text" name="cvd_total" id="cvd_total_new" style="width:100%;"/></td>
                </tr>
                <tr>
                  <td><strong>Custom E.Cess</strong> </td>
                  <td>
				  <select name="cstm_ecess_per" id="cstm_ecess_per" style="width: 55%" onchange="calcCustmexcess(this.value)">
		<?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 $accgroup_row['caption'];?></option>
		<?php } ?>
		</select><input type="text" name="custom_ecess" id="custom_ecess_new" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Custom SE E.Cess</strong> </td>
                  <td><select name="cstm_ecessec_per" id="cstm_ecessec_per" style="width: 55%" 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 $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
				<input type="text" name="custom_sec_ecess" id="custom_sec_ecess_new" style="width:100%;"/></td>
                </tr>
				<tr>
                  <td><strong>Additional Duty </strong> </td>
                  <td><select name="cstm_add_per" id="cstm_add_per" style="width: 55%" 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 $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
				  <input name="add_charges" id="add_charges_new" type="text"  size="25" style="width:100%;" /></td>
                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="tot_freight" id="TotalCharge2" style="width:100%;" value="<?php echo $venddata['totalcharge']; ?>"     /></td>
                </tr>
				<tr>
                  <td><strong>Loading/Unloading</strong> </td>
                  <td><input type="text" name="loading" id="loading2" style="width:100%;" value="<?php echo $venddata['loading']; ?>"/></td>
                </tr>
				<!--<tr>
					<td><strong>Round Off</strong></td>
					<td><input type="text" name="round_off" id="round_off" style="width:100%;"/></td>
				</tr>-->
                <tr>
				<td><strong>Grand Total <font color="#FF0000">*</font></strong></td>
                  <td><input type="text" name="grandtotal" id="orig_grand_tot2" onfocus="cal_grandamount5()"  size="12"/><input type="hidden"  id="orig_grand_tot2" />&nbsp;<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="+">+</option>
				  <option value="-">-</option>
				  </select></td>
                </tr>
              </table>
		     </th>
		<td>		</td>
		</tr>
			</table>
</div>
<?php
}
?>