				<?php ob_start();

				$PageSecurity = 4;

				$PageName = 'MaterialReceiptNote';

				include('includes/DefinePOClass.php');

				include('includes/SQL_CommonFunctions.inc');

				if (isset($_GET['ModifyOrderNumber']) and $_SESSION[UserType]=='SuperAdmin')  {

					$title = _('Modify Purchase Order') . ' ' . $_GET['ModifyOrderNumber'];

				} else {

				}

				if(isset($_GET['issueid'])  && isset($_GET['issueid']) !='')

				{

					$title = _('Update Issue Slip');

				}

				else

				{

					$title = _('Modify Material Receipt Note');

				}

				

				$url_cancel= "index.php?route=Inventory/transation/material_receipt_note_index".$rurl;

				$url_add= "index.php?route=Inventory/transation/material_receipt_note_edit".$rurl;

				

				

			

				



			if($_REQUEST['action']=='del')

			{

				$del_sql="Update addmrnqty SET delete_status='0' WHERE issue_id='".$_REQUEST['mrnid']."'

				          AND itemcode='".$_REQUEST['itemcode']."'"; 

				header("Location: view_MRN.php?Type=".$_REQUEST['Type']."&ModfingOnly=1&mrnid=".$_REQUEST['mrnid']);

				$del_res=DB_query($del_sql,$db);

			}



            //********************************** cancel mrn *************************************//

				if($_REQUEST['cancel']!='')

				{

					$cancel_sql="UPDATE addmrnqty SET delete_status='1' WHERE 

							issue_id='".$_REQUEST['mrnid']."' AND delete_status='0'";

					$cancel_res=DB_query($cancel_sql,$db);

				}

				

        //**************************************** Update Mrn Data     *****************************************//

				if($_REQUEST['Update'])

				{

				 if($_POST['receiviedagaist']=='Without PO')

				 {

				  $ReceivedFrom1=$_POST['vendor'];

				 }

				else

				{

				$ReceivedFrom1=$_POST['vendor1'];

				}

					 $updatemrn_sql="UPDATE addmrn SET 

								   DocumentType='".$_POST['DocumentType']."',

								   BillNo='".$_POST['billno']."',

								   ReceivedFrom ='".$ReceivedFrom1."',

								   MRNVoucherDate='".FormatDateForSQL($_POST['MRNVoucherDate'])."',

								   GetPassNo='".$_POST['gatepassno']."',

								   Inwardsdate='".FormatDateForSQL($_POST['inwardate_save'])."',

								   Transp_name='".$_POST['transport']."',

								   VehicleNo='".$_POST['vehicalno']."',

								   TimeIn='".$_POST['timein']."',

								   Timeout='".$_POST['timeout']."',

								   LRno='".$_POST['lrno']."',

								   LRdate='".FormatDateForSQL($_POST['lrdate'])."',

								   TotalWeight='".$_POST['total_weight']."',

								   form_type='".$_REQUEST['form_type']."',

								   form_no='".$_REQUEST['form_no']."',

								   gatepassdate='".FormatDateForSQL($_REQUEST['gatepassdate'])."',

								   RemarksIfAny='".$_POST['RemarksIfAny']."',				   

								   total_Item_Amount='".$_POST['total_item_amount']."',

								   pkg_perc='".$_POST['pkg_perc']."',  

								   pkg_charges ='".$_POST['pkg_charges']."', 

								   vat_cst='".$_POST['vat_cst']."',  

								   vat_cst_val ='".$_POST['taxvalue']."', 

								   sur_oct_per='".$_POST['sur_oct_per']."',  

								   sur_oct_amt='".$_POST['sur_oct_amt']."',  

								   tot_freight='".$_POST['tot_freight']."',  

								   add_charges='".$_POST['add_charges']."',  

								   grandtotal ='".$_POST['grandtotal']."', 

								   round_off='".$_POST['round_off']."'

								   WHERE id='".$_REQUEST['mrnid']."' ";

				   

		//echo "<pre>";

		//print_r($updatemrn_sql); exit;

		

					$updatemrn_res=DB_query($updatemrn_sql,$db);

					$product_id1=	implode(",",$_REQUEST['product_id']);

     

	

		for($CR=0;$CR<$_REQUEST['countval'];$CR++)

		{

		

		

		

	    $text_item_code = htmlspecialchars($_REQUEST['product_id'][$CR], ENT_QUOTES);	

	    $update_add_mrn_qty="UPDATE addmrnqty SET batch_no='".$_REQUEST['batch_no'][$CR]."',

												qty_as_per_bill='".$_REQUEST['qty_as_per_bill'][$CR]."',

	 										   reciveqty='".$_REQUEST['reciveqty'][$CR]."',

											   short_accessid='".$_REQUEST['short_accessid'][$CR]."',

											   itemprice='".$_REQUEST['itemrate'][$CR]."',

											   item_total_rate='".$_REQUEST['item_total_rate'][$CR]."',

											   taxamount_rate='".$_REQUEST['taxableamount'][$CR]."',

											   val_after_disc='".$_REQUEST['val_after_disc'][$CR]."',

											   disc_type= '".$_REQUEST['disc_type'][$CR]."',

											   secondaryqty='".$_REQUEST['scecondarqty'][$CR]."',

											   discount='".$_REQUEST['discount'][$CR]."',

											   discount_amount='".$_REQUEST['discount_amount'][$CR]."',

											   val_after_disc='".$_REQUEST['val_after_disc'][$CR]."',

											   sp_disc_perc='".$_REQUEST['sp_disc_perc'][$CR]."',

											   sp_disc_amt='".$_REQUEST['sp_disc_amt'][$CR]."', 								 

											   basic='".$_REQUEST['basic'][$CR]."',  

											   billing_type='".$_REQUEST['billing_type'][$CR]."',  

											   excise_duty='".$_REQUEST['excise_duty'][$CR]."',  

											   excise_perc='".$_REQUEST['excise_perc'][$CR]."',  

											   excise_val='".$_REQUEST['excise_val'][$CR]."',  

											   e_cess_perc='".$_REQUEST['e_cess_perc'][$CR]."',  

											   e_cess_val='".$_REQUEST['e_cess_val'][$CR]."',  

											   sah_perc='".$_REQUEST['sah_perc'][$CR]."',  

											   sah_val='".$_REQUEST['sah_val'][$CR]."',

											   total_amt_with_tax='".$_REQUEST['total'][$CR]."',

											   remarks='".$_REQUEST['remarks'][$CR]."' 

											   where issue_id='".$_REQUEST['mrnid']."' and itemcode='".$text_item_code."'";

		

		

		

	 $update_add_mrn_qty_res=DB_query($update_add_mrn_qty,$db);

	

                     

						

					

					

					    $stock=DB_query("Select * from update_mrn_qty where 

					             order_no='".$_REQUEST['Purchase_Order']."'

						         and itemcode='".$text_item_code."'", $db);

					    $stock_row=DB_fetch_array($stock);		

					 					

					

					 

					

			if($stock_row['itemcode']==$text_item_code && $stock_row['order_no']==$_REQUEST['Purchase_Order'])

				{

				$condition1="itemcode='".$text_item_code."' && order_no='".$_REQUEST['Purchase_Order']."' ";

					 

				if($stock_row['po_qty']=='0')

					{

						$current_bal= $_REQUEST['poqty'][$CR] - $_REQUEST['reciveqty'][$CR];

					 }

					else

					{

						$current_bal=$stock_row['po_qty'] - $_REQUEST['reciveqty'][$CR]; 

					 }

					 

					

					if($current_bal=='0')

					{

						 $status="0";

						  $Update_sql="UPDATE purchorderdetails SET status='Receive'

						   where orderno='".$_REQUEST['Purchase_Order']."' and prod_id='".$text_item_code."'"; 

						$Updateresult = DB_query($Update_sql,$db);

					}

					else

					{

						 $status="1";

						  $Update_sql="UPDATE purchorderdetails SET status='Pending'

						   where orderno='".$_REQUEST['Purchase_Order']."' and prod_id='".$text_item_code."'";

						$Updateresult = DB_query($Update_sql,$db);

					}

					

					

					

					$update_mrn_qty['mrn_no'] = $strBothFinal;

					$update_mrn_qty['order_no'] = $_REQUEST['Purchase_Order']; 

					$update_mrn_qty['site'] = $_REQUEST['sitecode']; 

					$update_mrn_qty['store'] = $_REQUEST['storecode']; 

					$update_mrn_qty['itemcode']= $text_item_code;

					$update_mrn_qty['po_qty']= $current_bal;

					$update_mrn_qty['mrn_qty']= $_REQUEST['reciveqty'][$CR];

					$update_mrn_qty['status']= $status;

					$up_mrn=$s->EditRecord(update_mrn_qty, $update_mrn_qty, $condition1);

					$row1=DB_query($up_mrn,$db);

					

			} 

			else

			{

					 

						 if($_REQUEST['poqty'][$i]==$_REQUEST['reciveqty'][$CR])

						{

							$status="0";

						 	$Update_sql="UPDATE purchorderdetails SET 

						      status='Receive' where orderno='".$_REQUEST['Purchase_Order']."' 

						      and prod_id='".$text_item_code."'"; 

							$Updateresult = DB_query($Update_sql,$db);

						}

						else

						{

							$status="1";

							$Update_sql="UPDATE purchorderdetails SET status='Pending'

							 where orderno='".$_REQUEST['Purchase_Order']."' and prod_id='".$text_item_code."'";

							$Updateresult = DB_query($Update_sql,$db);

								

						}

					  $current_bal=$_REQUEST['poqty'][$i] - $_REQUEST['reciveqty'][$CR];					 

					  $update_mrn_qty['mrn_no'] = $strBothFinal;

					  $update_mrn_qty['order_no'] = $_REQUEST['Purchase_Order']; 

					  $update_mrn_qty['site'] = $_REQUEST['sitecode']; 

					  $update_mrn_qty['store'] = $_REQUEST['storecode']; 

					  $update_mrn_qty['itemcode']=$text_item_code;

					  $update_mrn_qty['po_qty']=  $current_bal;

					  $update_mrn_qty['mrn_qty']= $_REQUEST['reciveqty'][$CR];

					  $update_mrn_qty['status']= $status;

					$insert_mrn_maintenance=$s->insertRecord('update_mrn_qty', $update_mrn_qty);

					$row1=DB_query($insert_mrn_maintenance,$db); 

					

			}

					 

					 if($_REQUEST['oldreceiveqty'][$CR]>$_REQUEST['reciveqty'][$CR])

					 {

					  $stbal=$_REQUEST['short_accessid'][$CR];

					  $st='NBal';

					 }

					 else if($_REQUEST['oldreceiveqty'][$CR]<$_REQUEST['reciveqty'][$CR])

					 {

					  $stbal=($_REQUEST['reciveqty'][$CR]-$_REQUEST['oldreceiveqty'][$CR]);

					  $st='Bal';

					 }

									 

					 

					if($_REQUEST['reciveqty'][$CR]!='0.00')

					{

								 

					  $data_date=explode('/',$_REQUEST['MRNdate']);

                      $date51=$data_date[2].'-'.$data_date[1].'-'.$data_date[0];	

			          $date12= strtotime(date("Y-m-d", strtotime($date51)) . " +0 day");

					

                        $date= date("Y-m-d",$date12);

						

					   $check_current_opening="Select * from stock_summary where date='".$date."'

					 and site='".$_REQUEST['sidecode']."' and store='".$_REQUEST['storecode']."' 

					 and item='".$_REQUEST['mst_itemid'][$CR]."'";

					 

					

					$check_current_op_result=DB_query($check_current_opening,$db);

					//echo DB_num_rows($check_current_op_result);

					

					if(DB_num_rows($check_current_op_result)=='0')

					{

						$get_previous_closing="Select * from stock_summary where site='".$_REQUEST['sidecode']."' 

						and store='".$_REQUEST['storecode']."' and item='".$_REQUEST['mst_itemid'][$CR]."'

						 and date<'".$date."' ORDER BY DATE DESC LIMIT 0,1";

						 

						$previous_closing_result=DB_query($get_previous_closing,$db);

						$previous_closing_row=DB_fetch_array($previous_closing_result);

						

						if(DB_num_rows($previous_closing_result)=='0')

						{

							 $check_opening_entry="Select * from opening_stockitemwise 

													where site='".$_REQUEST['sidecode']."' 

													and store='".$_REQUEST['storecode']."' 

													and itemcode='".$_REQUEST['mst_itemid'][$CR]."'

													and reveive_date<'".$date."'  ";

													

							$check_opening_entry_result=DB_query($check_opening_entry,$db);

							$check_opening_entry_row=DB_fetch_array($check_opening_entry_result);

							

							if(DB_num_rows($check_opening_entry_result)>0){

							$opening_qty=$check_opening_entry_row['stock'];

							$opening_rate=$check_opening_entry_row['rate'];

							$opening_value=$check_opening_entry_row['amount'];}else

							{$opening_qty='';

							$opening_rate='';

							$opening_value='';}

						}

						else

						{

							$opening_qty=$previous_closing_row['closing_qty'];

							$opening_rate=$previous_closing_row['closing_rate'];

							$opening_value=$previous_closing_row['closing_value'];

						}

					     	$inwards_qty=$_REQUEST['reciveqty'][$CR]; 

						 	$inwards_value=$_REQUEST['basic'][$CR];

							$inwards_rate=$_REQUEST['basic'][$CR]/$_REQUEST['reciveqty'][$CR];

							

							$closing_qty=$opening_qty+$inwards_qty;

							$closing_value=$opening_value+$inwards_value;

							$closing_rate=round($closing_value/$closing_qty);

							$insert_first_summary="Insert into stock_summary set 

													site='".$_REQUEST['sidecode']."',     

													store='".$_REQUEST['storecode']."',    

													item='".$_REQUEST['mst_itemid'][$CR]."',

													opening_qty='".$opening_qty."',  

													opening_rate='".$opening_rate."',    

													opening_value='".$opening_value."',    

													inwards_qty='".$inwards_qty."',    

													inwards_rate='".round($inwards_rate,2)."',    

													inwards_value='".$inwards_value."',    

													closing_qty='".$closing_qty."',    

													closing_rate='".$closing_rate."',    

													closing_value='".$closing_value."',    

													date='".$date."' 	"; 

							$result1=DB_query($insert_first_summary,$db);

						

					}

					else

					{

					$check_current_op_row=DB_fetch_array($check_current_op_result);

					$id=$check_current_op_row['id'];

					if($st=='NBal')

					{

					$inwards_qty=$check_current_op_row['inwards_qty']-$stbal; 

					$inwards_value=$check_current_op_row['inwards_value']-($stbal*$_REQUEST['itemrate'][$CR]);					 

					$inwards_rate=$inwards_value/$inwards_qty; 					

					}

					else if($st=='Bal')

					{

					$inwards_qty=$check_current_op_row['inwards_qty']+$stbal; 

					$inwards_value=$check_current_op_row['inwards_value']+($stbal*$_REQUEST['itemrate'][$CR]); 

					$inwards_rate=$inwards_value/$inwards_qty; 

					}					

					else if($check_current_op_row['inwards_qty']!=$_REQUEST['reciveqty'][$CR])

					{

					$inwards_qty=$check_current_op_row['inwards_qty']+$_REQUEST['reciveqty'][$CR]; 

					$inwards_value=$check_current_op_row['inwards_value']+$_REQUEST['basic'][$CR]; 

					$inwards_rate=$inwards_value/$inwards_qty; 

				   	}

					else 

					{

					$inwards_qty=$check_current_op_row['inwards_qty']+$_REQUEST['reciveqty'][$CR]; 

					$inwards_value=$check_current_op_row['inwards_value']+$_REQUEST['basic'][$CR]; 

					$inwards_rate=$inwards_value/$inwards_qty; 				

					}		

					

					//echo  $inwards_qty;			

					

			        //print_r($_REQUEST['reciveqty']);

					

					

					

					$closing_qty=$check_current_op_row['opening_qty']+$inwards_qty-$check_current_op_row['outwards_qty'];

					$closing_value=$check_current_op_row['opening_value']+$inwards_value-$check_current_op_row['outwards_value'];

					$closing_rate= round($closing_value/$closing_qty);

						

						

						

						   $update_summary="Update  stock_summary set 

													inwards_qty='".$inwards_qty."',    

													inwards_rate='".round($inwards_rate,2)."',    

													inwards_value='".$inwards_value."',    

													closing_qty='".$closing_qty."',    

													closing_rate='".$closing_rate."',    

													closing_value='".$closing_value."' where id=$id ";

																									

						$result2=DB_query($update_summary,$db);

						

					}

					

					/******************** End  update_mrn_qty Po QTY   **************************************/	

					    $data_date1=explode('/',$_REQUEST['MRNdate']);

                       $date52=$data_date1[2].'-'.$data_date1[1].'-'.$data_date1[0];

				    $date2= strtotime(date("Y-m-d", strtotime($date52)) . " +1 day");

                     $date1= date("Y-m-d",$date2);

				  

				  // echo $_REQUEST['mst_itemid'][$CR];

				  

				   if($date1<=date('Y-m-d'))

					{

 	get($_REQUEST['sidecode'],$_REQUEST['storecode'],$date1,$_REQUEST['mst_itemid'][$CR],$closing_qty,$closing_rate,$closing_value);

					}	

					}					 

					 

					 

					}

			

			$numval1=0;

			$countval=0;

			$sqldata=DB_query("select * from purchorderdetails where orderno='".$_REQUEST['Purchase_Order']."'",$db);

			$numval1=DB_num_rows($sqldata);

			while($data_chk=DB_fetch_array($sqldata))

			{

				

				if($data_chk['status']=='Receive')

				{

				$countval=$countval+1;

					

				}

			}

			if($countval==$numval1)

			{				

				

			$update=DB_query("update purchorders set Po_recive_status='Receive'

			 where orderno='".$_REQUEST['Purchase_Order']."'",$db);

			}

			else {

				$update=DB_query("update purchorders set Po_recive_status='Pending'

				 where orderno='".$_REQUEST['Purchase_Order']."'",$db);

			}	 

	

	

	

	$_SESSION['success_msg']="Update Successfully";

	if($_REQUEST['page']!='')

	{

	 echo "<script>location='index.php?route=Inventory/transation/material_receipt_note_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."&page=".$_REQUEST['page']."'</script>";

	}

	else

   echo "<script>location='index.php?route=Inventory/transation/material_receipt_note_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";

	 }

	 



//**************************Modify Section*******************************************************

if(isset($_REQUEST['mrnid']))

{

	    $condition="id='".$_REQUEST['mrnid']."'";

		$GetData=$s->GetRecord('addmrn', $condition);

		$GetResultData= DB_query($GetData,$db);

		$GetRowData=DB_fetch_array($GetResultData);

		//echo "<pre>";

		//print_r($GetRowData);

		$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'];

		$Transp_name=$GetRowData['Transp_name'];

		$VehicleNo=$GetRowData['VehicleNo'];

		$TimeIn=$GetRowData['TimeIn'];

		$Timeout=$GetRowData['Timeout'];

		$LRno=$GetRowData['LRno'];

		$LRdate=$GetRowData['LRdate'];

		$TotalWeight=$GetRowData['TotalWeight'];

		$Form_Type=$GetRowData['form_type'];

		$Form_No=$GetRowData['form_no'];

		$gatepassdate=$GetRowData['gatepassdate'];

		$RemarksIfAny=$GetRowData['RemarksIfAny'];

		$OrderDate=$GetRowData['OrderDate'];

	    $StoreCode=$GetRowData['StoreCode'];

		$StoreName=$GetRowData['StoreName'];

		$totalqty=$GetRowData['totalqty'];

		$_REQUEST['chargeamount']=$GetRowData['Charge_Amount'];

		$_REQUEST['tax_chargeamount']=$GetRowData['tax_chargeamount'];

		$_REQUEST['tax_suroct_value']=$GetRowData['tax_suroct_value'];

		$_REQUEST['grandtotal']=$GetRowData['grandtotal'];

		$_REQUEST['percent_inclusive']=$GetRowData['percent_inclusive'];

		$_REQUEST['percent_inclusivecharge']=$GetRowData['percent_inclusivecharge'];

		$_REQUEST['itemamount']=$GetRowData['total_Item_Amount'];

		$_REQUEST['taxable_amt']=$GetRowData['taxable_amt'];

		$_REQUEST['taxname']=$GetRowData['taxname'];

		$_REQUEST['itemamount']=$GetRowData['total_Item_Amount'];

		 

		 if($percent_inclusivecharge=='SUR')

		 {

		  $tax_suroct_value	=($tax_chargeamount*$percent_inclusive)/100;

		 }

		 else{

		  $tax_suroct_value	=(($tax_chargeamount+$total_Item_Amount)*$percent_inclusive)/100;

 		 }

		$Remarks=$GetRowData['Remarks'];	}

?>





<div style="width:auto; overflow:auto; margin-left:auto; margin-right:auto;">



<form action="" method="post">

<h2 align="center"><strong>Material Receipt Note</strong></h2>

<br />

<table width="100%"border="0" cellpadding="2" cellspacing="1">

<?php if($_REQUEST['r'])

	{

	   ?>

	     <tr>

		 <td colspan="2" style="color:#FF0000; font-weight:bold">Record Updated Successfully ! </td>

		 </tr>

	   <?php 

	} ?>



</table>









<div style="width:100%">

<h3><strong>GENERAL DETAILS</strong></h3>

<table width="100%" border="1" cellspacing="2" cellpadding="5" align="center">

<?php 

if(isset($msg_error))

{

?>

  <tr>

  		<td colspan="">

		<table width="50%" border="0"  style="color:#FF0000;font-weight:bold" align="left">

	  <tr>

 		<?php for($i=0;$i<count($msg_error);$i++)

		{	

		  if($i%2==0)	

		  echo "</tr><tr>";

 	    	echo "<td>".$msg_error[$i]."</td>" ;

		}?>

		</table>		</td>

  </tr>

 <?php } 	 ?>

  <tr>

    <th width="15%"><strong>Mrn No. </strong></th>

    <td width="30%"><input type="text" value="<?php echo $MRNNo;?>" style="width:100%"/></td>

    <th width="31%"><strong>MRN Date </strong></th>

    <td width="24%" colspan="2"><input type="text" name="MRNdate" value="<?php echo ConvertSQLDate($MRNDate);?>" style="width:180px"/></td>

  </tr>

  <tr>

   <th><strong>Site Code - Name </strong></th>

    <td>

	<?php $site_name=$s->getField('locations','loccode',$OrderFromSite,'locationname');?>

	<input type="text" value="<?php echo $OrderFromSite;?>" style="width:100%" name="sidecode" id="sidecode" />	</td>

	

    <th><strong>Store Code - Name </strong></th>

     <td>	

		<?php

		 $sql_store = "select distinct StoreCode, StoreName from storetype where id='".$StoreCode."'"; 

		$resultStkLocs = DB_query($sql_store,$db);

		$store_name=DB_fetch_array($resultStkLocs);

		?><input type="text" value="<?php echo $StoreCode;?>" style="width:100%" name="storecode" id="storecode"   />	</td>

    </tr>

  

  <tr>

   <th><strong>Received Against</strong></th>

    <td ><input name="text" type="text" style="width:100%" value="<?php if($Type=='PO'){echo "Purchase Order";} else {echo $Type;}?>"/>

    <input type="hidden" name="receiviedagaist" id="receiviedagaist" value="<?php echo $Type;?>" />

	<input id="hidden_form_site" type="hidden" value="<?php echo $_REQUEST['sitecode'];?>" />

    <input id="hidden_form_type" type="hidden" value="<?php echo $_GET['type'];?>" />

    <input type="hidden" name="receive_type" id="receive_type" value="<?php echo $_GET['type'];?>" />	</td>

    <th scope="row"><strong>Recevied From </strong></th>

    <td>

	  <?php if($Type=='Without PO') 

	  { ?>

		 <select name="vendor" id="vendor"  style="width:100%"  >

			

			<option value="000" >---Select1---</option>

			<?php

			$sql="select id  ,vendor_code, vendor_name from suppliers";

			$result = DB_query($sql, $db);

			while($myrow = DB_fetch_array($result))

			{ 

			$p='';

			if($ReceivedFrom==$myrow['id'])

			$p="selected";

			?>

			 <option  value="<?php echo $myrow['id']; ?>"<?php echo $p;?> ><?php echo  str_replace(array("M/s ","M/S"),'',$myrow['vendor_name']); ?></option>

		<?php }

			?>

			</select>

			<?php } else {

			 $sql="select id  ,vendor_code, vendor_name from suppliers where id='".$ReceivedFrom."'";

			$result = DB_query($sql, $db);

			$myrow = DB_fetch_array($result);

			 ?>

			

			 <input type="hidden" name="vendor1" value="<?php echo $ReceivedFrom; ?>" />

			

			<?php 

			echo str_replace(array("M/s ","M/S"),'',$myrow['vendor_name']);

			} ?>

		 

		   </td>

   </tr>

  <tr>

    <th scope="row"><strong><?php if($Type=='PO'){?>PO/Challan/WO/ Ref.No.<?php }else{ ?>Requisition No.<?php } ?></strong></th>

    <td >

    <?php

	 if($Type=='PO'){

   $sql="select orderno,orddate, PO_Orderno from purchorders Where orderno='".$PO."'";

	$result = DB_query($sql,$db);

     $myrow=DB_Fetch_array($result);

     $x=$myrow['PO_Orderno'];}

	 else if($GetRowData['req_no']!='' || $GetRowData['req_no']!='0')

	{

		 $sql="select Reqno from materialrequisitions Where requisitionno='".$GetRowData['req_no']."'";

			$result = DB_query($sql,$db);

     	$myrow=DB_Fetch_array($result);

     	$x=$myrow['Reqno'];

	}else{$x="";} ?> <input type="text" value="<?php echo $x;?>" style="width:100%"/>

	 <input type="hidden" name="Purchase_Order" value="<?php echo $PO; ?>" /></td>

    <th><strong>Order Date </strong></th>

    <td><input type="text" value="<?php echo ConvertSQLDate($OrderDate); ?>" style="width:100%"/>	   </td>

  </tr>

  

  <tr>

    <th scope="row"><strong>Document Type</strong></th>

    <td> <select name="DocumentType" id="DocumentType" style="width:100%">

	<option value="Challan">Challan</option>

	<option value="Bill">Bill</option>

	</select></td>

    <th><strong>Document No. </strong></th>

    <td colspan="2"><input name="billno" type="text" id="billno" style="width:100%" value="<?php  echo $BillNo; ?>" /></td>

  </tr>

  

  <tr>

    <th scope="row"><strong>Challan / Bill Date</strong></th>

    <td><input type="text" name="MRNVoucherDate" style="width:100%" class="datepicker"  onblur="valdate();"  value="<?php echo ConvertSQLDate($MRNVoucherDate); ?>"/></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>

	

	<?php 

    echo $Transp_name; 

	      ?>

		  

		  </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>In Time</strong></th>

    <td> <select name="timein" id="timein" style="width:70px">

	<option value="Day" <?php echo $timein=='Day'?'selected':''?>>Day</option>

	<option value="Night" <?php echo $timein=='Night'?'selected':''?>>Night</option>

	</select><input type="text" name="timeout" value="<?php if(isset($_SESSION['timeout'])) echo $timeout; else echo date("h:i:s",time());?>" style="width:68%" ></td>

    <th><strong>L R No.</strong></th>

    <td><input name="lrno" type="text" id="lrno" style="width:100%" value="<?php echo $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); ?>"  onblur="LRdate();" class="datepicker"/></td>

    <th><strong>Form Type</strong></th>

    <td> <input type="text" name="form_type"  style="width:100%" value="<?php echo $Form_Type; ?>" id="form_type" /></td>

  </tr>

  <tr>

    <th scope="row"><strong>Form No</strong></th>

    <td><input type="text" name="form_no"  style="width:100%" value="<?php echo $Form_No; ?>" id="form_no" /></td>

    <th>Get Pass Date</th>

    <td><input type="text" name="gatepassdate" id="gatepassdate" value="<?php echo ConvertSQLDate($gatepassdate); ?>" style="width:100%" class="datepicker" /></td>

  </tr>

  

  

  <tr>

    <th scope="row"><strong>Remarks If Any</strong></th>

    <td colspan="3"><input name="RemarksIfAny" type="text" id="RemarksIfAny" value="<?php echo $RemarksIfAny;?>" style="width:100%; height:50px;">	</td>



  </tr>

  

</table>

</div>









<br /><br />



<table width="100%" border="0" cellspacing="1" cellpadding="2">

<tr>

<td>

<?php  

$CR=1;

$Vendor_Quot_No=$s->GetFieldValue('purchorders',"orderno ='".$_GET['mrnid']."'",'mst_vendor_quotesid');

?>

<?php 

$sqlQty = "SELECT * From addmrnqty Where issue_id='".$_GET['mrnid']."'";

$Qty_result = DB_query($sqlQty, $db);



//echo "<pre>";

//print_r($Qty_result);

?>

<div style="overflow:auto; width:968px; margin-left:auto; margin-right:auto; height:auto"  >

<h4 style="text-align:left; padding-left:10px;">ITEM DETAILS</h4>



<table width="100%" border="1" cellspacing="1" cellpadding="2">

 <tr>

	 <th scope="col"><strong>S. NO. </strong></th>

    <th scope="col"><strong>ITEM CODE </strong></th>

    <th scope="col"><strong>DESCRIPTION</strong></th>

    <!--<th scope="col"><strong>MAKE</strong></th>-->

    <th scope="col"><strong>GRADE</strong></th>

    <th scope="col"><strong>SIZE</strong></th>

    <th scope="col"><strong>Primary UOM</strong></th>

	 <th scope="col"><strong>Secondary UOM</strong></th>

	<?php if($Type=='PO'){?>

    <th scope="col"><strong>PO QTY </strong></th><?php } ?>

	<th scope="col"><strong>BATCH NO </strong></th>

    <th scope="col"><strong>QTY AS PER BILL </strong></th>

    <th scope="col"><strong>Primary QTY RECEIVED </strong></th>

	 <th scope="col"><strong>Secondary QTY RECEIVED </strong></th>

    <th scope="col"><strong>SHORT QUANTITY </strong></th>

    <th scope="col"><strong>RATE</strong></th>

	<th scope="col"><strong>TOTAL ITEM PRICE</strong></th>

	 <th scope="col"><strong>DISCOUNT TYPE</strong></th>

	  <th scope="col"><strong>DISCOUNT %</strong></th>

	 <th scope="col"><strong>DISCOUNT AMT.</strong></th> 

	  <th scope="col"><strong>SUB TOTAL</strong></th> 

	   <th><strong>SPECIAL DISCOUNT Type</strong></th>

	  <th scope="col"><strong>SPL. DISC. %</strong></th> 

	   <th scope="col"><strong>SPL. DISC. AMT.</strong></th>  

	   <th scope="col"><strong>BASIC AMT.</strong></th> 

	    <th scope="col"><strong>EXCISE FLAG</strong></th> 

	   <th scope="col"><strong>EXCISE</strong></th> 

	    <th scope="col"><strong>E-CESS</strong></th>

	    <th scope="col"><strong>SAH-CESS</strong></th>	

       <th scope="col"><strong>EXCISE AMOUNT</strong></th>

	  <th scope="col"><strong>TOTAL AMOUNT</strong></th>

      <th scope="col"><strong>REMARKS</strong></th>

  </tr>

 <?php 

$i=0;

 $item_count=DB_num_rows($Qty_result);

while($myrow2 = DB_fetch_array($Qty_result)) 

{

extract($myrow2);

//echo "select * from item_master where StockID='".$myrow2['itemcode']."'";

	$record=DB_query("select * from item_master where id='".$myrow2['mst_itemid']."'",$db);

	$record_row=DB_fetch_array($record);

	if($Type=='Without PO' || $Type=='DirectPOOrder')

	{

	$confac=$record_row['conv_factor'];	

	?>

	<tr bgcolor="#FFFFFF">

<td> <?php echo $i+1;?>	</td>

<td><?php echo $myrow2['itemcode']; ?>

<input type="hidden" name="convfac[]" id="convfac_<?php echo $i; ?>" value="<?php echo $confac; ?>" />

<input type="hidden" name="product_id[]" id="product_id_[<?php echo $i;?>]" value="<?php echo $myrow2['itemcode']; ?>">

<input type="hidden" name="mst_itemid[]" id="mst_itemid_<?php echo $i; ?>" value="<?php echo $myrow2['mst_itemid']; ?>" />

</td>

<td><?php echo $record_row['item_name']; ?></td>

<!--<td><?php //$makename=$s->getField('product_manufacture','id',$record_row['make'],'manufacturer');echo $makename; ?></td>-->

<td><?php $gradename=$s->getField('product_grade','id',$record_row['grade'],'grade');echo $gradename; ?></td>

<td><?php $sizename=$s->getField('size_master','id',$record_row['size'],'size');echo $sizename; ?></td>

<td><?php $unit=$s->getField('unitsofmeasure','unitid',$record_row['mst_unitid'],'unitname');echo $unit; ?></td>

<td><?php $unit=$s->getField('unitsofmeasure','unitid',$record_row['conv_unit'],'unitname');echo $unit; ?></td>

<td>

<input type="text" name="batch_no[]"  id="batch_no_<?php echo $i;?>" value="<?php echo $myrow2['batch_no']; ?>"  >





</td>

<td>

<input type="text" name="qty_as_per_bill[]"  id="qty_as_per_bill_<?php echo $i;?>" value="<?php echo $myrow2['qty_as_per_bill']; ?>"  >





</td>

<td style="white-space:nowrap">

<input type="text" name="reciveqty[]" id="reciveqty_<?php echo $i;?>" value="<?php echo $myrow2['reciveqty']; ?>" onkeyup="calamt(<?php echo $i; ?>)" onchange="check_po_qty2(<?php echo $i;?>)" >

<input type="hidden" name="oldreceiveqty[]"  value="<?php echo $myrow2['reciveqty']; ?>" /></td>

<td> <input name="scecondarqty[]" type="text" id="scecondarqty_<?php echo $i; ?>"  size="8"  value="<?php echo $secondaryqty;?>"  /></td>

<td><input type="text" onfocus="short_qty(<?php echo $i; ?>);" name="short_accessid[]"  id="short_accessid_<?php echo $i;?>" value="<?php echo $myrow2['short_accessid']; ?>"  readonly></td>

<td><input type="text" name="itemrate[]" id="itemrate_<?php echo $i;?>" value="<?php echo $myrow2['itemprice']; ?>"></td>

<td><input name="item_total_rate[]" type="text" id="item_total_rate_<?php echo $i; ?>" value="<?php echo $myrow2['item_total_rate'];?>" size="8" onfocus="calc_total_price(<?php echo $i;?>)"/></td>

  <td><select style="width:80px;" name="disc_type[]" id="PerAmo_<?php echo $i;?>">

            <option value="Amount" <?php echo ($disc_type=='Amount')?'selected':''?>>Amount</option>

            <option value="PercentAmt"<?php echo ($disc_type=='PercentAmt')?'selected':''?>>Percent Amt</option></select></td>

	  <td><input type="text" style="width:40px" name="discount[]" id="Discount_<?php echo $i;?>" onblur="DiscountAmount(this.value,<?php echo $i;?>)" value="<?php echo $discount;?>" readonly="true" /></td>

	  <td><input type="text" style="width:35px" name="discount_amount[]" id="perc_<?php echo $i;?>"  readonly="true" onfocus="Check(this.value,<?php echo $i;?>)" value="<?php echo $discount_amount;?>"/></td>

	  <td><input type="text"  id="NetRate_<?php echo $i;?>" name="val_after_disc[]" style="width:70px;" readonly value="<?php echo $val_after_disc;?>"/></td>

	  <td><select style="width:100%;" name="Perspc[]" id="Perspc_<?php echo $i;?>">

            <option value="Amount" <?php echo ($_POST['Perspc']=='Amount'|| $specialdis_type=='Amount')?'selected':''?>>Amount</option>

            <option value="PercentAmt" <?php echo ($_POST['Perspc']=='PercentAmt' || $specialdis_type=='PercentAmt')?'selected':''?>>Percent Amt</option>

          </select></td>

	  <td><input type="text" name="sp_disc_perc[]" id="special_discount_<?php echo $i;?>" size="10" style="width:35px;" onblur="DiscountAmountdpc(this.value,<?php echo $i;?>)"  value="<?php echo $sp_disc_perc;?>" /></td>

	  <td><input type="text"  name="sp_disc_amt[]" id="Specialperc_<?php echo $i;?>"  style="width:70px;" onfocus="check1(this.value,<?php echo $i;?>)" value="<?php echo $sp_disc_amt;?>"/></td>

	   <td><input type="text" style="width:70px" id="basic_<?php echo $i;?>" name="basic[]" readonly value="<?php echo $basic?>"/></td>

	  <td><select name="billing_type[]" style="width:85px" id="billing_type_<?php echo $i;?>"  onchange="checkExcisable(this.value,<?php echo $i; ?>)">

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

	<option value="NonExcisable" <?php if($billing_type=='NonExcisable') echo "selected";?>>NonExcisable</option>

	<option value="Excisable" <?php if($billing_type=='Excisable') echo "selected";?>>Excisable</option>

	<option value="IncludeTax" <?php if($billing_type=='IncludeTax') echo "selected";?>>IncludeTax</option>

</select></td>

	  <td><select name="excise_duty[]" id="exciseDuty_<?php echo $i;?>" style="width:120px;" onchange="claculateExcise(<?php echo $i; ?>,this.value)" onfocus="checkexiseflag(<?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))

			{?>

				<option value="<?php echo $excise_row['id'];?>" <?php if($excise_duty==$excise_row['id']) echo "selected";?>><?php echo $excise_row['caption'];?></option>

			<?php 	

			}

    	    ?> 

  	      </select><div id="exciseId_<?php echo $i; ?>"><input type="text" name="excise_perc[]" id="ExcisePercentage_<?php echo $i;?>" value="<?php echo $excise_perc;?>" size="5" onblur="calcExcise(this.value,<?php echo $i;?>)" /><input type="text" name="excise_val[]" id="exciseValue_<?php echo $i;?>" value="<?php echo $excise_val;?>" size="10"  onfocus="calculateExciseDuty(<?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++;

			 } 

			if($sah_perc==''|| $sah_perc=='0.00')

			$sah_perc=$rate[2];

			if($e_cess_perc=='' || $e_cess_perc=='0.00')

			$e_cess_perc=$rate[1]; 

			

    	     ?>

	  <td>

	  <input name="e_cess_perc[]" id="ECessPercentage_<?php echo $i;?>" type="text" value="<?php echo   $e_cess_perc;  ?>" style="width:35px;" readonly onfocus="caldata(<?php echo $i;?>)"  /><input name="e_cess_val[]" id="ECessValue_<?php echo $i;?>" type="text" value="<?php echo $e_cess_val;?>"  style="width:70px;" readonly onfocus="calculateECess(<?php echo $i; ?>)"/></td>

	  <td><input name="sah_perc[]" id="SAHCessPercentage_<?php echo $i;?>" type="text" value="<?php  echo $sah_perc; ?>" style="width:35px;" readonly/><input name="sah_val[]" id="SAHCessValue_<?php echo $i;?>" type="text" value="<?php echo $sah_val;?>"  style="width:65px;" readonly onfocus="calculateSAHCess(<?php echo $i; ?>)"/></td> 

 <td><input name="taxableamount[]" type="text" id="taxableamount_<?php echo $i;?>"  size="12" readonly="true" onfocus="caltaxamout(<?php echo $i;?>)" value="<?php echo $taxamount_rate;?>" /></td>

 <td><input name="total[]" type="text" id="total_<?php echo $i ;?>" value="<?php echo $total_amt_with_tax;?>" size="12"  onfocus="value_after_discount(<?php echo $i; ?>)"/></td>



<td><input type="text" name="remarks[<?php echo $i;?>]" id="remarks_[<?php echo $i;?>]" value="<?php echo $remarks; ?>"></td>

</tr>

	<?php 

	}

	

	

	

	else

	{

    ?> 

<!--PO-->

<tr bgcolor="#FFFFFF">

	<td> <?php echo $i+1;?><input type="hidden" name="itemcount[]" id="itemcount[]" value="<?php echo $item_count;?>"></td>

	<input type="hidden" name="mst_itemid[]" id="mst_itemid_<?php echo $i; ?>" value="<?php echo $myrow2['mst_itemid']; ?>" />

<td><?php echo $myrow2['itemcode']; ?><input type="hidden" name="product_id[]" id="product_id_[<?php echo $i;?>]" value="<?php echo $myrow2['itemcode']; ?>"></td>

<td><?php echo $record_row['item_name']; ?></td>

<!--<td><?php 

//$makename=$s->getField('product_manufacture','id',$record_row['make'],'manufacturer');

//echo $makename; ?></td>-->

<td><?php 

$gradename=$s->getField('product_grade','id',$record_row['grade'],'grade');

echo $gradename; ?></td>

<td><?php 

$sizename=$s->getField('size_master','id',$record_row['size'],'size');

echo $sizename; ?></td>

<td><?php 

$unit=$s->getField('unitsofmeasure','unitid',$record_row['unit'],'unitname');

echo $unit; ?></td>

<?php if($Type=='PO'){?>

<td><?php if($sql_query_update['po_qty']!='')

{

	echo $poqty=$sql_query_update['po_qty']; 

}

else

{

	echo $poqty=$myrow2['POQty'];

}

extract($myrow2);

?>

<input name="poqty[]" type="hidden" id="poqty_<?php echo $i; ?>" value="<?php echo $poqty;?>" size="10"/></td><?php } ?>

<td><input type="text" name="batch_no[]"  id="batch_no_<?php echo $i;?>" value="<?php echo $myrow2['batch_no']; ?>"></td>

<td><input type="text" name="qty_as_per_bill[]"  id="qty_as_per_bill_<?php echo $i;?>" value="<?php echo $myrow2['qty_as_per_bill']; ?>"></td>



<td><input type="text" name="reciveqty[]" id="reciveqty_<?php echo $i;?>" value="<?php echo $myrow2['reciveqty']; ?>" onblur="check_bill_qty(this.value,<?php echo $i;?>)">

<input type="hidden" name="oldreceiveqty[]"  value="<?php echo $myrow2['reciveqty']; ?>" />

</td>



<td><input type="text" onfocus="short_qty(<?php echo $i; ?>);" name="short_accessid[]"  id="short_accessid_<?php echo $i;?>" value="<?php echo $myrow2['short_accessid']; ?>"  readonly></td>

<td><input type="text" name="itemrate[<?php echo $i;?>]" id="itemrate_<?php echo $i;?>" value="<?php echo $myrow2['itemprice']; ?>"></td>

<td><input name="item_total_rate[]" type="text" id="item_total_rate_<?php echo $i; ?>" value="<?php echo $myrow2['item_total_rate'];?>" size="8" onfocus="calc_total_price(<?php echo $i;?>)"/></td>





 <td><select style="width:80px;" name="disc_type[]" id="PerAmo_<?php echo $i;?>">

            <option value="Amount" <?php echo ($disc_type=='Amount')?'selected':''?>>Amount</option>

            <option value="PercentAmt"<?php echo ($disc_type=='PercentAmt')?'selected':''?>>Percent Amt</option></select></td>

	  <td><input type="text" style="width:40px" name="discount[]" id="Discount_<?php echo $i;?>" onblur="DiscountAmount(this.value,<?php echo $i;?>)" value="<?php echo $discount;?>" readonly="true"/></td>

	  <td><input type="text" style="width:70px" name="discount_amount[]" id="perc_<?php echo $i;?>"  readonly="true" onfocus="Check(this.value,<?php echo $i;?>)" value="<?php echo $discount_amount;?>"/></td>

	  <td><input type="text"  id="NetRate_<?php echo $i;?>" name="val_after_disc[]" style="width:70px;" readonly value="<?php echo $val_after_disc;?>" /></td>

	  

	  <td><select style="width:100%;" name="Perspc[]" id="Perspc_<?php echo $i;?>">

            <option value="Amount" <?php echo ($_POST['Perspc']=='Amount'|| $specialdis_type=='Amount')?'selected':''?>>Amount</option>

            <option value="PercentAmt" <?php echo ($_POST['Perspc']=='PercentAmt' || $specialdis_type=='PercentAmt')?'selected':''?>>Percent Amt</option>

          </select></td>

	  <td><input type="text" name="sp_disc_perc[]" id="special_discount_<?php echo $i;?>" size="10" style="width:35px;" onblur="DiscountAmountdpc(this.value,<?php echo $i;?>)"  value="<?php echo $sp_disc_perc;?>" /></td>

	  <td><input type="text"  name="sp_disc_amt[]" id="Specialperc_<?php echo $i;?>"  style="width:70px;" onfocus="check1(this.value,<?php echo $i;?>)" value="<?php echo $sp_disc_amt;?>"/></td>

	   <td><input type="text" style="width:70px" id="basic_<?php echo $i;?>" name="basic[]" value="<?php echo $basic?>" readonly="true"/></td>

	  <td><input type="text" style="width:70px" id="billing_type_<?php echo $i;?>" name="billing_type[]" readonly value="<?php echo $billing_type;?>"/></td>

	  <td><select name="excise_duty[]" id="exciseDuty_<?php echo $i;?>" style="width:120px;" onchange="claculateExcise(<?php echo $i; ?>,this.value)" onfocus="checkexiseflag(<?php echo $i; ?>)">

	  <option value="0">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))

			{

			?>

				<option value="<?php echo $excise_row['id'];?>" <?php if($excise_duty==$excise_row['id']) echo "selected";?>><?php echo $excise_row['caption'];?></option>

			<?php 	

			}

    	    ?> 

  	      </select><div id="exciseId_<?php echo $i; ?>"><input type="text" name="excise_perc[]" id="ExcisePercentage_<?php echo $i;?>" value="<?php echo $excise_perc;?>" size="5" onblur="calcExcise(this.value,<?php echo $i;?>)" /><input type="text" name="excise_val[]" id="exciseValue_<?php echo $i;?>" value="<?php echo $excise_val;?>" size="10"  onfocus="calculateExciseDuty(<?php echo $i; ?>)"/></div></td>

  	      <?php 

    	     $cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);

			 $k=1;

			 while($cessRow=DB_fetch_array($cessSql))

			 {

			 	$caption[$k]=$cessRow['caption']; 

				

				$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);

				while($rate_row=DB_fetch_array($rate_sql))

				{

					$rate[$k]=$rate_row['def_rate'];

				}

				$k++;

			 } 

			 

			 

    	     ?>

	  <td><input name="e_cess_perc[]" id="ECessPercentage_<?php echo $i;?>" type="text" value="<?php echo $rate[2];?>" style="width:70px;" readonly onfocus="caldata(<?php echo $i;?>)"  /><input name="e_cess_val[]" id="ECessValue_<?php echo $i;?>" type="text" value="<?php echo $e_cess_val;?>"  style="width:70px;" readonly onfocus="calculateECess(<?php echo $i; ?>)"/></td>

	  <td><input name="sah_perc[]" id="SAHCessPercentage_<?php echo $i;?>" type="text" value="<?php echo $rate[1];?>" style="width:35px;" readonly/><input name="sah_val[]" id="SAHCessValue_<?php echo $i;?>" type="text" value="<?php echo $sah_val;?>"  style="width:65px;" readonly onfocus="calculateSAHCess(<?php echo $i; ?>)"/></td>

	  

	  

	  

	  

	  





 <td><input name="taxableamount[]" type="text" id="taxableamount_<?php echo $i;?>"  size="12" readonly="true" onfocus="caltaxamout(<?php echo $i;?>)" value="<?php echo $taxamount_rate;?>" /></td>





 <td><input name="total[]" type="text" id="total_<?php echo $i?>" value="<?php echo $total_amt_with_tax;?>" size="12" readonly="true" onfocus="value_after_discount(<?php echo $i ?>);"/></td>





