<?php $PageSecurity = 4;
global  $db;
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
include('includes/stockcalculation.php');

?>
<table width="100%" border="0" cellspacing="3" cellpadding="2" align="center">
<tr>
	<th width="5%"><strong>SELECT</strong></th>
    <th><strong>ASSET CODE</strong></th>
	<th><strong>ASSET NAME</strong></th>
	 <th><strong>UOM</strong></th> 
	</tr>
	<?php 
	$filter=array();
	
	if($_REQUEST['code']!='')
	{
		$filter[]="code LIKE '%".$_REQUEST['code']."%'";
	}
	if($_REQUEST['name']!='')
	{
		$filter[]="name LIKE '%".$_REQUEST['name']."%'";
	}
	/*if($_REQUEST['site']!='')
	{
		$filter[]="location = '".$_REQUEST['site']."'";
	}*/
	
	$filter1='';
	if(!empty($filter))
	{
		$filter1=implode(" AND ", $filter);
	}	

	if($filter1=='')
	{	
		//echo "Select * from machine_center where CompanyId='".$_SESSION['ACGCompanyId']."' ";
	 $sql=DB_query("Select * from machine_center where CompanyId='".$_SESSION['ACGCompanyId']."' ",$db); 
	}else{
		//echo "Select * from machine_center where ".$filter1." and CompanyId='".$_SESSION['ACGCompanyId']."' ";
	$sql=DB_query("Select * from machine_center where ".$filter1." and CompanyId='".$_SESSION['ACGCompanyId']."' ",$db); 
}
	
	$i=0;
	if(DB_num_rows($sql)>0)
	{
		while($myrow=DB_fetch_array($sql))
	  	{ 
		 $parameter=$myrow['id'];
		 $sqlU=DB_query("Select * from unitsofmeasure where unitid='".$myrow['unit']."' ",$db); 
		 $myrow_unit=DB_fetch_array($sqlU);
      
		 $sqlG=DB_query("Select * from machine_group_master where id='".$myrow['under_group']."' ",$db); 
		 $myrow_group=DB_fetch_array($sqlG);

		 $sqlH=DB_query("SELECT MAX(end_meter_reading) AS HighestPrice FROM tpl_fixed_asset_logbook_details where asset_code=".$myrow['id']." ",$db); 
		 $myrow_mx=DB_fetch_array($sqlH);
		 

$title='';
		   $title1=DB_query("select * from tbl_title_master order by serial_no ASC limit 0,3",$db);
		   while($r=DB_fetch_array($title1))
		   {
		    $title[]=$r['db_field_name'];
		   }  
		 
		 
?>
 <tr bgcolor="#CCCCCC">
      <td width="9%"><input type="checkbox" name="row_id[<?php echo $i;?>]" id="row_id_<?php echo $i;?>" value="<?php echo $parameter;?>" 
		onclick="getItemsList('<?php echo $parameter;?>','<?php echo $myrow['code'];?>','<?php echo  htmlspecialchars($myrow['name'], ENT_QUOTES);?>','Nos','<?php echo $i;?>')"></td>
      <td><?php echo $myrow['code'];?></td>
	     <td><?php echo  $myrow['name'];?></td>
      <td><?php echo $myrow_unit['unitname']; ?></td>
 
      </tr>
<?php $i++;} }?>
 </table>

