104 lines
4.0 KiB
PHP
104 lines
4.0 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 = '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']);
|
|
}
|
|
if (!isset($_POST['rp'])) {
|
|
$rp=10;
|
|
}
|
|
// Setup sort and search SQL using posted data
|
|
$hasReadAccess = isAccessible($_SESSION['RoleId'],$menu_key,'R');
|
|
$hasWriteAccess = isAccessible($_SESSION['RoleId'],$menu_key,'W');
|
|
$hasExecuteAccess = isAccessible($_SESSION['RoleId'],$menu_key,'E');
|
|
|
|
$sortSql = " order by $sortname $sortorder";
|
|
$searchSql = ($qtype != '' && $query != '') ? " where $qtype = '$query'" : '';
|
|
// Get total count of records
|
|
$sql_guest_count = "SELECT count(*) FROM guest_patient $searchSql ";
|
|
|
|
$result_guest_count = mysqli_query($conn,$sql_guest_count);
|
|
$rowCount_guest_count = mysqli_fetch_array($result_guest_count);
|
|
$total = $rowCount_guest_count[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 id, fname, lname,father_name,gender,email_id, primary_phone, blood_group,associated_emp_id as emp_id,address,emp_relationship_type,aadhar_no,age FROM guest_patient";
|
|
//echo $sql_list;
|
|
|
|
$sql_export=$sql_list." $searchSql $sortSql";
|
|
$sql_list = $sql_list." $searchSql $sortSql $limitSql";
|
|
$resultList = mysqli_query($conn,$sql_list);
|
|
$count=($page-1)*$rp+1;
|
|
while ($row = mysqli_fetch_assoc($resultList)) {
|
|
|
|
$id=$row['id'];
|
|
|
|
$view_link="<a href=\"#\"class=\"green\" onclick=\"open_guest('".$id."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
|
|
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_guest('".$id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
|
|
//$activate_link="<a href=\"#\" class=\"blue\" onclick=\"delete_employee('".$user_id_val."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
|
|
$opd_link="<a href=\"#\" class=\"green\" onclick=\"guest_opd_form('".$id."');\"><i class=\"ace-icon fa fa-ambulance bigger-130\"></i></a>";
|
|
|
|
$injury_link="<a href=\"#\" class=\"red\" onclick=\"guest_injury_form('".$id."');\"><i class=\"ace-icon fa fa-ambulance bigger-130\"></i></a>";
|
|
|
|
|
|
$delete_link = "<a href=\"#\" class=\"blue\" onclick=\"delete_guest('" . $id . "','E');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
|
|
|
|
$firstName =$row['fname'];
|
|
$last_name =$row['lname'];
|
|
$space=" ";
|
|
$links = $view_link.$space.$edit_link.$space.$opd_link.$space.$injury_link.$space.$delete_link;
|
|
$data['rows'][] = array(
|
|
'id' => $row['id'],
|
|
'cell' => array($count++, $firstName.' '.$last_name,$row['father_name'],$row['age'],getTableFieldValue('employee',"concat(fname,' ',lname)",'id',$row['emp_id']),$row['emp_relationship_type'], $row['gender']=='M'?'Male':'Female',$row['primary_phone'],
|
|
$row['aadhar_no'],$row['address'],$row['email_id']==null || ''?'':$row['email_id'],
|
|
|
|
$row['blood_group'], $links)
|
|
);
|
|
}
|
|
$data['rows'][] = array(
|
|
'id' => $row['filterkey'],
|
|
'cell' => array('', "<input type=hidden name='filterkey' id='filterkey' value=\"".base64_encode($sql_export)."\">", "<input type=hidden name=paramlist id=paramlist value=\"".base64_encode($paramlist)."\">", '', '','', '', '', '', '', '', '', '','', '', '','', '', '','')
|
|
);
|
|
echo json_encode($data);
|
|
|
|
|
|
?>
|