<?php
if(isset($_POST['batch_no'])){
   require_once('../../assets/config/config.php');
   $obj=new Database();
   $time=date('d-M-Y H:i:s');
   $batch_no=$_POST['batch_no'];
   $student_id=$_POST['student_id'];
   $student_name=$_POST['student_name'];                              
   $s_date=date("d-M-Y",strtotime($_POST['s_date']));
   $status=$_POST['status'];   
   $checker=null;
   if(!attendence_checker($batch_no,$s_date))
   {
      $checker=$obj->insert('students_attendence',['attendence_time'=>$time,'student_id'=>$student_id,'student_name'=>$student_name,'batch_no'=>$batch_no,'attendence_date'=>$s_date,'status'=>$status]);   
   }
   echo $checker;
}
function attendence_checker($batch_no,$date)
{
   $obj=new Database();
   $id="batch_no='".$batch_no."' and attendence_date='".$date."'";
   $obj->select('students_attendence','*',null,$id,null,null);
   $result1=$obj->getResult(); 
   if($result1)
   {
      return true;
   } 
}
?>
