<?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'];
	$fetch = mysql_fetch_array(mysql_query("select * from inventory_readyitem where id_stock = '$id_stock'"));
	$kode_stock  = $fetch['kode_stock'];
	$id_supplier = $fetch['id_supplier'];
	$lbprice  = $fetch['lbprice'];
	$cbprice  = $fetch['cbprice'];
	$msprice  = $fetch['msprice'];
	$barcodeno  = $fetch['barcodeno'];
	$weight  = $fetch['weight'];
	$combineitem  = $fetch['combineitem'];
	$supplieritem  = $fetch['supplieritem'];
	$description  = $fetch['description'];
	$id_status  = $fetch['id_status'];
	$id_branch  = $fetch['id_branch'];
	$picture = $fetch['picture'];
	$loc = "readyitem/";
	$all = $loc.$picture; 
	if($act == 1)
	{
		$id_stock = $_REQUEST['id_stock'];// echo $id_stock; exit;
		$status = $_REQUEST['status'];
		$description = $_REQUEST['description'];
		$update  = mysql_query("update inventory_readyitem set id_status = '$status', user_update  = '$USERNAME',description='$description' where id_stock = '$id_stock'");
		if($update)
		{
			if($status == 3)
			{
				$update  = mysql_query("update inventory_readyitem set date_stock = '$tanggaltanggal' where id_stock = '$id_stock'");
			}
			?>
						<script language="javascript">
						 alert("Change Status Inventory Success");
						document.location="inventory_monitoring.php";
						</script>
			<?php
		}
		else
		{
			?>
						<script language="javascript">
						 alert("Change Status Inventory Failed");
						document.location="change_readyitem.php?id_stock=<?php echo $id_stock; ?>";
						</script>
			<?php
		}
	}
?>
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-gears (alias)"></i>Inventory Ready Item</h1>
</div>

<!--<ol class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Bread</a></li>
  <li><a href="#">Crumbs</a></li>
  <li class="active">Example</li>
</ol>-->
          <div class="main-content">
            <div class="row">
                <div class="widget">
                  <div class="widget-content-white glossed">
                    <div class="padded">
                      <form method="post" action="change_readyitem.php?act=1&id_stock=<?php echo $id_stock; ?>"  role="form" class="form-horizontal">
                        <div class="form-group">
                          <label class="col-md-4 control-label">Stock ID</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="kode" id="kode"   value="<?php echo $kode_stock; ?>"  readonly="readonly">
                          </div>
                          </div>
                           <div class="form-group">
                          <label class="col-md-4 control-label">Kode Supplier -  Nama Supplier</label>
                          <div class="col-md-8"><select name="supplier" id="supplier" class="form-control">
                               <?php
                                              $sql3 = "select * from tbl_supplier where status_supplier='1' order by nama_supplier,kode_supplier";
                                              $rs3 = mysql_query($sql3);
                                              while($fetch3 = mysql_fetch_array($rs3))
                                              {
                                               ?>
                                         <option <?php if($fetch3['id_supplier']==$id_supplier) { ?> selected="selected" <?php } ?> value="<?php echo $fetch3['id_supplier']; ?>"><?php echo  $fetch3['kode_supplier'];  ?> - <?php echo  $fetch3['nama_supplier'];  ?></option>
                                                      <?php
                                              }
                                             ?>
                            </select>
                          </div>
                        </div>
                         <div class="form-group">
                          <label class="col-md-4 control-label">Supplier Item No.</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="supplieritem" id="supplieritem" value="<?php echo $supplieritem; ?>"  >
                          </div>
                          </div>
                           <div class="form-group">
                          <label class="col-md-4 control-label">Barcode No.</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="barcode" id="barcode" value="<?php echo $barcodeno; ?>" >
                          </div>
                          </div>
                           <div class="form-group">
                          <label class="col-md-4 control-label">MS Price</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="cbprice" id="cbprice" value="<?php  echo number_format($msprice, 0, ',', ','); ?>"  >
                          </div>
                          </div>
                           <div class="form-group">
                          <label class="col-md-4 control-label">CB Price</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="msprice" id="msprice" value="<?php  echo number_format($cbprice, 0, ',', ','); ?>"  >
                          </div>
                          </div>
                          <div class="form-group">
                          <label class="col-md-4 control-label">LB Price</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="lbprice" id="lbprice" value="<?php  echo number_format($lbprice, 0, ',', ','); ?>" >
                          </div>
                          </div>
                          <div class="form-group">
                          <label class="col-md-4 control-label">Weight (in gram)</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="weight" id="weight" value="<?php echo $weight; ?>"  >
                          </div>
                          </div>
                           <div class="form-group">
                          <label class="col-md-4 control-label">Combine Item No.</label>
                          <div class="col-md-8">
                            <input type="text" class="form-control" name="combine" id="combine" value="<?php echo $combineitem; ?>" >
                          </div>
                          </div>
                          <div class="form-group">
                          <label class="col-md-4 control-label">Status Inventory</label>
                          <div class="col-md-8"><select name="status" id="status" class="form-control">
                               <?php
                                              $sql3 = "select * from tbl_status where id_status in (1,3,5,6) ";
                                              $rs3 = mysql_query($sql3);
                                              while($fetch3 = mysql_fetch_array($rs3))
                                              {
                                               ?>
                                        <option <?php if($fetch3['id_status']==$id_status) { ?> selected="selected" <?php } ?> value="<?php echo $fetch3['id_status']; ?>"><?php echo  $fetch3['status'];  ?></option>
                                                      <?php
                                              }
                                             ?>
                            </select>
                          </div>
                        </div>
                         <div class="form-group">
                          <label class="col-md-4 control-label">Branch ID</label>
                          <div class="col-md-8"><select name="id_branch" id="id_branch" class="form-control">
                            <?php if($id_branch == NULL)
                            {
                            ?>
                            <option value="">Head Office</option>
                           	<?php
						    }
                            else
                            {
                                              $sql3 = "select *
											  from tbl_branch where id_branch='$id_branch' order by nama_branch";
                                              $rs3 = mysql_query($sql3);
                                              while($fetch3 = mysql_fetch_array($rs3))
                                              {
                                               ?>
                                        <option <?php if($fetch3['id_branch']==$id_branch) { ?> selected="selected" <?php } ?> value="<?php echo $fetch3['id_branch']; ?>"><?php echo  $fetch3['nama_branch'];  ?></option>
                                                      <?php
                                              }
                                             
                            }
							?>
                            </select>
                          </div>
                        </div>
                       
                           <div class="form-group">
                          <label class="col-md-4 control-label">Picture *max file 1MB and format file only JPEG/GIF</label>
                          <div class="col-md-8">
                          <a class="image" href="readyitem/<?php echo $picture; ?>">
							<img src="<?php echo $all; ?>" alt="" height="69" width="117"/></a>&nbsp;
                      
                          </div>
                        </div>
                      
                         <div class="form-group">
                          <label class="col-md-4 control-label">Description</label>
                          <div class="col-md-8">
                          <textarea id="description" name="description" rows="15" cols="80" style="width: 80%" class="form-control" ><?php echo $description; ?></textarea>
                          </div>
                        </div>
                        <div class="form-group">
                          <div class="col-md-offset-4 col-md-8">
                             <button type="submit" class="btn btn-default">Submit</button>
                            <button type="reset" class="btn btn-default">Reset</button>
                          </div>
                        </div>
                      </form>
                    </div>
                    </div>
                    </div>
                    </div>
                    </div>
                   

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

</html>