����JFIF��`�`�����Viewing File: /home/u820193700/domains/throtllr.in/public_html/admin/edit_bike.php
<?php
require_once '../includes/db.php';
require_once '../includes/functions.php';
require_once '../includes/bike_models.php';
if(!is_logged_in()) { redirect("login.php"); }

$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if (!$id) redirect('manage_bikes.php');

$stmt = $pdo->prepare("SELECT * FROM bikes WHERE id = ?");
$stmt->execute([$id]);
$bike = $stmt->fetch();
if (!$bike) redirect('manage_bikes.php');

// Handle individual media deletion
if (isset($_GET['delete_gallery_id'])) {
    $del_gal_id = (int)$_GET['delete_gallery_id'];
    $imgStmt = $pdo->prepare("SELECT image_url FROM bike_images WHERE id = ? AND bike_id = ?");
    $imgStmt->execute([$del_gal_id, $id]);
    $imgUrl = $imgStmt->fetchColumn();
    if ($imgUrl) {
        $filePath = '../' . $imgUrl;
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        $delStmt = $pdo->prepare("DELETE FROM bike_images WHERE id = ?");
        $delStmt->execute([$del_gal_id]);
    }
    redirect("edit_bike.php?id=" . $id);
}

if (isset($_GET['delete_video'])) {
    $vidStmt = $pdo->prepare("SELECT video_url FROM bike_videos WHERE bike_id = ?");
    $vidStmt->execute([$id]);
    $vidUrl = $vidStmt->fetchColumn();
    if ($vidUrl) {
        $filePath = '../' . $vidUrl;
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        $delStmt = $pdo->prepare("DELETE FROM bike_videos WHERE bike_id = ?");
        $delStmt->execute([$id]);
    }
    redirect("edit_bike.php?id=" . $id);
}

if (isset($_GET['delete_360'])) {
    $t360Stmt = $pdo->prepare("SELECT folder_path FROM bike_360_images WHERE bike_id = ?");
    $t360Stmt->execute([$id]);
    $folderPath = $t360Stmt->fetchColumn();
    if ($folderPath) {
        $fullFolderPath = '../' . $folderPath;
        if (file_exists($fullFolderPath)) {
            // Remove folder and files inside it
            $files = glob($fullFolderPath . '*');
            foreach ($files as $file) {
                if (is_file($file)) {
                    unlink($file);
                }
            }
            rmdir($fullFolderPath);
        }
        $delStmt = $pdo->prepare("DELETE FROM bike_360_images WHERE bike_id = ?");
        $delStmt->execute([$id]);
    }
    redirect("edit_bike.php?id=" . $id);
}