<td><input type="text" name="remarks[<?php echo $i;?>]" id="remarks_[<?php echo $i;?>]" value="<?php echo $myrow2['remarks']; ?>"></td>

</tr>



<?php }$i++; }  ?>

<input type="hidden" name="countval" value="<?php echo $i; ?>"  id="count"/>

</table>

</div>



<?php    

?>

</td>

</tr>

</table>





<?php ?>



<div style="clear:both"></div>





<div style="width:auto; float:right;">			

			<table width="100%">

			<tr><th>

		      <table width="100%" border="0" cellspacing="2" cellpadding="2">

                <tr>

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

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

               </tr>

              <tr>

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

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

                </tr>

                <tr>

                  <td><strong>Vat/Cst(discription) </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_rate1(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="taxval">

                  <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_per"  size="10" onchange="calsuroctamt(this.value)" value="<?php echo $GetRowData['sur_oct_per'];?>"/><input name="sur_oct_amt" type="text" id="sur_oct_amt" 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_charges" id="additionalCharges" type="text" value="<?php echo $GetRowData['add_charges'];?>" size="25" 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</strong></td>

                  <td><input type="text" name="grandtotal" id="GrandTotal" onfocus="cal_grandamount()"  size="12" value="<?php echo $GetRowData['grandtotal'];?>"/><input type="hidden"  id="orig_grand_tot" value="<?php echo $GetRowData['grandtotal'];?>"/>&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="+" <?php if($GetRowData['round_off']=='+') echo "selected";?>>+</option>

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

				  </select></td>

                </tr>

              </table>

			  </th>

			  </tr></table>



</div>



<div style="clear:both;"></div>





<p align="center">

<?php if($Type!='PO'){ ?>

    <input type="submit" name="Update" value="Update" onclick="return confirmPost1()" />

	<?php }else{ ?>

	<input type="submit" name="Update" value="Update" />

	<?php } ?>

  <input type="reset" name="reset" value="Reset" /> <a href="index.php?route=Inventory/transation/material_receipt_note_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&NewReturn=yes"><input type="button" value="Cancel" name="Back" /></a></p>

  <?php 

if($Type!='PO'){

	$sqlmax="SELECT max_price FROM direct_mrn_config";

	$resultmax=DB_query($sqlmax,$db); 

	$rowmax=DB_fetch_array($resultmax);

?>



	<input type="hidden" name="max_price" id="max_price" value="<?php echo $rowmax['max_price'];;?>" />

<?php }?>

</form>



</div>

























<script language="javascript" type="text/javascript">

function DiscountAmount(DA,i)

{

	var discount_percent = document.getElementById("PerAmo_"+i).value;

	var discount = document.getElementById("Discount_"+i).value;

	var totalPrice = document.getElementById("item_total_rate_"+i).value;

	

	if(discount_percent=='PercentAmt')

	{

		if(discount==''){discount=0;}

		var percent = parseFloat(totalPrice) * parseFloat(discount)/100;

		var subTotal = parseFloat(totalPrice)-parseFloat(percent);

	}

	else if(discount_percent=='Amount')

	{ 

		

	//alert(totalnetrate);

	

		var percent = parseFloat(document.getElementById("Discount_"+i).value);

		if(isNaN(percent)){percent=0;}

		var subTotal = totalPrice-parseFloat(percent);

	

	}

	document.getElementById("perc_"+i).value=percent.toFixed(2);

	document.getElementById("NetRate_"+i).value=subTotal.toFixed(2);

	

	/*Total=parseFloat(Total) + parseFloat(subTotal);

	document.getElementById("Total").value=Total;*/

	//return true;

}

function DiscountAmountspe(DA,i)

{

	var total1=document.getElementById("NetRate_"+i).value;

	var discount1 = document.getElementById("SpecialDiscount_"+i).value;

	var Specialperc=document.getElementById("Specialperc_"+i).value;

	

	if(discount1=='' && Specialperc=='')

	{

		var total1=document.getElementById("NetRate_"+i).value;

		

		document.getElementById("basic_"+i).value=total1;

	

	}

	else

	{

		if(discount1=='' && Specialperc!='')

		{

			var elx=document.getElementById("Specialperc_"+i).value;

			var total1=document.getElementById("NetRate_"+i).value;

			

			var TotalAmount2 = total1-parseFloat(elx);

			

			document.getElementById("basic_"+i).value=TotalAmount2.toFixed(2);

		}

		else

		{

			var percent1 = total1 * parseFloat(discount1)/100;

			var TotalAmount2 = total1-parseFloat(percent1);

	

			document.getElementById("Specialperc_"+i).value=percent1.toFixed(2);

			document.getElementById("basic_"+i).value=TotalAmount2.toFixed(2);

		}

	

	}

}

function checkExcisable(str,i)

{	

	if(str=='NonExcisable')

	{

		document.getElementById("exciseDuty_"+i).disabled=true;

		document.getElementById("ECessPercentage_"+i).disabled=true;

		document.getElementById("ECessValue_"+i).disabled=true;

		document.getElementById("SAHCessPercentage_"+i).disabled=true;

		document.getElementById("SAHCessValue_"+i).disabled=true;

		document.getElementById("taxableamount_"+i).disabled=true;

	}

	else if(str=='Excisable' || str==0)

	{

		document.getElementById("exciseDuty_"+i).disabled=false;

		//document.getElementById("exciseValue_"+i).disabled=false;

		document.getElementById("ECessPercentage_"+i).disabled=false;

		document.getElementById("ECessValue_"+i).disabled=false;		

		document.getElementById("SAHCessPercentage_"+i).disabled=false;	

		document.getElementById("SAHCessValue_"+i).disabled=false;

		document.getElementById("taxableamount_"+i).disabled=false;

	}

	else{

		document.getElementById("exciseDuty_"+i).disabled=true;

		//document.getElementById("exciseValue_"+i).disabled=true;

		document.getElementById("ECessPercentage_"+i).disabled=true;

		document.getElementById("ECessValue_"+i).disabled=true;

		document.getElementById("SAHCessPercentage_"+i).disabled=true;

		document.getElementById("SAHCessValue_"+i).disabled=true;

		document.getElementById("taxable_amt_"+i).disabled=true;

		document.getElementById("taxname_"+i).disabled=true;

		document.getElementById("taxvalue_"+i).disabled=true;

		document.getElementById("sur_oct_perc_"+i).disabled=true;

		document.getElementById("sur_oct_amt_"+i).disabled=true;

		document.getElementById("TotalCharge_"+i).disabled=true;

		document.getElementById("packagingCharges_"+i).disabled=true;

		document.getElementById("additionalCharges_"+i).disabled=true;

		document.getElementById("roundOff_"+i).disabled=true;

		document.getElementById("exciseDuty_"+i).value='';

		//document.getElementById("exciseValue_"+i).value='';

		document.getElementById("ECessPercentage_"+i).value='';

		document.getElementById("ECessValue_"+i).value='';

		document.getElementById("SAHCessPercentage_"+i).value='';

		document.getElementById("SAHCessValue_"+i).value='';

		document.getElementById("taxable_amt_"+i).value='';

		document.getElementById("taxname_"+i).value='';

		document.getElementById("taxvalue_"+i).value='';

		document.getElementById("sur_oct_perc_"+i).value='';

		document.getElementById("sur_oct_amt_"+i).value='';

		document.getElementById("TotalCharge_"+i).value='';

		document.getElementById("packagingCharges_"+i).value='';

		document.getElementById("additionalCharges_"+i).value='';

		document.getElementById("roundOff_"+i).value='';

	}

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

}

function claculateExcise(i,str)

{

	

	var discounted=document.getElementById("basic_"+i).value;

	if (str.length==0)

  		{

  			document.getElementById("exciseId_"+i).innerHTML="";

  			return;

  		}

		if (window.XMLHttpRequest)

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

  			xmlhttp=new XMLHttpRequest();

  		}

		else

  		{// code for IE6, IE5

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

  		}

		xmlhttp.onreadystatechange=function()

  		{

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

    		{

    			document.getElementById("exciseId_"+i).innerHTML=xmlhttp.responseText;

    		}

  		}

		xmlhttp.open("GET","calculateExcise.php?mrnTaxId="+str+"&data="+i,true);

		xmlhttp.send();

}

