<?php
require_once 'includes/db.php';

echo "<h2>Populating Dummy Gallery Data...</h2>";

// Get service IDs
$services_res = $conn->query("SELECT id, title FROM services");
$service_ids = [];
while($row = $services_res->fetch_assoc()) {
    $service_ids[$row['title']] = $row['id'];
}

// Dummy images for each category
$dummy_data = [
    'Education' => [
        ['https://images.unsplash.com/photo-1503676260728-1c00da094a0b?q=80&w=2022&auto=format&fit=crop', 'Digital Classroom', 'Empowering students with modern technology.'],
        ['https://images.unsplash.com/photo-1497633762265-9d179a990aa6?q=80&w=2073&auto=format&fit=crop', 'Library Session', 'A world of knowledge at their fingertips.'],
        ['https://images.unsplash.com/photo-1509062522246-3755977927d7?q=80&w=2104&auto=format&fit=crop', 'Rural Schooling', 'Bringing quality education to every village.'],
    ],
    'Environment' => [
        ['https://images.unsplash.com/photo-1542601906990-b4d3fb778b09?q=80&w=2013&auto=format&fit=crop', 'Tree Plantation', 'Making the world greener, one tree at a time.'],
        ['https://images.unsplash.com/photo-1532996122724-e3c354a0b15b?q=80&w=2070&auto=format&fit=crop', 'Waste Management', 'Promoting clean and sustainable living.'],
        ['https://images.unsplash.com/photo-1441974231531-c6227db76b6e?q=80&w=2071&auto=format&fit=crop', 'Forest Preservation', 'Protecting our natural heritage for future generations.'],
    ],
    'Others Social Work' => [
        ['https://images.unsplash.com/photo-1488521787991-ed7bbaae773c?q=80&w=2070&auto=format&fit=crop', 'Food Distribution', 'Ensuring no one goes hungry in our community.'],
        ['https://images.unsplash.com/photo-1593113589914-07599018dda0?q=80&w=2070&auto=format&fit=crop', 'Health Camp', 'Providing basic medical checkups to the needy.'],
        ['https://images.unsplash.com/photo-1469571486292-0ba58a3f068b?q=80&w=2070&auto=format&fit=crop', 'Elderly Care', 'Supporting the senior citizens with love and respect.'],
    ],
    'Shaaskt Bharat' => [
        ['https://images.unsplash.com/photo-1532375811400-d72522079093?q=80&w=2070&auto=format&fit=crop', 'Nation Building', 'Uniting the country for a stronger future.'],
        ['https://images.unsplash.com/photo-1552664730-d307ca884978?q=80&w=2070&auto=format&fit=crop', 'Youth Empowerment', 'Training the next generation of leaders.'],
        ['https://images.unsplash.com/photo-1517048676732-d65bc937f952?q=80&w=2070&auto=format&fit=crop', 'Skill Development', 'Creating opportunities through vocational training.'],
    ],
    'Awareness' => [
        ['https://images.unsplash.com/photo-1517245386807-bb43f82c33c4?q=80&w=2070&auto=format&fit=crop', 'Community Workshop', 'Spreading awareness on legal and social rights.'],
    ],
    'Women Supporting' => [
        ['https://images.unsplash.com/photo-1573497019940-1c28c88b4f3e?q=80&w=2070&auto=format&fit=crop', 'Self Defense Training', 'Empowering women with confidence and skills.'],
    ]
];

foreach ($dummy_data as $title => $items) {
    if (isset($service_ids[$title])) {
        $sid = $service_ids[$title];
        foreach ($items as $item) {
            $stmt = $conn->prepare("INSERT INTO service_gallery (service_id, image, title, subtitle) VALUES (?, ?, ?, ?)");
            $stmt->bind_param("isss", $sid, $item[0], $item[1], $item[2]);
            $stmt->execute();
        }
    }
}

echo "<p style='color:green;'>Dummy gallery data populated successfully!</p>";
?>
