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

122 lines
4.0 KiB
PHP

<?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_department_wise_active_quarantine_report.xls');
?>
<body>
<table border="1" width="100%">
<?php
include('includes/config/config.php');
error_reporting(E_ERROR | E_PARSE);
$ohc_location = $_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'];
$start_date = $_REQUEST['startDate'];
$end_date= $_REQUEST['endDate'];
$qry_bu ="";
$qry_date="";
if(isset($ohc_location) && $ohc_location!=''){
$qry_bu.=" and b.ohc_type_id ='".$ohc_location."' ";
}
if(isset($patient_category) && $patient_category!=''){
$qry_bu.=" and b.emp_cat_id ='".$patient_category."' ";
}
if(isset($dept) && $dept!=''){
$qry_bu.=" and b.dept_id ='".$dept."' ";
}
if(isset($emp_designation) && $emp_designation!=''){
$qry_bu.=" and b.designation_id ='".$emp_designation."' ";
}
if(isset($emp_cadre) && $emp_cadre!=''){
$qry_bu.=" and b.emp_cadre ='".$emp_cadre."' ";
}
if(isset($employer_contractor) && $employer_contractor!=''){
$qry_bu.=" and b.employer_contractor_id ='".$employer_contractor."' ";
}
if(isset($gender) && $gender!=''){
$qry_bu.=" and b.gender ='".$gender."' ";
}
if(isset($start_date) && $start_date!=''){
//$qry_date.=" and b.checkup_date >='".$start_date."' ";
$qry_date.=" and b.medical_entry_date >=str_to_date('".$start_date."','%d-%m-%Y') ";
}
if(isset($end_date) && $end_date!=''){
//$qry_date.=" and b.checkup_date <='".$end_date."' ";
$qry_date.=" and b.medical_entry_date <=str_to_date('".$end_date."','%d-%m-%Y') ";
}
$query="SELECT patient_master.patient_name from medical_examination INNER JOIN patient_master ON medical_examination.patient_id = patient_master.id where bp>130 and patient_id in ($query1) $qry_date";
// echo $query;
$result = @mysqli_query($conn,$query);
?>
<tr>
<div style="font-size: 12px">
<td width="25%" align="left"> Run Date : <?php echo date("d-M-Y"); ?></td>
<td width="50%" align="center"><strong>Department Wise Covid Active Quarantine</strong></td>
<td align="left"> User : <?php echo $username ?></td>
</tr>
<tr style="background: #eeeeee;"><td><strong>Dept. Name</strong></td><td><strong>Active Quarantine</strong></td><td><strong>%</strong></td></tr>
<?php
$sql="select count(a.id) as total, f.dept_name from covid_monitoring a left join patient_master b on a.emp_id = b.id left join department f on b.dept_id = f.dept_id where (a.staying_id = '1' or a.staying_id='2') $qry_bu group by f.dept_name ";
//echo $sql;
$total_query="SELECT count(*) as total_active from covid_monitoring where id in (select a.id from covid_monitoring a left join patient_master b on a.emp_id = b.id left join department f on b.dept_id = f.dept_id where (a.staying_id='1' or a.staying_id='2') $qry_bu group by f.dept_name )";
//echo $query;
$result = @mysqli_query($conn,$sql);
//echo $result;
while($rowOfEmployee=@mysqli_fetch_array($result)){
if (!$result_result = @mysqli_query($conn,$total_query)) {
exit(mysqli_error($conn));
}
if(mysqli_num_rows($result_result) > 0) {
if ($row = @mysqli_fetch_assoc($result_result)) {
$percentage=($rowOfEmployee['total']/$row['total_active'])*100;
?><tr><td><?php echo $rowOfEmployee['dept_name']?></td><td><?php echo $rowOfEmployee['total']?></td><td><?php echo number_format($percentage, 2)?>%</td></tr><?php
}
}
}
?>
<tr><td>Total</td><td><?php echo $row['total_active']?></td><td><?php echo number_format(100, 2)?>%</td></tr>
</table>
</body>