function calcExcise(str,i)

{

	var basic=document.getElementById("basic_"+i).value;

	var excise_val=basic*(str/100);

	document.getElementById("exciseValue_"+i).value=excise_val.toFixed(2);

}

function calculateECess(i)

{

	

	var exciseValue=document.getElementById("exciseValue_"+i).value;

	var ECessPercentage=document.getElementById("ECessPercentage_"+i).value;

	var total=exciseValue*(ECessPercentage/100);

	document.getElementById("ECessValue_"+i).value=total.toFixed(2);

}



function calculateSAHCess(i)

{

	var exciseValue=document.getElementById("exciseValue_"+i).value;

	var SAHCessPercentage=document.getElementById("SAHCessPercentage_"+i).value;

	var total=exciseValue*(SAHCessPercentage/100);

	document.getElementById("SAHCessValue_"+i).value=total.toFixed(2);

}



function caltaxamout(i)

{

	

var excise=parseFloat(document.getElementById("exciseDuty_"+i).value);



if(excise!=0)

{

var basic_amount=document.getElementById("exciseValue_"+i).value;

var ecessamt=document.getElementById("ECessValue_"+i).value;

var sahamt=document.getElementById("SAHCessValue_"+i).value;

var totaltax=parseFloat(basic_amount)+parseFloat(ecessamt)+parseFloat(sahamt);	

document.getElementById('taxableamount_'+i).value=totaltax.toFixed(2);	

}

else

{

document.getElementById('taxableamount_'+i).value=0;		

}	

	

}



