<?php session_name('CAKEPHP'); session_start();
$PageSecurity = 4;
$PageName = 'Add Items';
include('includes/DefinePOClass.php');
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/DefineSuppTransClass.php');
//include('includes/header.inc');
include('includes/function_lib.php');
$function_filter[]=$date1;
							
                      
							
						/*************************** new *****************************/
						
						function openingBalance($function_filter,$item)
							{
								global $db;
								
								$site=$function_filter[0];
								$store=$function_filter[1];
								$from=$function_filter[2];								
								if($site!='')
								$filter[]="site = '".$site."'";
								if($store!='')
								$filter[]="store = '".$store."'";
								if($from!='--' && $to!='--')
								$filter[]="reveive_date <= '".$from."'";
								if($item!='')
								$filter[]="itemcode = '".$item."'";
								
								$filter=implode(' and ',$filter);
								$sql1="Select stock, rate from opening_stockitemwise where $filter";
								$result1=DB_query($sql1,$db);
								$myrow1=DB_fetch_array($result1);
								return $myrow1['stock'];
							}
						
                   function receivedMRN($function_filter,$item)
						{
							global $db;
							$site=$function_filter[0];
							$store=$function_filter[1];
							$from=$function_filter[2];
							if($site!='')
							$filter[]="addmrn.site = '".$site."'";
							if($store!='')
							$filter[]="addmrn.StoreCode = '".$store."'";
							if($item!='')
							$filter[]="addmrnqty.mst_itemid = '".$item."'";
							if($from!='')
							$filter[]="addmrn.MRNDate <= '".$from."'";
							
							$filter=implode(' and ',$filter);
							   $sql1="Select SUM(addmrnqty.reciveqty),sum(addmrnqty.item_total_rate) as total
							  from addmrn left join addmrnqty 
							       on(addmrn.id=addmrnqty.issue_id) where Cancel_status!='Y' and $filter";
							$result1=DB_query($sql1,$db);
							$myrow1=DB_fetch_array($result1);
							  $return_array[]=$myrow1['SUM(addmrnqty.reciveqty)'];
							  if($myrow1['total']!='' && $myrow1['SUM(addmrnqty.reciveqty)']!=0 )
							  $rate1=$myrow1['total']/$myrow1['SUM(addmrnqty.reciveqty)'];
							  else
							  $rate1=0;
							   $rate=round($rate1,2);
								$return_array[]=$rate;
								$return_array[]=$myrow1['total'];
							  return $return_array;
						}
						
			               function issueSlip($function_filter,$item)
							{
								global $db;
								$site=$function_filter[0];
								$store=$function_filter[1];
								$from=$function_filter[2];
								if($site!='')
								$filter[]="addissue.site = '".$site."'";
								if($store!='')
								$filter[]="addissue.mst_storeid = '".$store."'";
								if($item!='')
								$filter[]="issueqty.mst_itemid = '".$item."'";
								
								
								$filter=implode(' and ',$filter);
							
								 $sql1="Select SUM(issueqty.issueqty) from addissue left join 
								 issueqty on(addissue.id=issueqty.issue_id) where $filter";
								$result1=DB_query($sql1,$db);
								$myrow1=DB_fetch_array($result1);
								
								return $myrow1['SUM(issueqty.issueqty)'];
							}

				function receivedReturn($function_filter,$item)
				{
					global $db;
					$site=$function_filter[0];
					$store=$function_filter[1];
					$from=$function_filter[2];
					$to=$function_filter[3];
					
					if($site!='')
					$filter[]="material_return.site = '".$site."'";
					if($store!='')
					$filter[]="material_return.store = '".$store."'";
					if($from!='--' && $to!='--')
					$filter[]="material_return.returndate <='".$from."' ";
					if($item!='')
					$filter[]="material_return_details.itemid = '".$item."'";
					
					$filter=implode(' and ',$filter);
					   $sql1="Select SUM(material_return_details.receiveqty) 
					  from material_return left join material_return_details    
					  on(material_return.id=material_return_details.parentId) where $filter";
					
					$result1=DB_query($sql1,$db);
					$myrow1=DB_fetch_array($result1);
					return $myrow1['SUM(material_return_details.receiveqty)'];
				}


				function receivedSiteToSite($function_filter,$item)
				{
					global $db;
					$site=$function_filter[0];
					$store=$function_filter[1];
					$from=$function_filter[2];
					$to=$function_filter[3];
					
					if($site!='')
					$filter[]="transfer_receipt.Received_to = '".$site."'";
					if($store!='')
					$filter[]="transfer_receipt.Received_store = '".$store."'";
					if($from!='--' && $to!='--')
					$filter[]="transfer_receipt.MRNDate <='".$from."' ";
					if($item!='')
					$filter[]="transfer_receipt_details.itemid = '".$item."'";
					
					$filter=implode(' and ',$filter);
					
					 $sql1="Select SUM(transfer_receipt_details.reciveqty)
					  from transfer_receipt left join transfer_receipt_details 
					  on(transfer_receipt.id=transfer_receipt_details.transfer_receipt_id) where $filter";
					$result1=DB_query($sql1,$db);
					$myrow1=DB_fetch_array($result1);
					return $myrow1['SUM(transfer_receipt_details.reciveqty)'];
				}

				function issueSiteToSite($function_filter,$item)
				{
					global $db;
				 
					$site=$function_filter[0];
					$store=$function_filter[1];
					$from=$function_filter[2];
					$to=$function_filter[3];
					
					if($site!='')
					$filter[]="transfer_issue.sitecode = '".$site."'";
					if($store!='')
					$filter[]="transfer_issue.fromstore = '".$store."'";
					if($from!='--' && $to!='--')
					$filter[]="transfer_issue.issuedate <='".$from."' ";
					if($item!='')
					$filter[]="transfer_issue_details.itemid = '".$item."'";
					
					$filter=implode(' and ',$filter);
						  $sql1="Select SUM(transfer_issue_details.issueqty)  from
						  transfer_issue left join transfer_issue_details  
						  on(transfer_issue.id=transfer_issue_details.transfer_issue_id) where $filter";
					$result1=DB_query($sql1,$db);
					$myrow1=DB_fetch_array($result1);
					$return_array=$myrow1['SUM(transfer_issue_details.issueqty)'];
					//$avg_rate=$myrow1['SUM(transfer_issue_details.rate)'];
					//$return_array[]=$avg_rate;
					return $return_array;
					
				}
					function issueMatarialReturn($function_filter,$item)
					{
						global $db;
						$site=$function_filter[0];
						$store=$function_filter[1];
						$from=$function_filter[2];
						$to=$function_filter[3];						
						if($site!='')
						$filter[]="inv_material_return.sitecode = '".$site."'";
						if($store!='')
						$filter[]="inv_material_return.storecode = '".$store."'";
						if($from!='--' && $to!='--')
						$filter[]="inv_material_return.MRNDate <='".$from."' ";
						if($item!='')
						$filter[]="inv_material_return_details.itemid = '".$item."'";
						
						$filter=implode(' and ',$filter);
						
					  $sql1="Select SUM(inv_material_return_details.ReturnQty) 
					  from inv_material_return left join inv_material_return_details   
					   on(inv_material_return.id=inv_material_return_details.parentId) where $filter";
						$result1=DB_query($sql1,$db);
						$myrow1=DB_fetch_array($result1);
						return $myrow1['SUM(inv_material_return_details.ReturnQty)'];
					}

	 function Rgpchallan($function_filter,$item)
					  {
					  
					      global $db;
							$site=$function_filter[0];
							$store=$function_filter[1];
							$from=$function_filter[2];
							$to=$function_filter[2];
							
							if($site!='')
							$filter[]="rgp_tab.branch = '".$site."'";
							if($store!='')
							$filter[]="rgp_tab.store = '".$store."'";
							if($from!='--' && $to!='--')
							$filter[]="rgp_tab.date <= '".$from."'";
							if($item!='')
							$filter[]="rgp_tab_details.mst_itemid = '".$item."'";
							
							$filter=implode(' and ',$filter);
							
							  $sql1="Select SUM(rgp_tab_details.qty) 
							  from rgp_tab left join rgp_tab_details 
							  on(rgp_tab.id=rgp_tab_details.parent_id) where $filter";
							$result1=DB_query($sql1,$db);
							$myrow1=DB_fetch_array($result1);
							return $myrow1['SUM(rgp_tab_details.qty)'];
					  
					  
					  		
					  }	
					   function Rgpreturn($function_filter,$item)
					    {
					  
					        global $db;
							$site=$function_filter[0];
							$store=$function_filter[1];
							$from=$function_filter[2];
							$to=$function_filter[2];
							
							if($site!='')
							$filter[]="rgp_return.branch = '".$site."'";
							if($store!='')
							$filter[]="rgp_return.store = '".$store."'";
							if($from!='--' && $to!='--')
							$filter[]="rgp_return.return_date <= '".$from."' ";
							if($item!='')
							$filter[]="rgp_return_details.item_id = '".$item."'";
							
							$filter=implode(' and ',$filter);
							
							  $sql1="Select SUM(rgp_return_details.qty) 
							  from rgp_return left join rgp_return_details 
							  on(rgp_return.id=rgp_return_details.parent_id) where $filter";
							$result1=DB_query($sql1,$db);
							$myrow1=DB_fetch_array($result1);
							return $myrow1['SUM(rgp_return_details.qty)'];
					  
					  
					  		
					  }	
					  
					  function Nrgp($function_filter,$item)
					    {					  
					        global $db;
							$site=$function_filter[0];
							$store=$function_filter[1];
							$from=$function_filter[2];
							$to=$function_filter[2];
							
							if($site!='')
							$filter[]="nrgp_challan.branch = '".$site."'";
							if($store!='')
							$filter[]="nrgp_challan.store = '".$store."'";
							if($from!='--' && $to!='--')
							$filter[]="nrgp_challan.date <= '".$from."' ";
							if($item!='')
							$filter[]="nrgp_challan_details.item_code = '".$item."'";
							
							$filter=implode(' and ',$filter);
							
							  $sql1="Select SUM(nrgp_challan_details.qty) 
							  from nrgp_challan left join nrgp_challan_details 
							  on(nrgp_challan.id=nrgp_challan_details.parant_id) where $filter";
							$result1=DB_query($sql1,$db);
							$myrow1=DB_fetch_array($result1);
							return $myrow1['SUM(nrgp_challan_details.qty)'];
					  
					  
					  		
					  }	
					  
					  function FinishedMR($function_filter,$item)
					    {					  
					        global $db;
							$site=$function_filter[0];
							$store=$function_filter[1];
							$from=$function_filter[2];
														
							if($site!='')
							$filter[]="finished_recieved.site = '".$site."'";
							if($store!='')
							$filter[]="finished_recieved.store = '".$store."'";
							if($from!='--' && $to!='--')
							$filter[]="finished_recieved.recieved_date <= '".$from."' ";
							if($item!='')
							$filter[]="finished_recieved_details.mst_itemid = '".$item."'";
							
							$filter=implode(' and ',$filter);
							
							   $sql1="Select SUM(finished_recieved_details.reciveqty) 
							  from finished_recieved left join finished_recieved_details 
							  on(finished_recieved.id=finished_recieved_details.finished_recieved_id) where $filter";
							$result1=DB_query($sql1,$db);
							$myrow1=DB_fetch_array($result1);
							return $myrow1['SUM(finished_recieved_details.reciveqty)'];
					  
					  
					  		
					  }	
