2024-10-16 19:18:52 +05:30
< ? 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_covid_weekly_trends.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 checkup_date <='".$end_date."' ";
$qry_date .= " and medical_entry_date <=str_to_date(' " . $end_date . " ','%d-%m-%Y') " ;
}
?>
< 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 > Covid Active vs New Case </ strong ></ td >
< td align = " left " > User : < ? php echo $username ?> </td>
</ tr >
< tr style = " background: #eeeeee; " >< td >< strong > Week No .</ strong ></ td >< td >< strong > Confirm Cases </ strong ></ td >< td >< strong > Quarantine Case </ strong ></ td >< td >< strong > Discharge Case </ strong ></ td ></ tr >
< ? php
// }
$i = 0 ;
$record = array ();
// get the last 30 days of from today
$i = 0 ;
$week_count = 10 ;
$record = Array ();
$today = new DateTime (); // today
$begin = $today -> sub ( new DateInterval ( 'P10W' )); //created 30 days interval back
$end = new DateTime ();
$end = $end -> modify ( '+7 day' ); // interval generates upto last day
$interval = new DateInterval ( 'P1W' ); // 1d interval range
$daterange = new DatePeriod ( $begin , $interval , $end ); // it always runs forwards in date
foreach ( $daterange as $date ) { // date object
$new_week = date ( " W " , strtotime ( $date -> format ( " Y-m-d " ))); // your date
?> <tr><?php
// get covid confirm case in a week
$query = " SELECT count(a.emp_id) as confirm_case FROM covid_monitoring a left join patient_master b on a.emp_id = b.id WHERE YEARWEEK(a.date_added) = YEARWEEK(NOW() - INTERVAL " . $week_count . " WEEK) and a.covid_test_result_id ='2' $qry_bu group by week(date_added) " ;
// echo $query;
error_log ( 'query: ' . $query );
if ( ! $result = @ mysqli_query ( $conn , $query )) {
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
if ( mysqli_num_rows ( $result ) > 0 ) {
while ( $row = @ mysqli_fetch_assoc ( $result )) {
$record [ $i ][ 'confirm_case' ] = $row [ 'confirm_case' ];
$record [ $i ][ 'week' ] = $new_week ;
?> <td><?php echo $new_week;?></td><td><?php echo $row['confirm_case']?></td><?php
}
} else {
$record [ $i ][ 'confirm_case' ] = 0 ;
$record [ $i ][ 'week' ] = $new_week ;
?> <td><?php echo $new_week;?></td><td>0</td><?php
}
$quarantine_query = " SELECT count(a.emp_id) as quarantine_case FROM covid_monitoring a left join patient_master b on a.emp_id = b.id WHERE YEARWEEK(a.date_added) = YEARWEEK(NOW() - INTERVAL $week_count WEEK) $qry_bu group by week(a.date_added) " ;
// echo $query;
// error_log('query: '.$query);
if ( ! $quarantine_result = @ mysqli_query ( $conn , $quarantine_query )) {
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
if ( mysqli_num_rows ( $quarantine_result ) > 0 ) {
while ( $row = @ mysqli_fetch_assoc ( $quarantine_result )) {
$record [ $i ][ 'quarantine_case' ] = $row [ 'quarantine_case' ];
$record [ $i ][ 'week' ] = $new_week ;
?> <td><?php echo $row['quarantine_case']?></td><?php
}
} else {
$record [ $i ][ 'quarantine_case' ] = 0 ;
$record [ $i ][ 'week' ] = $new_week ;
?> <td>0</td><?php
}
$discharge_query = " SELECT count(a.emp_id) as discharge FROM covid_monitoring a left join patient_master b on a.emp_id = b.id WHERE YEARWEEK(a.discharge_on) = YEARWEEK(NOW() - INTERVAL $week_count WEEK) $qry_bu group by week(a.discharge_on) " ;
// echo $discharge_query;
// error_log('discharge_query: '.$discharge_query);
if ( ! $discharge_result = @ mysqli_query ( $conn , $discharge_query )) {
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
if ( mysqli_num_rows ( $discharge_result ) > 0 ) {
while ( $row = @ mysqli_fetch_assoc ( $discharge_result )) {
$record [ $i ][ 'discharge' ] = $row [ 'discharge' ];
$record [ $i ][ 'week' ] = $new_week ;
?> <td><?php echo $row['discharge'];?></td><?php
}
} else {
$record [ $i ][ 'discharge' ] = 0 ;
$record [ $i ][ 'week' ] = $new_week ;
?> <td>0</td><?php
}
?> </tr><?php
$week_count -- ;
$i ++ ;
}
?>
</ table >
</ body >