<?php $this->extend('admin/layout'); ?>
<?php $this->section('content'); ?>
<div class="container mt-4">
    <h2>Tickets for Author: <?= esc($author) ?></h2>
    <a href="<?= site_url('admin/predictions') ?>" class="btn btn-secondary mb-3">&larr; Back to Predictions</a>
    <div class="card">
        <div class="card-header">Tickets</div>
        <div class="card-body">
            <?php if (empty($tickets)): ?>
                <div class="alert alert-info">No tickets found for this author.</div>
            <?php else: ?>
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Title</th>
                                <th>Created At</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($tickets as $ticket): ?>
                                <tr>
                                    <td><?= esc($ticket['id']) ?></td>
                                    <td><?= esc($ticket['title']) ?></td>
                                    <td><?= esc($ticket['created_at']) ?></td>
                                    <td>
                                        <a href="<?= site_url('admin/ticket-predictions/' . $ticket['id']) ?>" class="btn btn-sm btn-primary">View Predictions</a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php $this->endSection(); ?> 