function value_after_discount(i)

{

	

	var basic = parseFloat(document.getElementById('basic_'+i).value);

	

	if(document.getElementById('taxableamount_'+i).value=='')

	{

	var taxableamt = 0;	

	}

	else

	{

	var taxableamt = parseFloat(document.getElementById('taxableamount_'+i).value);

	}

 	var val_after_disc = parseFloat(basic+taxableamt);

	document.getElementById('total_'+i).value=val_after_disc.toFixed(2);	

	

	

}

function calculateExciseDuty(i)

{

	var basic=document.getElementById("basic_"+i).value;

	var ExcisePercentage=document.getElementById("ExcisePercentage_"+i).value;

	

	var exciseVal=basic*(ExcisePercentage/100);

	document.getElementById("exciseValue_"+i).value=exciseVal.toFixed(2);

}





function cal_totalamount()

{	

var total=0;

var t=document.getElementById("count").value;



for(var i=0;i<t;i++)

	{

		var amt=parseFloat(document.getElementById("total_"+i).value);

		if(isNaN(amt)){amt=0;}

		total=parseFloat(total)+amt;	

	}	

document.getElementById("total_item_amount").value=total.toFixed(2);	

}

function calcPackaging(str)

{

	if(str!='')

	{

		var tota_amt=document.getElementById("total_item_amount").value;

		var pckgng_val=(str/100)*tota_amt;

		document.getElementById("pkg_charges1").value=pckgng_val.toFixed(2);

	}

}



