<?php
include("../../db.php");
header('Content-Type: application/json');

$status = 0;
$msg = "Unable to fetch data..! Please retry later";
$data = array();

$result = $db->getRows("SELECT id,name,detail,status FROM tbl_roll where school_id='1'  ORDER BY name,id ASC");

if ($result) {
    $status = 1;

    foreach ($result as $row) {

        $make_dis_status  = $db->getVal("SELECT a FROM tbl_privilages WHERE roll_id = '$row[id]' AND page_name = 'MakeDiscount' ");
        $reset_dis_status = $db->getVal("SELECT a FROM tbl_privilages WHERE roll_id = '$row[id]' AND page_name = 'ResetDiscount' ");

        if (!$make_dis_status)  $make_dis_status  = 0;
        if (!$reset_dis_status) $reset_dis_status = 0;

        $row['make_discount_status']  = $make_dis_status;
        $row['reset_discount_status'] = $reset_dis_status;

        $data[] = $row;
    }

    $msg = "Record found";
} else {
    $msg = "Record not found";
}

echo json_encode(array("status" => $status, "data" => $data, "msg" => $msg));

