148 lines
6.7 KiB
PHP
148 lines
6.7 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/auth/auth.php');
|
||
|
include('includes/functions.php');include('access.php');
|
||
|
// error_reporting(E_ERROR | E_PARSE);
|
||
|
include('log_entry.php')
|
||
|
?>
|
||
|
<?php
|
||
|
|
||
|
// Connect to mysqli database
|
||
|
$page = 1; // The current page
|
||
|
$sortname = 'appointment_date'; // 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
|
||
|
$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";
|
||
|
|
||
|
if ($qtype == 'appointment_date') {
|
||
|
// $searchSql = " where date_format(date(appointment_date),'%Y-%m-%d')=str_to_date('$query','%d/%m/%Y') ";
|
||
|
$searchSql = ($qtype != '' && $query != '') ? " where upper($qtype)= STR_TO_DATE('" . trim ( $query ) . "','%d/%m/%Y')" : '';
|
||
|
error_log ( "appointment_date......." . $searchSql );
|
||
|
} else if ($qtype == 'patient_name') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
error_log ( "patient name......." . $searchSql );
|
||
|
} else if ($qtype == 'approval_date_between') {
|
||
|
$dates = explode ( "-", $query );
|
||
|
$searchSql = " and approval_date between str_to_date('" . trim ( $dates [0] ) . "','%d/%m/%Y') and str_to_date('" . trim ( $dates [1] ) . "','%d/%m/%Y') ";
|
||
|
} else if ($qtype == 'father_name') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
} else if ($qtype == 'gender') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
} else if ($qtype == 'personal_phone') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
} else if ($qtype == 'ticket_no') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
} else if ($qtype == 'remarks') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
} else if ($qtype == 'emp_code') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if ($qtype == 'entry_med_test') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if ($qtype == 'reviewer_comment') {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else {
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}
|
||
|
//$searchSql = " where a.ohc_type_id='".$_SESSION ['current_ohcttype']."' ";
|
||
|
//$searchSql .=($qtype != '' && $query != '') ? " and upper($qtype) like upper('%$query%')" : '';
|
||
|
// Get total count of records
|
||
|
$sql = "select count(*) from visitors_employee_appointment a left join visitor_patient_master b on a.emp_id = b.id $searchSql";
|
||
|
$result = @mysqli_query($conn,$sql);
|
||
|
$row = @mysqli_fetch_array($result);
|
||
|
$total = $row[0];
|
||
|
// Setup paging
|
||
|
if(!isSet($rp)){
|
||
|
$rp=10;
|
||
|
}
|
||
|
$pageStart = ($page-1)*$rp;
|
||
|
$limitSql = "limit $pageStart, $rp";
|
||
|
// Return JSON data
|
||
|
$data = array();
|
||
|
$data['page'] = $page;
|
||
|
$data['total'] = $total;
|
||
|
$data['rows'] = array();
|
||
|
$sql_ailment = "select a.*, b.* from visitors_employee_appointment a left join visitor_patient_master b on a.emp_id = b.id $searchSql $sortSql $limitSql";
|
||
|
$sql_export = "select a.*, b.* from visitors_employee_appointment a left join visitor_patient_master b on a.emp_id = b.id $searchSql $sortSql";
|
||
|
//echo $sql_ailment;
|
||
|
error_log("Sql: ".$sql_ailment);
|
||
|
$results_ailment = @mysqli_query($conn,$sql_ailment);
|
||
|
$count=($page-1)*$rp+1;
|
||
|
|
||
|
//echo $sql_ailment;
|
||
|
//echo $access_level;
|
||
|
|
||
|
while ($row_ailment = @mysqli_fetch_assoc($results_ailment)) {
|
||
|
|
||
|
$id=$row_ailment['appointment_id'];
|
||
|
//echo $id;
|
||
|
// error_log("id: ".$id);
|
||
|
$view_link="";
|
||
|
$edit_link="";
|
||
|
$delete_link="";
|
||
|
$links="";
|
||
|
if($hasReadAccess)
|
||
|
{
|
||
|
//echo "shubham";
|
||
|
$view_link="<a href=\"#\"class=\"green\" onclick=\"open_visitor_details('".$id."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
||
|
}
|
||
|
|
||
|
if($hasWriteAccess)
|
||
|
{
|
||
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_visitor_details('".$id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
||
|
}
|
||
|
if($hasExecuteAccess)
|
||
|
{
|
||
|
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_visitor_details('".$id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
||
|
}
|
||
|
$space=" ";
|
||
|
$links = $assign_link.$space.$view_link.$space.$edit_link.$space.$delete_link;
|
||
|
|
||
|
// calculate age by dob
|
||
|
$age = date_diff(date_create($row_ailment['dob']), date_create('now'))->y;
|
||
|
// $date_added= date_create($row_ailment['date_added']);
|
||
|
// $date_added=date_format($date_added,"d-m-Y");
|
||
|
// $resumed_duties_from=date_create($row_ailment['resumed_duties_from']);
|
||
|
// $resumed_duties_from=date_format($resumed_duties_from,"d-m-Y");
|
||
|
// $tested_positive_on=date('d-m-Y h:i A', strtotime($row_ailment['tested_positive_on']));
|
||
|
// $discharge_on=date('d-m-Y h:i A', strtotime($row_ailment['discharge_on']));
|
||
|
|
||
|
$appointment_date = date_format(date_create($row_ailment['appointment_date']),"d/m/Y g:i a");
|
||
|
|
||
|
$data['rows'][] = array(
|
||
|
'id' => $row_ailment['id'],
|
||
|
'cell' => array($links, $count++, $appointment_date ,$row_ailment['patient_name'],$row_ailment['father_name'], $age, $row_ailment['gender'], $row_ailment['ticket_no'], $row_ailment['emp_code'], $row_ailment['personal_phone'], $row_ailment['entry_med_test'], $row_ailment['remarks'], $row_ailment['reviewer_comment'])
|
||
|
);
|
||
|
}
|
||
|
|
||
|
$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);
|
||
|
// error_log(json_encode($data));
|
||
|
?>
|