csrtechnew.ohctech.in/batch_fees_report_excel.php
2025-08-29 16:30:39 +05:30

114 lines
3.6 KiB
PHP

<?php //include('pdf_header_reverse.php');
include('includes/config/config.php');
include('includes/functions.php');
//include('pop_up_top.php');
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=batch_wise_fees_reports_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ERROR | E_PARSE);
$startDate = date('Y-m-d', strtotime($_POST['startDate_enroll']));
$endDate = date('Y-m-d', strtotime($_POST['endDate_enroll']));
$ohc = $_SESSION['current_ohcttype'];
$sql = "SELECT pm.*, eb.beneficiary_id,te.batch_id
FROM patient_master pm
INNER JOIN training_batch_enrollment_beneficiary eb ON pm.id = eb.beneficiary_id
INNER JOIN training_batch_enrollment te ON eb.batch_pri_tbl_id = te.id
WHERE DATE(te.batch_start_date) BETWEEN STR_TO_DATE('2024-01-01', '%Y-%m-%d') AND STR_TO_DATE('2024-12-31', '%Y-%m-%d') AND te.ohc_type_id=$ohc";
error_log($sql . "get sql");
$result = mysqli_query($conn, $sql);
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<body>
<?php
$max_total = 0;
$max_scored = 0;
$queryc = "SELECT * FROM company_profile";
$resultc = mysqli_query($conn, $queryc);
$row_company = mysqli_fetch_array($resultc);
@extract($row_company);
?>
<div class="report-header row">
<div class="col-md-6">
<strong>Duration: <?php echo date("d-M-Y", strtotime($startDate)); ?> to <?php echo date("d-M-Y", strtotime($endDate)); ?></strong>
</div>
<div class="col-md-6 text-md-center">
<strong>Batch Name: </strong><?php echo getFieldFromTable('batch_name', 'training_batch_master', 'batch_id', $batch_id); ?>
</div>
</div>
<div>
<div class="col-md-12">
<h4 class="text-center">Batch Wise Fees Report</h4>
</div>
<table class="table table-bordered table-custom">
<thead class="thead-light">
<tr>
<th>Sr.No</th>
<th>Trainee Name</th>
<th>Fees</th>
<th>Receipt No</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM fee_collection
WHERE date(collection_date) BETWEEN STR_TO_DATE('" . $startDate . "', '%Y-%m-%d')
AND STR_TO_DATE('" . $endDate . "', '%Y-%m-%d')
AND ohc_type_id='" . $_SESSION['current_ohcttype'] . "'
AND batch_name = $batch_id";
error_log($sql . " get sql");
$result = mysqli_query($conn, $sql);
$count = 1;
$total_fee = 0; // Initialize total
while ($row1 = mysqli_fetch_assoc($result)) {
extract($row1);
$total_fee += $row1['fee_amount']; // Add to total
?>
<tr>
<td><?php echo $count; ?></td>
<td><?php echo getFieldFromTable('patient_name', 'patient_master', 'id', $row1['beneficiary_name']); ?></td>
<td><?php echo number_format($row1['fee_amount'], 2); ?></td>
<td><?php echo $row1['fee_collection_id']; ?></td>
<td><?php echo date('d-m-Y', strtotime($row1['collection_date'])); ?></td>
</tr>
<?php
$count++;
}
?>
<!-- Total Row -->
<tr>
<td colspan="2" class="text-cemter"><strong>Total Batch Fees</strong></td>
<td><strong><?php echo number_format($total_fee, 2); ?></strong></td>
<td colspan="2"></td>
</tr>
</tbody>
</table>
</body>
<script>
$(document).ready(function() {
window.print();
});
</script>