<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Support Requests</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Favicon -->
    <link href="<?= base_url('assets/images/favicon.ico') ?>" rel="icon">
</head>

<body>
    <?php include(__DIR__ . '/partials/header.php'); ?>
    <?php include(__DIR__ . '/partials/navbar.php'); ?>

    <div class="container-fluid">
        <div class="row">
            <main class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
                <div class="pt-3 pb-2 mb-3" style="margin-left: -2in;">
                    <h1 class="h2">My Support Requests</h1>
                    <h5 class="h5 mt-2">View your submitted support requests</h5>
                </div>
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>Subject</th>
                                <th>Message</th>
                                <th>Status</th>
                                <th>Created At</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (!empty($requests) && is_array($requests)) : ?>
                            <?php foreach ($requests as $request) : ?>
                            <tr>
                                <td><?= esc($request['subject']); ?></td>
                                <td><?= esc($request['message']); ?></td>
                                <td><?= esc($request['status']); ?></td>
                                <td><?= esc(!empty($request['created_at']) ? local_datetime($request['created_at'], 'm-d-Y H:i') : '') ?></td>
                            </tr>
                            <?php endforeach; ?>
                            <?php else : ?>
                            <tr>
                                <td colspan="4">No support requests found.</td>
                            </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </main>
        </div>
    </div>

    <?php include(__DIR__ . '/partials/footer.php'); ?>
</body>

</html>