function cal_grandamount()

{

	var total=document.getElementById("total_item_amount").value;

	var loading=document.getElementById("loading").value;

	var sur_oct_amt=document.getElementById("sur_oct_amt").value;

	var TotalCharge=document.getElementById("TotalCharge").value;

	var taxamt=document.getElementById("taxvalue").value;

	var packagingCharges=document.getElementById("pkg_charges1").value;

	var additionalCharges=document.getElementById("additionalCharges").value;	

	if(total==''){total=0;}

	if(loading==''){loading=0;}

	if(sur_oct_amt==''){sur_oct_amt=0;}

	if(TotalCharge==''){TotalCharge=0;}

	if(packagingCharges==''){packagingCharges=0;}

	if(additionalCharges==''){additionalCharges=0;}

	if(taxamt==''){taxamt=0;}

	//var roundOffVal=document.getElementById("round_off").value;

	var grand=document.getElementById("GrandTotal").value;

	

	grandtotal=parseFloat(total)+parseFloat(sur_oct_amt)+parseFloat(TotalCharge)+parseFloat(packagingCharges)+parseFloat(additionalCharges)+parseFloat(taxamt)+parseFloat(loading);

	/*if(roundOffVal==''){roundOffVal='-.0';}

	

	var test=roundOffVal.split(".");

	

	 if(test[0]=='-')

	 {

		var dot=".";

		var roundval=dot + test[1];

		

	 document.getElementById("GrandTotal").value=parseFloat(grandtotal) - parseFloat(roundval);

	 }

	 else

	 {

	 	var dot=".";

		var roundval=dot + test[1];

	 	document.getElementById("GrandTotal").value=parseFloat(grandtotal) + parseFloat(roundval);	

	 }*/

document.getElementById("GrandTotal").value=grandtotal.toFixed(2);	

document.getElementById("orig_grand_tot").value=grandtotal.toFixed(2);	

}





