363 lines
8.4 KiB
PHP
363 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;
|
|
|
|
}
|
|
|
|
$pageStart = ($page-1)*$rp;
|
|
|
|
$limitSql = "limit $pageStart, $rp";
|
|
|
|
|
|
|
|
$sortSql = "order by $sortname $sortorder";
|
|
|
|
$searchSql = ($qtype != '' && $query != '') ? "where 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='DRP' $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,s.ticket_no, ap.ticket_no as token_no,date_absent_to,DATEDIFF(date_absent_to ,date_absent) AS date_difference, sickness_id,sickness_date,from_date,certificate_type, to_date, date_absent, date_return,agency,sickness_name,des from sickness s, patient_master e,employee_appointment ap where ap.appointment_id=s.followup_to_opd and s.emp_id=e.id and s.ohc_type_id='".$_SESSION['current_ohcttype']."' and s.attended_status='DRP' $searchSql $sortSql $limitSql";
|
|
|
|
error_log('xxx '.$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)) {
|
|
|
|
$sickness = getTableFieldValue ( 'ailment_system', 'ailment_sys_name', 'ailment_sys_id', $row_sickness['sickness_name'] );
|
|
|
|
error_log("ssssssiiiiiiiiiiiiiiiii".$row_sickness['sickness_name']);
|
|
|
|
error_log("sicccccccccccccccck".$sickness);
|
|
|
|
$certificate_type = $row_sickness['certificate_type'];
|
|
$sickness_id=$row_sickness['sickness_id'];
|
|
|
|
//echo $sickness_id;
|
|
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");
|
|
}
|
|
|
|
$view_link="";
|
|
|
|
$edit_link="";
|
|
|
|
$delete_link="";
|
|
$certificate="";
|
|
$links="";
|
|
|
|
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($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>";
|
|
}
|
|
|
|
if(isAccessible($_SESSION['RoleId'],'','W'))
|
|
|
|
{
|
|
$delete_link="<a href=\"#\" class=\"red\" onclick=\"delete_fitness('".$sickness_id."');\"><i class=\"ace-icon fa fa-trash bigger-130\"></i></a>";
|
|
//$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_employee_appointment('".$appointment_id."','".$appointment_type."','".$emp_id."','E');\"><i class=\"glyphicon glyphicon-share\"></i></a>";
|
|
|
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_pending_fitness('".$sickness_id."');\"><i class=\"gace-icon fa fa-edit bigger-130\"></i></a>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$space=" ";
|
|
|
|
$links = $space.$edit_link.$space.$certificate.$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' ;
|
|
|
|
|
|
$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['token_no'], $row_sickness['patient_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,$row_sickness['agency'],$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)."\">", '', '','', '', '', '', '', '', '', '','', '', '','', '', '')
|
|
|
|
);
|
|
|
|
echo json_encode($data);
|
|
|
|
?>
|