<?php
include("../../db.php");
//header("Access-Control-Allow-Origin: * ");

header('Content-Type: application/json');
         
   	    $session=$_REQUEST['session'];
	 
	   //$session=mysql_real_escape_string($session);
	 
	

           $sdate=date("Y-m-d");
           $newDate = date("%-m-d", strtotime($sdate));	 

           $pdate=date('%-m-d', strtotime("+1 day", strtotime($sdate)));
           $ndate=date('%-m-d', strtotime("+2 day", strtotime($sdate)));

           $t=date('t');
           $d=date('d');
           $m=date("m");
          $lastdate="%-".$m."-".$t;
  

				
         $student_class=$db->getRows("SELECT class  FROM class where school_id='1'");
        
        //echo $ss="SELECT class  FROM student where school_id='1' and session='$session'  and dob  like'".$newDate."' or dob  like'".$pdate."'  group  by class ";

         $jsonp=array();
         $i=0;
   foreach($student_class as $class){$i++;


         $a=array("class"=>$class['class']);
         $b=array();

    for($ii=$d;$ii<=$t;$ii++)
				{
		 $ip=str_pad($ii, 2, "0", STR_PAD_LEFT);	    
	$ddmmyy="%-".$m."-".$ip;
	
          $allstudent=$db->getRows("SELECT *  FROM student where school_id='1' and session='$session'  and dob like'".$ddmmyy."' and class='".$class['class']."'");
          
         // echo $ss="SELECT *  FROM student where school_id='1' and session='$session'  and dob like'".$ddmmyy."' and class='".$class['class']."'";

        // $allstudent=$db->getRows("SELECT *  FROM student where school_id='1' and session='$session'  and (dob like'".$newDate."' or dob like'".$pdate."' or dob like'".$ndate."' )   and class='".$class['class']."' ");
         
         foreach($allstudent as $sub){
    
        array_push($b,array("name"=>$sub['name'],"bday"=>$sub['dob'],"section"=>$sub['section'],"photo"=>"media/photo/".$sub['photo']));

         }
				}
       if(count($b)>0){
  	 $a["students"]=$b;
     array_push($jsonp,$a);
      }

      }

       $json['status']=1;
		$json['msg']="Profile found Successfully..!";
		$json['data']=$jsonp;		
	
    echo json_encode($json);
?>
