<tr>
    <td colspan="12">&nbsp;</td>
    <td class="center">
        <script type="text/javascript">
            function toggleChecked(status) {
                $(".checkbox").each(function () {
                    $(this).prop("checked", status);
                })
            }
        </script>
        <input type="checkbox" value="1" onclick="toggleChecked(this.checked)"/>
        All
    </td>
</tr>
<tr>
    <?php

    use Mtc\Core\Permissions;

    if (Permissions::can(Permissions::REVIEW_NHS_ORDERS)) {
    ?>
        <th>DOB</th>
        <th>Exemption</th>
        <th>NHS Number</th>
    <?php
    } else {
        ?>
        <th>Status</th>
        <?php
    }
    ?>
    <th>
        Pharmacy Note<br/>
        <div class="row">
            <select name="pharmacist_note" id="pharmacist_note" class="headerFilter">
                <option value="">Any</option>
                <option value="not_empty" <?= $_REQUEST['pharmacist_note'] === 'not_empty' ? 'selected' : ''; ?>>Not Empty</option>
                <option value="empty" <?= $_REQUEST['pharmacist_note'] === 'empty' ? 'selected' : ''; ?>>Empty</option>
            </select>
        </div>
    </th>
    <th>
        <a href="<?= 'manage.orders.php?' . modifyViewStateQueryString($_REQUEST, $view_state_keys, ['orderbydir' => $orderbydiropp, 'orderbyfield' => 'order-id', 'page' => 1]) ?>">
            Order
            <?php
            if ($_REQUEST['orderbyfield'] != 'order-id') {
                $oiorderbydir = 'DESC';
            } else {
                $oiorderbydir = $orderbydir;
            }
            ?>
            <img src="/admin/images/<?php if ($oiorderbydir == 'DESC') { ?>down.png<?php } else { ?>up.png<?php } ?>"
                 border="0"/>
        </a>
    </th>
    <th>
        <a href="<?= 'manage.orders.php?' . modifyViewStateQueryString($_REQUEST, $view_state_keys, ['orderbydir' => $orderbydiropp, 'orderbyfield' => 'item']) ?>">
            Purchased
            <?php
            if ($_REQUEST['orderbyfield'] !== 'item') {
                $odorderbydir = 'ASC';
            } else {
                $odorderbydir = $orderbydir;
                ?>
                <img src="/admin/images/<?php if ($odorderbydir === 'DESC') { ?>down.png<?php } else { ?>up.png<?php } ?>"
                     border="0"
                     alt=""
                />
                <?php
            }
            ?>
        </a>
        <div class="row">
            <select name="approval_status" id="approval_status" class="headerFilter">
                <option value="">All</option>
                <option value="approved" <?= $_REQUEST['approval_status'] === 'approved' ? 'selected' : ''; ?>>Approved</option>
                <option value="not_approved" <?= $_REQUEST['approval_status'] === 'not_approved' ? 'selected' : ''; ?>>Not Approved</option>
            </select>
        </div>
    </th>

    <?php
    if (!Permissions::can(Permissions::REVIEW_NHS_ORDERS)) {
        ?>
        <th>
            Doctor Note<br/>
            <div class="row">
                <select name="doctor_note" id="doctor_note" class="headerFilter">
                    <option value="">Any</option>
                    <option value="not_empty" <?= $_REQUEST['doctor_note'] === 'not_empty' ? 'selected' : ''; ?>>Not
                        Empty
                    </option>
                    <option value="empty" <?= $_REQUEST['doctor_note'] === 'empty' ? 'selected' : ''; ?>>Empty</option>
                </select>
            </div>
        </th>
        <?php
    }
    ?>
    <th>
        <?= Permissions::can(Permissions::REVIEW_NHS_ORDERS) ? 'Billing Address' : 'Ship To'; ?>
    </th>
    <th>
        Shipment Created<br/>
        <div class="row">
            <select name="shipment_created" id="shipment_created" class="headerFilter">
                <option value="">Any</option>
                <option value="yes" <?= $_REQUEST['shipment_created'] === 'yes' ? 'selected' : ''; ?>>Yes</option>
                <option value="no" <?= $_REQUEST['shipment_created'] === 'no' ? 'selected' : ''; ?>>No</option>
            </select>
        </div>
    </th>
    <th class="center">
        <a href="<?= 'manage.orders.php?' . modifyViewStateQueryString($_REQUEST, $view_state_keys, ['orderbydir' => $orderbydiropp, 'orderbyfield' => 'order-date', 'page' => 1]) ?>">
            Date
            <?php
            if ($_REQUEST['orderbyfield'] != 'order-date') {
                $odorderbydir = 'DESC';
            } else {
                $odorderbydir = $orderbydir;
            }
            ?>
            <img src="/admin/images/<?php if ($odorderbydir == 'DESC') { ?>down.png<?php } else { ?>up.png<?php } ?>"
                 border="0"/>
        </a>
    </th>
    <th width="120">
        <a href="<?= 'manage.orders.php?' . modifyViewStateQueryString($_REQUEST, $view_state_keys, ['orderbydir' => $orderbydiropp, 'orderbyfield' => 'order-cost_total', 'page' => 1]) ?>">
            Total
            <?php
            if ($_REQUEST['orderbyfield'] != 'order-cost_total') {
                $octorderbydir = 'DESC';
            } else {
                $octorderbydir = $orderbydir;
            }
            ?>
            <img src="/admin/images/<?php if ($orderbydir == 'DESC') { ?>down.png<?php } else { ?>up.png<?php } ?>"
                 border="0"/>
        </a>
    </th>
    <th>Actions</th>
    <th class="center">Process</th>
</tr>
