ESH/injury_report_excel.php

103 lines
4.0 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=excel_task_history_report.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<?php
include('includes/config/config.php');
include('includes/functions.php');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
$from_date = $_REQUEST['injuryStartDate2'];
$to_date = $_REQUEST['injuryEndDate2'];
$filter_array = $_REQUEST['injury_filter'];
$filter_query = "";
$i = 0;
foreach ($filter_array as $filter) {
if($i == 0){
$filter_query .= " and injury_classes = '".$filter."'";
}else{
$filter_query .= "or injury_classes = '".$filter."'";
}
$i++;
}
// error_log("filter_query: ".print_r($_REQUEST['injury_filter'],true));
error_log("filter_query: ".$filter_query);
?><div style="font-size:22px;" align="center">Injury History Report</div>
<table width="100%" class="tbl2">
<tr><td> <br></td></tr>
<tr>
<td width="8%" align="left"><p>Run Date : <?php echo date("d-M-Y"); ?></p></td>
<td width="8%" align="left"><h5> User : <?php echo $username ?></h5></td>
<?php if(isset($from_date) && isset($to_date)){?>
<td width="8%" align="left"><p> Range : <?php echo $from_date; ?> To <?php echo $to_date ;?> </p></td>
<?php }?>
</tr>
</table>
<table border="1" width="100%">
<tr>
<th width="1%" bgcolor="yellow">Sr.</th>
<th width="3%" bgcolor="yellow">Appointment Date</th>
<th width="8%" bgcolor="yellow">Patient Name</th>
<th width="8%" bgcolor="yellow">DOB</th>
<th width="8%" bgcolor="yellow">Sex</th>
<th width="2%" bgcolor="yellow">Primary Phone</th>
<th width="2%" bgcolor="yellow">Injury Class</th>
<th width="2%" bgcolor="yellow">Injury Time</th>
</tr>
<?php
$sql_injury_report="select DISTINCT(appointment_date) from employee_appointment where appointment_date between STR_TO_DATE('".$from_date."', '%d-%m-%Y') AND STR_TO_DATE('".$to_date."', '%d-%m-%Y') and appointment_type='I' $filter_query order by appointment_date ASC ";
//echo $sql_injury_report;
error_log("sql: ".$sql_injury_report);
$result_injury_report = @mysqli_query($conn,$sql_injury_report);
$count=0;
while($row_injury_report=@mysqli_fetch_array($result_injury_report)){
$query_for_date="SELECT a.*, b.patient_name, b.dob, b.primary_phone, b.gender, c.inj_class_name FROM employee_appointment a left join patient_master b on a.emp_id = b.id left join injury_class c on c.inj_class_id = a.injury_classes where a.appointment_date='".$row_injury_report['appointment_date']."' ";
error_log("sql: ".$query_for_date);
$result_for_date=@mysqli_query($conn,$query_for_date);
while($row_for_date=@mysqli_fetch_array($result_for_date)){
$patient_name = $row_for_date['patient_name'];
$dob = $row_for_date['dob'];
$sex = $row_for_date['gender'];
$primary_phone = $row_for_date['primary_phone'];
$injury_classes = $row_for_date['inj_class_name'];
$injury_time = date_format(date_create($row_injury_report['injury_time']),"d-M-Y g:i a");
$appointment_date = date_format(date_create($row_injury_report['appointment_date']),"d-M-Y ");
}
?>
<tr>
<td text-align="left"><?php echo $count+1;?></td>
<td text-align="left"><?php echo $appointment_date;?></td>
<td text-align="left"><?php echo $patient_name;?></td>
<td text-align="left"><?php echo $dob;?></td>
<td text-align="left"><?php echo $sex;?></td>
<td text-align="left"><?php echo $primary_phone;?></td>
<td text-align="left"><?php echo $injury_classes;?></td>
<td text-align="left"><?php echo $injury_time;?></td>
</tr><?php
//$total=$total_for_yellow_mines+$total_for_yellow_plant+$total_for_red_plant+$total_for_red_mines+$total_for_white_plant+$total_for_white_mines+$total_for_blue_plant+$total_for_blue_mines;
$count++;
}
?>
</table>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>