<?php
require_once 'config/database.php';

try {
    // Insert a test event with date range
    $stmt = $pdo->prepare("INSERT INTO academic_calendar (title, description, event_date, end_date, event_type, status) VALUES (?, ?, ?, ?, ?, ?)");
    $stmt->execute([
        'মে মাসের ছুটি',
        'ঈদ উপলক্ষে মে মাসের ছুটি',
        '2025-05-01',
        '2025-05-10',
        'holiday',
        'active'
    ]);
    
    echo "Test event with date range created successfully!\n";
    
    // Fetch and display the event
    $stmt = $pdo->query("SELECT * FROM academic_calendar WHERE title = 'মে মাসের ছুটি' ORDER BY id DESC LIMIT 1");
    $event = $stmt->fetch(PDO::FETCH_ASSOC);
    
    if ($event) {
        echo "Event details:\n";
        echo "Title: " . $event['title'] . "\n";
        echo "Start Date: " . $event['event_date'] . "\n";
        echo "End Date: " . ($event['end_date'] ?? 'N/A') . "\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>