<?php
if ( ! defined( 'ABSPATH' ) ) exit;

?>

<div class="flex flex-col lg:flex-row lg:items-center gap-2 mb-5">
    <header class="">
        <h1 class="!m-0"><?php echo esc_html($page_name) ?></h1>
    </header>

    <div class="filter-form-wrapper">
        <form action="" id="frm-admin-orders" class="flex flex-col lg:flex-row gap-5 items-center flex-grow">
            <input type="hidden" name="action" value="anbarak_get_admin_orders">
            <input type="hidden" name="page" value="1">
            <input type="hidden" name="ipp" value="5">
            <input type="hidden" name="security" value="<?php echo esc_attr(ANBARAK_AJAX_NONCE) ?>">

            <?php
            anbarak_get_template_part('report/filter-form-dates', [
                'date_from' => strtotime('-3 months'),
                'date_to' => time(),
                'predefined' => true,
                'selected_predefined_date' => '3-month'
            ]);
            ?>

            <?php if (anbarak_user_is_admin_or_manager()): ?>
                <select name="order-status" id="order-status-filter" class="border order-gray-200 bg-white p-2 px-10 text-sm dark:bg-[#1a1a1a] dark:text-gray-200 dark:border-[#2a2a2a]">
                    <option value="all"><?php esc_html_e('All Orders', 'anbarak'); ?></option>
                    <option value="processing"><?php esc_html_e('Processing', 'anbarak'); ?></option>
                    <option value="completed"><?php esc_html_e('Completed', 'anbarak'); ?></option>
                    <option value="cancelled"><?php esc_html_e('Canceled', 'anbarak'); ?></option>
                </select>
            <?php endif ?>
            <button type="submit" class="button button--primary"><?php esc_html_e('Apply filters', 'anbarak') ?></button>
        </form>
    </div>
</div>

<div id="admin-orders-holder" data-filter-form="frm-admin-orders">
    <div class="table-container">
        <table class="table w-full divide-y divide-gray-200">
            <thead class="bg-gray-50 dark:bg-[#1a1a1a]">
                <tr>
                    <th class="">#</th>
                    <th class=""><?php esc_html_e('Order ID', 'anbarak') ?></th>
                    <th class=""><?php esc_html_e('Date', 'anbarak') ?></th>
                    <th class=""><?php esc_html_e('Customer', 'anbarak') ?></th>
                    <th class=""><?php esc_html_e('Total', 'anbarak') ?></th>
                    <th class=""><?php esc_html_e('Profit', 'anbarak') ?></th>
                    <th class=""><?php esc_html_e('Status', 'anbarak') ?></th>
                    <th class=""><?php esc_html_e('Actions', 'anbarak') ?></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td colspan="8">
                        <div class="text-large text-center p-3 text-bold text-gray">
                                                    <?php esc_html_e('Loading...', 'anbarak') ?>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>


</div>
