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

    header('Content-Type: application/json');

    $class = $_POST['class'];
    $session = $_POST['session'];


    $noticeArray = array();
	$allSubject = $db->getRows("select * from student_notice where class='$class' and type='2' and session='$session' ORDER BY id DESC LIMIT 5");
    if(count($allSubject) > 0){
        $status = 1;

    	foreach($allSubject as $subject){
                array_push($noticeArray,["id"=>"$subject[id]","class"=>"$subject[class]","notice"=>"$subject[notice_detail]","date"=>"$subject[date]","image"=>"$_SERVER[HTTP_HOST]/uploads/notice/$subject[upload_notice]" ]);
    	}

    }
    
    $homeworkArray = array();
	$allSubject = $db->getRows("select * from assignment where class='$class'  and session='$session' ORDER BY id DESC LIMIT 5");
    if(count($allSubject) > 0){
        $status = 1;
    	foreach($allSubject as $subject){
                array_push($homeworkArray,["id"=>"$subject[id]","detail"=>"$subject[detail]","date"=>"$subject[date]","image"=>"$_SERVER[HTTP_HOST]/uploads/assignment/$subject[upload_assignment]" ]);
    	}
    }


    $result=$db->getRows("select * from cms_slidess ");
	if($result)
	{
	    foreach ($result as $rowc) 
	{
    	$slider[]=array("id"=>$rowc['id'],"slider"=>"$_SERVER[HTTP_HOST]/uploads/assignment/".$rowc['image']);
	  
        //$json['status']=1;
		
	}  
	} 
   
   
   
    $result=$db->getRows("select * from staff where status='1' and photo IS NOT NULL");
	
	if($result)
	{
	    foreach ($result as $rows) 
	{
    	$staff[]=array("id"=>$rows['idno'],"name"=>$rows['name'],"designation"=>$rows['designation'],"photo"=>"$_SERVER[HTTP_HOST]/media/photo/".$rows['photo']);
	  
        //$json['status']=1;
		
	}  
	} 
   
      
      
      $result=$db->getRows("select * from cms_topper ");
	
	if($result)
	{
	    foreach ($result as $rowt) 
	{
    	$topper[]=array("name"=>$rowt['name'],"detail"=>$rowt['detail'],"photo"=>"$_SERVER[HTTP_HOST]/uploads/content/".$rowt['image']);
	  
        //$json['status']=1;
		
	}  
	}   
	
	
	
	
	 $result=$db->getRows("select * from cms_blog ");
	
	if($result)
	{
	    foreach ($result as $rowt) 
	{
    	$blog[]=array("detail"=>$rowt['detail'],"photo"=>"$_SERVER[HTTP_HOST]/uploads/content/".$rowt['image']);
	  
        //$json['status']=1;
		
	}  
	}   
 
	 $result=$db->getRows("select * from cms_news ");
	
	if($result)
	{
	    foreach ($result as $rowc) 
	{
    	$jsonc[]=array("id"=>$rowc['id'],"news"=>$rowc['news']);
	}
	
	}

	$json['data']=$jsonc;
	$json['slider']=$slider;
	$json['staff']=$staff;
	$json['topper']=$topper;
	$json['blog']=$blog;
	$json['notice']=$noticeArray;
	$json['homework']=$homeworkArray;

	echo json_encode($json);
	

?>