<?php
if(isset($_POST['s_date'])){
   require_once('../../assets/config/config.php');
   $obj=new Database();
   $b=[];   
   if($_POST['s_date']=='month')
   {
   
      $date=date("M-Y",strtotime($_POST['date']));
      $id="batch_no='".$_POST['id']."' and attendence_date like '%".$date."'";
      $obj->select('students_attendence','*',null,$id,null,null);
      $result=$obj->getResult();                              
      foreach($result as $row)
      {   
      
         array_push($b,$row);                
      }
   }
   if($_POST['s_date']=='report')
   {
   
      $date1=date("d-M-Y",strtotime($_POST['date1']));
      $date2=date("d-M-Y",strtotime($_POST['date2']));

      $id='';
      if($_POST['batch_no']=='')
      {
         $id="attendence_date between '".$date1."' and '".$date2."'";
      }
      else
      {
         $id="batch_no='".$_POST['batch_no']."' and attendence_date between '".$date1."' and '".$date2."'";
      }
      
      $obj->select('students_attendence','*',null,$id,'id DESC',null);
      $result=$obj->getResult();                              
      foreach($result as $row)
      {   
      
         array_push($b,$row);                
      }
   }
   if($_POST['s_date']=='reportIn')
   {
   
      $date1=date("d-M-Y",strtotime($_POST['date1']));
      $date2=date("d-M-Y",strtotime($_POST['date2']));
      $id='';
      if($_POST['type']=='')
      {
         $id="date between '".$date1."' and '".$date2."'";
      }
      else
      {
         $id="particular='".$_POST['type']."' and date between '".$date1."' and '".$date2."'";
      }
   
      $obj->select('inventory','*',null,$id,'id DESC',null);
      $result=$obj->getResult();                              
      foreach($result as $row)
      {   
      
         array_push($b,$row);                
      }
   }
   if($_POST['s_date']=='reportFee')
   {
   
      $date1=date("d-M-Y",strtotime($_POST['date1']));
      $date2=date("d-M-Y",strtotime($_POST['date2']));

      $id='';
      if($_POST['batch_no']=='')
      {
         $id="payment_date between '".$date1."' and '".$date2."'";
      }
      else
      {
         $id="batch_no='".$_POST['batch_no']."' and payment_date between '".$date1."' and '".$date2."'";
      }
      
      $obj->select('students_fee','*',null,$id,'id DESC',null);
      $result=$obj->getResult();                              
      foreach($result as $row)
      {   
      
         array_push($b,$row);                
      }
   }
         
         header('Content-type:application/json');
         echo json_encode($b);
   }


?>