$sql="select a.*,date(a.start_date_time) as date from shift_status_details a where current_status='R' and ohc_location_id='".$_SESSION['current_ohcttype']."'";
$result=@mysqli_query($conn,$sql);
error_log(mysqli_num_rows($result));
if(!$row=@mysqli_fetch_assoc($result)){
error_log($sql);
}
$data='';
$shift_id=$_REQUEST['shift_id'];
$shift_id_new=$row['shift_id'];
$date=$row['record_date'];
error_log("form shift id ".$shift_id);
error_log("shift id new ".$shift_id_new);
error_log("datesafasf".$date);
// echo $procurement_refno;
begin();
if(mysqli_num_rows($result)!=0){
$query="update shift_status_details set end_date_time='".$formatted_date_time."',current_status='C',modified_by = '".$_SESSION['user_id']."' where current_status='R' and ohc_location_id='".$_SESSION['current_ohcttype']."' ";
$query="insert into shift_status_details set record_date='".$formatted_date_time."',shift_id='".$shift_id."',start_date_time='".$formatted_date_time."',current_status='R',ohc_location_id='".$_SESSION['current_ohcttype']."',modified_by = '".$_SESSION['user_id']."' ";
$data=1;
error_log("query:".$query);
}
if(!$result=@mysqli_query($conn,$query)){
error_log("Failed to save Shift Status:".mysqli_error($conn).". Failed query:".$query);