<?php
require 'db_connection.php';

$receipt_no = $_GET['receipt_no'] ?? '';

$stmt = $conn->prepare("
SELECT r.*, s.name, p.amount
FROM receipts r
JOIN students s ON r.student_id = s.student_id
JOIN payments p ON r.payment_id = p.payment_id
WHERE r.receipt_no=?
");
$stmt->bind_param("s", $receipt_no);
$stmt->execute();
$data = $stmt->get_result()->fetch_assoc();

if (!$data) {
    die("Invalid receipt");
}
?>

<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body class="bg-light">

<div class="container mt-5">

<div class="card p-4 shadow">

<h3>School Receipt</h3>
<hr>

<p><b>Receipt No:</b> <?= $data['receipt_no'] ?></p>
<p><b>Student:</b> <?= $data['name'] ?></p>
<p><b>Amount Paid:</b> ₦<?= number_format($data['amount']) ?></p>
<p><b>Date:</b> <?= $data['date'] ?></p>

</div>

</div>

</body>
</html>