ESH/excel_critical_illnesswise_emp_report.php
2024-10-23 18:28:06 +05:30

287 lines
12 KiB
PHP

<?
// include('pdf_header.php');
include('includes/config/config.php');
include('includes/functions.php');
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename=excel_critical_illness_emp_report.xls');
?>
<body>
<table border="1" width="100%">
<?php
error_reporting(E_ERROR | E_PARSE);
$ohc_type = $_REQUEST['ohc_location'];
$patient_category = $_REQUEST['patient_category'];
$dept = $_REQUEST['dept'];
$emp_designation = $_REQUEST['emp_designation'];
$emp_cadre = $_REQUEST['emp_cadre'];
$employer_contractor = $_REQUEST['employer_contractor'];
$gender = $_REQUEST['gender'];
$illness = $_REQUEST['illness'];
$start_date = $_REQUEST['startDate'];
$end_date= $_REQUEST['endDate'];
$year = implode(',',$_REQUEST['year']);
$month = implode(',', $_REQUEST['month']);
$year2=implode(',',$_REQUEST['year']);
$year1 = explode(',',$year);
error_log("values::".$ohc_location." ".$patient_category." ".$dept." ".$emp_designation." ".$emp_cadre." ".$employer_contractor." ".$gender." ".$start_date." ".$end_date." ".$year." ".$month." ".$illness);
$qry_filter1 = "";
$qry_filter ="";
$qry_date="";
$qry_date1="";
if(isset($illness) && $illness!=''){
$qry_filter1.=" where param_id ='".$illness."'";
}
if (isset($dept) && $dept != '') {
$qry_filter .= " where dept_id ='" . $dept . "' ";
}
if (isset($ohc_type) && $ohc_type != '') {
$qry_filter .= " and ohc_type_id ='" . $ohc_type . "' ";
}
if (isset($gender) && $gender != '') {
$qry_filter .= " and gender ='" . $gender . "' ";
}
if (isset($patient_category) && $patient_category != '') {
$qry_filter .= " and emp_cat_id ='" . $patient_category . "' ";
}
if (isset($emp_designation) && $emp_designation != '') {
$qry_filter .= " and designation_id ='" . $emp_designation . "' ";
}
if (isset($emp_cadre) && $emp_cadre != '') {
$qry_filter .= " and emp_cadre ='" . $emp_cadre . "' ";
}
if (isset($employer_contractor) && $employer_contractor != '') {
$qry_filter .= " and employer_contractor_id ='" . $employer_contractor . "' ";
}
if (isset($start_date) && $start_date != '') {
$qry_date .= " and date(medical_entry_date) >=str_to_date('" . $start_date . "','%d-%m-%Y') ";
}
if(isset($start_date) && $start_date!=''){
$qry_date1.=" and date(medical_entry_date) >=str_to_date('".$start_date."','%d-%m-%Y') ";
}
if(isset($end_date) && $end_date!=''){
$qry_date1.=" and date(medical_entry_date) <=str_to_date('".$end_date."','%d-%m-%Y') ";
}
if(isset($month) && $month!=''){
$qry_date1.=" and month(medical_entry_date) in (".$month.")";
}
?>
<?
if(isset($year) && $year!='' && sizeof($year1)>1){
for($j=0; $j<sizeof($year1);$j++){
$qry_date="";
$qry_date.=" and year(medical_entry_date) ='".$year1[$j]."'";
?>
<tr>
<td colspan="2" align="center"><strong>CRITICAL ILLNESS WISE EMPLOYEE REPORT For <?=$year1[$j]?></strong></td>
<tr>
<td align="left"> Run Date : <? echo date("d-M-Y"); ?></td>
<td align="left"> User : <? echo $username ?></td>
</tr>
<tr>
<?php if(isset($start_date) && isset($end_date)){?>
<td colspan="2" ><strong>Filters Applied-</strong>
<u>Range:</u><? echo $start_date;?> to <? echo $end_date ;?>,
<u>EMPLOYER/CONTRACTOR:</u><?if($employer_contractor==''){echo "ALL";} else?><?echo getTableFieldValue(' employer_contractor','employer_contractor_name','id',$employer_contractor);?>,
<u>Gender:</u><?if($gender==''){echo "ALL";} else?><?echo $gender;?>,
<u>OHC Location:</u><?if($ohc_type==''){echo "ALL";} else?><?echo getTableFieldValue('ohc_type','ohc_type_name','ohc_type_id',$ohc_type);?>,
<u>Patient Category:</u><?if($patient_category==''){echo "ALL";} else?><?echo getTableFieldValue('patient_category','patient_cat_name','patient_cat_id',$patient_category);?>,
<u>Department:</u><?if($dept==''){echo "ALL";} else?><?echo getTableFieldValue('department','dept_name','dept_id',$dept); ?>,
<u>Illness:</u><?if($illness==''){echo "ALL";} else?><?echo getTableFieldValue('history_parameter','param_name','param_id',$illness); ?>,
<u>Designation:</u><?if($emp_designation==''){echo"ALL";} else?><?echo getTableFieldValue(' designation','designation_name','designation_id',$emp_designation);?>,
<u>Employee Cadre:</u><?if($emp_cadre==''){echo "ALL";} else?><?echo getTableFieldValue(' emp_cadre','emp_cadre','emp_cadre_id',$emp_cadre); ?>,
<u>Month:</u><?if($month==''){echo "ALL";} else?><?echo $month; ?>,
<u>Year:</u><?if($year==''){echo "ALL";} else?><?echo $year1[$j]; ?>
</td>
</tr>
<?php } ?>
</tr>
<strong>
<tr bgcolor="#eeeeee">
<td align="center">Illness Name</td>
<td align="center">Patient Name</td>
</tr>
</strong>
<?
error_reporting(E_ERROR | E_PARSE);
$param_query = "select param_id, param_name from history_parameter $qry_filter1";
$result_param = mysqli_query($conn, $param_query);
while($param_row = mysqli_fetch_assoc($result_param)){
$param_id = $param_row['param_id'];
?>
<tr>
<td align="left"><?=$param_row['param_name']?></td>
</tr>
<?
$id_query = "select id from patient_master where status='Active' $qry_filter";
$id_result = mysqli_query($conn, $id_query);
while($row_id = mysqli_fetch_assoc($id_result)){
// $pat_info = "select patient_id from medical_examination where past_present_illness in ($param_id) and medical_exam_id = (select max(medical_exam_id) from medical_examination where patient_id='".$row_id['id']."') $qry_date1 $qry_date";
// $pat_result = mysqli_query($conn, $pat_info);
// $pat_row = mysqli_fetch_assoc($pat_result);
$count_bmi = "select patient_name from patient_master where id = (select patient_id from medical_examination where past_present_illness in ($param_id) and medical_exam_id = (select max(medical_exam_id) from medical_examination where patient_id='".$row_id['id']."') $qry_date1 $qry_date)";
$bmi_result = mysqli_query($conn, $count_bmi);
error_log("count_bmi::".$pat_info);
while($row_bmi = mysqli_fetch_assoc($bmi_result)){
?>
<tr bgcolor="#eeeeee">
<td align="left"><?=$param_row['param_name']?></td>
<td align="left" width="15%"><?= $row_bmi['patient_name']?></td>
<?
}
}
?>
</tr>
<?
}
}
}else{
if(isset($year2) && $year2!=''){
$qry_date1.=" and year(medical_entry_date) ='".$year2."'";
}
?>
<tr>
<td colspan="2" align="center"><strong>CRITICAL ILLNESS WISE EMPLOYEE REPORT</strong></td>
<tr>
<td align="left"> Run Date : <? echo date("d-M-Y"); ?></td>
<td align="left"> User : <? echo $username ?></td>
</tr>
<tr>
<?php if(isset($start_date) && isset($end_date)){?>
<td colspan="2" ><strong>Filters Applied-</strong>
<u>Range:</u><? echo $start_date;?> to <? echo $end_date ;?>,
<u>EMPLOYER/CONTRACTOR:</u><?if($employer_contractor==''){echo "ALL";} else?><?echo getTableFieldValue(' employer_contractor','employer_contractor_name','id',$employer_contractor);?>,
<u>Gender:</u><?if($gender==''){echo "ALL";} else?><?echo $gender;?>,
<u>OHC Location:</u><?if($ohc_type==''){echo "ALL";} else?><?echo getTableFieldValue('ohc_type','ohc_type_name','ohc_type_id',$ohc_type);?>,
<u>Patient Category:</u><?if($patient_category==''){echo "ALL";} else?><?echo getTableFieldValue('patient_category','patient_cat_name','patient_cat_id',$patient_category);?>,
<u>Department:</u><?if($dept==''){echo "ALL";} else?><?echo getTableFieldValue('department','dept_name','dept_id',$dept); ?>,
<u>Illness:</u><?if($illness==''){echo "ALL";} else?><?echo getTableFieldValue('history_parameter','param_name','param_id',$illness); ?>,
<u>Designation:</u><?if($emp_designation==''){echo"ALL";} else?><?echo getTableFieldValue(' designation','designation_name','designation_id',$emp_designation);?>,
<u>Employee Cadre:</u><?if($emp_cadre==''){echo "ALL";} else?><?echo getTableFieldValue(' emp_cadre','emp_cadre','emp_cadre_id',$emp_cadre); ?>,
<u>Month:</u><?if($month==''){echo "ALL";} else?><?echo $month; ?>,
<u>Year:</u><?if($year==''){echo "ALL";} else?><?echo $year; ?>
</td>
</tr>
<?php } ?>
</tr>
<strong>
<tr bgcolor="#eeeeee">
<td align="center">ILLNESS NAME</td>
<td align="center">PATIENT NAME</td>
</tr>
</strong>
<?
error_reporting(E_ERROR | E_PARSE);
$param_query = "select param_id,param_name from history_parameter $qry_filter1";
$result_param = mysqli_query($conn, $param_query);
while($param_row = mysqli_fetch_assoc($result_param)){
$param_id = $param_row['param_id'];
?>
<tr>
<td></td>
</tr>
<?
$id_query = "select id from patient_master where status='Active' $qry_filter";
$id_result = mysqli_query($conn, $id_query);
while($row_id = mysqli_fetch_assoc($id_result)){
// $pat_info = "select patient_id from medical_examination where past_present_illness in ($param_id) and medical_exam_id = (select max(medical_exam_id) from medical_examination where patient_id='".$row_id['id']."') $qry_date1";
// $pat_result = mysqli_query($conn, $pat_info);
// $pat_row = mysqli_fetch_assoc($pat_result);
$count_bmi = "select patient_name from patient_master where id = (select patient_id from medical_examination where past_present_illness in ($param_id) and medical_exam_id = (select max(medical_exam_id) from medical_examination where patient_id='".$row_id['id']."') $qry_date1)";
$bmi_result = mysqli_query($conn, $count_bmi);
error_log("count_bmi::".$count_bmi);
while($row_bmi = mysqli_fetch_assoc($bmi_result)){
?>
<tr bgcolor="#eeeeee">
<td align="left"><?=$param_row['param_name']?></td>
<td align="left" width="15%"><?= $row_bmi['patient_name']?></td>
<?
}
}
?>
</tr>
<?
}
}
?>
</table>
</body>