<?php
require_once __DIR__.'/includes/functions.php'; mj263_schema();
$id=(int)($_GET['id']??0); $l=safe_one_public('SELECT l.*, c.name country_name, ci.name city FROM mj_listings l LEFT JOIN mj_countries c ON c.id=l.country_id LEFT JOIN mj_cities ci ON ci.id=l.city_id WHERE l.id=? LIMIT 1',[$id]); if(!$l){http_response_code(404);exit('Listing not found');}
$img=''; $imgs=mj263_listing_images($id); if($imgs) $img=$imgs[0]['image_path']; $url=mj263_listing_url($l); $qr=mj263_qr_url($url,360);
?><!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>QR Poster</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"><style>body{background:#f3f4f6}.poster{max-width:760px;margin:30px auto;background:white;border-radius:28px;padding:42px;box-shadow:0 20px 60px rgba(0,0,0,.15);text-align:center}.photo{max-height:360px;width:100%;object-fit:cover;border-radius:22px}.qr{border:12px solid #f8fafc;border-radius:24px}</style></head><body><div class="poster"><h5 class="text-primary fw-bold">MJ Marketplace</h5><h1 class="fw-bold"><?=e($l['title'])?></h1><p class="text-muted"><?=e(($l['city']??'').' '.($l['country_name']??''))?></p><?php if($img): ?><img class="photo mb-4" src="<?=e(base_url($img))?>"><?php endif; ?><h2 class="text-success fw-bold mb-3"><?=money($l['price']??0,$l['currency_code']??'SGD')?></h2><img class="qr" src="<?=e($qr)?>" width="260" height="260"><h4 class="mt-3">Scan to view this listing</h4><p class="small text-muted"><?=e($url)?></p><button onclick="window.print()" class="btn btn-primary rounded-pill px-4">Print Poster</button></div></body></html>
