csrtechnew.ohctech.in/beneficiary_enquiry_pdf.php
2025-10-16 15:19:10 +05:30

109 lines
4.3 KiB
PHP

<?php
include('pdf_header.php');
include('includes/config/config.php');
// Sanitize allowed search fields
$allowedFields = ['beneficiary_name', 'gender', 'dob', 'trainees_no', 'parents_no', 'reference_from', 'addmission_status', 'state', 'tehsil', 'district'];
$qtype = isset($_POST['qtype']) && in_array($_POST['qtype'], $allowedFields) ? $_POST['qtype'] : '';
$query = isset($_POST['query']) ? trim($_POST['query']) : '';
// Build search condition
$ohc_type_id = "ohc_type_id = " . intval($_SESSION['current_ohcttype']);
$searchSql = ($qtype && $query)
? "WHERE UPPER($qtype) LIKE UPPER('%" . mysqli_real_escape_string($conn, $query) . "%')
AND ($ohc_type_id)
AND (addmission_status = 'enroll' OR addmission_status = 'BPE')"
: "WHERE ($ohc_type_id)
AND (addmission_status = 'enroll' OR addmission_status = 'BPE' OR addmission_status = '')";
// Run beneficiary query
$sql = "SELECT * FROM beneficiary_enquiry $searchSql";
$result = mysqli_query($conn, $sql);
if (!$result) {
die("Error executing query: " . mysqli_error($conn));
}
// Fetch company details
$company = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM company_profile"));
?>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 14px; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; font-weight: bold; }
tr:nth-child(even) { background-color: #f9f9f9; }
</style>
<!-- Header -->
<table>
<tr>
<td width="20%">
<?php if (!empty($company['company_logo'])): ?>
<img src="data:<?php echo $company['image_type'] ?>;base64,<?php echo base64_encode($company['company_logo']) ?>" style="width: 150px; height: 60px;">
<?php endif; ?>
</td>
<td width="60%" align="center">
<strong><?php echo $company['company_name'] ?></strong><br>
<small>Vocational Training Institute</small>
</td>
<td width="20%" align="right">
User: <?php echo htmlspecialchars($_SESSION['username']) ?>
</td>
</tr>
</table>
<h3 style="text-align: center;">Beneficiary Enquiry List</h3>
<!-- Table -->
<table>
<thead>
<tr>
<th>Sr.</th>
<th>Date of Enquiry</th>
<th>Name</th>
<th>Program</th>
<th>Gender</th>
<th>State</th>
<th>Tehsil</th>
<th>District</th>
<th>Date of Birth</th>
<th>Trainee No</th>
<th>Parents No</th>
<th>Education</th>
<th>Reference</th>
</tr>
</thead>
<tbody>
<?php
$count = 1;
while ($row = mysqli_fetch_assoc($result)) {
$state = getFieldFromTable('name', 'states', 'id', $row['state']);
$tehsil = getFieldFromTable('name', 'tehsils', 'id', $row['tehsil']);
$district = getFieldFromTable('name', 'districts', 'id', $row['district']);
$subject_name = getCommaSeperatedValuesForInClause("SELECT name FROM courses", "id", $row['subject']);
$education = getFieldFromTable('qualification', 'qualification', 'id', $row['education']);
$dob = ($row['dob'] && $row['dob'] != '0000-00-00') ? date("d-m-Y", strtotime($row['dob'])) : '';
$doe = ($row['enquiry_date'] && $row['enquiry_date'] != '0000-00-00') ? date("d-m-Y", strtotime($row['enquiry_date'])) : '';
?>
<tr>
<td><?= $count++ ?></td>
<td><?= $doe ?></td>
<td><?= htmlspecialchars($row['beneficiary_name']) ?></td>
<td><?= htmlspecialchars($subject_name) ?></td>
<td><?= htmlspecialchars($row['gender']) ?></td>
<td><?= htmlspecialchars($state) ?></td>
<td><?= htmlspecialchars($tehsil) ?></td>
<td><?= htmlspecialchars($district) ?></td>
<td><?= $dob ?></td>
<td><?= htmlspecialchars($row['trainees_no']) ?></td>
<td><?= htmlspecialchars($row['parents_no']) ?></td>
<td><?= htmlspecialchars($education) ?></td>
<td><?= htmlspecialchars($row['reference_from']) ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php include('pdf_footer.php'); ?>