50 lines
2.1 KiB
PHP
50 lines
2.1 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
$query="";
|
||
|
if(!empty($_REQUEST['flex_appointment_id'])){
|
||
|
//echo $query = " delete from employee_appointment where appointment_id = '".$_REQUEST['flex_appointment_id']."'";
|
||
|
$query = "DELETE FROM employee_appointment,treatment USING employee_appointment left JOIN treatment on (employee_appointment.appointment_id = treatment.appointment_id) WHERE employee_appointment.appointment_id= '".$_REQUEST['flex_appointment_id']."'";
|
||
|
|
||
|
//$query = "DELETE FROM employee_appointment,treatment USING employee_appointment INNER JOIN treatment on (employee_appointment.appointment_id = treatment.appointment_id) WHERE employee_appointment.appointment_id= '".$_REQUEST['flex_appointment_id']."'";
|
||
|
// echo $query;
|
||
|
|
||
|
|
||
|
$query_appointment="select * from appointment_stock_history where appointment_id='".$_REQUEST['flex_appointment_id']."' ";
|
||
|
//echo $query_appointment;
|
||
|
$result_stock = @mysqli_query($conn,$query_appointment);
|
||
|
while($row_stock=@mysqli_fetch_array($result_stock)){
|
||
|
$issued_qty=$row_stock['issued_qty'];
|
||
|
//echo "iss".$issued_qty;
|
||
|
$current_stock_level=0;
|
||
|
$select_query="select * from tbl_items where item_id='".$row_stock['item_id']."' ";
|
||
|
//echo $select_query;
|
||
|
$select_result = @mysqli_query($conn,$select_query);
|
||
|
|
||
|
while($row_select=@mysqli_fetch_array($select_result)){
|
||
|
$current_stock_level=$row_select['current_stock_level'];
|
||
|
// echo "cuu".$row_select['current_stock_level'];
|
||
|
}
|
||
|
|
||
|
|
||
|
$current_stock_qty=$current_stock_level+$issued_qty;
|
||
|
// echo "current_stock_qty".$current_stock_qty;
|
||
|
$query_stock = "update tbl_items SET current_stock_level='".$current_stock_qty."' where item_id='".$row_stock['item_id']."' ";
|
||
|
@mysqli_query($conn,$query_stock);
|
||
|
}
|
||
|
|
||
|
|
||
|
$query1="DELETE from appointment_stock_history where appointment_stock_history.appointment_id='".$_REQUEST['flex_appointment_id']."' ";
|
||
|
$result = @mysqli_query($conn,$query);
|
||
|
$result1 = @mysqli_query($conn,$query1);
|
||
|
|
||
|
if (!$result&&!$result1) {
|
||
|
|
||
|
exit(mysqli_error($conn));
|
||
|
echo json_encode("FAILURE");
|
||
|
}else{
|
||
|
echo json_encode("SUCCESS");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|