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

try {
    // Check fees table structure
    echo "=== Fees Table Structure ===\n";
    $stmt = $pdo->query("DESCRIBE fees");
    $results = $stmt->fetchAll();
    foreach ($results as $row) {
        echo $row['Field'] . " " . $row['Type'] . " " . ($row['Null'] === 'YES' ? 'NULL' : 'NOT NULL') . " " . ($row['Key'] ?? '') . " " . ($row['Default'] ?? '') . " " . ($row['Extra'] ?? '') . "\n";
    }
    
    echo "\n=== Fee Payments Table Structure ===\n";
    $stmt = $pdo->query("DESCRIBE fee_payments");
    $results = $stmt->fetchAll();
    foreach ($results as $row) {
        echo $row['Field'] . " " . $row['Type'] . " " . ($row['Null'] === 'YES' ? 'NULL' : 'NOT NULL') . " " . ($row['Key'] ?? '') . " " . ($row['Default'] ?? '') . " " . ($row['Extra'] ?? '') . "\n";
    }
    
    echo "\n=== Sample Data Check ===\n";
    // Check if we can insert a test record
    $stmt = $pdo->prepare("SELECT id FROM students LIMIT 1");
    $stmt->execute();
    $student = $stmt->fetch();
    if ($student) {
        echo "Found student with ID: " . $student['id'] . "\n";
    } else {
        echo "No students found in database\n";
    }
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>