?>
<script> 
function getdata1(str)
{  
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	 var data=xmlhttp.responseText.split("__");	 
	document.getElementById("ItemListDiv").innerHTML=data;
	//document.getElementById("subcategory1").innerHTML=data[0];
		
    }
  }
  xmlhttp.open("GET","item_list_ajax.php?site="+str,true);
xmlhttp.send();
//xmlhttp.open("GET","getSort.php?s="+str+"&cat="+cat,true);

}
	function getItemsNew(str)
	{		
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();}
		else
  		{// code for IE6, IE5
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
		
		xmlhttp.onreadystatechange=function()
  		{if (xmlhttp.readyState==4 && xmlhttp.status==200){
    		document.getElementById("ItemListDiv").innerHTML=xmlhttp.responseText;
    	
        		}}
xmlhttp.open("GET","item_list_ajax.php?q="+str,true);
xmlhttp.send();
	}
	
	
	function getItems1(str)
	{		
		//var arr=document.getElementById("arr").value;
		//alert(arr);
		
		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("ItemListDiv").innerHTML=xmlhttp.responseText;
    	
        		}}
xmlhttp.open("GET","item_list_ajax.php?q="+str,true);
xmlhttp.send();
	}
	
	
function ExitWindow()
{
	opener.window.location="index.php?route=POModule/direct_purchase_order2&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&NewRequisition=Yes";self.close();
}


