ESH/appointment_management_script.php

93 lines
3.2 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include('includes/auth/auth.php');
include('includes/functions.php');include('access.php');
error_reporting ( E_ERROR | E_PARSE );
?>
<?php
// Connect to mysqli database
$page = 1; // The current page
$sortname = 'ohc_type_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($_POST['page']);
}
if (isset($_POST['sortname'])) {
$sortname = mysqli_real_escape_string($_POST['sortname']);
}
if (isset($_POST['sortorder'])) {
$sortorder = mysqli_real_escape_string($_POST['sortorder']);
}
if (isset($_POST['qtype'])) {
$qtype = mysqli_real_escape_string($_POST['qtype']);
}
if (isset($_POST['query'])) {
$query = mysqli_real_escape_string($_POST['query']);
}
if (isset($_POST['rp'])) {
$rp = mysqli_real_escape_string($_POST['rp']);
}
// Setup sort and search SQL using posted data
$sortSql = "order by $sortname $sortorder";
$searchSql = ($qtype != '' && $query != '') ? "where $qtype LIKE '%$query%'" : '';
// Get total count of records
$sql_count = "select count(*) from appointment_management_list";
error_log("APOOINTMENTS::".$sql_count);
$result = @mysqli_query($conn,$sql_count);
$row = @mysqli_fetch_array($result);
$total = $row[0];
// Setup paging SQL
$pageStart = ($page-1)*$rp;
$limitSql = "limit $pageStart, $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');
error_log($_SESSION['RoleId']);
error_log($menu_key);
// Return JSON data
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
$sql = "select * from appointment_management_list";
//echo $sql;
error_log("Staus:::".$sql);
$results = mysqli_query($conn,$sql);
$count=1;
while ($row = mysqli_fetch_assoc($results)) {
$appointment_id=$row['appointment_id'];
if($hasReadAccess)
{
$view_link="<a href=\"#\"class=\"green\" onclick=\"open_client_appointment('".$appointment_id."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
}
if($hasWriteAccess)
{
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_client_appointment('".$appointment_id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
}
if($hasExecuteAccess)
{
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_client_appointment('".$appointment_id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
}
$space="&nbsp;&nbsp;&nbsp;";
$links = $assign_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++, $links,$row['patient_name'], $row['contact_no'], $row['email_id'], $row['appointment_date'],getFieldFromTable('address', 'ohc_type', 'ohc_type_id', $row['appointment_center']),$row['appointment_type'],$row['message'],$row['appointment_time'],$row['app_status'],)
);
}
echo json_encode($data);
?>