<?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_consigment  = $_REQUEST['id_consigment'];
	$fetch = mysql_fetch_array(mysql_query("select * from inventory_consigment where id_consigment = '$id_consigment'"));
	$kode_consigment = $fetch['kode_consigment'];
	list($y, $m, $d)=split ("[-]",$fetch['tgl_consigment']);
	$tgl_consigment=$d."-".$m."-".$y;
	$id_branchfrom = $fetch['id_branchfrom'];
	$id_branchto = $fetch['id_branchto'];
	list($y, $m, $d)=split ("[-]",$fetch['receive_date']);
	$receive_date=$d."-".$m."-".$y;
	$user_receive = $fetch['user_receive'];
	
	?>
<body>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type='text/javascript' src='js/jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
<script type="text/javascript">
$().ready(function() {
	$("#item").autocomplete("search_consigment.php?id_branchfrom=<?php echo $id_branchfrom; ?>", {
		width: 260,
		matchContains: true,
		//mustMatch: true,
		//minChars: 0,
		//multiple: true,
		//highlight: false,
		//multipleSeparator: ",",
		selectFirst: false
	});
});
</script>

  <h1><i class="icon-truck"></i> View Consigment Input</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="add_consigment2.php?act=1&id=<?php echo $id; ?>">
                        <div class="form-group">
                        <div class="col-md-6"> 
                            <label>Consigment ID</label>
                            </div>
                                <div class="col-md-6"> 
                                 <input type="text" class="form-control" name="kode"   id="kode" value="<?php echo $kode_consigment; ?>"  readonly="readonly" >
                                </div>
                        </div>
                        <div class="form-group">
                        <div class="col-md-6"> 
                            <label>Consigment Date</label>
                            </div>
                                <div class="col-md-6"> 
                                 <input type="text" class="form-control" name="inputDate2" value="<?php echo $tgl_consigment; ?>" readonly="readonly">
                                </div>
                        </div>
                         
                         <div class="form-group">
                        <div class="col-md-6"> 
                            <label>From Branch</label>
                            </div>
                                <div class="col-md-6"> 
                                <select name="branchfrom" id="branchfrom" class="form-control">
                            <?php if($id_branchfrom == 0)
                            {
                            ?>
                            <option value="0">Head Office</option>
                           	<?php
						    }
                            else
                            {
                                              $sql3 = "select *
											  from tbl_branch where id_branch='$id_branchfrom' order by nama_branch";
                                              $rs3 = mysql_query($sql3);
                                              while($fetch3 = mysql_fetch_array($rs3))
                                              {
                                               ?>
                                        <option value="<?php echo $fetch3['id_branch']; ?>"><?php echo  $fetch3['nama_branch'];  ?></option>
                                                      <?php
                                              }
                                             ?>
                                              <?php
                            }
							?>
                            </select>
                                </div>
                        </div>
                         <div class="form-group">
                        <div class="col-md-6"> 
                            <label>To Branch</label>
                            </div>
                                <div class="col-md-6"> 
                                <select name="to" id="to" class="form-control">
                               <?php
                                              $sql3 = "select * from tbl_branch where id_branch='$id_branchto' order by nama_branch";
                                              $rs3 = mysql_query($sql3);
                                              while($fetch3 = mysql_fetch_array($rs3))
                                              {
                                               ?>
                                        <option value="<?php echo $fetch3['id_branch']; ?>"><?php echo  $fetch3['nama_branch'];  ?></option>
                                                      <?php
                                              }
                                             ?>
                            </select>
                                </div>
                        </div>
                        <div class="form-group">
                        <div class="col-md-6"> 
                            <label>User Receive</label>
                            </div>
                                <div class="col-md-6"> 
                                <input type="text" name="kode" id="kode" class="form-control" value="<?php echo $user_receive; ?>"  readonly="readonly" />
                                </div>
                        </div>
                         <div class="form-group">
                        <div class="col-md-6"> 
                            <label>Receive Date</label>
                            </div>
                                <div class="col-md-6"> 
                               <input id="" type="text" class="form-control" name=""  value="<?php echo $receive_date; ?>" readonly="readonly"/> 
                                </div>
                        </div>
                        <button class="btn btn-default" type="button" onClick="document.location='consigment.php'">Back</button>
                      </form>
                    </div>
             </div>
              <?php
					$sql = mysql_query("select * from  inventory_detailsconsigment
						where status = 1 and id_consigment='$id_consigment'");
					if(mysql_num_rows($sql)>0)
					{
					?>
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                   <thead>
                        <tr>
                       		<th>Type Inventory</th>
                            <th>Kode Stock</th>
                            <th>Barcode No.</th>
                        </tr>
                    </thead>
                    <tbody>
                      <?php
						$sql = mysql_query("select * from  inventory_detailsconsigment
						where status = 1 and id_consigment='$id_consigment'");
						while($fetch = mysql_fetch_array($sql))
						{
								$kode_stock = $fetch['kode_stock'];
								  $sql2 = "select type,kode_stock,barcodeno,id_stock from
								  (select 'Diamond' as type,kode_stock,barcodeno,id_stock from  inventory_diamond where status_stock=1
								  union all
								  select 'Gold' as type,kode_stock,barcodeno,id_stock from  inventory_gold  where status_stock=1
								  union all
								  select 'Logam Mulia' as type,kode_stock,barcodeno,id_stock from  inventory_logam  where status_stock=1
								  union all
								  select 'Ready Item' as type,kode_stock,barcodeno,id_stock from  inventory_readyitem  where status_stock=1
								   union all
									  select 'Cincin' as type,kode_stock,barcodeno,id_stock from  inventory_cincin  where status_stock=1 							
									  union all
									  select 'Mastura' as type,kode_stock,barcodeno,id_stock from  inventory_mastura  where status_stock=1
									   union all
									  select 'Liontin' as type,kode_stock,barcodeno,id_stock from  inventory_liontin  where status_stock=1
									  union all
									  select 'Kerabu' as type,kode_stock,barcodeno,id_stock from  inventory_kerabu  where  status_stock=1
									  union all
						select 'Gelang Kaku Gelang Rantai' as type,kode_stock,barcodeno,id_stock from  inventory_gkgr  where status_stock=1
									  union all
									  select 'Rangka' as type,kode_stock,barcodeno,id_stock from  inventory_rangka  where status_stock=1) a
								  where kode_stock = '$kode_stock'
								  order by type,kode_stock,barcodeno";
								$fetch2 = mysql_fetch_array(mysql_query($sql2));
					?>
                        <tr>
                        	<td><?php echo $fetch2['type']; ?></td>
                          <td><?php echo $fetch2['kode_stock']; ?></td>
                          <td><?php echo $fetch2['barcodeno']; ?></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>