csrtechnew.ohctech.in/registration_of_trainees_form_excel.php
2025-04-14 13:28:09 +05:30

86 lines
3.2 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
// Set headers for Excel file download
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=registration_of_trainees_form_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ERROR | E_PARSE);
$startDate = date('Y-m-d', strtotime($_POST['startDate_regi']));
$endDate = date('Y-m-d', strtotime($_POST['endDate_regi']));
$ohc = $_SESSION['current_ohcttype'];
// Log for debugging
error_log("Start date: " . $startDate);
error_log("End date: " . $endDate);
$sql = "SELECT pm.*, be.patient_id
FROM patient_master pm
INNER JOIN beneficiary_enquiry be
ON pm.id = be.patient_id
WHERE DATE(be.enquiry_date) BETWEEN STR_TO_DATE('$startDate', '%Y-%m-%d')
AND STR_TO_DATE('$endDate', '%Y-%m-%d')
AND be.ohc_type_id = '$ohc'";
$result = mysqli_query($conn, $sql);
if (!$result) {
die('Invalid query: ' . mysqli_error($conn));
}
echo '<table border="1" width="100%" cellspacing="0">';
echo '<tr bgcolor="#eeeeee">';
echo '<td>Sr.</td>';
echo '<td>Full Name</td>';
echo '<td>Gender</td>';
echo '<td>DOB</td>';
echo '<td>Email ID</td>';
echo '<td>Marital Status</td>';
echo '<td>Father Name</td>';
echo '<td>Guardians Name</td>';
echo '<td>Religion</td>';
echo '<td>Category</td>';
echo '<td>Disability</td>';
echo '<td>Type of Disability</td>';
echo '<td>Domicile State</td>';
echo '<td>Domicile District</td>';
echo '<td>ID Type</td>';
echo '<td>Type of Alternate ID</td>';
echo '<td>Mobile No</td>';
echo '<td>Education Level</td>';
echo '<td>Tehsil</td>';
echo '</tr>';
$count = 1;
while ($row1 = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>' . $count . '</td>';
echo '<td>' . htmlspecialchars($row1['patient_name']) . '</td>';
echo '<td>' . ($row1['gender'] == 'M' ? 'Male' : 'Female') . '</td>';
echo '<td>' . date('d-m-Y', strtotime($row1['dob'])) . '</td>';
echo '<td>' . htmlspecialchars($row1['email_id']) . '</td>';
echo '<td>' . htmlspecialchars($row1['marital_status']) . '</td>';
echo '<td>' . htmlspecialchars($row1['father_name']) . '</td>';
echo '<td>' . htmlspecialchars($row1['guardians_name']) . '</td>'; // Assuming this field exists
echo '<td>' . htmlspecialchars($row1['religen']) . '</td>';
echo '<td>' . getFieldFromTable('category_name', 'beneficiary_category', 'id', $row1['beneficiary_category']) . '</td>';
echo '<td>' . ($row1['disabilty'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . htmlspecialchars($row1['disabilty']) . '</td>';
echo '<td>' . getFieldFromTable('name', 'states', 'id', $row1['state']) . '</td>';
echo '<td>' . getFieldFromTable('name', 'districts', 'id', $row1['district']) . '</td>';
echo '<td>' . htmlspecialchars($row1['identity_type']) . '</td>';
echo '<td>' . htmlspecialchars($row1['identity_number']) . '</td>';
echo '<td>' . htmlspecialchars($row1['primary_phone']) . '</td>';
echo '<td>' . getFieldFromTable('qualification', 'qualification', 'id', $row1['education']) . '</td>';
echo '<td>' . getFieldFromTable('name', 'tehsils', 'id', $row1['tehsil']) . '</td>';
echo '</tr>';
$count++;
}
echo '</table>';
?>