<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Today's Homework - <?php echo $today; ?></title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; font-size: 13px; }
        h2 { text-align: center; margin-bottom: 5px; }
        p.date { text-align: center; margin-bottom: 15px; color: #555; }
        table { width: 100%; border-collapse: collapse; }
        th { background: #337ab7; color: #fff; padding: 8px; text-align: left; }
        td { padding: 7px 8px; border: 1px solid #ccc; vertical-align: top; }
        tr:nth-child(even) { background: #f5f5f5; }
        .no-record { text-align: center; color: #888; padding: 20px; }
        .btn-print { display: block; margin: 0 auto 15px auto; padding: 8px 24px; background: #337ab7; color: #fff; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; }
        @media print { .btn-print { display: none; } }
    </style>
</head>
<body>

    <h2>Today's Homework</h2>
    <p class="date">Date: <?php echo $today; ?></p>

    <button class="btn-print" onclick="window.print()">&#128438; Print / Save as PDF</button>

    <?php if (!empty($homeworklist)): ?>
    <table>
        <thead>
            <tr>
                <th>#</th>
                <th>Class</th>
                <th>Section</th>
                <th>Subject Group</th>
                <th>Subject</th>
                <th>Submission Date</th>
                <th>Description</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($homeworklist as $i => $hw): ?>
            <tr>
                <td><?php echo $i + 1; ?></td>
                <td><?php echo htmlspecialchars($hw['class']); ?></td>
                <td><?php echo htmlspecialchars($hw['section']); ?></td>
                <td><?php echo htmlspecialchars($hw['group_name']); ?></td>
                <td><?php echo htmlspecialchars($hw['subject_name']); ?></td>
                <td><?php echo date('d-m-Y', strtotime($hw['submit_date'])); ?></td>
                <td><?php echo strip_tags($hw['description']); ?></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    <?php else: ?>
        <p class="no-record">No homework found for today.</p>
    <?php endif; ?>

</body>
</html>
