/** * main action */ public function mainAction() { if ($_SESSION['client']['customer']['id'] > 0) { $customer_id = $_SESSION['client']['customer']['id']; } else { if (Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) { $customer_id = $this->GET['customer_id']; } else { msg('orders: You must be logged in first.', 'error'); onxshopGoTo("/"); } } /** * include node configuration */ require_once 'models/common/common_node.php'; $node_conf = common_node::initConfiguration(); $this->tpl->assign('NODE_CONF', $node_conf); /** * Get the list */ require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); $Order->setCacheable(false); $records = $Order->getOrderList($customer_id); /** * parse output */ if (count($records) > 0) { foreach ($records as $item) { $item['order_created'] = strftime('%d/%m/%Y %H:%M', strtotime($item['order_created'])); $item['status_title'] = $Order->getStatusTitle($item['order_status']); $this->tpl->assign('ITEM', $item); if ($Order->checkOrderStatusValidForPayment($item['order_status'])) { $this->tpl->parse('content.orders.item.make_payment'); } $this->tpl->parse('content.orders.item'); } $this->tpl->parse('content.orders'); } else { $this->tpl->parse('content.noorders'); } return true; }
/** * main action */ public function mainAction() { /*$order = $this->GET['order']; $search = trim($_POST['search']); $customer_id = $this->GET['customer_id']; $status = $this->GET['status'];*/ if (is_array($_SESSION['bo']['order-list-filter'])) { $order_list_filter = $_SESSION['bo']['order-list-filter']; } else { $order_list_filter = array(); } if (is_numeric($this->GET['customer_id'])) { $customer_id = $this->GET['customer_id']; //display all orders when looking for a customer $order_list_filter = array(); $order_list_filter['status'] = 'all'; } else { $customer_id = NULL; } if (is_numeric($this->GET['status'])) { $order_list_filter['status'] = $this->GET['status']; } /** * if query is numeric, go strait to order detail */ if (is_numeric($_POST['order-list-filter']['query'])) { onxshopGoTo("/backoffice/orders/{$_POST['order-list-filter']['query']}/detail"); } /** * Initialize pagination variables */ if (is_numeric($this->GET['limit_from'])) { $from = $this->GET['limit_from']; } else { $from = 0; } if (is_numeric($this->GET['limit_per_page'])) { $per_page = $this->GET['limit_per_page']; } else { $per_page = 25; } $limit = "{$from},{$per_page}"; /** * Initialize order object */ require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); /** * Get order list */ $order_list = $Order->getOrderList($customer_id, $order_list_filter, $per_page, $from); $count = $Order->getOrderListCount($customer_id, $order_list_filter); if ($count > 0) { /** * Display pagination */ $_Onxshop_Request = new Onxshop_Request("component/pagination~limit_from={$from}:limit_per_page={$per_page}:count={$count}~"); $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent()); /** * Display items * Implemented pagination */ foreach ($order_list as $item) { $even_odd = 'odd' != $even_odd ? 'odd' : 'even'; $item['even_odd'] = $even_odd; $item['order_created'] = strftime('%c', strtotime($item['order_created'])); $item['last_activity'] = strftime('%c', strtotime($item['last_activity'])); if (!is_numeric($item['goods_net'])) { $item['goods_net'] = 0; } // display payment due (for unpaid orders only) if ($item['order_status'] == 0 && isset($item['other_data']['payment_due'])) { $item['payment_due'] = $item['other_data']['payment_due']; } $item['status'] = $Order->getStatusTitle($item['order_status']); $this->tpl->assign('ITEM', $item); $this->tpl->parse('content.list.item'); } $this->tpl->parse('content.list'); } else { $this->tpl->parse('content.empty'); } return true; }
/** * getOrdersList */ public function getOrdersList($customer_id) { if (!is_numeric($customer_id)) { return false; } require_once 'models/ecommerce/ecommerce_order.php'; $Order = new ecommerce_order(); $records = $Order->getOrderList($customer_id); if (is_array($records)) { $valid_orders_list = array(); foreach ($records as $item) { //use only 1 New (paid), 2 Dispatched, 3 Complete if ($item['order_status'] == 1 || $item['order_status'] == 2 || $item['order_status'] == 3) { $valid_orders_list[] = $item; } } return $valid_orders_list; } else { return false; } }