<? // 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_emp_report_list.xls'); ?> <body> <table border="1" width="100%"> <?php include('includes/config/config.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']; $start_date = $_REQUEST['startDate']; $end_date = $_REQUEST['endDate']; $year = implode(',', $_REQUEST['year']); $month = implode(',', $_REQUEST['month']); $year2 = implode(',', $_REQUEST['year']); $year1 = explode(',', $year); // $year1 = array(2020,2021); error_log("values::" . $ohc_location . " " . $patient_category . " " . $dept . " " . $emp_designation . " " . $emp_cadre . " " . $employer_contractor . " " . $gender . " " . $start_date . " " . $end_date . " " . $year . " " . $month); $qry_filter = ""; if (isset($dept) && $dept != '') { $qry_filter .= " and 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_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 . ")"; } ?> <tr> <td align="center"> <strong style="text-decoration-color: white;">AGE WISE EMP WITH TOBACCO HABIT DISTRIBUTION REPORT</strong> </td> </tr> <tr bgcolor="yellow"> <td align="left"> Run Date : <?php echo date("d-M-Y"); ?> User : <?php echo $username ?></td> </tr> <tr> <? if (isset($start_date) && isset($end_date)) { ?> <td> <strong>Filters Applied-</strong> <u>Range:</u><?php echo $start_date; ?> to <?php echo $end_date; ?>, <u>EMPLOYER/CONTRACTOR:</u><?phpif ($employer_contractor == '') { echo "ALL"; } else ?><?php echo getTableFieldValue(' employer_contractor', 'employer_contractor_name', 'id', $employer_contractor); ?>, <u>Gender:</u><?phpif ($gender == '') { echo "ALL"; } else ?><?php echo $gender; ?>, <u>OHC Location:</u><?phpif ($ohc_type == '') { echo "ALL"; } else ?><?php echo getTableFieldValue('ohc_type', 'ohc_type_name', 'ohc_type_id', $ohc_type); ?>, <u>Patient Category:</u><?phpif ($patient_category == '') { echo "ALL"; } else ?><?php echo getTableFieldValue('patient_category', 'patient_cat_name', 'patient_cat_id', $patient_category); ?>, <u>Department:</u><?phpif ($dept == '') { echo "ALL"; } else ?><?php echo getTableFieldValue('department', 'dept_name', 'dept_id', $dept); ?>, <u>Designation:</u><?phpif ($emp_designation == '') { echo "ALL"; } else ?><?php echo getTableFieldValue(' designation', 'designation_name', 'designation_id', $emp_designation); ?>, <u>Employee Cadre:</u><?phpif ($emp_cadre == '') { echo "ALL"; } else ?><?php echo getTableFieldValue(' emp_cadre', 'emp_cadre', 'emp_cadre_id', $emp_cadre); ?>, <u>Month:</u><?phpif ($month == '') { echo "ALL"; } else ?><?php echo $month; ?>, <u>Year:</u><?phpif ($year == '') { echo "ALL"; } else ?><?php echo $year; ?> </td> </tr> <? if (isset($year) && $year != '' && count($year1) > 1) { for ($j = 0; $j < count($year1); $j++) { error_log("year:" . $year1[$j] . " size:" . count($year1)); $qry_date = ""; $qry_doj = ""; $qry_date .= "and year(medical_entry_date) ='" . $year1[$j] . "'"; $qry_doj .= "and year(doj) <= '" . $year1[$j] . "'"; $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=18 and YEAR(CURDATE())-year(p.dob)<25 and status='Active' $qry_filter $qry_doj) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center"> For Year <?= $year1[$j] ?> </td> </tr> <tr bgcolor="#eeeeee"> <td align="center">Age in years(18-25)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=25 and YEAR(CURDATE())-year(p.dob)<30 and status='Active' $qry_filter $qry_doj) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(25-30)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=30 and YEAR(CURDATE())-year(p.dob)<40 and status='Active' $qry_filter $qry_doj) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(30-40)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=40 and YEAR(CURDATE())-year(p.dob)<50 and status='Active' $qry_filter $qry_doj) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(40-50)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=50 and status='Active' $qry_filter $qry_doj) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(>=50)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } ?> <? } } else { if (isset($year2) && $year2 != '') { $qry_date .= " and year(medical_entry_date) ='" . $year2 . "'"; $qry_filter .= " and year(doj) <= '" . $year2 . "'"; } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=18 and YEAR(CURDATE())-year(p.dob)<25 and status='Active' $qry_filter) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(18-25)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=25 and YEAR(CURDATE())-year(p.dob)<30 and status='Active' $qry_filter) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(25-30)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=30 and YEAR(CURDATE())-year(p.dob)<40 and status='Active' $qry_filter) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(30-40)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=40 and YEAR(CURDATE())-year(p.dob)<50 and status='Active' $qry_filter) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(40-50)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } $query = "SELECT max(medical_exam_id),m.tobacco,p.patient_name from medical_examination m right join patient_master p on m.patient_id = p.id where patient_id in (SELECT id FROM patient_master p where YEAR(CURDATE())-year(p.dob)>=50 and status='Active' $qry_filter) $qry_date1 $qry_date and m.tobacco='1' GROUP by patient_id"; $result = mysqli_query($conn, $query); ?> <tr> <td align="center">Age in years(>=50)</td> </tr> <tr> <td align="center">Patient Name</td> </tr> <? error_reporting(E_ERROR | E_PARSE); if (mysqli_num_rows($result)) { while ($rowOfEmployee = mysqli_fetch_array($result)) { ?> <tr> <td align="left"><?= $rowOfEmployee['patient_name'] ?></td> </tr><? } } else { ?> <tr> <td align="left">No Records</td> </tr> <? } } } ?> </table> </body>