<?php
include ('common/connection.php');
$fetch_sql=mysqli_query($con,"select * from roster_master where Treatment_Service_Date='".date('Y-m-d',strtotime('-1 day'))."' and `Visited_By`!='' and `Total_Duty_Hours`=''");
while($fetch_attout=mysqli_fetch_array($fetch_sql))
{
$intime=$fetch_attout['Visiting_Time_From'];	
$fetch_attout['Duty_Hour_Start_Time'];
$roster_end=$fetch_attout['To_Time'];
$diff=$intime-$fetch_attout['Duty_Hour_Start_Time'];
$actual_hr=$roster_end-$intime;
$billed_hr=$roster_end-$fetch_attout['Visiting_Time_From'];
if(date('H:i:s')>$roster_end)
{
if($diff>1)
{
echo $update_attdnce_plannedhr="update roster_master set Visiting_Time_to='".$fetch_attout['To_Time']."',Total_Duty_Hours='".$actual_hr."',Planned_Hours_Count='".$actual_hr."' where Treatment_Service_Date='".date('Y-m-d',strtotime('-1 day'))."' and `Visited_By`!='' and `Total_Duty_Hours`=''";
}
else
{
echo $update_attdnce_plannedhr="update roster_master set Visiting_Time_to='".$fetch_attout['To_Time']."',Total_Duty_Hours='".$billed_hr."',Planned_Hours_Count='".$billed_hr."' where Treatment_Service_Date='".date('Y-m-d',strtotime('-1 day'))."' and `Visited_By`!='' and `Total_Duty_Hours`=''";	
}
}
?>
<script>
window.location.href="daily-operational-report.php";
</script>
<?php	
}
?>