2024-10-16 19:18:52 +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 , 'Procurement' , 'DELETE' , 'delete_procurement.php' );
$query1 = " " ;
$query2 = " " ;
if ( ! empty ( $_REQUEST [ 'flex_procurement_id' ])){
$current_stock_level_procurement_items_query = " select item_id,qty from procurement_items where procurement_id=' " . $_REQUEST [ 'flex_procurement_id' ] . " ' " ;
$results_procuerment_items = mysqli_query ( $conn , $current_stock_level_procurement_items_query );
//echo $current_stock_level_procurement_items_query;
while ( $rows_procurement_items = mysqli_fetch_assoc ( $results_procuerment_items )){
$current_stock_level_items_qty = getTableFieldValue ( 'tbl_items' , 'current_stock_level' , 'item_id' , $rows_procurement_items [ 'item_id' ]);
$current_stock_level_items_qty = $current_stock_level_items_qty - $rows_procurement_items [ 'qty' ];
//echo current_stock_level_items_qty;
$current_stock_query = " update tbl_items set current_stock_level=' " . $current_stock_level_items_qty . " ' where item_id=' " . $rows_procurement_items [ 'item_id' ] . " ' " ;
// echo $current_stock_query;
mysqli_query ( $conn , $current_stock_query );
}
$query1 = " delete from procurement where procurement_id = ' " . $_REQUEST [ 'flex_procurement_id' ] . " ' " ;
$query2 = " delete from procurement_items where procurement_id = ' " . $_REQUEST [ 'flex_procurement_id' ] . " ' " ;
//echo $query1;
if ( ! $result = @ mysqli_query ( $conn , $query1 ) and ! $result1 = @ mysqli_query ( $conn , $query2 )) {
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
echo json_encode ( " FAILURE " );
}
else
{
echo json_encode ( " SUCCESS " );
}
}
?>