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

	$idno=$_REQUEST['idno'];
	$session=$_REQUEST['session'];
	$school_id=$_REQUEST['school_id'];
	$idno=mysql_real_escape_string($idno);
	$session=mysql_real_escape_string($session);
	$school_id=mysql_real_escape_string($school_id);
	
  $class=$db->getVal("Select class FROM student where idno='".$idno."'");
$aryList=$db->getRows("SELECT date FROM student_notice where school_id='".$school_id."' and type='2' and session='".$session."' and (class='".$class."' OR class='') group by date");
//print_r($aryList);
//////////////Fetching values from array ///////
	
	$i=0;$data=array();$notice=array();$same_date="";
	
foreach($aryList as $list1){
		
		$j=0;
		
	if($list1["date"]!=$same_date){ $i++;
		
		
		
		$dat=date("d-m-Y",strtotime($list1["date"]));
		//$data[$i][]=$dat;
		
		$same_date=$list1["date"];
		
		$aryList1=$db->getRows("SELECT * FROM student_notice where school_id='".$school_id."' and type='2' and session='".$session."' and (class='".$class."' OR class='') and date='".$list1["date"]."'");
		
	foreach($aryList1 as $list){
			
		$type=$db->getval("select notice_type from notice where id=".$list['notice_type']);
		
		
		$notice[$j]["notice_head"]=$type;
		
		$notice[$j]["notice_detail"]=$list["notice_detail"];
		
		if($list["upload_notice"]!='')	$notice[$j]["file"]=URL_ROOT."uploads/notice/".$list['upload_notice'];
		else 	
			$notice[$j]["file"]=NULL;
$j++;
	}
	$data[$dat]=$notice;
	}
}
	
	if(is_array($aryList) && count($aryList)>0)
	{  
		echo json_encode(array('status' => 1, 'msg'=>'Notice found Successfully..!', "data"=>$data));    
			
	}else
	{		
	 	echo json_encode(array('status' => 0, 'msg'=>'No Notice Found..!'));
	}