function getItemsList(id,code,name,uom,stock,ctr,isuerate)
{
	var dup='empty';
	var itemcount=parseInt(window.opener.document.getElementById('count1').value)-1;
	 
	var edit_cnt=window.opener.document.getElementById('edit_cnt').value;
	if(edit_cnt=='')
		{var counter=1;} 
	else if(edit_cnt>itemcount)
		{var counter=edit_cnt;
		var itemcount=parseFloat(counter)+parseFloat(itemcount);
	} else  {var counter=edit_cnt-1;}
	
 
 if(document.getElementById("row_id_"+ctr).checked==true)
	{
 
 if(window.opener.document.getElementById('itemid').value=='')
   {
			if(edit_cnt==''){var counter=0;}
			if(dup=='empty')
			{		
	if(window.opener.document.getElementById('itemid'))
	{	
	if(window.opener.document.getElementById('itemid').value=='')
	{	
			 window.opener.document.getElementById('itemid').value = id;
			 window.opener.document.getElementById('itemcode').value = code;
			 window.opener.document.getElementById('itemname').value = name;
			 window.opener.document.getElementById('uom').value =uom;
			  window.opener.document.getElementById('Stockbalance').value =stock;
			  window.opener.document.getElementById('issuerate').value =isuerate;
			//window.opener.document.getElementById('conv_fac').value =data4;
			//window.opener.document.getElementById('unit_sec').innerHTML =data12;
			//window.opener.document.getElementById('total_stock').value =stock;
			//window.opener.document.getElementById('conf').value=data4;
	}
	}
		}
 }
		
		else
		{
			for(var i=counter; i<=itemcount; i++)
			{
			
			
				if(edit_cnt==''){var counter=0;}
									
				if(dup=='empty')
				{
				 if(window.opener.document.getElementById('itemid_'+i))
				 {	
					if(window.opener.document.getElementById('itemid_'+i).value=='')
					{
					 window.opener.document.getElementById('itemid_'+i).value = id;
			 window.opener.document.getElementById('itemcode_'+i).value = code;
			 window.opener.document.getElementById('itemname_'+i).value = name;
			 window.opener.document.getElementById('uom_'+i).value =uom;
			  window.opener.document.getElementById('Stockbalance_'+i).value =stock;
				 window.opener.document.getElementById('issuerate_'+i).value =isuerate;						
					
					//window.opener.document.getElementById('conv_fac_'+i).value =data4;
					//window.opener.document.getElementById('unit_sec_'+i).innerHTML =data12;
				//	window.opener.document.getElementById('total_stock_'+i).value =stock;
					//window.opener.document.getElementById('conf_'+i).value=data4;
			
	            break;
					
					
				}
				}
					
					else
					{
						continue;
					}
				}
			}
		}
	}
	else
	{
	 
		if(window.opener.document.getElementById('itemid').value==document.getElementById("row_id_"+ctr).value)
		{
				 window.opener.document.getElementById('itemid').value = '';
 				 window.opener.document.getElementById('itemcode').value = '';
	 			 window.opener.document.getElementById('itemname').value = '';
	 			 window.opener.document.getElementById('uom').value ='';
				  window.opener.document.getElementById('Stockbalance').value ='';
//	window.opener.document.getElementById('conf').value='';
	
		}
		else
		{
			for(var i=counter; i<itemcount; i++)
			{
				if(window.opener.document.getElementById('itemid_'+i).value==document.getElementById("row_id_"+ctr).value)
				{
      			 window.opener.document.getElementById('itemid_'+i).value = '';
	 			 window.opener.document.getElementById('itemcode_'+i).value = '';
		 		 window.opener.document.getElementById('itemname_'+i).value = '';
	 			 window.opener.document.getElementById('uom'+i).value ='';
				   window.opener.document.getElementById('Stockbalance_'+i).value ='';
				//	window.opener.document.getElementById('conf_'+i).value='';
	
				}
			}
		}
	}
}
</script>
<link href="css/professional/default.css" rel="stylesheet" type="text/css" />

 <h2 align="center">Search ITEMS</h2>
