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

header('Content-Type: application/json');
$session = $_REQUEST['session'];
$school_id = $_REQUEST['school_id'];
$date = date("Y-m-d");


// $session = mysql_real_escape_string($session);
// $school_id = mysql_real_escape_string($school_id);

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

// $result = mysql_query($sqlatt);
// while ($rowc = mysql_fetch_assoc($result)) 
foreach($sqlatt as $rowc)
{

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


}

//$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, name,designation,experience,dob,mobile,photo from staff where session='$session' and  status=1 ");

// $result1 = mysql_query($sqlsec);
// while ($rowc = mysql_fetch_assoc($result1)) 
foreach($sqlsec as $rowc)
{
    $jsonc[] = array("idno" => $rowc['idno'], "name" => $rowc['name'], "fname" => "$rowc[fname]", "designation" => $rowc['designation'],
        "experience" => $rowc['experience'], "dob" => $rowc['dob'], "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);

}



////////////////////
$day = date('l', strtotime($date));
if ($day == 'Sunday') {
    $holidays = 'S';
} else {
    $holidays = 'H';
}


$holiday_array= array();
$sql_staff_holiday = $db->getRows("select * from staff_holiday where date='$date' and session='$session' and school_id= '$school_id'");
// $exe_qry = mysql_query($sql_staff_holiday);
// while ($row_data = mysql_fetch_assoc($exe_qry))
foreach($sql_staff_holiday as $row_data)
{
    $row_data['holiday'] = $holidays;
    array_push($holiday_array,$row_data);
}
$json['holiday'] =  $holiday_array;

echo json_encode($json);
?>