<div class="modal" id="modal-search"></div>

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

    <div class="actions">
        <a data-load-with-modal data-modal="modal-search" class="btn btn-default btn-sm" href="<?= admin_url_to('/direct-market/orders/search') ?>"><?= __('Search') ?></a>
    </div>
</section>

<section class="content">
    <?php if (!$orders): ?>
        <div class="callout callout-warning">
            <h4>Ops!</h4>
            <p><?= __('No orders 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="60">#ID</th>
                        <th><?= __('Account') ?></th>
                        <th><?= __('Target') ?></th>
                        <th><?= __('Item') ?></th>
                        <th><?= __('Price') ?></th>
                        <th width="180"><?= __('Created at') ?></th>
                        <th width="120"><?= __('Status') ?></th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach ($orders as $order): ?>
                        <tr>
                            <td><?= $order['id'] ?></td>
                            <td><a data-ajax href="<?= admin_url_to('/accounts/edit/' . $order['account']) ?>"><?= $order['account'] ?></a></td>
                            <td><a data-ajax href="<?= admin_url_to('/accounts/edit/' . $order['target']) ?>"><?= $order['target'] ?></a></td>
                            <td>
                                <?php
                                $item = new \Morpheus\Item\Item($order['hex']); $item->parse();
                                echo \Morpheus\Util\Item::getFullName($item);
                                ?>
                            </td>
                            <td><?= util('Number')->currency($order['price']) ?></td>
                            <td><?= util('Date')->dateTime($order['create_date']) ?></td>
                            <td><?= $order['status'] ?></td>
                        </tr>
                    <?php endforeach ?>
                </tbody>
            </table>

            <div class="paginator">
                <?= $paginator->toHtml() ?>
            </div>
        </div>
    <?php endif ?>
</section>