<form action="" method="post" >
<table width="100%" align="center" border="0">
  <tr><td><strong>Search By Category</strong></td>
  <td><select name="category" id="category" onchange="getdata1(this.value)" >
  	<option value="">Select Group</option>
            <?php 
		 $store_sql ="SELECT * FROM stockmaincategory WHERE CompanyId='".$_SESSION['ACGCompanyId']."'";
		$store_result = DB_query($store_sql,$db);
		while($store_row = DB_fetch_array($store_result))
		{
			$p='';
			if($store_row['id'] == $_REQUEST['category'])	
			$p="selected";
		
		?>
            <option value="<?php echo $store_row['id']; ?>" <?php echo $p;?>><?php echo $store_row['stockmaincategoryname']; ?></option>
            <?php } ?>
</select>  	
  </td>
  </tr>
   <tr><td><strong>Search By Sub Category Category</strong></td>
     <td id="subcategory1"><select name="subcategory" id="subcategory" onchange="getItems1(this.value)" >
  	 <option value="">Select Sub Group</option>
  	 <?php $store_sql = "SELECT * FROM stockcategory WHERE CompanyId='".$_SESSION['ACGCompanyId']."'";
		$store_result = DB_query($store_sql,$db);
		while($store_row = DB_fetch_array($store_result))
		{
			$p1='';
			if($store_row['categoryid'] == $_REQUEST['subcategory'])
			{	
			$p1="selected";		
		}
			?>
            <option value="<?php echo $store_row['id'] ?>"<?php echo $p1 ?>><?php echo $store_row['categorydescription']; ?></option>
          <?php  } ?>
  	 
           
