<link rel='stylesheet' type='text/css' href="../../include/css/display_styles.css" />	
<?php
include "../../include/config.php";
# Baca Variabel Form
$message = array();
$Act	 = isset($_REQUEST['Act'])?$_REQUEST['Act']:'';
$id		 = isset($_REQUEST['id'])?$_REQUEST['id']:'';
$nama	 = isset($_REQUEST['nama'])?$_REQUEST['nama']:'';
if($Act=="SIMPAN"){
	if(count($message)==0){	
		if(empty($id)){
			$qrySave=mysql_query("INSERT INTO master_warehouse SET mw_name='$nama', mw_status=10") or die ("Gagal query".mysql_error());
		}else{
			$qrySave=mysql_query("UPDATE master_warehouse SET mw_name='$nama' WHERE id='$id'") or die ("Gagal query".mysql_error());
		}				
		if($qrySave){
			echo "<meta http-equiv='refresh' content='0; url=?page=Add-Satuan'>";				
		}
		exit; 
	}	
}
if($Act=="DETAIL"){
	$qd = mysql_query("SELECT id,mw_name FROM master_warehouse WHERE id='$id'");
	$dd=mysql_fetch_object($qd);		
	$id 		= $dd->id;			
	$nama		= $dd->mw_name;
}
if($Act=="DELETE"){
	$qd = mysql_query("UPDATE master_warehouse SET mw_status=100 WHERE id='$id'");
	if($qd){
		echo "<meta http-equiv='refresh' content='0; url=popup_addwh.php'>";				
	}
	exit;
}
if (! count($message)==0 ){
	echo "<div class='mssgBox'>";
	echo "<img src='images/attention.png' class='imgBox'> <hr>";
		$Num=0;
		foreach ($message as $indeks=>$pesan_tampil) { 
		$Num++;
			echo "&nbsp;&nbsp;$Num. $pesan_tampil<br>";	
		} 
	echo "</div> <br>"; 
}
?>
<div id="popup">
<form action="popup_addwh.php" method="post" name="frmadd" target="_self">
<table width="100%" cellpadding="2" cellspacing="1" class="table-list" style="margin-top:0px;">
	<tr>
	  <th colspan="3" bgcolor="#99FFFF" align="left">INPUT DATA GUDANG</th>
	</tr>
	<tr>
	  <td width="30%"><b>Nama Gudang</b></td>
	  <td width="1%"><b>:</b></td>
	  <td width="69%"><input type="hidden" name="id" value="<?php echo $id; ?>" size="50" />
	  				  <input name="nama" value="<?php echo $nama; ?>" size="20" /></td></tr>	 
	<tr>
	  <td>&nbsp;</td>
	  <td>&nbsp;</td>
	  <td>
	  	<input type="submit" name="Act" value="SIMPAN" style="cursor:pointer;">
	  </td>
    </tr>
</table>
</form>
<br>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
  <tr>
    <th colspan="2" align="left"></td><b>LIST GUDANG</b></th>
  </tr>  
  <tr>
    <td colspan="2"><table width="100%" border="0" cellspacing="1" cellpadding="1">
      <tr>
        <th align="center">No.</th>
        <th align="center">Nama Gudang</th>
		<th align="center">Action</th>
      </tr>
      <?php
	  $no=0;
	  $qh = mysql_query("SELECT id, mw_name FROM master_warehouse WHERE mw_status=10 ORDER BY mw_name ASC");
	  while($dh=mysql_fetch_object($qh)){		
	   	$no++;
	  ?> 
		<tr>
			<td align="center"><?=$no;?>.</td>
			<td align="left"><?=$dh->mw_name;?></td>
			<td align="center">
				<a href="popup_addwh.php?id=<?=$dh->id;?>&Act=DETAIL" target="_self" alt="Edit Data"><img src="../../images/btn_edit.png" width="20" height="20" border="0" title="Edit" /></a>&nbsp;
			    <a href="popup_addwh.php?id=<?=$dh->id;?>&Act=DELETE" target="_self" alt="Delete Data"><img src="../../images/btn_delete.png" width="20" height="20"  border="0"  title="Hapus" /></a>
			</td>
		</tr>
      <?php } ?>
    </table></td>
  </tr>
</table>
</div>
