<?php 
if(isset($_POST['batch_no'])){
        require_once('../../assets/config/config.php');
        $obj=new Database();
        $batch_no=$_POST['batch_no'];
        $id1=date("d-M-Y",strtotime($_POST['s_date']));
        $id2=date("d-M-Y",strtotime($_POST['e_date']));
        $id='';
        if($batch_no==''){
          $id="attendence_date BETWEEN '".$id1."' AND '".$id2."'";
        }
        else{
          $id="batch_no='".$batch_no."' and "."attendence_date BETWEEN '".$id1."' AND '".$id2."'";
        }

        $obj->select('students_attendence','*',null,$id,null,null);
        $result=$obj->getResult();
        $obj->select('organization','*',null," id=1",null,null);
        $result2=$obj->getResult();
        $GLOBALS['date_se']="Statement (".$id1." to ".$id2.")";
        $GLOBALS['org']=$result2[0]["organization"];
        $GLOBALS['batch_no']=$batch_no;
        if($batch_no==''){
          $batch_no='All batch';
        }
        require ("../../assets/fpdf/fpdf.php");

        //customer and invoice details
        $info=[

        
        ];
        class PDF extends FPDF
        {
          
          function Header(){
            
            //Display Company Info
            $this->SetFont('Arial','B',10);
            $this->Cell(50,10,$GLOBALS['org'],0,1);
            $this->SetFont('Arial','',9);
            $this->Cell(50,7,$GLOBALS['date_se'],0,1);
      
            
            //Display INVOICE text
            $this->SetY(15);
            $this->SetX(-60);
            $this->SetFont('Arial','B',14);
            $this->Cell(50,10,"Attendence History",0,1);
            
            //Display Horizontal line
            //$this->Line(0,48,210,48);
          }
          
          function body($info,$result){
            
          
            //Display Table headings
            $this->SetY(30);
            $this->SetX(10);
            $this->SetFont('Arial','B',8);
            $this->Cell(40,9,"Student Name",1,0,"L");
            $this->Cell(70,9,"Attendnce Date",1,0,"L");
            $this->Cell(40,9,"Time",1,0,"C");
            $this->Cell(40,9,"Status",1,1,"C");
            $this->SetFont('Arial','',7);
            $c=0;
            //Display table product rows
            foreach($result as $row){
              $this->Cell(40,9,$row["student_name"],"LR",0,"L");
              $this->Cell(70,9,$row["attendence_date"],"R",0,"L");
              $this->Cell(40,9,$row["attendence_time"],"R",0,"C");
              $this->Cell(40,9,$row["status"],"R",1,"C");
            
                $c=$c+1;
              }
        
            
          
            //Display table total row
            $this->SetFont('Arial','B',8);
            $this->Cell(110,9,"Batch No :   ".$GLOBALS['batch_no'],1,0,"C");
            $this->Cell(40,9,'Total',1,0,"C");
            $this->Cell(40,9,$c,1,1,"C");
            
            //Display amount in words

            
          }

        }
        //Create A4 Page with Portrait 
        $pdf=new PDF("P","mm","A4");
        $pdf->AddPage();
        $pdf->body($info,$result);
        $pdf->Output();
  }
?>