<?php


use Hura8\Components\Order\AdminController\AOrderController;
use Hura8\Components\Order\Controller\OrderStatus;
use Hura8\System\Paging;

$numPerPage = 30;

$conditions = array(
    'orderCode' => getRequest('orderCode', ''),
    'q' => getRequest('q', ''),
    //'coupon' => getRequest('coupon', ''),
    'cus_id' => getRequest('cus_id', ''),
    'province' => getRequest('province', ''),
    //'district' => getRequest('district', ''),
    'folder' => getRequest('folder', ''),
    'view_status' => getRequest('view_status', ''),
    'update_by' => getRequest('update_by', ''),
    //'shipping_status' => getRequest('shipping_status', ''),
    'assign_to' => getRequest('assign_to', ''),
    'from_date' => getRequest('from_date', ''),
    'to_date' => getRequest('to_date', ''),
    //'from_hour' => getRequest('from_hour', ''),
    //'to_hour' => getRequest('to_hour', ''),
    'payment' => getRequest('payment', ''),
    'fullfillment' => getRequest('fullfillment', ''),
    'status'    => getRequest('status', ''),
    //'excluded_ids' => getRequest('', ''),
    //'included_ids' => getRequest('', ''),
    'list' => getRequest('list', ''),
    'numPerPage' => $numPerPage,
    'page' => getPageId(),
);

$objAOrderController  = new AOrderController();
$totalResults      = $objAOrderController->getTotal($conditions);
$item_list = $objAOrderController->getList($conditions);

//debug_var($item_list);

list($page_collection, $tb_page, $total_pages) = Paging::paging_template($totalResults, $numPerPage);

return [
    "total"         => $totalResults,
    "item_list"     => $item_list,
    "pagination"    => [
        'collection' => $page_collection,
        'html' => $tb_page,
        'total_pages' => $total_pages,
    ],
    "order_status_list"         => OrderStatus::ORDER_STATUS ,
    "payment_status_list"       => OrderStatus::PAYMENT_STATUS,
    "fullfillment_status_list"  => OrderStatus::FULFILLMENT_STATUS ,
];
