94 lines
3.4 KiB
PHP
94 lines
3.4 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/auth/auth.php');
|
|
include('includes/functions.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
?>
|
|
<?php
|
|
// Connect to mysqli database
|
|
|
|
$page = 1; // The current page
|
|
$sortname = 'user_name'; // 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']);
|
|
}
|
|
if (!isset($_POST['rp'])) {
|
|
$rp=10;
|
|
}
|
|
// 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 tbl_users a left join role_master b on a.role_id=b.role_id left join patient_master e on a.emp_id=e.id $searchSql";
|
|
|
|
$result = mysqli_query($conn,$sql);
|
|
$rowCount = mysqli_fetch_array($result);
|
|
$total = $rowCount[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_list = "SELECT a.user_name,a.status, a.email, a.user_id, a.role_id, a.role_id, a.emp_id, e.emp_code, patient_name, a.remarks,a.ohc_type, a.vendor_id FROM tbl_users a left join role_master b on a.role_id=b.role_id left join patient_master e on a.emp_id=e.id $searchSql $sortSql $limitSql";
|
|
$resultList = mysqli_query($conn,$sql_list);
|
|
$count=1;
|
|
while ($row = mysqli_fetch_assoc($resultList)) {
|
|
|
|
$user_id_val=$row['user_id'];
|
|
$status_val=$row['status'];
|
|
|
|
$view_link="<a href=\"#\"class=\"grey\" onclick=\"open_user('".$user_id_val."','V');\"><i class=\"ace-icon fa fa-eye bigger-130\"></i></a>";
|
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_user('".$user_id_val."','E');\"><i class=\"ace-icon fa fa-edit bigger-130\"></i></a>";
|
|
$activate_link="<a href=\"#\" class=\"red\" onclick=\"delete_user('".$user_id_val."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
|
|
if($_SESSION['RoleId']!=1)
|
|
{
|
|
//$activate_link=" ";
|
|
//$edit_link=" ";
|
|
}
|
|
|
|
if($status_val=='1'){
|
|
$status="Active";
|
|
}else{
|
|
$status="Inactive";
|
|
}
|
|
|
|
$email =$row['email'];
|
|
$space=" ";
|
|
$links = $assign_link.$space.$view_link.$space.$edit_link.$space.$activate_link;
|
|
$ohc_type_names=getCommaSeperatedValuesForInClause("select ohc_type_name from ohc_type","ohc_type_id",$row['ohc_type']);
|
|
$role_names=getCommaSeperatedValuesForInClause("select role_name from role_master","role_id",$row['role_id']);
|
|
$vendor_names=getTableFieldValue("employer_contractor",'employer_contractor_name',"id",$row['vendor_id']);
|
|
|
|
$data['rows'][] = array(
|
|
'id' => $row['id'],
|
|
'cell' => array($count++, $user_id_val, $row['user_name'],$row['patient_name'],$row['emp_code'], $email,$role_names,$ohc_type_names, $status,
|
|
// $vendor_names,
|
|
$links)
|
|
);
|
|
}
|
|
echo json_encode($data);
|
|
?>
|