function calcRounded(str)

{

	var gtotal=document.getElementById('orig_grand_tot').value;

	var gtotal_brk=gtotal.split('.');

	if(str=='+')

	{var final=parseInt(gtotal_brk[0])+1;}

	else if(str=='-')

	{var final=parseInt(gtotal_brk[0]);}

	else if(str=='')

	{var final=gtotal;}

	document.getElementById('GrandTotal').value=final;

}

function tax_rate1(str)

{



var taxableAmount=document.getElementById("total_item_amount").value;

var taxableAmount1=document.getElementById("pkg_charges1").value;

if(taxableAmount1==''){taxableAmount1=0;}

var taxableAmount2=parseFloat(taxableAmount)+parseFloat(taxableAmount1);

if (str.length==0)

  {

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

  return;

  }

if (window.XMLHttpRequest)

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

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

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

  }

xmlhttp.onreadystatechange=function()

  {

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

    {

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

    }

  }

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

xmlhttp.send();

}

function DiscountAmountdpc(DA,i)

{

	var discount_percent = document.getElementById("Perspc_"+i).value;

	var totalPrice = document.getElementById("NetRate_"+i).value;

	var discount = document.getElementById("special_discount_"+i).value;

	if(discount_percent=='PercentAmt' )

	{

	   if(discount==''){discount=0;}

		var percent = parseFloat(totalPrice) * parseFloat(discount)/100;

		var subTotal = parseFloat(totalPrice)-parseFloat(percent);

	}

	else if(discount_percent=='Amount')

	{

		var percent = parseFloat(document.getElementById("special_discount_"+i).value);

		if(isNaN(percent)){percent=0;}

		var subTotal = parseFloat(totalPrice)-parseFloat(percent);

	}

	if(parseFloat(discount)>=100 && discount_percent=='PercentAmt')

		{

		alert("Discount Percentage Should Be Less Then 100");

		document.getElementById("Specialperc_"+i).value='';

		document.getElementById("special_discount_"+i).value='';

	     document.getElementById("basic_"+i).value='';

	     document.getElementById("special_discount_"+i).focus();

		return false;

		}

		else

		{

	document.getElementById("Specialperc_"+i).value=percent.toFixed(2);

	document.getElementById("basic_"+i).value=subTotal.toFixed(2);

	

	/*Total=parseFloat(Total) + parseFloat(subTotal);

	document.getElementById("Total").value=Total;*/

	return true;



}

	}

	

	function calamt(str)

	{

	if(parseFloat(document.getElementById("reciveqty_"+str).value)>parseFloat(document.getElementById("qty_as_per_bill_"+str).value))

	{

	alert("Receive qty should not greater then po qty");

	return false;

	}

	return true;

		

	

	}

