<?php
require 'config.php';
require 'includes/db.php';
echo "<table border='1' cellpadding='10'>";
echo "<tr><th>ID</th><th>Template Name</th><th>System Slug</th><th>Image File Exists?</th><th>Image Preview</th></tr>";
$stmt = $pdo->query("SELECT id, name, slug FROM templates ORDER BY id ASC");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $slug = $row['slug'];
    $imgPath = __DIR__ . '/assets/landing/' . $slug . '.png';
    $exists = file_exists($imgPath) ? 'YES' : 'NO';
    $url = SITE_URL . '/assets/landing/' . $slug . '.png';
    echo "<tr>";
    echo "<td>{$row['id']}</td>";
    echo "<td>{$row['name']}</td>";
    echo "<td>{$slug}</td>";
    echo "<td>{$exists}</td>";
    echo "<td>" . ($exists == 'YES' ? "<img src='{$url}' width='50'>" : "") . "</td>";
    echo "</tr>";
}
echo "</table>";
?>

