<?php
session_name("AUTHENUSER");
session_start();
$USERNAME = $_SESSION['SES_USERNAME'];
if(!session_name("AUTHENUSER"))
	{
?>
						<script language="javascript">
						 alert("Waktu Login telah habis.Silahkan Login Kembali");
						document.location="index.php";
						</script>
<?php
	}
if(!$USERNAME)
	{
?>
						<script language="javascript">
						 alert("Harap Login Dahulu.");
						document.location="index.php";
						</script>
<?php
	}
	?>
	<?php include "common/config.php";
	include "include/head.php"; ?>
    <?php
	$act  = $_REQUEST['act'];
	$type  =$_REQUEST['type'];
	$barcode  =$_REQUEST['barcode'];
	$stock  =$_REQUEST['stock'];
	?>
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
   
  <h1><i class="icon-search"></i> Status Monitoring</h1>
</div>


   <div class="main-content">
   
            <div class="widget">
            <div class="widget-content-white glossed">
                    <div class="padded">
                      <form role="form" class="form-horizontal" method="post" action="inventory_monitoring.php">
                        <div class="form-group">
                        <div class="col-md-6"> 
                            <label>Inventory Type</label>
                            </div>
                                <div class="col-md-6"> 
                                 <select name="type" id="type" class="form-control">
                               <option value="1">Ready Item</option>
                               <option value="2">Gold</option>
                               <option value="3">Logam Mulia</option>
                               <option value="4">Diamond</option>
                            </select>
                                </div>
                        </div>
                        <div class="form-group">
                        <div class="col-md-6"> 
                            <label>Barcode No.</label>
                            </div>
                                <div class="col-md-6"> 
                                 <input type="text" class="form-control" name="barcode"   id="barcode" >
                                </div>
                        </div>
                         <div class="form-group">
                        <div class="col-md-6"> 
                            <label>Stock No.</label>
                            </div>
                                <div class="col-md-6"> 
                                 <input type="text" class="form-control" name="stock"   id="stock" >
                                </div>
                        </div>
                        <button class="btn btn-primary" type="submit">Submit</button>
                        <button class="btn btn-default" type="reset">Reset</button>
                      </form>
                    </div>
             </div>
                <?php if($type <> "") {?>
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                   <thead>
                        <tr>
                       		<th>Stock ID</th>
                            <th>Kode - Nama Supplier</th>
                            <th>Barcode No.</th>
                            <th>Status</th>
                            <th>Branch ID</th>
                            <th>Details</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php
						
						if($type == 1)
						{
							$sql = mysql_query("select * from inventory_readyitem a
							inner join tbl_status b on a.id_status = b.id_status
							inner join tbl_supplier c on a.id_supplier = c.id_supplier
							left join tbl_branch d on a.id_branch = d.id_branch
							where status_stock = 1 and a.id_status in (1,3,5) 
							and (barcodeno like '%$barcode%' or kode_stock like '%$stock%')
							order by a.id_stock");
						}
						elseif($type == 2)
						{
							$sql = mysql_query("select * from inventory_gold a
							inner join tbl_status b on a.id_status = b.id_status
							inner join tbl_supplier c on a.id_supplier = c.id_supplier
							left join tbl_branch d on a.id_branch = d.id_branch
							where status_stock = 1 and a.id_status in (1,3,5) 
							and (barcodeno like '%$barcode%' or kode_stock like '%$stock%')
							order by a.id_stock");
						}
						elseif($type == 3)
						{
							$sql = mysql_query("select * from inventory_logam a
							inner join tbl_status b on a.id_status = b.id_status
							inner join tbl_supplier c on a.id_supplier = c.id_supplier
							left join tbl_branch d on a.id_branch = d.id_branch
							where status_stock = 1 and a.id_status in (1,3,5) 
							and (barcodeno like '%$barcode%' or kode_stock like '%$stock%')
							order by a.id_stock");
						}
						elseif($type == 4)
						{
							$sql = mysql_query("select * from inventory_diamond a
							inner join tbl_status b on a.id_status = b.id_status
							inner join tbl_supplier c on a.id_supplier = c.id_supplier
							left join tbl_branch d on a.id_branch = d.id_branch
							inner join tbl_shape e on a.id_shape = e.id_shape
							inner join tbl_type f on a.id_type = f.id_type
							where status_stock = 1 and a.id_status in (1,3,5) 
							and (barcodeno like '%$barcode%' or kode_stock like '%$stock%')
							order by a.id_stock");
						}
						while($fetch = mysql_fetch_array($sql))
						{
								$id_stock = $fetch['id_stock'];	
								$id_branch = $fetch['id_branch'];
								if($id_branch == NULL)
								{
									$branch = 'Head Office';
								}
								else
								{
									$branch = $fetch['nama_branch'];
								}
					?>
                        <tr>
                          	<td><?php echo $fetch['kode_stock'];?></td>
                            <td><?php echo $fetch['kode_supplier'];?> - <?php echo $fetch['nama_supplier'];?></td>
                            <td><?php echo $fetch['barcodeno'];?></td>
                            <td><?php echo $fetch['status'];?></td>
                            <td><?php echo $branch;?></td>
                            <td class="actions aligncenter"><?php if($type == 1) {?><a href="change_readyitem.php?id_stock=<?php echo $id_stock; ?>" class="btn btn-default btn-xs"><i class="icon-pencil"></i> edit</a>
                            </a><?php }elseif($type == 2) { ?><a href="change_gold.php?id_stock=<?php echo $id_stock; ?>" class="btn btn-default btn-xs"><i class="icon-pencil"></i> edit</a>
                            </a><?php }elseif($type == 3) { ?><a href="change_logam.php?id_stock=<?php echo $id_stock; ?>" class="btn btn-default btn-xs"><i class="icon-pencil"></i> edit</a>
                            </a><?php }elseif($type == 4) { ?><a href="change_diamond.php?id_stock=<?php echo $id_stock; ?>" class="btn btn-default btn-xs"><i class="icon-pencil"></i> edit</a>
                            </a><?php } ?></td>
                        </tr>
                        <?php
						}
						?>
                  </tbody>
                </table>
                </div>
              </div>
              <?php
			  }
			  ?>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</div>       

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>

</html>