<?php
require_once '../../private/db.php';

$id=(int)($_GET['id'] ?? 0);

$stmt=$pdo->prepare("SELECT * FROM cash_receipts WHERE id=? LIMIT 1");
$stmt->execute([$id]);

$receipt=$stmt->fetch();

if(!$receipt){
die('Receipt not found');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Receipt</title>
</head>
<body onload="window.print()">

<h1>Executive Protection Institute</h1>

<p>Invoice: <?= htmlspecialchars($receipt['invoice_number']) ?></p>

<p>Date: <?= htmlspecialchars($receipt['created_at']) ?></p>

<hr>

<pre><?= htmlspecialchars($receipt['receipt_text']) ?></pre>

<h3>Total: $<?= number_format((float)$receipt['total'],2) ?></h3>

</body>
</html>
