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

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

$session=$_REQUEST['session'];

// 	$session=mysql_real_escape_string($session);
$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."'");

//echo $ss="SELECT class  FROM student where school_id='1' and session='$session'  and dob  like'".$newDate."' or dob  like'".$pdate."'  group  by class ";
$arydate=$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");

$jsonp=array();
$i=0;
foreach($arydate as $cls){$i++;

    $s=$cls['date'];
    $a=array("date"=>$cls['date']);
    $b=array();

    $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='".$cls['date']."' ORDER BY id DESC");

    //	echo $ss="SELECT * FROM student_notice where school_id='".$school_id."' and type='2' and session='".$session."' and (class='".$class."' OR class='') and date='".$class['date']."'";




    // 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($aryList1 as $sub){
        $type=$db->getval("select notice_type from notice where id=".$sub['notice_type']);

        $noticeFile = $sub['upload_notice'];

        /*$fileFullPath = "";
        if (!($noticeFile == "NA" || $noticeFile == "N/A")){
            $fileFullPath = URL_ROOT."uploads/notice/".$noticeFile;
        }*/

        $fileArray = array();
        if ($noticeFile == "N/A" || $noticeFile == "NA" || $noticeFile == '' || $noticeFile == null){

        }else{
            $files = explode(",", $noticeFile);
            foreach ($files as $names){
                $fileArray[] = URL_ROOT."uploads/notice/".$names;
            }
        }

        array_push($b,array("notice_head"=>$type,"notice_detail"=>$sub['notice_detail'],"photo"=>$fileArray));

    }

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

}

$json['status']=1;
$json['msg']="Profile found Successfully..!";
$json['data']=$jsonp;

echo json_encode($json);
?>
