<?php
// Test script to verify the delete page works
session_start();
require_once '../config/database.php';

echo "<h2>Delete Page Verification</h2>";

// Test if the file exists
if (file_exists('delete_routine_page.php')) {
    echo "<p>✓ Delete routine page file exists.</p>";
    
    // Test the query part separately
    try {
        // Include just the database query part
        $stmt = $pdo->prepare("SELECT * FROM exams ORDER BY exam_date DESC");
        $stmt->execute();
        $routines = $stmt->fetchAll(PDO::FETCH_ASSOC);
        
        echo "<p>✓ Database query in delete page works correctly.</p>";
        echo "<p>Found " . count($routines) . " exams ready for deletion.</p>";
        
        if (!empty($routines)) {
            echo "<h3>Available Exams for Deletion:</h3>";
            echo "<table border='1' cellpadding='5' cellspacing='0'>";
            echo "<tr><th>ID</th><th>Name</th><th>Exam Date</th></tr>";
            foreach (array_slice($routines, 0, 3) as $routine) { // Show only first 3
                echo "<tr>";
                echo "<td>" . htmlspecialchars($routine['id']) . "</td>";
                echo "<td>" . htmlspecialchars($routine['name']) . "</td>";
                echo "<td>" . htmlspecialchars($routine['exam_date']) . "</td>";
                echo "</tr>";
            }
            echo "</table>";
        }
    } catch (Exception $e) {
        echo "<p style='color: red;'>✗ Database query error: " . $e->getMessage() . "</p>";
    }
} else {
    echo "<p style='color: red;'>✗ Delete routine page file not found.</p>";
}

echo "<p><a href='delete_routine_page.php'>Go to Delete Routine Page</a></p>";
echo "<p><a href='routine.php'>Go to Main Routine Page</a></p>";
?>