csrtechnew.ohctech.in/fees_report_excel.php

62 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2025-04-14 13:28:09 +05:30
<?php
include('includes/config/config.php');
include('includes/functions.php');
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=fees_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ERROR | E_PARSE);
$startDate = date('Y-m-d', strtotime($_POST['startDate_fees']));
$endDate = date('Y-m-d', strtotime($_POST['endDate_fees']));
?>
<body>
<table width="100%">
<tr>
<td style="font-size: 15px;"><strong style="margin-left: 400px">Fees Report</strong></td>
</tr>
<tr>
<td align="left" style="font-size: 12px"><strong>Duration: <?php echo date("d-M-Y", strtotime($startDate)); ?> to <?php echo date("d-M-Y", strtotime($endDate)); ?></strong></td>
</tr>
</table>
<br>
<table width="100%" cellspacing="0" border="1">
<tr>
<td>Sr.No</td>
<td>Trainee Name</td>
<td>Fees</td>
<td>Receipt No</td>
<td>Date</td>
</tr>
<?php
$count = 1;
// Prepare the SQL statement to prevent SQL injection
$stmt = $conn->prepare("SELECT * FROM fee_collection WHERE date(collection_date) BETWEEN ? AND ? AND ohc_type_id = ?");
$stmt->bind_param("ssi", $startDate, $endDate, $_SESSION['current_ohcttype']);
$stmt->execute();
$result = $stmt->get_result();
while ($row1 = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $count; ?></td>
<td><?php echo getFieldFromTable('patient_name', 'patient_master', 'id', $row1['beneficiary_name']); ?></td>
<td><?php echo $row1['fee_amount']; ?></td>
<td><?php echo $row1['fee_collection_id']; ?></td>
<td><?php echo date('d-m-Y', strtotime($row1['collection_date'])); ?></td>
</tr>
<?php
$count++;
}
$stmt->close();
?>
</table>
</body>