if($_SERVER['REQUEST_METHOD'] === 'POST') {
    $model_name = $_POST['model_name'] ?? '';
    $price = $_POST['price'] ?? 0;
    $year = $_POST['year'] ?? date('Y');
    $km_driven = $_POST['km_driven'] ?? 0;
    $location = $_POST['location'] ?? '';
    $map_url = $_POST['map_url'] ?? '';
    $status = $_POST['status'] ?? 'available';
    $description = $_POST['description'] ?? '';

    $colour = $_POST['colour'] ?? '';
    $engine_capacity = $_POST['engine_capacity'] ?? '';
    $insurance_status = $_POST['insurance_status'] ?? '';
    $ownership = $_POST['ownership'] ?? '1st';
    
    $fuel_tank_capacity = $_POST['fuel_tank_capacity'] ?? '';
    $insurance_valid_upto = $_POST['insurance_valid_upto'] ?? '';
    $rc_status = $_POST['rc_status'] ?? 'Available';
    $rto_code = $_POST['rto_code'] ?? '';
    
    $engine_condition = $_POST['engine_condition'] ?? 'Good';
    $tyres_condition = $_POST['tyres_condition'] ?? 'Good';
    $brakes_condition = $_POST['brakes_condition'] ?? 'Good';
    $battery_condition = $_POST['battery_condition'] ?? 'Good';
    $suspension_condition = $_POST['suspension_condition'] ?? 'Good';
    
    try {
        $upd = $pdo->prepare("UPDATE bikes SET model_name=?, price=?, year=?, km_driven=?, location=?, map_url=?, status=?, description=?, colour=?, engine_capacity=?, insurance_status=?, ownership=?, engine_condition=?, tyres_condition=?, brakes_condition=?, battery_condition=?, suspension_condition=?, fuel_tank_capacity=?, insurance_valid_upto=?, rc_status=?, rto_code=? WHERE id=?");
        $upd->execute([$model_name, $price, $year, $km_driven, $location, $map_url, $status, $description, $colour, $engine_capacity, $insurance_status, $ownership, $engine_condition, $tyres_condition, $brakes_condition, $battery_condition, $suspension_condition, $fuel_tank_capacity, $insurance_valid_upto, $rc_status, $rto_code, $id]);

        $uploadDir = '../assets/uploads/bikes/' . $id . '/';
        if (!file_exists($uploadDir)) {
            mkdir($uploadDir, 0777, true);
        }

        // Handle Main Image Upload
        if (!empty($_FILES['main_image']['name'])) {
            // Remove old main image
            $oldMainStmt = $pdo->prepare("SELECT id, image_url FROM bike_images WHERE bike_id = ? AND is_main = TRUE LIMIT 1");
            $oldMainStmt->execute([$id]);
            $oldMain = $oldMainStmt->fetch();
            if ($oldMain) {
                $oldPath = '../' . $oldMain['image_url'];
                if (file_exists($oldPath)) {
                    unlink($oldPath);
                }
                $delStmt = $pdo->prepare("DELETE FROM bike_images WHERE id = ?");
                $delStmt->execute([$oldMain['id']]);
            }

            // Save new main image
            $fileName = basename($_FILES['main_image']['name']);
            $targetPath = $uploadDir . $fileName;
            if (move_uploaded_file($_FILES['main_image']['tmp_name'], $targetPath)) {
                $dbPath = 'assets/uploads/bikes/' . $id . '/' . $fileName;
                $imgStmt = $pdo->prepare("INSERT INTO bike_images (bike_id, image_url, is_main) VALUES (?, ?, TRUE)");
                $imgStmt->execute([$id, $dbPath]);
            }
        }

        // Handle Gallery Images Upload (Multiple)
        if (!empty($_FILES['gallery_images']['name'][0])) {
            foreach ($_FILES['gallery_images']['name'] as $key => $name) {
                if ($_FILES['gallery_images']['error'][$key] == UPLOAD_ERR_OK) {
                    $fileName = uniqid() . '_' . basename($name);
                    $targetPath = $uploadDir . $fileName;
                    if (move_uploaded_file($_FILES['gallery_images']['tmp_name'][$key], $targetPath)) {
                        $dbPath = 'assets/uploads/bikes/' . $id . '/' . $fileName;
                        $imgStmt = $pdo->prepare("INSERT INTO bike_images (bike_id, image_url, is_main) VALUES (?, ?, FALSE)");
                        $imgStmt->execute([$id, $dbPath]);
                    }
                }
            }
        }

        // Handle Video Upload
        if (!empty($_FILES['video']['name'])) {
            // Remove old video
            $oldVidStmt = $pdo->prepare("SELECT id, video_url FROM bike_videos WHERE bike_id = ?");
            $oldVidStmt->execute([$id]);
            $oldVid = $oldVidStmt->fetch();
            if ($oldVid) {
                $oldPath = '../' . $oldVid['video_url'];
                if (file_exists($oldPath)) {
                    unlink($oldPath);
                }
                $delStmt = $pdo->prepare("DELETE FROM bike_videos WHERE id = ?");
                $delStmt->execute([$oldVid['id']]);
            }

            // Save new video
            $fileName = uniqid() . '_' . basename($_FILES['video']['name']);
            $targetPath = $uploadDir . $fileName;
            if (move_uploaded_file($_FILES['video']['tmp_name'], $targetPath)) {
                $dbPath = 'assets/uploads/bikes/' . $id . '/' . $fileName;
                $vidStmt = $pdo->prepare("INSERT INTO bike_videos (bike_id, video_url) VALUES (?, ?)");
                $vidStmt->execute([$id, $dbPath]);
            }
        }

        // Handle 360 Zip Upload
        if (!empty($_FILES['zip_360']['name'])) {
            $zipPath = $_FILES['zip_360']['tmp_name'];
            $zip = new ZipArchive;
            if ($zip->open($zipPath) === TRUE) {
                $three60Dir = $uploadDir . '360/';
                
                // Clear old 360 directory if it exists
                if (file_exists($three60Dir)) {
                    $files = glob($three60Dir . '*');
                    foreach ($files as $file) {
                        if (is_file($file)) {
                            unlink($file);
                        }
                    }
                } else {
                    mkdir($three60Dir, 0777, true);
                }

                // Delete old 360 record
                $delStmt = $pdo->prepare("DELETE FROM bike_360_images WHERE bike_id = ?");
                $delStmt->execute([$id]);

                // Extract to a temporary directory first
                $tempExtractDir = $three60Dir . 'temp_extract/';
                if (!file_exists($tempExtractDir)) mkdir($tempExtractDir, 0777, true);
                
                $zip->extractTo($tempExtractDir);
                $zip->close();
                
                // Recursively find all images
                $images = [];
                $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempExtractDir));
                foreach ($iterator as $file) {
                    if ($file->isFile()) {
                        $ext = strtolower($file->getExtension());
                        if (in_array($ext, ['jpg', 'jpeg', 'png', 'webp'])) {
                            $images[] = $file->getPathname();
                        }
                    }
                }
                
                natsort($images);
                $frameCount = count($images);
                if($frameCount > 0) {
                    $sequence = 1;
                    foreach($images as $oldPath) {
                        $ext = strtolower(pathinfo($oldPath, PATHINFO_EXTENSION));
                        $newPath = $three60Dir . $sequence . '.' . $ext;
                        rename($oldPath, $newPath);
                        $sequence++;
                    }
                    $dbFolderPath = 'assets/uploads/bikes/' . $id . '/360/';
                    
                    $stmt360 = $pdo->prepare("INSERT INTO bike_360_images (bike_id, folder_path, frame_count) VALUES (?, ?, ?)");
                    $stmt360->execute([$id, $dbFolderPath, $frameCount]);
                }
                
                // Cleanup temp dir
                $rmIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempExtractDir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
                foreach ($rmIterator as $file) {
                    $file->isDir() ? rmdir($file->getPathname()) : unlink($file->getPathname());
                }
                rmdir($tempExtractDir);
            }
        }

        redirect('manage_bikes.php');
    } catch (\PDOException $e) {
        $error = "Error updating bike: " . $e->getMessage();
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Edit Bike - ReOwn Admin</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="admin.css?v=<?php echo time(); ?>">
</head>
<body>
<?php include 'admin_sidebar.php'; ?>
<div id="main-content">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2>Edit Bike: <?php echo htmlspecialchars($bike['reference_id']); ?></h2>
        <a href="manage_bikes.php" class="btn btn-outline-light"><i class="fas fa-arrow-left me-2"></i> Back</a>
    </div>

    <div class="glass-card p-4">
        <form method="POST" enctype="multipart/form-data">
            <div class="row g-3">
                <?php if(isset($error)): ?>
                <div class="col-12"><div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div></div>
                <?php endif; ?>
                <div class="col-md-6">
                    <label>Model Name</label>
                    <select name="model_name" class="form-select bg-dark text-white border-secondary" required>
                        <option value="" disabled>-- Select Royal Enfield Model --</option>
                        <?php foreach ($bike_categories as $category => $models): ?>
                            <optgroup label="<?php echo htmlspecialchars($category); ?>">
                                <?php foreach ($models as $model): ?>
                                    <option value="<?php echo htmlspecialchars($model); ?>" <?php echo ($bike['model_name'] === $model) ? 'selected' : ''; ?>>
                                        <?php echo htmlspecialchars($model); ?>
                                    </option>
                                <?php endforeach; ?>
                            </optgroup>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="col-md-6">
                    <label>Price</label>
                    <input type="number" name="price" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['price']); ?>" required>
                </div>
                <div class="col-md-3">
                    <label>Year</label>
                    <input type="number" name="year" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['year']); ?>" required>
                </div>
                <div class="col-md-3">
                    <label>KM Driven</label>
                    <input type="number" name="km_driven" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['km_driven']); ?>" required>
                </div>
                <div class="col-md-3">
                    <label>Location</label>
                    <input type="text" name="location" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['location']); ?>" required>
                </div>
                <div class="col-md-3">
                    <label>Status</label>
                    <select name="status" class="form-control bg-dark text-white border-secondary">
                        <option value="available" <?php echo $bike['status'] == 'available' ? 'selected' : ''; ?>>Available</option>
                        <option value="pending" <?php echo $bike['status'] == 'pending' ? 'selected' : ''; ?>>Pending</option>
                        <option value="sold" <?php echo $bike['status'] == 'sold' ? 'selected' : ''; ?>>Sold</option>
                    </select>
                </div>
                <div class="col-12 mt-2">
                    <label>Google Maps URL (for this vehicle location)</label>
                    <input type="url" name="map_url" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['map_url'] ?? ''); ?>" placeholder="e.g. https://www.google.com/maps/...">
                </div>
                <div class="col-12 mt-3">
                    <label>Description</label>
                    <textarea name="description" class="form-control bg-dark text-white border-secondary" rows="4"><?php echo htmlspecialchars($bike['description'] ?? ''); ?></textarea>
                </div>

                <hr class="border-secondary my-4">
                <h5 class="text-re-red mb-3">Bike Specifications</h5>
                <div class="col-md-3">
                    <label>Color</label>
                    <input type="text" name="colour" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['colour'] ?? ''); ?>">
                </div>
                <div class="col-md-3">
                    <label>Engine Capacity (e.g. 350)</label>
                    <input type="text" name="engine_capacity" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['engine_capacity'] ?? ''); ?>">
                </div>
                <div class="col-md-3">
                    <label>Insurance Status</label>
                    <input type="text" name="insurance_status" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['insurance_status'] ?? ''); ?>">
                </div>
                <div class="col-md-3">
                    <label>Ownership</label>
                    <select name="ownership" class="form-select bg-dark text-white border-secondary">
                        <option value="1st" <?php echo ($bike['ownership'] == '1st') ? 'selected' : ''; ?>>1st Owner</option>
                        <option value="2nd" <?php echo ($bike['ownership'] == '2nd') ? 'selected' : ''; ?>>2nd Owner</option>
                        <option value="3rd" <?php echo ($bike['ownership'] == '3rd') ? 'selected' : ''; ?>>3rd Owner</option>
                        <option value="4th+" <?php echo ($bike['ownership'] == '4th+') ? 'selected' : ''; ?>>4th+ Owner</option>
                    </select>
                </div>
                <div class="col-md-3">
                    <label>Fuel Tank Capacity</label>
                    <input type="text" name="fuel_tank_capacity" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['fuel_tank_capacity'] ?? ''); ?>" placeholder="e.g. 13.5 L">
                </div>
                <div class="col-md-3">
                    <label>Insurance Valid Upto</label>
                    <input type="date" name="insurance_valid_upto" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['insurance_valid_upto'] ?? ''); ?>">
                </div>
                <div class="col-md-3">
                    <label>RC Status</label>
                    <select name="rc_status" class="form-select bg-dark text-white border-secondary">
                        <option value="Available" <?php echo ($bike['rc_status'] == 'Available') ? 'selected' : ''; ?>>Available</option>
                        <option value="Not Available" <?php echo ($bike['rc_status'] == 'Not Available') ? 'selected' : ''; ?>>Not Available</option>
                    </select>
                </div>
                <div class="col-md-3">
                    <label>RTO Code</label>
                    <input type="text" name="rto_code" class="form-control bg-dark text-white border-secondary" value="<?php echo htmlspecialchars($bike['rto_code'] ?? ''); ?>" placeholder="e.g. KA02">
                </div>

                <hr class="border-secondary my-4">
                <h5 class="text-re-red mb-3">150-Point Inspection Report</h5>
                <div class="col-md-4">
                    <label>Engine Condition</label>
                    <select name="engine_condition" class="form-select bg-dark text-white border-secondary">
                        <option value="Excellent" <?php echo ($bike['engine_condition'] == 'Excellent') ? 'selected' : ''; ?>>Excellent</option>
                        <option value="Good" <?php echo ($bike['engine_condition'] == 'Good' || !$bike['engine_condition']) ? 'selected' : ''; ?>>Good</option>
                        <option value="Average" <?php echo ($bike['engine_condition'] == 'Average') ? 'selected' : ''; ?>>Average</option>
                    </select>
                </div>
                <div class="col-md-4">
                    <label>Tyres Condition</label>
                    <select name="tyres_condition" class="form-select bg-dark text-white border-secondary">
                        <option value="Excellent" <?php echo ($bike['tyres_condition'] == 'Excellent') ? 'selected' : ''; ?>>Excellent</option>
                        <option value="Good" <?php echo ($bike['tyres_condition'] == 'Good' || !$bike['tyres_condition']) ? 'selected' : ''; ?>>Good</option>
                        <option value="Average" <?php echo ($bike['tyres_condition'] == 'Average') ? 'selected' : ''; ?>>Average</option>
                    </select>
                </div>
                <div class="col-md-4">
                    <label>Brakes Condition</label>
                    <select name="brakes_condition" class="form-select bg-dark text-white border-secondary">
                        <option value="Excellent" <?php echo ($bike['brakes_condition'] == 'Excellent') ? 'selected' : ''; ?>>Excellent</option>
                        <option value="Good" <?php echo ($bike['brakes_condition'] == 'Good' || !$bike['brakes_condition']) ? 'selected' : ''; ?>>Good</option>
                        <option value="Average" <?php echo ($bike['brakes_condition'] == 'Average') ? 'selected' : ''; ?>>Average</option>
                    </select>
                </div>
                <div class="col-md-6">
                    <label>Battery Condition</label>
                    <select name="battery_condition" class="form-select bg-dark text-white border-secondary">
                        <option value="Excellent" <?php echo ($bike['battery_condition'] == 'Excellent') ? 'selected' : ''; ?>>Excellent</option>
                        <option value="Good" <?php echo ($bike['battery_condition'] == 'Good' || !$bike['battery_condition']) ? 'selected' : ''; ?>>Good</option>
                        <option value="Average" <?php echo ($bike['battery_condition'] == 'Average') ? 'selected' : ''; ?>>Average</option>
                    </select>
                </div>
                <div class="col-md-6">
                    <label>Suspension Condition</label>
                    <select name="suspension_condition" class="form-select bg-dark text-white border-secondary">
                        <option value="Excellent" <?php echo ($bike['suspension_condition'] == 'Excellent') ? 'selected' : ''; ?>>Excellent</option>
                        <option value="Good" <?php echo ($bike['suspension_condition'] == 'Good' || !$bike['suspension_condition']) ? 'selected' : ''; ?>>Good</option>
                        <option value="Average" <?php echo ($bike['suspension_condition'] == 'Average') ? 'selected' : ''; ?>>Average</option>
                    </select>
                </div>
                <hr class="border-secondary my-4">
                <h5 class="text-re-red mb-3">Manage Media & Files</h5>
                
                <!-- Display Current Main Image -->
                <div class="col-md-6 mt-3">
                    <label class="fw-bold mb-2">Main Image (Required)</label>
                    <div class="mb-2">
                        <?php
                        $mainImgStmt = $pdo->prepare("SELECT * FROM bike_images WHERE bike_id = ? AND is_main = TRUE LIMIT 1");
                        $mainImgStmt->execute([$id]);
                        $mainImg = $mainImgStmt->fetch();
                        if ($mainImg):
                        ?>
                            <div class="position-relative d-inline-block">
                                <img src="../<?php echo htmlspecialchars($mainImg['image_url']); ?>" style="width: 150px; height: 100px; object-fit: cover;" class="rounded border border-secondary">
                            </div>
                        <?php else: ?>
                            <p class="text-muted small">No main image uploaded.</p>
                        <?php endif; ?>
                    </div>
                    <input type="file" name="main_image" class="form-control bg-dark text-white border-secondary" accept="image/*">
                    <small class="text-muted">Uploading a new main image will replace the current one.</small>
                </div>

                <!-- Display Current Gallery Images -->
                <div class="col-12 mt-4">
                    <label class="fw-bold mb-2">Gallery Images</label>
                    <div class="row g-2 mb-3">
                        <?php
                        $galStmt = $pdo->prepare("SELECT * FROM bike_images WHERE bike_id = ? AND is_main = FALSE");
                        $galStmt->execute([$id]);
                        $galImages = $galStmt->fetchAll();
                        if ($galImages):
                            foreach ($galImages as $gImg):
                        ?>
                            <div class="col-auto position-relative">
                                <img src="../<?php echo htmlspecialchars($gImg['image_url']); ?>" style="width: 120px; height: 80px; object-fit: cover;" class="rounded border border-secondary">
                                <a href="edit_bike.php?id=<?php echo $id; ?>&delete_gallery_id=<?php echo $gImg['id']; ?>" class="btn btn-danger btn-sm position-absolute top-0 end-0 p-1" onclick="return confirm('Delete this gallery image?');" style="font-size: 0.75rem;"><i class="fas fa-trash"></i></a>
                            </div>
                        <?php
                            endforeach;
                        else:
                        ?>
                            <div class="col-12"><p class="text-muted small">No gallery images uploaded.</p></div>
                        <?php endif; ?>
                    </div>
                    <input type="file" name="gallery_images[]" class="form-control bg-dark text-white border-secondary" accept="image/*" multiple>
                    <small class="text-muted">Choose files to add more images to the gallery.</small>
                </div>

                <!-- Display Current Video -->
                <div class="col-md-6 mt-4">
                    <label class="fw-bold mb-2">Vehicle Video</label>
                    <div class="mb-2">
                        <?php
                        $vidStmt = $pdo->prepare("SELECT * FROM bike_videos WHERE bike_id = ? LIMIT 1");
                        $vidStmt->execute([$id]);
                        $currVideo = $vidStmt->fetch();
                        if ($currVideo):
                        ?>
                            <div class="d-flex align-items-center gap-2">
                                <span class="text-success"><i class="fas fa-check-circle me-1"></i> Video uploaded</span>
                                <a href="edit_bike.php?id=<?php echo $id; ?>&delete_video=1" class="btn btn-sm btn-outline-danger" onclick="return confirm('Delete the video?');"><i class="fas fa-trash me-1"></i>Delete</a>
                            </div>
                        <?php else: ?>
                            <p class="text-muted small">No video uploaded.</p>
                        <?php endif; ?>
                    </div>
                    <input type="file" name="video" class="form-control bg-dark text-white border-secondary" accept="video/*">
                    <small class="text-muted">Uploading a new video will replace the current one.</small>
                </div>

                <!-- Display Current 360° view -->
                <div class="col-md-6 mt-4">
                    <label class="fw-bold mb-2">360° Rotating Images (ZIP)</label>
                    <div class="mb-2">
                        <?php
                        $t360Stmt = $pdo->prepare("SELECT * FROM bike_360_images WHERE bike_id = ? LIMIT 1");
                        $t360Stmt->execute([$id]);
                        $curr360 = $t360Stmt->fetch();
                        if ($curr360):
                        ?>
                            <div class="d-flex align-items-center gap-2">
                                <span class="text-success"><i class="fas fa-check-circle me-1"></i> 360° view active (<?php echo $curr360['frame_count']; ?> frames)</span>
                                <a href="edit_bike.php?id=<?php echo $id; ?>&delete_360=1" class="btn btn-sm btn-outline-danger" onclick="return confirm('Delete the 360° view?');"><i class="fas fa-trash me-1"></i>Delete</a>
                            </div>
                        <?php else: ?>
                            <p class="text-muted small">No 360° view configured.</p>
                        <?php endif; ?>
                    </div>
                    <input type="file" name="zip_360" class="form-control bg-dark text-white border-secondary" accept=".zip">
                    <small class="text-muted">Upload a ZIP file containing sequential images (36 to 72+ frames) to enable or update 360° view.</small>
                </div>

                <div class="col-12 mt-5 border-top border-secondary border-opacity-25 pt-4">
                    <button type="submit" class="btn btn-primary btn-lg"><i class="fas fa-save me-2"></i>Update Details</button>
                    <a href="manage_bikes.php" class="btn btn-outline-light btn-lg ms-2">Cancel</a>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>
Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����