csrtechnew.ohctech.in/patient_master_data_excel.php

167 lines
4.8 KiB
PHP
Raw Normal View History

2025-04-14 13:28:09 +05:30
<?php
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=excel_emp_list.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
include ('includes/config/config.php');
include ('includes/functions.php');
$pat_cat_id = $_POST['pat_cat_id'] ?? '';
$plant_code = $_POST['plant_code'] ?? '';
$grade_code = $_POST['grade_code'] ?? '';
$query_parts = [];
if (!empty($pat_cat_id)) {
$query_parts[] = "patient_cat_id = '" . mysqli_real_escape_string($conn, $pat_cat_id) . "'";
}
if (!empty($plant_code)) {
$query_parts[] = "plant_id = '" . mysqli_real_escape_string($conn, $plant_code) . "'";
}
if (!empty($grade_code)) {
$query_parts[] = "grade_id = '" . mysqli_real_escape_string($conn, $grade_code) . "'";
}
$query_filter = "";
if (!empty($query_parts)) {
$query_filter = " WHERE " . implode(" AND ", $query_parts);
}
?>
<table border="1" width="100%">
<?php
$sql = "select * from view_patient_master" . $query_filter;
error_log("query " . $sql);
$result = mysqli_query($conn, $sql);
?>
<tr>
<th>EMP Code</th>
<th>Patient Name</th>
<th>Father Name</th>
<th>Designation</th>
<th>Department</th>
<th>Aadhar No</th>
<th>Date Of Joining</th>
<th>Date Of Birth</th>
<th>Age</th>
<th>Ohc</th>
<th>Gender</th>
<th>Blood Group</th>
<th>Primary phone</th>
<th>Grade</th>
<th>Plant</th>
<th>Email</th>
<th>Status</th>
<th>Is First Aider</th>
</tr>
<?php
$count = 0;
error_reporting(E_ERROR | E_PARSE);
while ($rowOfEmployee = mysqli_fetch_array($result)) {
$count = $count + 1;
$doj = trim($rowOfEmployee['doj']);
if ($doj == '0000-00-00' || $doj == null || $doj == '30/11/-0001' || $doj == '1970-01-01') {
$doj = "Not Available";
} else {
$doj = trim($doj);
}
$dob = trim($rowOfEmployee['dob']);
if ($dob == '0000-00-00' || $dob == null || $dob == '30/11/-0001' || $dob == '1970-01-01') {
$dob = "Not Available";
} else {
$dob = trim($dob);
}
$age = 0;
if ($dob == '0000-00-00' || $dob == null || $dob == '30/11/-0001' || $row_employee['dob'] == '1970-01-01') {
$age = "Not Available";
} else {
$birthday = DateTime::createFromFormat('Y-m-d', $dob, new DateTimeZone('Asia/Kolkata'));
if ($birthday !== false) {
$currentDate = new DateTime(null, new DateTimeZone('Asia/Kolkata'));
$interval = $birthday->diff($currentDate);
$age = $interval->y;
}
}
$ohc = '';
if ($rowOfEmployee['ohc_type_id'] != '') {
$ohc = getFieldFromTable('ohc_type_name', 'ohc_type', 'ohc_type_id', $rowOfEmployee['ohc_type_id']);
}
$status = $rowOfEmployee['status'];
?>
<tr>
<td>
<?php echo $rowOfEmployee['emp_code'] ?>
</td>
<td>
<?php echo $rowOfEmployee['patient_name'] ?>
</td>
<td>
<?php echo $rowOfEmployee['father_name'] ?>
</td>
<td>
<?php echo $rowOfEmployee['designation_name'] ?>
</td>
<td>
<?php echo $rowOfEmployee['dept_name'] ?>
</td>
<td>
<?php echo $rowOfEmployee['aadhar_no'] ?>
</td>
<td>
<?php echo $doj ?>
</td>
<td>
<?php echo $dob ?>
</td>
<td>
<?php echo $age ?>
</td>
<td>
<?php echo $ohc ?>
</td>
<td>
<?php echo $rowOfEmployee['gender'] ?>
</td>
<td>
<?php echo $rowOfEmployee['blood_group'] ?>
</td>
<td>
<?php echo $rowOfEmployee['primary_phone'] ?>
</td>
<td>
<?php echo getFieldFromTable('grade_name', 'grade_master', 'grade_id', $rowOfEmployee['grade_id']); ?>
</td>
<td>
<?php echo getFieldFromTable('plant_name', 'plant_master', 'plant_id', $rowOfEmployee['plant_id']); ?>
</td>
<td>
<?php echo $rowOfEmployee['offiial_email_id']; ?>
</td>
<td>
<?php echo $status ?>
</td>
<td>
<?php echo $rowOfEmployee['is_first_aid'] == 1 ? 'Yes' : 'No' ?>
</td>
</tr>
<?php
}
?>
</table>