97 lines
3.5 KiB
PHP
97 lines
3.5 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/auth/auth.php');
|
|
include('includes/functions.php');include('access.php');
|
|
?>
|
|
<?php
|
|
|
|
// Connect to mysqli database
|
|
|
|
$page = 1; // The current page
|
|
$sortname = 'role_id'; // Sort column
|
|
$sortorder = 'asc'; // Sort order
|
|
$qtype = ''; // Search column
|
|
$query = ''; // Search string
|
|
// Get posted data
|
|
if (isset($_POST['page'])) {
|
|
$page = mysqli_real_escape_string($conn,$_POST['page']);
|
|
}
|
|
if (isset($_POST['sortname'])) {
|
|
$sortname = mysqli_real_escape_string($conn,$_POST['sortname']);
|
|
}
|
|
if (isset($_POST['sortorder'])) {
|
|
$sortorder = mysqli_real_escape_string($conn,$_POST['sortorder']);
|
|
}
|
|
if (isset($_POST['qtype'])) {
|
|
$qtype = mysqli_real_escape_string($conn,$_POST['qtype']);
|
|
}
|
|
if (isset($_POST['query'])) {
|
|
$query = mysqli_real_escape_string($conn,$_POST['query']);
|
|
}
|
|
if (isset($_POST['rp'])) {
|
|
$rp = mysqli_real_escape_string($conn,$_POST['rp']);
|
|
}
|
|
// Setup sort and search SQL using posted data
|
|
$sortSql = "order by $sortname $sortorder";
|
|
$searchSql = ($qtype != '' && $query != '') ? "where $qtype = '$query'" : '';
|
|
// Get total count of records
|
|
$sql = "select count(*)from role_master $searchSql";
|
|
$result = mysqli_query($conn,$sql);
|
|
$row = mysqli_fetch_array($result);
|
|
$total = $row[0];
|
|
// Setup paging SQL
|
|
$pageStart = ($page-1)*$rp;
|
|
$limitSql = "limit $pageStart, $rp";
|
|
// Return JSON data
|
|
$data = array();
|
|
$data['page'] = $page;
|
|
$data['total'] = $total;
|
|
$data['rows'] = array();
|
|
$sql = "select role_id, role_name, role_code, role_description, role_home_page,icon_color,icon_text
|
|
from role_master $searchSql $sortSql $limitSql";
|
|
$results = mysqli_query($conn,$sql);
|
|
$count=1;
|
|
while ($row = mysqli_fetch_assoc($results)) {
|
|
|
|
$role_id_val=$row['role_id'];
|
|
|
|
if($access_level=='R' ||$access_level=='W' || $access_level=='E' )
|
|
{
|
|
$view_link="<a href=\"#\"class=\"grey\" onclick=\"open_role('".$role_id_val."','V');\"><i class=\"ace-icon fa fa-eye bigger-130\"></i></a>";
|
|
}
|
|
$assign_link="<a href=\"#\"class=\"green\" onclick=\"window.open('assign_menu.php?Role_id=$role_id_val','mywindow','menubar=0,resizable=0,status=0,scrollbars=1,width=650,height=500,top=50,left=50')\"><i class=\"glyphicon glyphicon-paperclip\"></i></a> ";
|
|
|
|
$assign_report_link="<a href=\"#\"class=\"green\" onclick=\"window.open('assign_report_master.php?Role_id=$role_id_val','mywindow','menubar=0,resizable=0,status=0,scrollbars=1,width=650,height=500,top=50,left=50')\"><i class=\"glyphicon glyphicon-flash\"></i></a> ";
|
|
|
|
|
|
|
|
if($access_level=='W' || $access_level=='E' )
|
|
{
|
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_role('".$role_id_val."','E');\"><i class=\"ace-icon fa fa-edit bigger-130\"></i></a>";
|
|
}
|
|
|
|
|
|
$delete_link="<a href=\"#\" class=\"red\" onclick=\"delete_role('".$role_id_val."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
|
|
|
|
$sql_check_child=" SELECT count(*) FROM assign_menu where role_id = '".$role_id_val."'";
|
|
$res_check_child=@mysqli_query($conn,$sql_check_child);
|
|
|
|
$check_child_row = mysqli_fetch_array($res_check_child);
|
|
$num=$check_child_row[0];
|
|
|
|
// if($role_id_val==2 || $num>0)
|
|
// {
|
|
// $delete_link=" ";
|
|
// }
|
|
$space=" ";
|
|
$links = $assign_link.$space.$assign_report_link.$space.$view_link.$space.$edit_link.$space.$delete_link;
|
|
//$links="<div class=\"hidden-sm hidden-xs btn-group\">".$links."</div>";
|
|
|
|
$data['rows'][] = array(
|
|
'id' => $row['id'],
|
|
'cell' => array($count++, $row['role_id'], $row['role_name'], $row['role_code'],$row['role_description'],$row['role_home_page'],$row['icon_color'],$row['icon_text'],$links)
|
|
);
|
|
}
|
|
echo json_encode($data);
|
|
?>
|