<?php $PageSecurity = 2;
include('includes/DefineSuppTransClass.php');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');
include('includes/function_lib.php');
include('includes/stockcalculation.php');
$function_filter[]=$_REQUEST['site'];
$function_filter[]=$_REQUEST['store'];
$function_filter[]=date('Y-m-d');

							
?>

<link href="css/professional/default.css" rel="stylesheet" type="text/css" />
<form name="form1" action="" method="post">
<div id="ItemListDiv">
<br />
<table width="100%" border="0" style="border:1px solid #333333;" align="right" cellspacing="0" cellpadding="3">
<tr style="height:30px;">
	<td style="border-bottom:1px solid #FF0000;"><strong>Select</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Item Code</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Item Name</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>UOM</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Stock Balance</strong></td>
	
</tr>
<?php $where=array();
if($_REQUEST['code']!=''){
    $where[]="StockID LIKE '".$_REQUEST['code']."%'";
}
if($_REQUEST['name']!=''){
    $where[]="item_name LIKE '".$_REQUEST['name']."%'";
}
if($_REQUEST['cat']!=''){
    $where[]=" CategoryID='".$_REQUEST['cat']."'";
}
if($_REQUEST['subcat']!=''){
    $where[]="SubCategoryID='".$_REQUEST['subcat']."'";
}
if(!empty($where))
{
	$filter2=implode(" and ",$where);
}

if(!empty($where))
{
	//echo "SELECT * 	FROM item_master WHERE $filter2";
	$sql=DB_query("SELECT * 	FROM item_master WHERE $filter2",$db); 
 	$i=0;
	if(DB_num_rows($sql)>0)
	{
		while($myrow=DB_fetch_array($sql))
		{ 	
			
			if(!is_null($myrow['conv_factor']))
				$confac=$myrow['conv_factor'];
	    	else
	    		$confac="null";	
		
			$total_current=$tot;
			$unit=$s->getField('unitsofmeasure','unitid',$myrow['mst_unitid'],'unitname');
			$unit1=DB_query("select * from  unitsofmeasure 	where unitid ='".$myrow['mst_unitid']."' ",$db);
			$numrow=DB_num_rows($unit1);
			if($numrow>0)
			{                  
			   while($unit_row=DB_fetch_array($unit1))
				{
				   $data1.="<option value=".$unit_row['unitid'].">".$unit_row['unitname']."</option>";
				}
		 	}
		 	$data22='';
		 	$unit2=DB_query("select * from  unitsofmeasure where unitid ='".$myrow['conv_unit']."' ",$db);
		 	$numrow1=DB_num_rows($unit2);
		 	if($numrow1>0)
		 	{                  
				 while($unit_row=DB_fetch_array($unit2))
			 	 {
			   		$data22.="<option value=".$unit_row['unitid'].">".$unit_row['unitname']."</option>";
			 	 }
		 	}
?>
		<tr bgcolor="#c1c1c1">
			<td><input type="checkbox" name="row_id[<?php echo $i;?>]" id="row_id_<?php echo $i;?>" value="<?php echo $parameter;?>" onclick="getItemsList('<?php echo $myrow['id'];?>','<?php echo $myrow['StockID'];?>','<?php echo $myrow['item_name'];?>','<?php echo $data1;?>','<?php echo $myrow['conv_unit'];?>','<?php echo $data22; ?>','<?php echo $i; ?>')"/></td>
			<td><strong><?php echo $myrow['StockID'];?></strong></td>
			<td><?php echo  $myrow['item_name'];?></td>
			<td><?php echo $myrow['item_desc'];?></td>
			<td><?php  echo $unit;?></td>
			<td><?php echo $total_current; ?></td>
		</tr>
	<?php $i++;} 
	}
}?>
 </table>
 </div>
</form>
<?php
function string_sanitize($s) 
{	
    $result = preg_replace("/[^a-zA-Z0-9]+/", "", html_entity_decode($s, ENT_QUOTES));
    return $result;
} 
?>