</select>  	
  </td>
  </tr>
  <tr><td><strong>Enter Part Name/Part Code</strong></td>
  <td><input name="part_name" type="text" id="part_name" size="25" onkeyup="getItemsNew(this.value)" />
  	  	
  </td>
  </tr>
</table></form>
<?php 
if($_REQUEST['Select'] != '')
{
	$item_array=array();
	$item_array=$_REQUEST['row_id'];
	if(empty($_SESSION['ACGRequisition-ItemList']))
	{
		$_SESSION['ACGRequisition-ItemList']=$item_array;
	}
	else if(!empty($_SESSION['ACGRequisition-ItemList']))
	{ if(!empty($_REQUEST['row_id']))
		{ 
		$_SESSION['IntermediateList']=$_REQUEST['row_id'];
		$_SESSION['ACGRequisition-ItemList']=array_unique(array_merge($_SESSION['ACGRequisition-ItemList'],$_SESSION['IntermediateList']));
		}
	}
	if(!empty($_SESSION['ACGRequisition-ItemList']))
	{
	//print_r($_SESSION['ACGRequisition-ItemList']);
	$itemlist=implode("#",$_SESSION['ACGRequisition-ItemList']);
	$_SESSION['ACGRequisition-ItemList_1']=$itemlist;
	}
	print_r($_SESSION['ACGRequisition-ItemList']); 
if($_REQUEST['Reset']!='')
{
	unset($_SESSION['ACGRequisition-ItemList']);
	unset($_SESSION['ACGRequisition-ItemList_1']);
	unset($_SESSION['IntermediateList']);
}
}
?>
<form name="form1" action="" method="post">
	<input type="hidden" value="<?php print_r($_SESSION['ACGRequisition-ItemList']);?>" id="arr" />
  