function check_bill_qty(str,id)

{

  

	var poqty=parseInt(document.getElementById("poqty_"+id).value);

	str1=parseInt(str);

	if(poqty!='')

	{

	var qty=(poqty*20)/100;

	var poqty1=parseInt(poqty)+parseInt(qty);

	//var poqty2=poqty-qty;	

	if(str1>poqty1)

	{

		alert("Quantity As Per Bill Cannot Be Greater Than 20 % of PO Quantity");

		document.getElementById("qty_as_per_bill_"+id).value='';

		document.getElementById("qty_as_per_bill_"+id).focus();

		return false;

	}

	}

}

  



</script>

<link rel="stylesheet" href="css/jquery.ui.all.css">

<script src="js/jquery-1.5.1.js"></script>

<script src="ui/jquery.ui.core.js"></script>

<script src="ui/jquery.ui.widget.js"></script>

<script src="ui/jquery.ui.datepicker.js"></script>

<script type="text/javascript" src="js/dynamicRow.js"></script>

<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>-->

<script src="js/edit_tax_calculation.js"></script>

<script src="js/modify_add_mrn.js"></script>

  <!--  To display calender ---->

<script type="text/javascript">



function short_qty(i)

{

	var qty_as_per_bill=parseFloat(document.getElementById('qty_as_per_bill_'+i).value);

	var reciveqty=parseFloat(document.getElementById('reciveqty_'+i).value);

	var short_accessid=parseFloat(qty_as_per_bill-reciveqty);

	document.getElementById('short_accessid_'+i).value=parseFloat(qty_as_per_bill-reciveqty);

	return true;



}

