<?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'];
	$id_stock  = $_REQUEST['id_stock'];
	if($act == 3)
	{
		$delete = mysql_query("update inventory_readyitem set status_stock = 2,user_update  = '$USERNAME' where id_stock='$id_stock'");
		if($delete)
		{
				?>
				<script language="javascript">
                alert("Delete Ready Item Success");
                document.location="inventory_readyitem.php";
                </script>
				<?php
			}
			else
			{
				?>
				<script language="javascript">
                alert("Delete Ready Item Failed");
                document.location="inventory_readyitem.php";
                </script>
				<?php	
			}
	}
	?>
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-download-alt"></i> Consigment Receive</h1>
</div>

   <div class="main-content">
            <div class="widget">
              <h3 class="section-title first-title"><i class="icon-table"></i> Listing Consigment Receive</h3>
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                  <thead>
                    <tr>
                       <th>Kode Consigment</th>
                            <th>Tanggal Consigment</th>
                            <th>Branch From</th>
                            <th>Branch To</th>
                            <th>Details</th>
                    </tr>
                  </thead>
                  <tbody>
                     <?php
						$sql = mysql_query("select * from  inventory_consigment
						where status_consigment = 1 and user_receive = '' order by id_consigment");
						while($fetch = mysql_fetch_array($sql))
						{
								$id_consigment = $fetch['id_consigment'];
								$id_branchto = $fetch['id_branchto'];
								$id_branchfrom = $fetch['id_branchfrom'];
								if($id_branchto == 0)
								{
									$branchto = 'Head Office';
								}
								else
								{
									$id_branchto = $fetch['id_branchto'];
									$fetch3 = mysql_fetch_array(mysql_query("select * from tbl_branch where id_branch = '$id_branchto'"));
									$branchto = $fetch3['nama_branch'];
								}
								if($id_branchfrom == 0)
								{
									$branchfrom = 'Head Office';
								}
								else
								{
									$id_branchfrom = $fetch['id_branchfrom'];
									$fetch3 = mysql_fetch_array(mysql_query("select * from tbl_branch where id_branch = '$id_branchfrom'"));
									$branchfrom = $fetch3['nama_branch'];
								}
								list($y, $m, $d)=split ("[-]",$fetch['tgl_consigment']);
								$tgl_consigment=$d."-".$m."-".$y;
					?>
                        <tr class="gradeX">
                          	<td><a href="view_consigment.php?id_consigment=<?php echo $id_consigment; ?>"><?php echo $fetch['kode_consigment'];?></a></td>
                            <td><?php echo $tgl_consigment;?></td>
                            <td><?php echo $branchfrom;?></td>
                            <td><?php echo $branchto;?></td>
                             <td class="actions aligncenter"><a href="consigment_receive.php?id_consigment=<?php echo $id_consigment; ?>" class="edit">View</a></td>
                        </tr>
                        <?php
						}
						?>
                  </tbody>
                </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

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

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

</html>