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

$id = $_REQUEST['staff_id'];
$session = $_REQUEST['session'];

// 	$staff_id=mysql_real_escape_string($id);
// 	$session=mysql_real_escape_string($session);

$arrayData = array();

if (isset($_GET[staff_id]) && isset($_GET[session])) {
    $staffRole = $db->getVal("select role_id from staff where idno=$id and session='$session' ");
// echo "select role_id from staff where idno=$id and session='$session' ";
// print_r($staffRole);
    if ($staffRole > 0) {
        $assignedRoles = $db->getRows("SELECT * from staff_privilages where role_id=$staffRole and a=1 and school_id=1 ");
        if (is_array($assignedRoles) && count($assignedRoles) > 0) {

            foreach ($assignedRoles as $roles) {
                array_push($arrayData, $roles[page_name]);
            }

        }


        $staffStatus = $db->getVal("select status from staff where idno=$id and session='$session' ");

//get app color
        $app_color = $db->getVal("select app_theme_color from tbl_info where id='1'");

        $teacher_att_period = $db->getVal("select teacher_attendance_period from tbl_info where id='1'");

        $meet_account = $db->getRow("select * from meet_account where teacher_id='$id' ");

        $online_study_server = $db->getVal("select online_study_server from tbl_info where id='1'");

        $school_location = $db->getVal("select school_location from tbl_info where id='1'");

        $loc_arr = explode(',', $school_location);

        $loc_radius = 1150;

        $face_att_system = $db->getVal("select face_att_system from tbl_info where id='1'");

        $school_message = $db->getVal("select value from settings where field='extra_footer'");

        echo json_encode(array('status' => 1, 'data' => $arrayData, 'app_theme_color' => $app_color, 'sdk_key' => $meet_account['sdk_key'],
            'sdk_secret' => $meet_account['sdk_secret'], 'mail' => $meet_account['mail'], 'pass' => $meet_account['pass'],
            "teacher_attendance_period" => $teacher_att_period, 'online_study_server' => $online_study_server,
            'school_loc_lat' => $loc_arr[0], 'school_loc_lng' => $loc_arr[1], "loc_radius" => $loc_radius, 'staff_status' => $staffStatus, 'school_message' => $school_message,
            'face_att_system' => $face_att_system));

    } else {
        echo json_encode(array('status' => 0, 'data' => 'No data Found..!'));
    }

}