				<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
	
       var e = document.getElementById("print");
      
     	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
</script>
				
				<?php ob_start();
				$PageSecurity = 4;
				$PageName = 'MaterialReceiptNote';
				include('includes/DefinePOClass.php');
				include('includes/SQL_CommonFunctions.inc');
				include('config.php');
				include('includes/ConnectDB.inc');
				include('includes/function_lib.php');
				include('includes/LanguageSetup.php');
				include('includes/DateFunctions.inc');
				
				//echo $_REQUEST['mrnid'];
				
		if(isset($_REQUEST['mrnid']))
		{
		//echo "SELECT *,lrdate from addmrn where id='".$_REQUEST['mrnid']."'";
		$GetData="SELECT *,lrdate from addmrn where id='".$_REQUEST['mrnid']."'";
		$GetResultData= DB_query($GetData,$db);
		$GetRowData=DB_fetch_array($GetResultData);
		$dutytype=$GetRowData['duty_type'];
		$prdby=$s->getField('log_reason','id',$row_quotes['doc_id'],'reason_id'); 
		$Trans=$GetRowData['Transp_name'];
		$Form_Type=$GetRowData['form_type'];
		  $vnum=$GetRowData['vehicalno'];
		   $lrdate=$GetRowData['lrdate'].'--';
		  $getentryno=$GetRowData['gatepassno'];
		  $getentrydate=$GetRowData['gatepassdate'];
		  $orddate=$GetRowData['orderdate'];
		  $docno=$GetRowData['billno'];
		  $warehouse=$GetRowData['storename'];
		  $billdate=$GetRowData['BillDate']; 
		   //echo    $frmtype=$GetRowData['form_type'];
		  $doctype=$GetRowData['DocumentType']; 
		  $contno=$GetRowData['containerNo'];
		 $RemarksIfAny=$GetRowData['RemarksIfAny'];
		$MRNNo=$GetRowData['MRNNo'];
		$MRNDate= ($GetRowData['MRNDate']);
		$sitecode=$GetRowData['OrderFromSite'];
		$OrderFromSite=$GetRowData['site'];
		$MRNVoucherDate=($GetRowData['MRNVoucherDate']);
	 	$ReceivedFrom=$GetRowData['ReceivedFrom'];
		$MaterialReceiptOnBasis=$GetRowData['MaterialReceiptOnBasis'];
		$receiviedagaist=$GetRowData['receiviedagaist'];
		$rmrs_no=$GetRowData['rmrs_no'];
		$Type=$GetRowData['Type'];
		$site_name=$GetRowData['site_name'];
	    $PO=$GetRowData['PO_WO_MTO'];
		$BillNo=$GetRowData['BillNo'];
		$Inwardsdate=$GetRowData['Inwardsdate'];
		$DocumentType=$GetRowData['DocumentType'];
		$GetPassNo=$GetRowData['GetPassNo'];
	    //$conno=$$GetRowData['containerNo'];
		$VehicleNo=$GetRowData['VehicleNo'];
		$LRno=$GetRowData['LRno'];
		$LRdate=$GetRowData['LRdate'];
		$TotalWeight=$GetRowData['TotalWeight'];
		
		$Form_No=$GetRowData['form_no'];
		$gatepassdate=$GetRowData['gatepassdate'];
		
	}
?>
<!--link rel="stylesheet" href="css/new_mxerp.css"--->

