<section class="content-header">
    <h1><?= __('Support tickets') ?></h1>
</section>

<section class="content">
    <?php if (empty($tickets)): ?>
        <div class="callout callout-warning">
            <h4>Ops!</h4>
            <p><?= __('No support tickets found') ?></p>
        </div>
    <?php else: ?>

        <div class="box box-default table-responsive">
            <table data-table class="table table-condensed table-hover table-striped">
                <thead>
                    <tr>
                        <th width="40">#</th>
                        <th><?= __('User') ?></th>
                        <th><?= __('Subject') ?></th>
                        <th><?= __('Department') ?></th>
                        <th style="text-align:center"><?= __('Messages') ?></th>
                        <th><?= __('Responsible') ?></th>
                        <th width="120"><?= __('Created at') ?></th>
                        <th><?= __('Status') ?></th>
                        <th width="10"></th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach ($tickets as $ticket): ?>
                        <tr>
                            <td><?= $ticket['id'] ?></td>
                            <td><a data-ajax href="<?= admin_url_to('/accounts/edit/' . $ticket['account']) ?>"><?= $ticket['account'] ?></a></td>
                            <td><?= $ticket['subject'] ?></td>
                            <td><?= $ticket['department'] ?></td>
                            <td style="text-align:center"><?= $ticket['total_messages'] ?></td>
                            <td><?= $ticket['responsible_name'] ?></td>
                            <td><?= date('d/m/Y H:i', strtotime($ticket['create_date'])) ?></td>
                            <td><?= util('HelpDesk.HelpDesk')->ticketStatus($ticket['status']) ?></td>
                            <td class="record-actions">
                                <a data-ajax class="btn btn-default btn-xs" href="<?= admin_url_to('/helpdesk/tickets/view/' . $ticket['id']) ?>"><?= __('View') ?></a>
                            </td>
                        </tr>
                    <?php endforeach ?>
                </tbody>
            </table>
        </div>
    <?php endif ?>
</section>