186 lines
6.7 KiB
PHP
186 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 = 'comm_date'; // Sort column
|
|
$sortorder = 'desc'; // Sort order
|
|
$qtype = ''; // Search column
|
|
$query = ''; // Search string
|
|
$searchSql = "";
|
|
// 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');
|
|
error_log("xxxxxxxxx" . $qtype);
|
|
if ($qtype === 'comm_date') {
|
|
|
|
$searchSql = " and date_format(date(comm_date),'%Y-%m-%d')=str_to_date('$query','%d/%m/%Y') ";
|
|
} else if ($qtype === 'comm_date_between') {
|
|
$query = explode("-", $query);
|
|
$searchSql = ($qtype != '' && $query != '') ? "and comm_date between STR_TO_DATE('" . trim($query[0]) . "','%d/%m/%Y') and STR_TO_DATE('" . trim($query[1]) . "','%d/%m/%Y')" : '';
|
|
}
|
|
$sortSql = "order by $sortname $sortorder";
|
|
|
|
// Get total count of records
|
|
$sql = "select * from communication_details where ohc_location_id='" . $_SESSION['current_ohcttype'] . "' " . $searchSql ." group by shift_details_id ". $sortSql;
|
|
$result = @mysqli_query($conn, $sql);
|
|
$total = @mysqli_num_rows($result);
|
|
|
|
error_log("count shift " . $sql);
|
|
// 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_communication = "select * from communication_details where ohc_location_id='" . $_SESSION['current_ohcttype'] . "'" . $searchSql . " group by shift_details_id " . $sortSql;
|
|
//echo $sql_communication;
|
|
error_log("comm q:" . $sql_communication);
|
|
$sql_communication .= " $limitSql ";
|
|
|
|
$results_communication = @mysqli_query($conn, $sql_communication);
|
|
$count = ($page - 1) * $rp + 1;
|
|
|
|
//echo $;
|
|
//echo $access_level;
|
|
|
|
while ($row = @mysqli_fetch_assoc($results_communication)) {
|
|
$comm_date = date_format(date_create($row['comm_date']), "Y-m-d");
|
|
$shift_details_id = $row['shift_details_id'];
|
|
|
|
$sql_communication_details = "select * from communication_details where date(comm_date) ='" . $comm_date . "' and ohc_location_id='" . $_SESSION['current_ohcttype'] . "' and shift_details_id='" . $shift_details_id . "'";
|
|
|
|
$results_communication_details = @mysqli_query($conn, $sql_communication_details);
|
|
|
|
error_log("sql comm details: " . $sql_communication_details);
|
|
//$communication_info='';
|
|
|
|
$communication_info = "";
|
|
// $remarks_info = "";
|
|
while ($row_details = @mysqli_fetch_assoc($results_communication_details)) {
|
|
@extract($row_details);
|
|
// if (isset($row_details['details']) && $row_details['details'] != '') {
|
|
$communication_info .= '<b>' . getTableFieldValue('communication', 'com_item', 'communication_id', $row_details['communication_id']) . '</b>::' . $row_details['details'] . '<br>';
|
|
|
|
// error_log("dettttttttttttttails" . $communication_info);
|
|
// }
|
|
// if (isset($row_details['remarks']) && $row_details['remarks'] != '') {
|
|
// $remarks_info .= '<b>' . getTableFieldValue('communication', 'com_item', 'communication_id', $row_details['communication_id']) . '</b>::' . $row_details['remarks'] . '<br>';
|
|
|
|
// error_log("remarks:::" . $remarks_info);
|
|
// }
|
|
|
|
$comm_date = date_format(date_create($row['comm_date']), "Y-m-d");
|
|
|
|
$query_data = "select start_date_time, end_date_time,shift_id from shift_status_details where shift_details_id='".$shift_details_id."' and ohc_location_id = '".$_SESSION['current_ohcttype']."' and date(end_date_time) = '".$comm_date."' ";
|
|
$result_data = mysqli_query($conn,$query_data);
|
|
$row_data = mysqli_fetch_assoc($result_data);
|
|
|
|
$shift_id = $row_data['shift_id'];
|
|
$start_date_time = $row_data['start_date_time'];
|
|
$end_date_time = $row_data['end_date_time'];
|
|
|
|
$shift_name = getFieldFromTable('status_name', 'shift_status', 'shift_status_id', $shift_id);
|
|
|
|
error_log("shift details ==>" .$shift_id. " ".$start_date_time." ".$end_date_time. " ".$shift_name);
|
|
}
|
|
|
|
//echo $;
|
|
$view_link = "";
|
|
$edit_link = "";
|
|
$delete_link = "";
|
|
$links = "";
|
|
|
|
|
|
$current_date = date("Y-m-d H:i:s");
|
|
error_log("current date" . $current_date);
|
|
$timestamp1 = strtotime($current_date);
|
|
error_log("time 1 date" . $timestamp1);
|
|
error_log("comm_date " . $comm_date);
|
|
$timestamp2 = strtotime($comm_date);
|
|
error_log("time 2 date" . $timestamp2);
|
|
$tim_diff = round(($timestamp1 - $timestamp2) / 3600, 1);
|
|
|
|
error_log("Actusal hhhhhhhhhhhhhhhh" . $tim_diff);
|
|
|
|
|
|
|
|
// error_log("modified by:::::" . $row['modified_by']);
|
|
if ($hasReadAccess) {
|
|
//echo "";
|
|
// $view_link = "<a href=\"#\"class=\"green\" onclick=\"open_communication('" . $row['modified_by'] . "','" . $comm_date . "','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
|
}
|
|
|
|
if ($hasWriteAccess) {
|
|
//if ($tim_diff <= 24) {
|
|
// $edit_link = "<a href=\"#\" class=\"blue\" onclick=\"open_communication('" . $row['modified_by'] . "','" . $comm_date . "','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
//}
|
|
}
|
|
|
|
if ($hasExecuteAccess) {
|
|
//if ($tim_diff <= 24) {
|
|
// $delete_link = "<a href=\"#\" class=\"blue\" onclick=\"delete_communication('" . $row['modified_by'] . "','" . $comm_date . "');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
//}
|
|
}
|
|
|
|
// $pdf_link = $space . "<a href=\"#\" class=\"red\" onclick=\"shift_summ('" . $comm_date . "','" . $row['status_name'] . "');\"><i class=\"fa fa-file-pdf-o\" style=\"font-size: 15px;\"></i></a>";
|
|
|
|
$space = " ";
|
|
$links = $assign_link . $space . $view_link . $space . $edit_link . $space . $delete_link . $space . $pdf_link;
|
|
|
|
$data['rows'][] = array(
|
|
'id' => $row['com_id'],
|
|
'cell' => array(
|
|
$links,
|
|
$count++,
|
|
$shift_name,
|
|
$start_date_time,
|
|
$end_date_time,
|
|
date_format(date_create($row['comm_date']), "d-M-Y"),
|
|
// getTableFieldValue('patient_master', 'patient_name', 'id', $row['emp_id']),
|
|
|
|
$communication_info,
|
|
|
|
// $remarks_info,
|
|
|
|
)
|
|
|
|
);
|
|
}
|
|
|
|
|
|
// error_log(print_r($data, true));
|
|
echo json_encode($data);
|
|
?>
|