<h2 align="center"><strong>Material Receipt Note Edit</strong></h2>
<br />
<div style="width:100%">
<h3><strong>GENERAL DETAILS</strong></h3>
</div>
<form action="" method="post">
<table width="100%" border="1" cellspacing="2" cellpadding="5" align="center">
    <th width="15%"><strong>Mrn No. </strong></th>
    <td width="30%">
    <?php echo $MRNNo; ?></td>
    <th width="31%"><strong>MRN Date </strong></th>
    <td width="24%" colspan="2"><?php echo $MRNDate; ?></td>
  </tr>
  <tr>
    <th><strong>Site</strong></th>
    <td><?php echo $s->getField('locations','loccode',$OrderFromSite,'locationname');?></td>
    <th><strong> Warehouse  </strong>        </th>
    <td>
        <?php echo $s->getField('storetype','id',$warehouse,'StoreName'); ?></td>
  </tr>
  <tr>
    <th><strong>Received Against</strong></th>
    <td ><input name="receiviedagaist" type="text" id="receiviedagaist" style="width:100%" value="<?php if($_REQUEST['receipt']!="")
	{ echo $_REQUEST['receipt']; } else {echo $Type;} ?>" readonly/></td>
    <th scope="row"><strong>Vendor</strong></th>
    <td>
	<input type="text" value="<?php echo str_replace(array("M/s ","M/S"),'',$s->getField('suppliers','id',$ReceivedFrom,'vendor_name'));
	 ?>" style="width:100%" name="vendor" id="vendor" readonly/>
		 </td>
  </tr>
 <tr>
    <th><strong>PO</strong></th>
    <td>
	<input name="Purchase_Order" type="text" style="width:100%" readonly value="<?php echo $s->getField('direct_po','id',$GetRowData['PO_WO_MTO'],'pr_no'); ?>"/> 
	 </td>
    <th><strong>PO Date </strong></th>
    <td><input name="ordDate" type="text" style="width:100%" value="<?php echo  ConvertSQLDate($s->getField('direct_po','id',$GetRowData['PO_WO_MTO'],'pr_date')); ?>" readonly/>    </td>
  </tr>
  <tr>
    <th><strong>GRN Type</strong></th>
    <td>
	<input name="GrnType" type="text" style="width:100%" readonly value="<?php if($grntype=='1') { echo 'Import'; } else { echo 'Domestic'; } ?>"/>
     </td>
    <th><strong>Document No. </strong></th>
    <td><input name="billno" type="text" id="billno" style="width:100%" value="<?php  echo $GetRowData['BillNo']; ?>" /></td>
  </tr>
  <tr>
    <th scope="row"><strong>Challan / Bill Date</strong></th>
    <td><input type="text" name="MRNVoucherDate" style="width:100%" class="datepicker"  value="<?php echo ConvertSQLDate($billdate); ?>"/></td>
    <th><strong>Gate Entry no</strong></th>
    <td><input type="text" name="gatepassno"  style="width:100%" id="gatepassno"  value="<?php echo $GetPassNo;?>" /></td>
  </tr>
  <tr>
    <th scope="row"><strong>Transporter Name</strong></th>
    <td>
	 <input type="text" name="gatepassno"  style="width:100%" id="gatepassno"  value="<?php echo $s->getField('form_type_master','id',$Form_Type,'form_name');
	 $Trans;?>"  />
		</td>
    <th><strong>Vehicle No.</strong></th>
    <td><input name="vehicalno" type="text" id="vehicalno"  style="width:100%" value="<?php echo $VehicleNo; ?>"/></td>
  </tr>
  <tr>
    <th scope="row"><strong>Container No.</strong></th>
    <td><input type="text" name="gatepassno"  style="width:100%" id="gatepassno"  value="<?php echo $contno; ?>" /> </td>
    <th><strong>L R No.</strong></th>
    <td><input name="lrno" type="text" id="lrno" style="width:100%" value="<?php echo $GetRowData['LRno']; ?>"/></td>
  </tr>
  <tr>
    <th scope="row"><strong>L R Date</strong></th>
    <td><input name="lrdate" type="text" id="lrdate" style="width:100%" value="<?php echo ConvertSQLDate($lrdate); ?>"   class="datepicker"/></td>
    <th><strong>Form Type</strong></th>
    <td><input name="lrdate" type="text" id="lrdate" style="width:100%" value="<?php echo $s->getField('form_type_master','id',$Form_Type,'form_name'); ?>"   class="datepicker"/>
	 </td>
  </tr>
  <tr>
    <th height="37" scope="row"><strong>Form No</strong></th>
    <td>
      <input type="text" name="form_no"  style="width:100%" value="<?php echo $GetRowData['form_no']; ?>" id="form_no" /></td>
    <th>Gate Entry Date</th>
    <td><input type="text" name="gatepassdate" id="gatepassdate" value="<?php echo $getentrydate; ?>" style="width:100%" /></td>
  </tr>
  <tr>
  <th scope="row"><strong>Remarks If Any</strong></th>
    <td><textarea name="RemarksIfAny"  id="RemarksIfAny"  style="width:200px;"><?php echo $RemarksIfAny;?></textarea></td>
    
    <th scope="row"><strong>Document Type</strong></th>
    <td><input type="text" name="gatepassdate" id="gatepassdate" value="<?php echo $DocumentType ; ?>" style="width:100%" class="datepicker" /> </td>
  </tr>
  
  
  
  <tr class="row1">
    
	
	

  </tr>