function calc_total_price(str)

{

	

	var item_total_rate=0;

	var reciveqty = document.getElementById("reciveqty_"+str).value;

	var itemrate=document.getElementById("itemrate_"+str).value;	

	if(reciveqty!='' && itemrate!='')

	{

		document.getElementById("item_total_rate_"+str).value=(parseFloat(reciveqty)*parseFloat(itemrate)).toFixed(2);

	}

}



function calculate_short(id)

{

	

	alert(poqty);

	var poqty = parseFloat(document.getElementById('qty_as_per_bill_'+id).value);

	var x = parseFloat(document.getElementById('reciveqty_'+id).value);

	if(x != '')

	{

		if(poqty >= x)

		{

 				document.getElementById('short_accessid_'+id).value = parseInt(poqty)- parseInt(x);

				return true;

		}

	  }

	else

	{

		document.getElementById('short_accessid_'+id).value = 0;

			return true;

	}

}



function openPopupProfile(i)

{

  	window.open("Search_item_MRN.php?rowcount="+i,"profiles_popup_window","height=425,width=640,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");

}

//function value_after_discount(id)

//{

   // var item_total_rate = parseInt(document.getElementById('item_total_rate_'+id).value);

	//var discount_amount = parseInt(document.getElementById('discount_amount_'+id).value);

 	//var val_after_disc = parseInt(item_total_rate-discount_amount);

	//document.getElementById('val_after_disc_'+id).value=val_after_disc;

//}



function cal_total(x)

{

	var dis_amt=document.getElementById("val_after_disc_"+x).value;

	var dis_faight=document.getElementById("freight_"+x).value;

	//alert(dis_amt);

	var Total=parseFloat(dis_amt)+parseFloat(dis_faight);

	document.getElementById("total_amt_"+x).value=Total;

}



function confirmPost1()

{

		var max_price=document.getElementById("max_price").value;

		var grand_price=document.getElementById("GrandTotal").value;

		if(parseFloat(grand_price) > parseFloat(max_price)){

			$alertmasg="Grandtotal not more than Maximum Direct Purchase Allowed Amount - "+max_price;

			alert($alertmasg);

			return false;

		}

return true;

}





function calsuroctamt(str)

{

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

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

	var amount=(amt*suroctper)/100;

	document.getElementById("sur_oct_amt").value=amount.toFixed(2);	

}



function check_po_qty2(i)

  {

       

		reciveqty=parseFloat(document.getElementById("reciveqty_"+i).value);

		

  if(document.getElementById("convfac_"+i).value!='')

   var k=parseFloat(document.getElementById("convfac_"+i).value); 

 else

 var k=0;

 var amt=reciveqty/k;

 document.getElementById("scecondarqty_"+i).value=amt.toFixed(2);

 }







</script>