<?php
session_start();
ob_start();
require "../model/configuration.php";
 $stfid = $_GET['id'];
 $da=$_GET['date'];
 $date = date("Y-m-d",strtotime($_GET['date']));
 $mnyr=date("Y-m",strtotime($_GET['date']));
 $val=$_GET['val'];
$atqry=$db->execute("select * from staff_attendence where date='$date' and staffid='$stfid' and delet='0' ");
$attrow=$atqry->fetch_assoc();
if($atqry->num_rows > 0){
	if($val==1)
		{
		$db->execute("UPDATE staff_attendence set status= '1' where staffid='$stfid'and date='$date'");
		}
	else if($val==0)
		{
		$db->execute("UPDATE staff_attendence set status= '0' where staffid='$stfid'and date='$date'");
		}
}
else{
if($val==1)
{
$db->execute("INSERT INTO staff_attendence(staffid,date,mnthyear,status) VALUES('$stfid','$date','$mnyr','1')");
}
else if($val==0)
{
$db->execute("INSERT INTO staff_attendence(staffid,date,mnthyear,status) VALUES('$stfid','$date','$mnyr','0')");
}
}
header("location:../Pages/staff_attendance.php?date=$da");
?>