<?php
include 'includes/auth.php';
include 'db.php';

$id = intval($_GET['id']);
$payment = $conn->query("SELECT p.*, g.name as guest_name 
                         FROM payments p 
                         JOIN guests g ON g.id=p.guest_id 
                         WHERE p.id=$id")->fetch_assoc();
if(!$payment) die("Payment not found");

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Receipt</title>
<style>
body { font-family: monospace; font-size: 14px; }
.container { width: 300px; margin: auto; }
.text-center { text-align: center; }
hr { border: dashed 1px #000; }
</style>
</head>
<body onload="window.print()">
<div class="container">
    <div class="text-center">
        <h3>RAMS EXECUTIVE LODGE</h3>
          <p class="center">
        Web:www.ramslodgemw.com<br>
        Phone:+265 993 899 382<br>
          Phone:+265 883 899 382<br>
       >
    </p>
        <p>Front Office Receipt</p>
    </div>
    <hr>
    <p><strong>Guest:</strong> <?= $payment['guest_name'] ?></p>
    <p><strong>Date:</strong> <?= date('d-M-Y H:i', strtotime($payment['payment_date'])) ?></p>
    <p><strong>Type:</strong> <?= $payment['type'] ?></p>
    <p><strong>Method:</strong> <?= $payment['method'] ?></p>
    <p><strong>Amount:</strong> MK <?= number_format($payment['amount'],2) ?></p>
    <p><strong>Description:</strong> <?= $payment['description'] ?></p>
    <hr>
    <p class="text-center">Thank you for your payment!</p>
</div>
</body>
</html>
