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

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

$date = $_REQUEST['date'];

// 	 $session=mysql_real_escape_string($session);

$sqlatt = $db->getRows("SELECT id,idno,status,period from attandenc where date='$date' and session='$session' and type='2'");

// 	$result = mysql_query($sqlatt);
//   while ($rowc = mysql_fetch_assoc($result)) 	
foreach ($sqlatt as $rowc) {
    $period_data = ($rowc[period] == "") ? array() : json_decode($rowc[period]);

    $jsonn[] = array("idno" => $rowc['idno'], "status" => $rowc['status'], "period" => $period_data, "id" => $rowc[id]);

}

//$arr=$db->getRows("select idno, admissionno,name,fname,fincome,class,section from student where session='$session' and  status=1  and issue_TC=0 order by name");


$sqlsec = $db->getRows("select idno, admissionno,name,fname,fincome,class,section,mobile,photo from student where session='$session' and  status=1  and issue_TC=0 order by name");

// 	$result1 = mysql_query($sqlsec);
//   while ($rowc = mysql_fetch_assoc($result1)) 	
foreach ($sqlsec as $rowc) {
    $jsonc[] = array("idno" => $rowc['idno'], "name" => $rowc['name'], "admissionno" => $rowc['admissionno'], "name" => $rowc['name'], "fname" => $rowc['fname'],
        "fincome" => $rowc['fincome'], "class" => $rowc['class'], "section" => $rowc['section'], "mobile" => $rowc['mobile'],
        "photo" => "$rowc[photo]");

    $json['status'] = 1;
    $json['msg'] = "Profile found Successfully..!";
    $json['data'] = array("student" => $jsonc, "att_date" => $date, "att_status" => $jsonn);

}


echo json_encode($json);
?>