<?php
require_once __DIR__.'/../includes/functions.php'; $admin=require_admin(); mj263_schema(); $adminTitle='Listing Public Check';
$id=(int)($_GET['id']??0); $l=$id?one('SELECT * FROM mj_listings WHERE id=? LIMIT 1',[$id]):null; include __DIR__.'/_header.php'; ?>
<div class="card card-info card-outline"><div class="card-header"><h3 class="card-title"><i class="fas fa-eye mr-2"></i>Why Not Showing Public?</h3></div><div class="card-body"><form class="form-inline mb-3"><input class="form-control mr-2" name="id" value="<?=e($id)?>" placeholder="Listing ID"><button class="btn btn-primary">Check</button></form><?php if(!$id): ?><div class="alert alert-info">Enter listing ID.</div><?php elseif(!$l): ?><div class="alert alert-danger">Listing does not exist.</div><?php else: [$ok,$reason]=mj263_visible_reason($l); $imgs=mj263_listing_images($id); $pending=mj263_pending_revision($id); ?><h4><?=e($l['title']??'Listing')?> <span class="badge badge-<?=$ok?'success':'danger'?>"><?=$ok?'Visible':'Hidden'?></span></h4><div class="alert alert-<?=$ok?'success':'warning'?>"><?=e($reason)?></div><table class="table table-bordered"><tr><th>Status</th><td><?=e($l['status']??'')?></td></tr><tr><th>Deleted</th><td><?=e(($l['is_deleted']??0).' / '.($l['deleted_at']??''))?></td></tr><tr><th>Expiry</th><td><?=e($l['expires_at']??'')?></td></tr><tr><th>Country / State / City</th><td><?=e(($l['country_id']??''). ' / '.($l['state_id']??'').' / '.($l['city_id']??''))?></td></tr><tr><th>Category</th><td><?=e($l['category_id']??'')?></td></tr><tr><th>Images</th><td><?=count($imgs)?></td></tr><tr><th>Pending edit</th><td><?= $pending ? 'Yes, revision #'.e($pending['id']) : 'No' ?></td></tr><tr><th>Public URL</th><td><a target="_blank" href="../listing.php?id=<?=$id?>">../listing.php?id=<?=$id?></a></td></tr></table><a class="btn btn-primary" href="listing-edit.php?id=<?=$id?>">Edit Listing</a> <a class="btn btn-secondary" target="_blank" href="../listing.php?id=<?=$id?>">Open Public URL</a><?php endif; ?></div></div><?php include __DIR__.'/_footer.php'; ?>