</table>
<br /><br />
	<div id="itemTable" style="width:950px;overflow:auto;">
	<table width='100%' 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>QTY AS PER BILL </strong></td>
	<td class='tabledata'><strong>QTY Recieved</strong></td>
	<td class='tabledata'><strong>Short/Excess Quantity</strong></td>
 </tr>
 <?php
$i=0;
$sql=DB_query("select * from addmrnqty where issue_id='".$GetRowData['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');
	 $check_last_mrn="Select qty from direct_po_details 
	where parent_id='".$GetRowData['PO_WO_MTO']."' and mst_itemid='".$row['mst_itemid']."'";
	$last_mrn_res=DB_query($check_last_mrn,$db);
	$last_mrn_row=DB_fetch_array($last_mrn_res);
	
	$check_last_mrn1="Select sum(reciveqty) from addmrnqty inner join addmrn on addmrn.id=addmrnqty.issue_id 
	where addmrn.PO_WO_MTO='".$GetRowData['PO_WO_MTO']."' and addmrnqty.mst_itemid='".$row['mst_itemid']."'";
	$last_mrn_res1=DB_query($check_last_mrn1,$db);
	
	$last_mrn_row1=DB_fetch_array($last_mrn_res1);
	 $last_mrn_row1['sum(reciveqty)'];
	if($last_mrn_row['qty']>=$last_mrn_row1['sum(reciveqty)'])
	{
		$pending_qty=$last_mrn_row['qty']-($last_mrn_row1['sum(reciveqty)']);
		 $pending_qty;
	}
	else
	{
		$pending_qty=$last_mrn_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; ?>' />
	<input type='hidden' readonly='' id='tolerances_<?php echo $i; ?>' name='tolrancees[]' size='15'  value='<?php echo $tolerance; ?>' />
	<input type='hidden' readonly='' id='pending_<?php echo $i; ?>' name='pending[]' size='15'  value="<?php echo $pending_qty; ?>" /></td>
	<input type='hidden' readonly='' id='mst_itemid_".$i."' name='details_id[]' size='15' value='<?php echo $row['id']; ?>' />
	<td><?php echo $row['mst_itemid']; ?></td>
	<td><?php echo $unitname=$s->getField('unitsofmeasure','unitid',$unit,'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 name='qty_as_per_bill[]' type='text' id='qty_as_per_bill_<?php echo $i; ?>'  onkeyup='calTotalQty1(this.value,<?php echo $i; ?>);' size='8' onblur='check_bill_qtyNew(this.value,<?php echo $i; ?>)' value='<?php echo $row['qty_as_per_bill']; ?>'/></td>
	<td><input name='reciveqty[]' type='text' id='reciveqty_<?php echo $i; ?>' onkeyup='calTotalQty(this.value,<?php echo $i; ?>);' value='<?php echo $row['reciveqty']; ?>'  size='8' /></td>
	<td><input name='short_accessid[]' type='text' id='short_accessid_<?php echo $i; ?>' value='<?php echo $row['short_accessid']; ?>' size='8' readonly='true' onfocus='calculate_poshort(<?php echo $i; ?>);'/></td>
</tr>
<?php
 
 $i++; }
 ?>	
<tr bgcolor='#c1c1c1'>
<td colspan='6'>Total Qty </td>
<td><input name='totalBillQty' type='text' value='<?php echo $GetRowData['totalBillQty']; ?>' id='short'  size='8' /></td>
<td colspan='2'><input name='totalRecQty' type='text' value='<?php echo $GetRowData['totalRecQty']; ?>' id='short1'  size='8' /></td>
</tr>
 <input type='hidden' name='countval' value='<?php echo $i; ?>'   id='count'/>
</table>
 	</div>
	<br/>
	<br/>
	 <div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
<div align="center" style="width:130px; margin-left:auto; margin-right:auto;">
	<div style="background-image:url(images/print_icon.png); background-repeat:no-repeat; width:50px; height:100; float:left; padding:5px;" onclick="toggle_visibility()" id="print">&nbsp;</div>	
	
	</div>
<div id="abc">
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td>
<?php if($grntype=='1' && $dutyType=='Itemwise') { ?>
 <div  style="width:900px;display:block;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;
$sql=DB_query("select * from addmrnqty where issue_id='".$_REQUEST['mrnid']."'",$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['itemprice'];?>"/>
	</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="text" name="countval" value="<?php echo $i; ?>"  id="count"/>
</table>
 </div>

<div  id="OLDcharges1" align="right">			
			<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()" value="<?php echo $totalAmount; ?>"/>
				
				  </td>
               </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_percs" id="pkg_perc" value="<?php echo $pkgPerc; ?>" size="5" onkeyup="calcPackaging12(this.value)" /><input name="pkg_chargess" id="pkg_charges" type="text" size="28"  
				  onfocus="calcPackaging1()" value="<?php echo $pkgCharges; ?>"/></td>
                </tr>
                <tr>
                  <td><strong>Custom Duty</strong> </td>
              <td><input type="text" name="custom_dutys" id="custom_duty" style="width:100%;" value="<?php echo $totalCustom; ?>"/></td>
              </tr>
              <tr>
              	<td><strong>CVD</strong></td>
              <td><div id="taxval">
                  <input type="text" name="cvd_totals" value="<?php echo $cvdTotal; ?>" id="cvd_total" style="width:100%;"/>
              </div>

	</td>
                </tr>
                <tr>
                  <td><strong>Custom E.Cess</strong> </td>
                  <td><input type="text" name="custom_ecesss" value="<?php echo $custEcess; ?>" 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 $custom_sec; ?>" 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 $addCharges; ?>" 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 $frieght; ?>" id="TotalCharge" style="width:100%;"   /></td>
                </tr>
				<tr>
                  <td><strong>Loading /Unloading</strong> </td>
                  <td><input type="text" name="loadings" id="loading1" value="<?php echo $loadingData; ?>" 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()" value="<?php echo $grandTotal; ?>" 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 } ?>
<?php if($grntype=='1' && $dutyType=='Consolidated') { ?>
 <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;
$sql=DB_query("select * from addmrnqty where issue_id='".$_REQUEST['mrnid']."'",$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='".$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['itemprice'];?>"/>
	</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 class="tabledata" id ="hideArea4"><input type="text" style="width:70px" id="basic1_<?php echo $i;?>" value="<?php echo $row['basic'];?>" name="basic[]" readonly/></td>
</tr>
  <?php $i++; }	 ?>
  <input type="hidden" name="countval1" 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_amounts" id="total_item_amount3" style="width:100%;" onfocus="cal_totalamount2()" value="<?php echo $totalAmount; ?>" />
				  </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 ($GetRowData['tot_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 $GetRowData['tot_conv_rate']; ?>" 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" value="<?php echo $GetRowData['tot_conv_amt']; ?>" size="28" /></td>
                </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_percs" id="pkg_perc" value="<?php echo $GetRowData['pkg_perc']; ?>" size="5" onkeyup="calcPackaging3(this.value)" /><input name="pkg_chargess" id="pkg_charges3" type="text" value="<?php echo $GetRowData['pkg_charges']; ?>" 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 ($GetRowData['custom_duty_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
			  <input type="text" name="custom_dutys" value="<?php echo $GetRowData['total_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 ($GetRowData['cvd_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select>
                  <input type="text" name="cvd_totals" id="cvd_total_new" value="<?php echo $GetRowData['cvd_total']; ?>" 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 ($GetRowData['cstm_ecess_per']==$accgroup_row['def_rate'])?'selected':''?>><?php echo $accgroup_row['caption'];?></option>
		<?php } ?>
		</select><input type="text" name="custom_ecess1" value="<?php echo $GetRowData['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 ($GetRowData['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 $GetRowData['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 ($GetRowData['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 $GetRowData['add_charges']; ?>" size="25" style="width:100%;" /></td>
                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="tot_freights" id="TotalCharge2" style="width:100%;" value="<?php echo $GetRowData['freight']; ?>"     /></td>
                </tr>
				<tr>
                  <td><strong>Loading/Unloading</strong> </td>
                  <td><input type="text" name="loadings" id="loading2" style="width:100%;" value="<?php echo $GetRowData['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="grandtotals" id="orig_grand_tot2" value="<?php echo $GetRowData['grandtotal']; ?>" 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 } ?>
<?php if($grntype=='2' && $dutyType=='Consolidated') { ?>
<div id="importPo4" style="width:950px;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;
$sql=DB_query("select * from addmrnqty where issue_id='".$_REQUEST['mrnid']."'",$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='".$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; ?>" />
	<input type="hidden" readonly="" id="tolerances_<?php echo $i; ?>" name="tolrancees[]" size="15"  value="<?php echo $tolerance; ?>" />
	<input type="hidden" readonly="" id="pending_<?php echo $i; ?>" 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 $unitname=$s->getField('unitsofmeasure','unitid',$unit1,'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_bill3_<?php echo $i; ?>"  size="8" onblur="check_bill_qty(this.value,<?php echo $i;?>)" value="<?php echo $row['qty_as_per_bill']; ?>"/>
	</td>
	<td><input name="reciveqty[]" type="text" id="reciveqty3_<?php echo $i; ?>"  size="8"  onkeyup="check_po_qty1(<?php echo $i;?>)" value="<?php echo $row['reciveqty']; ?>" /></td>
	<td><input name="short_accessid[]" type="text" id="short_accessid3_<?php echo $i; ?>" value="<?php echo $row['short_accessid']; ?>" size="8" readonly="true" onfocus="calculate_poshort3(<?php echo $i ?>);"/></td>
	<td><?php //echo $row['rate'];?>
	<input name="itemrate[]" type="text" id="itemrate3_<?php echo $i; ?>" value="<?php echo $row['itemprice']; ?>"  size="8" readonly="true"/>
	</td>
	<td>
	<input name="itemamount[]" type="text" id="itemamount3_<?php echo $i; ?>" value="<?php echo $row['itemamount']; ?>" onfocus="calculateTotalPrice3(this.id)"  size="8"/>
	</td>
	 <td class="tabledata"><select style="width:80px;" name="DiscountType1[]" id="PerAmo3_<?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 id ="hideArea2"><input type="text" style="width:40px" name="discount[]" id="Discount3_<?php echo $i;?>" onblur="DiscountAmount4(this.value,this.id)" value="<?php echo $row['discount']; ?>"  /></td>
	<td class="tabledata"><input type="text" name="discounted_amount1[]" id="perc3_<?php echo $i; ?>" value="<?php echo $row['discounted_amount1']; ?>" readonly="true" style="width:100%;" /></td>
		<td class="tabledata" id ="hideArea3"><input type="text" value="<?php echo $row['NetRate1']; ?>" id="NetRate3_<?php echo $i;?>" name="NetRate1[]" style="width:70px;" readonly/></td>
		<td class="tabledata" id ="hideArea4"><input type="text" value="<?php echo $row['basic']; ?>" style="width:70px" id="basic3_<?php echo $i;?>" name="basic[]" readonly/></td>
</tr>
  <?php $i++; }	 ?>
  <input type="hidden" name="countval3" 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_amounts" id="total_item_amount4" style="width:100%;" onfocus="cal_totalamount3()" value="<?php echo $GetRowData['total_amount']; ?>" /></td>

               </tr>

              <tr>

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

                  <td><input type="text" name="pkg_percs" id="pkg_perc4" size="5" value="<?php echo $GetRowData['pkg_perc']; ?>" onchange="calcPackaging4(this.value)" /><input name="pkg_chargess" id="pkg_charges4" value="<?php echo $GetRowData['pkg_charges']; ?>" type="text" size="28" /></td>
                </tr>
				<tr>
                  <td><strong>Total Excise Amt</strong> </td>
                  <td><select name="tot_excise_amt11" 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($Excise_Duty==$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 $GetRowData['excise_perc']; ?>"  style="width:35px;;"  /> 
	<input name="tot_excise_amt" id="exciseValueTot" type="text" style="width:70px;" onfocus="calculateExciseDuty2(<?php echo $i; ?>)" value="<?php echo $GetRowData['tot_excise_amt']; ?>" />
	</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 $GetRowData['e_cess_perc']; ?>" style="width:35px;" readonly   />
	<input name="tot_ecess_amt" id="ECessValueTot" type="text" value="<?php echo $GetRowData['tot_ecess_amt']; ?>"  style="width:70px;" readonly onfocus="calculateECess2()"/></td>
                </tr>
				<tr>
				<td><strong>Total SE E.Cess Amt</strong> </td>
				<td><input name="sahecess_per" id="SAHCessPercentageTot" type="text" value="<?php echo $GetRowData['sahecess_per']; ?>" style="width:35px;" readonly/>
	<input name="tot_sahecess_amt" id="SAHCessValueTot" type="text" value="<?php echo $GetRowData['tot_sahecess_amt']; ?>"  style="width:65px;" readonly onfocus="calculateSAHCess2()"/></td>
                </tr>
				<tr>
				<td><strong>Total Excise Duty Amt</strong> </td>

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

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

                  <td><input type="text" name="tot_taxable_amt" id="tot_taxable_amt3"  value="<?php echo $GetRowData['tot_taxable_amt']; ?>" 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 ($GetRowData['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" id="taxvalue2" style="width:100%;" value="<?php echo $GetRowData['taxvalue']; ?>" readonly="true"/>

              </div>
	</td>
                   </tr>
                <tr>
                  <td><strong>Surcharge Amount</strong> </td>
                  <td><input type="text" name="sur_oct_per" id="sur_oct_per3"  size="10" onchange="calsuroctamt3(this.value)" value=""/><input name="sur_oct_amt" type="text" id="sur_oct_amt3" value="<?php echo $GetRowData['sur_oct_per']; ?>" style="width:60%;" /></td>
                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input type="text" name="tot_freight" value="<?php echo $GetRowData['tot_freight']; ?>" id="TotalCharge1" style="width:100%;"/></td>
                </tr>
				 <td><strong>Loading/Unloading</strong> </td>
                  <td><input type="text" name="loading" value="<?php echo $GetRowData['loading']; ?>" id="loading1" style="width:100%;"/></td>
                </tr>
                <tr>
                  <td><strong>Additional Charges</strong> </td>
                  <td><input name="add_chargess" id="additionalCharges1" type="text" value="<?php echo $GetRowData['add_charges']; ?>" size="25" style="width:100%;" /></td>
                </tr>
                <tr>
				<td><strong>Grand Total</strong></td>
                  <td>
				  <input type="text" name="grandtotals" id="GrandTotals3" onfocus="cal_grandamounts3()"  size="12" value="<?php echo $GetRowData['grandtotal']; ?>"/>
				  <input type="hidden"  id="orig_grand_tots3" value=""/>&nbsp;<strong>Round Off</strong>&nbsp;
				  <select name="round_off" id="round_off1" style="width:50px; height:20px" onchange="calcRounded3(this.value)">
				  <option value="">None</option>
				  <option value="+" <?php if($GetRowData['round_off']=='+') echo "selected";?>>+</option>
				  <option value="-" <?php if($GetRowData['round_off']=='-') echo "selected";?>>-</option>
				  </select></td>
                </tr>
              </table>
		     </th>
		<td></td>
		</tr>
			</table>
</div>
<?php } ?>
<?php if($grntype=='2' && $dutyType=='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>
	<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>
	<!-- <th ><strong>Secondary UOM</strong></th>-->
	<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>
	<!--<th><strong>Secondary QTY RECEIVED</strong></th>-->
	<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"><strong>Dis. Type</strong></td>  
	<td class="tabledata"><strong>Dis. % <br />or amt.</strong></td>
	<td class="tabledata"><strong>Final<br  />Dis. Amt.</strong></td>
	<td class="tabledata"><strong>Discounted Amount</strong></td>
	<td class="tabledata" ><strong>Basic<br /> Amount</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 addmrnqty where issue_id='".$_REQUEST['mrnid']."'",$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='".$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; ?>" />
	<input type="hidden" readonly="" id="tolerances_<?php echo $i; ?>" name="tolrancees[]" size="15"  value="<?php echo $tolerance; ?>" />
	<input type="hidden" readonly="" id="pending_<?php echo $i; ?>" 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 $unitname=$s->getField('unitsofmeasure','unitid',$unit1,'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_bill3_<?php echo $i; ?>"  size="8" onblur="check_bill_qty(this.value,<?php echo $i;?>)" value="<?php echo $row['qty_as_per_bill']; ?>"/>
	</td>
	<td><input name="reciveqty[]" type="text" id="reciveqty3_<?php echo $i; ?>"  size="8"  onkeyup="check_po_qty1(<?php echo $i;?>)" value="<?php echo $row['reciveqty']; ?>" /></td>
	<td><input name="short_accessid[]" type="text" id="short_accessid3_<?php echo $i; ?>" value="<?php echo $row['short_accessid']; ?>" size="8" readonly="true" onfocus="calculate_poshort3(<?php echo $i ?>);"/></td>
	<td><?php //echo $row['rate'];?>
	<input name="itemrate[]" type="text" id="itemrate3_<?php echo $i; ?>" value="<?php echo $row['itemprice']; ?>"  size="8" readonly="true"/>
	</td>
	<td>
	<input name="itemamount[]" type="text" id="itemamount3_<?php echo $i; ?>" value="<?php echo $row['itemamount']; ?>" onfocus="calculateTotalPrice3(this.id)"  size="8"/>
	</td>
	 <td class="tabledata"><select style="width:80px;" name="DiscountType1[]" id="PerAmo3_<?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 id ="hideArea2"><input type="text" style="width:40px" name="discount[]" id="Discount3_<?php echo $i;?>" onblur="DiscountAmount4(this.value,this.id)" value="<?php echo $row['discount']; ?>"  /></td>
	<td class="tabledata"><input type="text" name="discounted_amount1[]" id="perc3_<?php echo $i; ?>" value="<?php echo $row['discounted_amount1']; ?>" readonly="true" style="width:100%;" /></td>
		<td class="tabledata" id ="hideArea3"><input type="text" value="<?php echo $row['NetRate1']; ?>" id="NetRate3_<?php echo $i;?>" name="NetRate1[]" style="width:70px;" readonly/></td>
		<td class="tabledata" id ="hideArea4"><input type="text" value="<?php echo $row['basic']; ?>" style="width:70px" id="basic3_<?php echo $i;?>" 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['billing_type']=='NonExcisable') { ?> selected="selected" <?php } ?>>NonExcisable</option>
	<option value="Excisable" <?php if($row['billing_type']=='Excisable') { ?> selected="selected" <?php } ?>>Excisable</option>
	<option value="IncludeTax" <?php if($row['billing_type']=='IncludeTax') { ?> selected="selected" <?php } ?>>IncludeTax</option>
	</select></td>
	<td><select name="excise_duty[]" 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($Excise_Duty==$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; ?>" type="text" value="<?php echo $row['excise_perc']; ?>"  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 $row['e_cess_perc']; ?>" style="width:35px;" readonly   /><!--onfocus="caldata1(<?php echo $i;?>)"-->
	<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 $row['sah_perc']; ?>" 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?>"  value="<?php echo $row['taxamount_rate']; ?>"  size="12"  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[]" value="<?php echo $row['remarks']; ?>" id="remarks" value=""/></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_amounts" id="total_item_amount2" style="width:100%;" onfocus="cal_totalamount2()" value="<?php echo $GetRowData['total_amount']; ?>"/></td>
               </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td><input type="text" name="pkg_percs" id="pkg_perc" value="<?php echo $GetRowData['pkg_perc']; ?>" size="5" onchange="calcPackaging2(this.value)" /><input name="pkg_chargess" id="pkg_charges2" type="text" value="<?php echo $GetRowData['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_amt2" value="<?php echo $GetRowData['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_amt2" value="<?php echo $GetRowData['tot_ecess_amt']; ?>" size="5" onfocus="calcecess2(this.value)" /></td>

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

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

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

                  <td><input type="text" name="tot_excise_duty_amt" id="tot_excise_duty_amt2" value="<?php echo $GetRowData['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" id="tot_taxable_amt2"  value="<?php echo $GetRowData['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_rate2(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 ($GetRowData['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="taxval2">
                  <input type="text" name="taxvalue" id="taxvalue" style="width:100%;" value="<?php echo $GetRowData['vat_cst_val']; ?>" readonly="true"/>
              </div>
	</td>
                   </tr>
                <tr>

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

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

                </tr>

                <tr>

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

                  <td><input type="text" name="tot_freight" id="TotalCharge" style="width:100%;" value="<?php echo $GetRowData['tot_freight']; ?>"/></td>

                </tr>

				 <td><strong>Loading/Unloading</strong> </td>

                  <td><input type="text" name="loading" id="loading" style="width:100%;" value="<?php echo $GetRowData['loading']; ?>"/></td>

                </tr>

                

                <tr>

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

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

                </tr>
                <tr>

				<td><strong>Grand Total</strong></td>
                  <td>
				  <input type="text" name="grandtotals" id="GrandTotals2" onfocus="cal_grandamounts2()"  size="12" value="<?php echo $GetRowData['grandtotal']; ?>"/>
				  <input type="hidden"  id="orig_grand_tots2" value=""/>&nbsp;<strong>Round Off</strong>&nbsp;
				  <select name="round_off" id="round_off" style="width:50px; height:20px" onchange="calcRounded2(this.value)">

				  <option value="">None</option>

				  <option value="+" <?php if($GetRowData['round_off']=='+') echo "selected";?>>+</option>

				  <option value="-" <?php if($GetRowData['round_off']=='-') echo "selected";?>>-</option>

				  </select></td>

                </tr>

              </table>
		     </th>
		<td></td>
		</tr>
			</table>
</div>
<?php } ?>
</div>

<!--<div align="center">
	<input type="submit" name="save" value="Update" class="search" onclick="return confirmPost()" />
    <input type="submit" name="reset" class="search" value="Reset" /><a href="index.php?route=Inventory/transation/material_receipt_note_exo_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&NewReturn=yes"><input type="button" class="search" value="Cancel" name="Back" /></a>
<input type="hidden" name="max_price" id="max_price" value="<?php echo $rowmax['max_price'];;?>" />
  </div>
-->
<div style="clear:both;"></div>
</form>

</div>
