ohctech_p8/form16_report_mis.php
2024-10-16 19:18:52 +05:30

334 lines
11 KiB
PHP

<?php
if (isset($_GET['excel']) != "YES") { ?>
<style>
@media print {
#printPageButton {
display: none;
}
}
</style>
<center>
<button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button>
</center>
<?php }
$startDate = $_POST['startDateForm16'];
$endDate = $_POST['endDateForm16'];
?>
<?php
include('includes/config/config.php');
include('log_entry.php');
include('includes/functions.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form 16 Report</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<body>
<?php
if (isset($_GET['excel']) == "YES") {
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename=form16_report'.$startDate.'To'.$endDate.'.xls');
}
include('new_pdf_header.php');
?>
<br>
<h3 style="text-align: center;">
HEALTH REGISTER FORM - 16
</h3>
<br>
<b style="text-align: center;">
Report From : <?php echo date_format(date_create($startDate), "d-M-Y"); ?> To <?php echo date_format(date_create($endDate), "d-M-Y"); ?>
</b>
<br>
<br>
<?php
if (isset($_GET['excel']) == "YES") {?>
<table width="100%" border="1">
<?php
}else{ ?>
<table width="100%" class="table table-bordered">
<?php
}
?>
<tr>
<td>
Sl No
</td>
<td>
Department
</td>
<td>
Emp Code
</td>
<td>
Name of Worker
</td>
<td>
Sex
</td>
<td>
Age (At Last Birth day)
</td>
<td>
Date of Employment on present Work
</td>
<td>
Date of Leaving or transfer to other work with reasons for discharge or transfer
</td>
<td>
Nature of Job or Occupation
</td>
<td>
Raw Materials or by products likely to be exposed to
</td>
<td>
Dates of Medical Examination and results thereof
</td>
<td>
Result - Fit/Unfit
</td>
<td>
Signs and symptom observed during Examination
</td>
<td>
Nature of Tests and Results
</td>
<td>
If declared unfit for work, state period of suspension with reasons in detaial
</td>
<td>
Whether certificate of Unfitness issued to the Worker
</td>
<td>
Recertified fit to resume duty on
</td>
<td>
Signature of the Certifying Surgeon with Date
</td>
</tr>
<?php
$department = $_POST['DepartmentForm16'];
if ($department == "ALL") {
$departmentSql = "";
} else {
$departmentSql = " AND p.dept_id = '$department'";
}
$Employee_Cate = $_POST['employeeCateForm16'];
if ($Employee_Cate == "ALL") {
$Employee_CateSql = "";
} else {
$Employee_CateSql = " AND p.patient_cat_id = '$Employee_Cate'";
}
$sqlForFetchData = "SELECT * FROM checkup_form c INNER JOIN patient_master p ON c.emp_id = p.id INNER JOIN form_32 f ON c.checkup_id = f.checkup_id WHERE c.form_type = 'form_16' AND DATE(checkup_date) BETWEEN '$startDate' AND '$endDate' $departmentSql $Employee_CateSql ";
error_log("SQL: " . $sqlForFetchData);
$result = mysqli_query($conn, $sqlForFetchData);
$count = 1;
while ($row = mysqli_fetch_assoc($result)) { ?>
<tr>
<td>
<?php
echo $count;
$count = $count + 1;
?>
</td>
<td>
<?php
$departmentId = $row['dept_id'];
echo getFieldFromTable('dept_name', 'department', 'dept_id', $departmentId);
?>
</td>
<td>
<?php
echo $row['emp_code'];
?>
</td>
<td>
<?php
echo $row['patient_name'];
?>
</td>
<td>
<?php
if ($row['gender'] == 'M') {
echo "Male";
} else if ($row['gender'] == 'F') {
echo "Female";
} else if ($row['gender'] == 'O') {
echo "Others";
}
?>
</td>
<td>
<?php
if (!empty($row['dob'])) {
$dob = $row['dob'];
echo $age = (date('Y') - date('Y', strtotime($dob)));
}
?>
</td>
<td>
<?php
if (!empty($row['dob'])) {
echo date_format(date_create($row['dob']), 'd-m-Y');
}
?>
</td>
<td>
<?php
$date_leaving = "NA";
$date_leavingVal = $row['date_leaving'];
error_log("date leaving " . $date_leavingVal);
if (empty($date_leavingVal) || $date_leavingVal == '30-Nov-0001' || $date_leavingVal == '00-00-0000' || $date_leavingVal == '0000-00-00' || $date_leavingVal == null) {
$date_leaving = 'NA';
} else {
$date_leaving = date_format(date_create($row['date_leaving']), "d-m-Y");
}
?>
</td>
<td><?php
$nature_of_job = getFieldFromTable('nature_of_job', 'department', 'dept_id', $row['dept_id']);
if ($nature_of_job == '') {
$nature_of_job = $row['nature_of_job'];
}
echo $nature_of_job;
?>
</td>
<td><?php
$raw_material_exposed = getFieldFromTable('raw_materials_exposed', 'department', 'dept_id', $row['dept_id']);
if ($raw_material_exposed == '') {
$raw_material_exposed = $row['raw_materials_exposed'];
}
echo $raw_material_exposed;
?>
</td>
<td>
<?php
if (!empty($row['checkup_date'])) {
echo date_format(date_create($row['checkup_date']), 'd-m-Y');
}
?>
</td>
<td><?php echo $row['fit_unfit_status'] ?></td>
<td>
<?php
if ($row['signs_symptoms'] != '' && $row['signs_symptoms'] != null) {
$tests_final = explode(",", $row['signs_symptoms']);
}
?>
</td>
<td>
<td width="22%">
<u><b>Test Performed: </b></u>
<?php
for ($i = 0; $i < count($tests_final); $i++) {
echo " $tests_final[$i] ";
?>
<br>
<?php
}
?>
</td>
<td>
<?php
$date_unfit = "NA";
$date_unfitVal = $row['date_unfit'];
error_log("date unfit " . $date_unfitVal);
if (empty($date_unfitVal) || $date_unfitVal == '30-Nov-0001' || $date_unfitVal == '00-00-0000' || $date_unfitVal == '0000-00-00' || $date_unfitVal == null) {
$date_unfit = 'NA';
} else {
$date_unfit = date_format(date_create($row['date_unfit']), "d-m-Y");
}
echo $date_unfit;
?>
</td>
<td>
<?php
$date_recitifed = "NA";
$date_recitifedVal = $row['date_recertified'];
error_log("date unfit " . $date_recitifedVal);
if (empty($date_recitifedVal) || $date_recitifedVal == '30-Nov-0001' || $date_recitifedVal == '00-00-0000' || $date_recitifedVal == '0000-00-00' || $date_recitifedVal == null) {
$date_recitifed = 'NA';
} else {
$date_recitifed = date_format(date_create($row['date_recertified']), "d-m-Y");
}
echo $date_recitifed;
?>
</td>
<td>
<?php
$sql_sign = "select * from employee_signature where emp_id='" . $row['doc_attend'] . "'";
$result_sign = mysqli_query($conn, $sql_sign);
$row_sign = mysqli_fetch_assoc($result_sign);
@extract($row_sign);
error_log("sign query " . $sql_sign);
?>
<img id='sign' style="align:center; width:70px; height:30px;" class="card-img-bottm" src="data:<?= $row_sign['image_type']; ?>;base64,<?= base64_encode($row_sign['emp_sign']) ?>"><br>
<hr>
<?php
echo getFieldFromTable('patient_name', 'patient_master', 'id', $row['doc_attend']);
?>
<hr>
<?php
echo $row_sign['qualification']
?>
<hr>
<?php echo $row_sign['registration_no'] ?>
</td>
</tr>
<?php
}
?>
</table>
</body>
</html>