<?php
// manage_photos.php
// Thin standalone wrapper around includes/photo_manager.php, used for jobs
// that are normally edited inside an AJAX-loaded modal (Appliance/Misc via
// view_appliance_job.php) where a normal redirecting upload form can't
// live directly inside the modal. Opens in a new tab from a "Manage
// Photos" button instead.

require 'db.php';

$jobPkId = isset($_GET['job_id']) ? (int) $_GET['job_id'] : 0;

$check = $pdo->prepare("SELECT ID, Job_No FROM tbl_jobs WHERE ID = ?");
$check->execute([$jobPkId]);
$job = $check->fetch(PDO::FETCH_ASSOC);

if (!$job) {
    die('Job not found.');
}

$currentPageUrl = 'manage_photos.php?job_id=' . $jobPkId;
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Photos - <?= htmlspecialchars($job['Job_No']); ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container my-4" style="max-width: 800px;">
    <h5 class="mb-3">Inspection Photos — <?= htmlspecialchars($job['Job_No']); ?></h5>
    <?php include 'includes/photo_manager.php'; ?>
    <button type="button" class="btn btn-secondary btn-sm" onclick="window.close();">Close</button>
</div>
</body>
</html>
