<?php 
include ('common/connection.php');
$emp_cont=$_REQUEST['emp_mobile'];
$app_cl=$_REQUEST['Approved_CL'];
$app_pl=$_REQUEST['Approved_PL'];
$admmin=$_REQUEST['adm_msg'];
$stdate=$_REQUEST['leave_start'];
$enddate=$_REQUEST['leave_end'];
$fetch_emp_master=mysqli_fetch_array(mysqli_query($con,"select * from employee_master where Mobile='".$emp_cont."'"));
$fetch_roster=mysqli_fetch_array(mysqli_query($con,"select * from roster_master where TNA_Name='".$fetch_emp_master['SLN']."'"));
if($app_cl!="")
{
$balcl=$fetch_emp_master['Available_CL']-$app_cl;
}
else
{
$balcl=$fetch_emp_master['Available_CL'];	
}
if($app_pl!="")
{
$balpl=$fetch_emp_master['Available_PL']-$app_cl;
}
else
{
$balpl=$fetch_emp_master['Available_PL'];	
}
$update_emp_master=mysqli_query($con,"update employee_master set Available_CL='".$balcl."',Available_PL='".$balpl."' where SLN='".$fetch_emp_master['SLN']."'");
for($a=$stdate;$a<=$enddate;$a++)
{
if($fetch_roster['TNA_Name']!="" && $fetch_roster['Treatment_Service_Date']!="")
{	
$update_roster=mysqli_query($con,"update roster_master set Treatment_Service_Date='".$a."',Offday='2' where TNA_Name='".$fetch_emp_master['SLN']."'");
}
else
{
$insert_roster=mysqli_query($con,"insert into roster_master (Treatment_Service_Date,Offday)values('".$a."','".$fetch_emp_master['SLN']."')");	
}
}
?>