<?php include "../include/config.php"; ?>
<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.prod_id").value = id;	
		eval("opener.document.form.prod_name").value = code+" - "+name;
		eval("opener.document.form.prod_sat").value = units;	
		window.close();
		self.close();	
	}
</script>
</head>
<body>
<?php $loc   = isset($_REQUEST['loc']) ? $_REQUEST['loc'] :''; ?>
<div id="popup">
<form action="popup_barang.php" method="post" enctype="multipart/form-data">
<table width="100%">
	<tr>
		<th colspan="4">
		Cari berdasarkan kode:<input type="text" name="cari" size="20">
							  <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	
	$cari  = isset($_REQUEST['cari']) ? $_REQUEST['cari'] :'';	
	if (isset($_REQUEST['proses'])=="CARI"){		
		$list = "WHERE a.prod_code LIKE '%$cari%'";
	}else{
		$list = "";
	}
	$query = mysql_query("SELECT a.id, prod_name, CONCAT_WS(' - ', a.prod_name,a.prod_sat,a.prod_type,a.prod_spec,a.prod_color) prodname, a.prod_code, a.prod_sat, a.prod_type, a.prod_spec, a.prod_color, a.prod_cat 
						  FROM product a
						  LEFT JOIN stock b ON b.stock_prodid=a.id AND b.stock_loc='$loc'
						  $list ORDER BY prod_name ASC ");
	while($data=mysql_fetch_object($query)){
	?>
	 <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>
