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

$student_id = 6252;

echo "Checking fees for student ID: " . $student_id . "\n";

// Get due fees for this student
$stmt = $pdo->prepare("
    SELECT id, amount, paid_amount, status, fee_type
    FROM fees 
    WHERE student_id = ? AND status IN ('pending', 'partial', 'overdue') 
    ORDER BY due_date ASC
");
$stmt->execute([$student_id]);
$due_fees = $stmt->fetchAll();

if ($due_fees) {
    echo "Found " . count($due_fees) . " due fees:\n";
    foreach ($due_fees as $fee) {
        $due_amount = $fee['amount'] - $fee['paid_amount'];
        echo "- Fee ID: " . $fee['id'] . " (" . $fee['fee_type'] . ")\n";
        echo "  Total: " . $fee['amount'] . ", Paid: " . $fee['paid_amount'] . ", Due: " . $due_amount . "\n";
        echo "  Status: " . $fee['status'] . "\n\n";
    }
} else {
    echo "No due fees found for this student.\n";
}
?>