<input type="hidden" name="prdate" value="<?php echo $_SESSION['prdate'];?>" />
<input type="hidden" name="mst_branchid" value="<?php echo $_SESSION['site'];?>" />
<input type="hidden" name="prdate" value="<?php echo $_SESSION['prdate'];?>" />
<input type="hidden" name="mst_branchid" value="<?php echo $_SESSION['site'];?>" />


  <table width="100%" border="0" cellspacing="3" cellpadding="2" align="center">
        <tr>
          <th width="13%"><strong>SELECT</strong></th>
          <th width="30%"><strong>ITEM CODE</strong></th>
          <th width="34%"><strong>ITEM NAME</strong></th>
                 <th width="23%"><strong>UNIT</strong></th>
        </tr></table>
<?php
$i=0;
  	if($i%2==0)
	{$bg="#CCCCCC";}
	else
	$bg="#C8BECB";
//echo "Select * from item_master where CategoryID!='FG'";
 	$sql=DB_query("Select * from item_master where CompanyId='".$_SESSION['ACGCompanyId']."'",$db); 	
	?>
	
	<div style="overflow: scroll; height: 300px" id="ItemListDiv"><table width="100%" border="0" cellspacing="3" cellpadding="2" align="center">
	<?php 
	
	if(DB_num_rows($sql)>0)
	{
		$i=0;
		while($myrow=DB_fetch_array($sql))
	  	{ 	
	  		$parameter=$myrow['id'];
			$c='';
			for($x=0;$x<count($_SESSION['ACGRequisition-ItemList']);$x++)
			{
				if($parameter==$_SESSION['ACGRequisition-ItemList'][$x])
				$c="checked";
			}
			$unit=$s->getField('unitsofmeasure','unitid',$myrow['mst_unitid'],'unitname');
			
			 $op=openingBalance($function_filter,$myrow['id']);
              //echo "openingBalance"."<br>";
 		      $in_1=receivedMRN($function_filter,$myrow['id']);
          //echo "receivedMRN"."<br>";
 		    $out_1=issueSlip($function_filter,$myrow['id']);
           // echo "issueSlip"."<br>";
		   $out_2=issueSiteToSite($function_filter,$myrow['id']);		
          // echo "issuesitetosite"."<br>";
		   $in_2=receivedSiteToSite($function_filter,$myrow['id']);
		// echo " receivesitetosite"."<br>";
		  $out_3=issueMatarialReturn($function_filter,$myrow['id']);
		 
		   $out_4=Rgpchallan($function_filter,$myrow['id']);
		   $out_5=Nrgp($function_filter,$myrow['id']);
		  $in_3=receivedReturn($function_filter,$myrow['id']);		 
		  //$in_4=return_rejection($function_filter,$myrow['id']);
		   $in_4=Rgpreturn($function_filter,$myrow['id']);
		     $in_5=FinishedMR($function_filter,$myrow['id']);
		    $invalue=($op+$in_1[0]+$in_2+$in_3+$in_4+$in_5);
		
		     $outvalue=($out_1+$out_2+$out_3+$out_4+$out_5);
		  $tot=trim($invalue)-trim($outvalue);
		
		
		 $total_current=$tot;
			
			
  ?>
 <tr bgcolor="<?php echo $bg;?>">
      <td width="13%"><input type="checkbox" onclick="getItemsList('<?php echo $parameter;?>','<?php echo $myrow['StockID'];?>','<?php echo $myrow['item_name'];?>','<?php echo $unit;?>','<?php echo $total_current;?>','<?php echo $i;?>','<?php echo $myrow['last_po_price'];?>');" name="row_id[]" id="row_id_<?php echo $i;?>" value="<?php echo $parameter;?>"	<?php echo $c;?> /></td>
      <td width="32%"><strong><?php echo $myrow['StockID'];?></strong></td>
      <td width="34%"><?php echo $myrow['item_name'];?></td>
          <td width="21%"><?php $unit=$s->getField('unitsofmeasure','unitid',$myrow['mst_unitid'],'unitname'); echo $unit;?></td>
    </tr>
<?php $i++;
		} 
}?>
<input type="hidden" name="row_sount" id="row_count" value="<?php echo $i;?>">
</table>
	</div>
  </form>

