<?php
include("common/connection.php");
	$update=$_REQUEST['par'];
    $tnaid=$_REQUEST['par1'];
	$day=$_REQUEST['addoff'];
	$fetch_location_employee_master=mysqli_fetch_array(mysqli_query($con,"select Office_Location_City from employee_master where SLN='".$tnaid."'"));
	$location_master=mysqli_fetch_array(mysqli_query($con,"select SLN from location_master where Location_Name='".$fetch_location_employee_master['Office_Location_City']."'"));
	$check_roster=mysqli_query($con,"select * from roster_master where Treatment_Service_Date='".$update."' and TNA_Name='".$tnaid."'");
	if(mysqli_num_rows($check_roster)=="0")
	{
 $sqloff=mysqli_query($con,"insert into roster_master (Offday,Treatment_Service_Date,TNA_Name,Control_Location) value ('".$day."','".$update."','".$tnaid."','".$location_master['SLN']."')");
	}
	else
	{
	$sql_update=mysqli_query($con,"update roster_master set Offday='".$day."',Active='0' where Treatment_Service_Date='".$update."' and TNA_Name='".$tnaid."'");	
	}
 $sql=mysqli_fetch_array(mysqli_query($con,"select * from roster_master where Treatment_Service_Date='".$update."' and TNA_Name='".$tnaid."'"));
 
 if($sql['Offday']=='1')
 {
 echo '1';
 }
 else if($sql['Offday']=='2')
 {
 echo '2';
 }
 else if($sql['Offday']=='3')
 {
 echo '3';
 }
 else if($sql['Offday']=='4')
 {
 echo '4';
 }
?>