43 lines
1.7 KiB
PHP
43 lines
1.7 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/functions.php');
|
||
|
|
||
|
if(!empty($stock_expiry_history_id)){
|
||
|
$sql_expiry_items="update stock_expiry_history set expiry_qty='".$item_qty."' where stock_expiry_hist_id='".$stock_expiry_history_id."'";
|
||
|
$old_expiry_qty=getTableFieldValue('stock_expiry_history','expiry_qty','stock_expiry_hist_id',$stock_expiry_history_id);
|
||
|
$data="update";
|
||
|
}else{
|
||
|
|
||
|
$data="save";
|
||
|
$procurement_id = $_POST['procurement_id'];
|
||
|
$item_id=$_POST['item_id'];
|
||
|
$sql_expiry_items="insert into stock_expiry_history set procurement_id='".$procurement_id."' ,item_id='".$item_id."',expiry_qty='".$item_qty."',batch='".$batch."' ,expiry=STR_TO_DATE('".$expiry_date."','%d/%m/%Y'), modified_by = '".$_SESSION['user_id']."'";
|
||
|
}
|
||
|
//echo $sql_expiry_items;
|
||
|
if (!$result = @mysqli_query($conn,$sql_expiry_items)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
else{
|
||
|
$current_stock_level= getTableFieldValue('tbl_items','current_stock_level','item_id',$item_id);
|
||
|
// echo $current_stock_level;
|
||
|
if(!empty($stock_expiry_history_id)){
|
||
|
|
||
|
//echo "old_expiry_qty ".$old_expiry_qty;
|
||
|
//echo "item_qty ".$item_qty;
|
||
|
$item_qty=$item_qty-$old_expiry_qty;
|
||
|
//echo $item_qty;
|
||
|
}
|
||
|
$current_stock_level=$current_stock_level-$item_qty;
|
||
|
$current_stock_query="update tbl_items set current_stock_level='".$current_stock_level."' where item_id='".$item_id."' ";
|
||
|
//echo $current_stock_query;
|
||
|
$result1=mysqli_query($conn,$current_stock_query);
|
||
|
// procurement_items
|
||
|
if(empty($stock_expiry_history_id)){
|
||
|
$sql_procurement_items="update procurement_items set isExpired='1' where item_id='".$item_id."' and procurement_id='".$procurement_id."' ";
|
||
|
$result2=mysqli_query($conn,$sql_procurement_items);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
echo json_encode($data);
|
||
|
?>
|