ESH/store_stock_update.php

42 lines
1.4 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
error_log ( "Start Printing Request Attributes" );
$requestStr="";
foreach ( $_REQUEST as $key => $value ) {
$requestStr.=$key . " : " . $value . "\n";
error_log ( $key . " : " . $value . "<br />\r\n" );
}
error_log ( "End Printing Request Attributes" );
save_log($requestStr,'Store Stock','SAVE','store_stock_update.php');
$itemId = $_POST['stock_item_id'];
//echo $itemId;
$stock_qty = $_POST['stock_qty'];
$item_batch_no = $_POST['item_batch_no'];
$exp_date = $_POST['exp_date'];
$check_item="select item_id from item_stock where item_id='".$itemId."' and item_batch_no='".$item_batch_no."'";
$check_items=mysqli_query($conn,$check_item);
$row_check =@mysqli_num_rows ( $check_items );
$query="";
if($row_check>0)
{
$query = "update item_stock set stock_qty = '$stock_qty',expiry_date='".$exp_date."' where item_id='".$itemId."' and item_batch_no = '$item_batch_no'";
}
else{
$query = "insert into item_stock set item_id = '$itemId', item_batch_no = '$item_batch_no' stock_qty = '$stock_qty',expiry_date='".$exp_date."'";
}
error_log("item_stock update query:".$query);
if (!$result = @mysqli_query($conn,$query)) {
error_log("Error saving Item store stock".mysqli_error($conn).". Error Query:".$query);
exit(mysqli_error($conn));
}