<?php
session_start();

// Simulate the student login for MST. HABIBA KHATUN (student ID 20250117)
// First, we need to find the user_id for this student
require_once 'config/database.php';

$stmt = $pdo->prepare("SELECT user_id FROM students WHERE student_id = ?");
$stmt->execute(['20250117']);
$student = $stmt->fetch();

if ($student) {
    $_SESSION['user_id'] = $student['user_id'];
    $_SESSION['user_role'] = 'student';
    
    echo "Testing payment display for student 20250117 (MST. HABIBA KHATUN)\n";
    echo "User ID: " . $student['user_id'] . "\n\n";
    
    // Change to fees directory to match paths in my_fees.php
    chdir('fees');
    
    // Capture the output of my_fees.php
    ob_start();
    include 'my_fees.php';
    $content = ob_get_contents();
    ob_end_clean();
    
    // Check if payments are displayed
    if (strpos($content, 'Payment History') !== false || strpos($content, 'পেমেন্ট হিস্টোরি') !== false) {
        echo "SUCCESS: Payment history section found in the page\n";
        
        // Check if actual payments are displayed
        if (strpos($content, '450.00') !== false || strpos($content, '550.00') !== false) {
            echo "SUCCESS: Payment amounts found in the page\n";
        } else {
            echo "WARNING: No payment amounts found in the page\n";
        }
        
        // Count how many payment rows are displayed
        $payment_rows = substr_count($content, 'fas fa-receipt');
        echo "Payment entries displayed: " . $payment_rows . "\n";
    } else {
        echo "ERROR: Payment history section not found in the page\n";
    }
} else {
    echo "Student not found!\n";
}

echo "\nTest completed.\n";
?>