|
|
|
php mysql จะแก้ไขจำนวนสินค้า แต่ต้องให้หัวหน้าอนุมัติ ทำอย่างไรค่ะ |
|
|
|
|
|
|
|
ปัจจุบัน สามารถแก้ไขจำนวนสินค้าคงเหลือได้ แต่อยากเพิ่มการอนุมัติโดยหัวหน้างานค่ะ
Code (PHP)
<?php include('header.php'); ?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Adjust</h1>
<p align="right">
<a href="show_addproductc.php">
<button name="insert" >History</button></a>
</p>
</section>
<!-- Main content -->
<section class="content">
<form class="form-horizontal" method="post" >
<div class="box-body">
<script>
function findproduct_current(str)
{
if (str.length == 0) {
document.getElementById("pro_qtycurrent").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("pro_qtycurrent").value = xmlhttp.responseText;
var qty= xmlhttp.responseText;
}
}
xmlhttp.open("GET", "find_product.php?id="+str, true);
xmlhttp.send();
findprono(str);
}
}
function findprono(str)
{
if (str.length == 0) {
document.getElementById("pro_no").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("pro_no").value = xmlhttp.responseText;
var qty= xmlhttp.responseText;
}
}
xmlhttp.open("GET", "find_prono.php?id="+str, true);
xmlhttp.send();
}
}
</script>
<div class="form-group">
<label for="pro_id" class="col-sm-2 control-label">Product name *</label>
<div class="col-sm-10">
<select name="pro_id" id="pro_id" class="form-control" onchange="findproduct_current(this.value)">
<option value="">
--Select--
</option>
<?php
$sqld=" select * from tb_product";
if(isset($_GET['pro_id']))
{
$pro_id=$_GET['pro_id'];
$sqld.=" where";
$sqld.=" pro_id='$pro_id'";
}
$resultd=$cls_con->select_base($sqld);
while($rowd=mysqli_fetch_array($resultd))
{
$pro_id=$rowd['pro_id'];
$pro_name=$rowd['pro_name'];
?>
<option value="<?=$pro_id;?>">
<?=$pro_name;?>
</option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label for="pro_no" class="col-sm-2 control-label">Product code</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="pro_no" id="pro_no" readonly placeholder="">
</div>
</div>
<div class="form-group">
<label for="pro_qtycurrent" class="col-sm-2 control-label">Current number</label>
<div class="col-sm-10">
<input readonly="readonly" class="form-control" name="pro_qtycurrent" id="pro_qtycurrent" placeholder="แสดงจำนวนปัจจุบัน">
</div>
</div>
<div class="form-group">
<label for="editpro_from" class="col-sm-2 control-label">Adjust amount</label>
<div class="col-sm-10">
<select name="editpro_from" id="editpro_from" class="form-control">
<option value="Adjust amount">Adjust amount</option>
</select>
</div>
</div>
<div class="form-group">
<label for="editpro_reason" class="col-sm-2 control-label">Note *</label>
<div class="col-sm-10">
<input type="readonly" class="form-control" name="editpro_reason" required="required" id="editpro_reason" placeholder="Note">
</div>
</div>
<div class="form-group">
<label for="editpro_qty" class="col-sm-2 control-label">Amount to adjust *</label>
<div class="col-sm-10">
<input class="form-control" name="editpro_qty" required="required" type="text" value="<?php echo @$_POST['editpro_qty'] ?>">
</div>
</div>
</div>
<!-- /.box-body -->
<center>
<button type="submit" name="submit" class="btn btn-info">Confirm</button>
<button type="reset" name="reset" class="btn btn-warning">Cancel</button>
</center>
</form>
<?php
if(isset($_POST['submit']))
{
$pro_id=$_POST['pro_id'];
$pro_qtycurrent=$_POST['pro_qtycurrent'];
$editpro_from=$_POST['editpro_from'];
$editpro_reason=$_POST['editpro_reason'];
$editpro_qty=$_POST['editpro_qty'];
$new_qty=$editpro_qty;
$sqlu=" update tb_product";
$sqlu.=" set";
$sqlu.=" pro_qty='$new_qty'";
$sqlu.=" where";
$sqlu.=" pro_id='$pro_id'";
$cls_con->write_base($sqlu);
$sql=" insert into tb_editproduct (pro_id,pro_qtycurrent,editpro_from,editpro_reason,editpro_qty,editpro_date)";
$sql.=" values ('$pro_id','$pro_qtycurrent','$editpro_from','$editpro_reason','$editpro_qty',now())";
if($cls_con->write_base($sql)==true){
echo $cls_con->show_message('Seccess');
echo $cls_con->goto_page(1,'show_editqty.php');
//echo $sql;
}
else{
echo $cls_con->show_message('Failed to save data');
}
}
?>
</section>
<!-- /.content -->
</div>
<!-- เนื้อหา -->
<?php include('footer.php'); ?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2021-06-08 17:48:17 |
By :
Vipada147 |
View :
484 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เพิ่มฟิลด์ status ใน tb_editproduct (หรือทำแยกตารางตามความเหมาะสม) เช่น
0 = waiting/pending
1 = approved
เมื่อหัวหน้าอนุมัติ update ฟิลด์ status เป็น 1 แล้วค่อย update tb_product
|
|
|
|
|
Date :
2021-06-08 23:21:04 |
By :
TheGreatGod_of_Death |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณพญามัจจุราช มากนะค่ะ ที่แนะนำการทำงานต่อค่ะ
|
|
|
|
|
Date :
2021-06-09 08:35:33 |
By :
Vipada147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|