<?php 
	include "../include/config.php"; 
	include "../function/inc_function.php"; 
	$start_date = get_startdate();
	$end_date   = get_enddate();
	$bulan	 	= substr($start_date,5,2);
	$tahun  	= substr($start_date,0,4);
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href="../include/css/popup_styles.css" />	
<script language='javascript'>
	function select_go(id,code,name,units)
	{			
		eval("opener.document.form.prodid").value = id;	
		eval("opener.document.form.prodcode").value = code+" - "+name;
		eval("opener.document.form.prodsat").value = units;	
		window.close();
		self.close();	
	}
</script>
</head>
<body>
<?php 
	$loc   = isset($_REQUEST['loc']) ? $_REQUEST['loc'] :''; 
	$cari  = isset($_REQUEST['cari']) ? $_REQUEST['cari'] :'';	
	if (isset($_REQUEST['proses'])=="CARI"){		
		$list = "WHERE prod_cat IN(1,2,6) AND CONCAT_WS(' - ', prod_code,prod_name) LIKE '%$cari%'";
	}else{
		$list = "WHERE prod_cat IN(1,2,6)";
	}
?>
<div id="popup">
<form action="popup_itempop.php" method="post" enctype="multipart/form-data">
<table width="100%">
	<tr>
		<th colspan="4">
		Cari berdasarkan kode/nama:<input type="text" name="cari" size="20" value="<?=$cari;?>">
							  <input type="hidden" name="loc" value="<?=$loc;?>" size="5">
		      <input type="submit" name="proses" value="CARI">
		</th>
	</tr>
	<tr>
		<th>Kode</th>
		<th>Nama</th>
		<th>Satuan</th>
		<th>Tipe/Style</th>
		<th>Ukuran</th>
		<th>Warna</th>
	</tr>
    <?php		
	$query = mysql_query("SELECT id, prod_name, CONCAT_WS(' - ', prod_name,prod_sat,prod_type,prod_spec,prod_color) prodname, prod_code, prod_sat, prod_type, prod_spec, prod_color, prod_cat  
	FROM product $list ORDER BY prod_code ASC ");
	while($data=mysql_fetch_object($query)){
		#$stock = get_stock($start_date,$end_date,$bulan,$tahun,$data->id,$data->prod_cat,$inv);
	?>
	 <tr>
	 	<td><?=$data->prod_code;?></td>
		<td><a href="#" onClick="select_go('<?=$data->id;?>','<?=$data->prod_code;?>','<?=$data->prodname;?>','<?=$data->prod_sat;?>')"><?=$data->prod_name;?></a></td>		
		<td><?=$data->prod_sat;?></td>
		<td><?=$data->prod_type;?></td>
		<td><?=$data->prod_spec;?></td>
		<td><?=$data->prod_color;?></td>
	</tr>	
	<?php } ?>
</table>
</form>
</div>
</body>
</html>
