191 lines
8.4 KiB
PHP
191 lines
8.4 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);
|
|
?>
|
|
<?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;
|
|
}
|
|
$menu_key = $_SESSION['menu_key'];
|
|
$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;
|
|
$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,ticket_no,e.emp_code,e.designation_id,e.dept_id,e.bu_id,token_no,half_day,DATEDIFF(date_absent_to ,date_absent) AS date_difference, certificate_type,sickness_id,sickness_date,from_date, to_date, date_absent, date_return,attended_status,agency,sickness_name,des,s.emp_id,s.doctor_last_attended,s.modified_by 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";
|
|
// $sql_export=$sql_sickness;
|
|
error_log("sickness:" . $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)) {
|
|
$sickness_id = $row_sickness['sickness_id'];
|
|
// echo $sickness_id;
|
|
$view_link = "";
|
|
|
|
$delete_link = "";
|
|
$edit_link = "";
|
|
$links = "";
|
|
$pdf_link = "";
|
|
$email_link = "";
|
|
$certificate_type = $row_sickness['certificate_type'];
|
|
$Rolecodes= explode(',',$_SESSION ['RoleCode']) ;
|
|
|
|
if (isAccessible($_SESSION['RoleId'], $menu_key, '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>";
|
|
$email_link = "<a href=\"#\" class=\"blue\" onclick=\"open_item('" . $sickness_id . "');\"><i class=\"fa fa-envelope\" style=\"font-size: 15px;\"></i></a>";
|
|
}
|
|
if (isAccessible($_SESSION['RoleId'], $menu_key, 'W')) {
|
|
$delete_link="<a href=\"#\" class=\"red\" onclick=\"delete_fitness('".$sickness_id."');\"><i class=\"ace-icon fa fa-trash bigger-130\"></i></a>";
|
|
if ($_SESSION['RoleCode'] == 'DOC' || in_array('DIS', $Rolecodes)) {
|
|
$edit_link = "<a href=\"#\" class=\"blue\" onclick=\"open_pending_fitness('" . $sickness_id . "');\"><i class=\"ace-icon fa fa-edit bigger-130\"></i></a>";
|
|
$email_link = "<a href=\"#\" class=\"blue\" onclick=\"open_item('" . $sickness_id . "');\"><i class=\"fa fa-envelope\" style=\"font-size: 15px;\"></i></a>";
|
|
}
|
|
if ($_SESSION['RoleCode'] == 'RCP') {
|
|
$edit_link = "<a href=\"#\" class=\"blue\" onclick=\"open_sickness('" . $sickness_id . "','W','" . $row_sickness['emp_id'] . "');\"><i class=\"ace-icon fa fa-edit bigger-130\"></i></a>";
|
|
$email_link = "<a href=\"#\" class=\"blue\" onclick=\"open_item('" . $sickness_id . "');\"><i class=\"fa fa-envelope\" style=\"font-size: 15px;\"></i></a>";
|
|
}
|
|
}
|
|
|
|
$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' ;
|
|
// $pdf_link = "<a href=\"#\" class=\"red\" onclick=\"open_pdf_fitness('" . $sickness_id . "');\"><i class=\"fa fa-file-pdf-o bigger-130\" ></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>";
|
|
}
|
|
$space = " ";
|
|
$links = $space . $view_link . $space . $edit_link . $space.$certificate.$space . $email_link.$space . $delete_link;
|
|
$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['patient_name'],
|
|
$row_sickness['emp_code'],
|
|
date_format(date_create($row_sickness['from_date']), "d-M-Y "),
|
|
date_format(date_create($row_sickness['to_date']), "d-M-Y "),
|
|
date_format(date_create($row_sickness['date_absent']), "d-M-Y "),
|
|
date_format(date_create($row_sickness['date_absent_to']), "d-M-Y "),
|
|
$days,
|
|
$row_sickness['agency'],
|
|
$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) . "\">",
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
'',
|
|
''
|
|
)
|
|
);
|
|
echo json_encode($data);
|
|
?>
|