<?php
@error_reporting(0);
include('../includes/config.php');
$q=$_GET['txn_id']??'';if(!$q)die('Invalid');

$r=mysqli_query($tng_conn,"SELECT * FROM recharge_history WHERE agentid='$q' LIMIT 1");
if($r&&mysqli_num_rows($r)>0){$d=mysqli_fetch_assoc($r);$u=$d['userid'];
$s=mysqli_query($tng_conn,"SELECT name,phone FROM users WHERE phone='$u' LIMIT 1");
$x=mysqli_num_rows($s)>0?mysqli_fetch_assoc($s):[];$b=$x['name']??'Unknown';
$o=$d['operator'];$c=$d['mobile'];$a=$d['amount'];$t=$d['opid'];$i=$d['agentid'];$dt=$d['date'];$st=$d['status'];$m=$d['msg'];}else die('No');
?>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1.0"><title>Receipt#<?php echo $i?></title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css"><style>body{background:#f0f2f5;font-family:sans-serif}.r{max-width:720px;margin:50px auto;background:#fff;border-radius:15px;padding:40px;box-shadow:0 12px 30px rgba(0,0,0,0.2);border-top:12px solid #007bff}.h{display:flex;justify-content:space-between;align-items:center;border-bottom:2px dashed #ddd;padding-bottom:15px;margin-bottom:30px}.h h2{color:#007bff;font-weight:700;margin:0;font-size:28px}.h small{color:#555;font-size:14px}.h img{width:80px}.table{border-radius:8px;overflow:hidden}.table th{background:#f8f9fa;font-weight:600;color:#333}.table td,.table th{vertical-align:middle!important;font-size:15px;padding:12px 15px}.s{color:#28a745;font-weight:600;font-size:16px}.f{font-size:13px;color:#888;text-align:center;margin-top:30px}@media print{body{background:#fff}.r{box-shadow:none;border-top:none}}</style></head>
<body onload="window.print()">
<div class="r"><div class="h"><div><h2>Recharge</h2><small><b>Date:</b><?php echo $dt?></small><br><small><b>Invoice:</b><?php echo $i?></small></div><div><img src="<?php echo XyZ_val('logo'); ?>" alt="logo"></div></div>
<table class="table table-bordered"><tbody>
<tr><th>BC Name</th><td><?php echo $b?></td></tr>
<tr><th>Provider</th><td><?php echo $o?></td></tr>
<tr><th>Consumer ID</th><td><?php echo $c?></td></tr>
<tr><th>Paid Amount</th><td><b>₹ <?php echo $a?></b></td></tr>
<tr><th>Transaction ID</th><td><?php echo $t?></td></tr>
<tr><th>Invoice Number</th><td><?php echo $i?></td></tr>
<tr><th>Message</th><td class="s"><?php echo $m?></td></tr>
<tr><th>Status</th><td class="s"><?php echo $st?></td></tr>
</tbody></table><div class="f"><p><b>Note:</b> System-generated receipt, no signature required.</p></div></div></body></html>
