393 lines
11 KiB
PHP
393 lines
11 KiB
PHP
<?php
|
|
|
|
include ('includes/config/config.php');
|
|
|
|
include ('includes/auth/auth.php');
|
|
|
|
include ('includes/functions.php');
|
|
include ('access.php');
|
|
|
|
include ('log_entry.php');
|
|
// error_reporting(E_ERROR | E_PARSE);
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// Connect to mysqli database
|
|
|
|
$page = 1; // The current page
|
|
|
|
$sortname = 'sickness_id'; // Sort column
|
|
|
|
$sortorder = 'desc'; // 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($rp)) {
|
|
|
|
$rp = 10;
|
|
}
|
|
|
|
$pageStart = ($page - 1) * $rp;
|
|
|
|
$limitSql = "limit $pageStart, $rp";
|
|
|
|
|
|
|
|
$sortSql = "order by $sortname $sortorder";
|
|
|
|
$searchSql = ($qtype != '' && $query != '') ? " and upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
|
|
|
|
|
|
if ($searchSql != '') {
|
|
|
|
|
|
|
|
if ($qtype == 'sickness_date') {
|
|
|
|
|
|
|
|
$searchSql = " and date_format(date(sickness_date),'%Y-%m-%d')=str_to_date('$query','%d-%m-%Y') ";
|
|
} elseif ($qtype == 'from_date') {
|
|
|
|
|
|
|
|
$searchSql = " and date_format(date(from_date),'%Y-%m-%d')=str_to_date('$query','%d-%m-%Y') ";
|
|
} elseif ($qtype == 'to_date') {
|
|
|
|
|
|
|
|
$searchSql = " and date_format(date(to_date),'%Y-%m-%d')=str_to_date('$query','%d-%m-%Y') ";
|
|
} elseif ($qtype == 'date_absent') {
|
|
|
|
|
|
|
|
$searchSql = " and date_format(date(date_absent),'%Y-%m-%d')=str_to_date('$query','%d-%m-%Y') ";
|
|
} elseif ($qtype == 'date_return') {
|
|
|
|
|
|
|
|
$searchSql = " and date_format(date(date_return),'%Y-%m-%d')=str_to_date('$query','%d-%m-%Y') ";
|
|
} else if ($qtype == 'sickness_date_between') {
|
|
|
|
$dates = explode("-", $query);
|
|
|
|
|
|
|
|
//$qtype=" due_date between ";
|
|
|
|
$searchSql = " and sickness_date between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
|
} else if ($qtype == 'from_date_between') {
|
|
|
|
$dates = explode("-", $query);
|
|
|
|
|
|
|
|
//$qtype=" due_date between ";
|
|
|
|
$searchSql = " and from_date between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
|
} else if ($qtype == 'to_date_between') {
|
|
|
|
$dates = explode("-", $query);
|
|
|
|
|
|
|
|
//$qtype=" due_date between ";
|
|
|
|
$searchSql = " and to_date between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
|
} else if ($qtype == 'date_absent_between') {
|
|
|
|
$dates = explode("-", $query);
|
|
|
|
|
|
|
|
//$qtype=" due_date between ";
|
|
|
|
$searchSql = " and date_absent between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
|
} else if ($qtype == 'date_return_between') {
|
|
|
|
$dates = explode("-", $query);
|
|
|
|
|
|
|
|
//$qtype=" due_date between ";
|
|
|
|
$searchSql = " and date_return between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
|
}
|
|
}
|
|
|
|
// $searchSql = preg_replace('/and/', 'where', $searchSql, 1);
|
|
|
|
// Get total count of records
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "select count(*) from sickness s, patient_master e where s.emp_id=e.id and s.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' and attended_status='DRA' $searchSql $sortSql $limitSql";
|
|
|
|
|
|
|
|
|
|
//echo $sql;
|
|
|
|
|
|
|
|
error_log("query: " . $sql);
|
|
|
|
$result = mysqli_query($conn, $sql);
|
|
|
|
$row = mysqli_fetch_array($result);
|
|
|
|
$total = $row[0];
|
|
|
|
// Setup paging
|
|
|
|
|
|
|
|
// Return JSON data
|
|
|
|
$data = array();
|
|
|
|
$data['page'] = $page;
|
|
|
|
$data['total'] = $total;
|
|
|
|
$data['rows'] = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql_sickness = "select patient_name,ailment_name,date_absent_to,DATEDIFF(date_absent_to ,date_absent) AS date_difference,half_day,emp_code,designation_id,dept_id,bu_id,s.ticket_no, sickness_id,sickness_date,certificate_type,from_date, to_date, date_absent, date_return,s.doctor_last_attended,s.modified_by,sickness_name,des,fitness_status from sickness s, patient_master e where s.emp_id=e.id and s.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' and s.attended_status='DRA' $searchSql $sortSql $limitSql";
|
|
|
|
|
|
error_log("query sickness: " . $sql_sickness);
|
|
//$sql_export=$sql_sickness;
|
|
|
|
//$sql_sickness = $sql_sickness." $searchSql $sortSql $limitSql";
|
|
|
|
//echo $sql_sickness;
|
|
|
|
$results_sickness = mysqli_query($conn, $sql_sickness);
|
|
|
|
$count = ($page - 1) * $rp + 1;
|
|
|
|
|
|
|
|
//echo $sql_sickness;
|
|
|
|
//echo $access_level;
|
|
|
|
|
|
|
|
while ($row_sickness = mysqli_fetch_assoc($results_sickness)) {
|
|
|
|
|
|
$dept_name = getTableFieldValue('department', 'dept_name', 'dept_id', $row_sickness['dept_id']);
|
|
|
|
$sickness = getCommaSeperatedValuesForInClause('select ailment_sys_name from ailment_system', 'ailment_sys_id', $row_sickness['sickness_name']);
|
|
$diagnosis = "";
|
|
$diagnosis = getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row_sickness['ailment_name']);
|
|
$sickness_id = $row_sickness['sickness_id'];
|
|
$status = $row_sickness['fitness_status'];
|
|
$certificate_type = $row_sickness['certificate_type'];
|
|
$fit = "";
|
|
if ($status == 'FIT') {
|
|
$fit = "<span class='green'>Fit</i></span>";
|
|
} else if ($status == 'APPROVED') {
|
|
$fit = "<span class='green'>Fit</i></span>";
|
|
} else if($status == 'RETURN BACK TO WORK' ) {
|
|
$fit = "<span class='lighter red'>Return Back To Work</i></span>";
|
|
}else if($status == 'REVIEW'){
|
|
$fit = "<span class='lighter red'>Temparory Unfit Review Later</i></span>";
|
|
}else if($status == 'ROLE CHANGE SUGGESTED'){
|
|
$fit = "<span class='lighter red'>Role Change Suggested</i></span>";
|
|
}else{
|
|
$fit = "<span class='red'>Unfit</i></span>";
|
|
}
|
|
|
|
if ($row_sickness['date_absent_to'] == '' || $row_sickness['date_absent_to'] == null || $row_sickness['date_absent_to'] == '0000-00-00 00:00:00') {
|
|
$row_sickness['date_absent_to'] = '';
|
|
} else {
|
|
$row_sickness['date_absent_to'] = date_format(date_create($row_sickness['date_absent_to']), "d-M-Y");
|
|
}
|
|
|
|
if ($row_sickness['date_absent'] == '' || $row_sickness['date_absent'] == null || $row_sickness['date_absent'] == '0000-00-00') {
|
|
$row_sickness['date_absent'] = '';
|
|
} else {
|
|
$row_sickness['date_absent'] = date_format(date_create($row_sickness['date_absent']), "d-M-Y");
|
|
} //echo $sickness_id;
|
|
|
|
$view_link = "";
|
|
|
|
$edit_link = "";
|
|
|
|
$delete_link = "";
|
|
$email_link = "";
|
|
$links = "";
|
|
$certificate = "";
|
|
|
|
if (isAccessible($_SESSION['RoleId'], '', 'R')) {
|
|
|
|
//echo "shubham";
|
|
|
|
$view_link = "<a href=\"#\"class=\"grey\" onclick=\"open_sickness('" . $sickness_id . "','V');\"><i class=\"ace-icon fa fa-eye bigger-130\"></i></a>";
|
|
}
|
|
|
|
|
|
|
|
if (isAccessible($_SESSION['RoleId'], '', 'W')) {
|
|
|
|
|
|
$edit_link = "<a href=\"#\" class=\"blue\" onclick=\"open_pending_fitness('" . $sickness_id . "');\"><i class=\"ace-icon fa fa-edit bigger-130\" style=\"font-size:17px\"></i></a>";
|
|
}
|
|
$delete_link = "<a href=\"#\" class=\"red\" onclick=\"delete_fitness('" . $sickness_id . "');\"><i class=\"ace-icon fa fa-trash bigger-130\"></i></a>";
|
|
|
|
$pdf_link = "<a href=\"#\" class=\"brown\" onclick=\"open_pdf_fitness_form('" . $sickness_id . "','" . $status . "');\"><i class=\"fa fa-file-pdf-o bigger-130\" style=\"font-size:17px\" ></i></a>";
|
|
error_log("certificate_type" . $certificate_type);
|
|
if ($certificate_type != '' || $certificate_type != null) {
|
|
$certificate = "<a href=\"#\" class=\"green\" onclick=\"open_pdf_fitness_certificate('" . $sickness_id . "','" . $certificate_type . "');\"><i class=\"fa fa-file-pdf-o bigger-130\" style=\"font-size:17px\" ></i></a>";
|
|
}
|
|
$email_link = "<a href=\"#\" class=\"blue\" onclick=\"open_item('" . $sickness_id . "','" . $status . "',this);\"><i class=\"fa fa-envelope\" style=\"font-size: 15px;\"></i></a>";
|
|
|
|
|
|
$space = " ";
|
|
// $space . $edit_link .
|
|
$links = $space . $pdf_link . $space . $certificate . $space . $edit_link . $space . $email_link . $space . $delete_link;
|
|
$half_day = $row_sickness['half_day'];
|
|
if ($row_sickness['date_difference'] == '' || $row_sickness['date_difference'] == 0 || $row_sickness['date_difference'] == null) {
|
|
if ($half_day == 1) {
|
|
$days = ' ';
|
|
} else {
|
|
$days = '1';
|
|
}
|
|
} else {
|
|
if ($half_day == 1) {
|
|
$days = $row_sickness['date_difference'];
|
|
} else {
|
|
$days = $row_sickness['date_difference'] + 1;
|
|
}
|
|
}
|
|
|
|
if ($row_sickness['half_day'] == 1) {
|
|
if ($row_sickness['date_difference'] == '' || $row_sickness['date_difference'] == 0 || $row_sickness['date_difference'] == null) {
|
|
$days .= ' Half ';
|
|
} else {
|
|
$days .= ' And Half ';
|
|
}
|
|
}
|
|
$days .= ' Day';
|
|
|
|
if (($row_sickness['date_absent'] == null || $row_sickness['date_absent'] == '0000-00-00') && ($row_sickness['date_absent_to'] == null || $row_sickness['date_absent_to'] == '0000-00-00')) {
|
|
$days = '';
|
|
}
|
|
|
|
$data['rows'][] = array(
|
|
|
|
'id' => $row_sickness['sickness_id'],
|
|
|
|
'cell' => array(
|
|
$links,
|
|
$count++,
|
|
date_format(date_create($row_sickness['sickness_date']), "d-M-Y H:i A"),
|
|
$row_sickness['ticket_no'],
|
|
$row_sickness['patient_name'],
|
|
$row_sickness['emp_code'],
|
|
$dept_name,
|
|
date_format(date_create($row_sickness['from_date']), "d-M-Y "),
|
|
date_format(
|
|
date_create($row_sickness['to_date']),
|
|
"d-M-Y "
|
|
),
|
|
$row_sickness['date_absent'],
|
|
$row_sickness['date_absent_to'],
|
|
$days,
|
|
$fit,
|
|
$row_sickness['agency'],
|
|
$diagnosis,
|
|
$sickness,
|
|
$row_sickness['des']
|
|
)
|
|
|
|
);
|
|
}
|
|
|
|
|
|
|
|
$data['rows'][] = array(
|
|
|
|
'id' => $row['filterkey'],
|
|
|
|
'cell' => array(
|
|
'',
|
|
"<input type=hidden name='filterkey' id='filterkey' value=\"" . base64_encode($sql_sickness)
|
|
. "\">",
|
|
"<input type=hidden name=paramlist id=paramlist value=\"" . base64_encode($paramlist) . "\">",
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
''
|
|
)
|
|
|
|
);
|
|
|
|
error_log("data: " . print_r($data, true));
|
|
echo json_encode($data);
|
|
|
|
?>
|