????????????????????
??????????????????
ÿØÿà
 JFIF      ÿÛ C      


!"$"$ÿÛ C    
ÿÂ p 
" ÿÄ     
         ÿÄ             ÿÚ 
   ÕÔË®

(%	aA*‚XYD¡(J„¡E¢RE,P€XYae )(E¤²€B¤R¥	BQ¤¢ X«)X…€¤   @  

adadasdasdasasdasdas


.....................................................................................................................................????????????????????
??????????????????
ÿØÿà
 JFIF      ÿÛ C      


!"$"$ÿÛ C    
ÿÂ p 
" ÿÄ     
         ÿÄ             ÿÚ 
   ÕÔË®

(%	aA*‚XYD¡(J„¡E¢RE,P€XYae )(E¤²€B¤R¥	BQ¤¢ X«)X…€¤   @  

adadasdasdasasdasdas


.....................................................................................................................................<!DOCTYPE html>
<html>
<head>
    <title>Test Fee Report System</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        .success { color: green; }
        .error { color: red; }
        table { border-collapse: collapse; width: 100%; margin: 20px 0; }
        table, th, td { border: 1px solid #ddd; }
        th, td { padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
        .btn { 
            background-color: #007bff; 
            color: white; 
            padding: 10px 20px; 
            text-decoration: none; 
            margin: 5px; 
            display: inline-block; 
            border-radius: 4px; 
        }
    </style>
</head>
<body>
    <h2>Fee Report System Test</h2>

    <?php
    include 'connection.php';

    echo "<h3>System Status Check:</h3>";

    // Check fees table
    $fees_check = "SELECT COUNT(*) as count FROM fees";
    $fees_result = $conn->query($fees_check);
    if ($fees_result) {
        $fees_count = $fees_result->fetch_assoc()['count'];
        echo "<p class='success'>✓ Fees table: $fees_count records found</p>";
    } else {
        echo "<p class='error'>✗ Fees table error: " . $conn->error . "</p>";
    }

    // Check accounts table
    $accounts_check = "SELECT COUNT(*) as count FROM accounts";
    $accounts_result = $conn->query($accounts_check);
    if ($accounts_result) {
        $accounts_count = $accounts_result->fetch_assoc()['count'];
        echo "<p class='success'>✓ Accounts table: $accounts_count records found</p>";
    } else {
        echo "<p class='error'>✗ Accounts table error: " . $conn->error . "</p>";
    }

    // Show sample fee records
    echo "<h3>Sample Fee Records:</h3>";
    $sample_sql = "SELECT f.admission_no, f.student_name, f.course_name, f.total_fee, f.payment_date, f.received_amount, 
                          a.due_amount, a.paid_amount, a.received_amount as account_received
                   FROM fees f
                   LEFT JOIN accounts a ON f.admission_no = a.admission_no
                   ORDER BY f.id DESC LIMIT 5";
    
    $sample_result = $conn->query($sample_sql);
    
    if ($sample_result && $sample_result->num_rows > 0) {
        echo "<table>";
        echo "<tr><th>Admission No</th><th>Student Name</th><th>Course</th><th>Total Fee</th><th>Due Amount</th><th>Payment Date</th><th>Received</th></tr>";
        
        while($row = $sample_result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>" . $row['admission_no'] . "</td>";
            echo "<td>" . $row['student_name'] . "</td>";
            echo "<td>" . $row['course_name'] . "</td>";
            echo "<td>₹" . number_format($row['total_fee'], 2) . "</td>";
            echo "<td>₹" . number_format($row['due_amount'] ?: $row['total_fee'], 2) . "</td>";
            echo "<td>" . $row['payment_date'] . "</td>";
            echo "<td>₹" . number_format($row['received_amount'], 2) . "</td>";
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "<p>No fee records found</p>";
    }

    // Test get_student_details.php
    echo "<h3>Testing Student Details API:</h3>";
    if ($sample_result && $sample_result->num_rows > 0) {
        $sample_result = $conn->query($sample_sql); // Re-run query
        $test_row = $sample_result->fetch_assoc();
        $test_admission = $test_row['admission_no'];
        
        echo "<p>Testing with admission number: <strong>$test_admission</strong></p>";
        echo "<button onclick=\"testStudentDetails('$test_admission')\">Test Student Details</button>";
        echo "<div id='test-result'></div>";
    }

    $conn->close();
    ?>

    <hr>
    <h3>Navigation:</h3>
    <a href="fee-report.php" class="btn">Open Fee Report</a>
    <a href="create-fee.php" class="btn">Create Fee</a>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
    function testStudentDetails(admission_no) {
        $('#test-result').html('<p>Testing...</p>');
        
        $.post("get_student_details.php", {admission_no: admission_no}, function(response) {
            console.log('Raw response:', response);
            console.log('Response type:', typeof response);
            
            var data;
            
            // Check if response is already parsed by jQuery
            if (typeof response === 'object') {
                data = response;
            } else {
                try {
                    data = JSON.parse(response);
                } catch (e) {
                    $('#test-result').html('<div style="background: #ffebee; padding: 15px; margin: 10px 0; border-radius: 5px; color: red;"><strong>JSON Parse Error:</strong> ' + e.message + '<br><strong>Response Type:</strong> ' + typeof response + '<br><strong>Raw Response:</strong> ' + response + '</div>');
                    return;
                }
            }
                
            var html = '<div style="background: #f8f9fa; padding: 15px; margin: 10px 0; border-radius: 5px;">';
            html += '<h4>API Response:</h4>';
            html += '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
            
            if (data.success) {
                html += '<p style="color: green;"><strong>✓ Success!</strong> Student details loaded correctly.</p>';
            } else {
                html += '<p style="color: red;"><strong>✗ Error:</strong> ' + data.message + '</p>';
            }
            
            html += '</div>';
            $('#test-result').html(html);
                
        }).fail(function(xhr, status, error) {
            $('#test-result').html('<div style="background: #ffebee; padding: 15px; margin: 10px 0; border-radius: 5px; color: red;"><strong>AJAX Request Failed:</strong> ' + status + ' - ' + error + '</div>');
        });
    }
    </script>
</body>
</html>