function index() { $is_admin = $this->_is_user_admin(); $month = $this->input->post('month'); if ($month === false) { $month = date("M"); } $data['heading'] = "Insights"; $all_orders = $this->database->GetAllOrders(); $gross = $this->_get_gross_info($all_orders); //get latest order $latest_order_index = count($all_orders) - 1; $latest_order = array($all_orders[$latest_order_index]); _add_address_and_user_to_orders($latest_order); //Get this months orders data $month_info = $this->_getOrdersDataForMonth($month); $data['gross'] = $gross; $data['month'] = $month; $data['total_products'] = $month_info['total_products']; $data['sales_data'] = $month_info['orders']; $data['num_orders'] = $month_info['num_orders']; $data['dates'] = $month_info['dates']; $data['revenue_data'] = $month_info['revenue']; $data['total_revenue'] = $month_info['total_revenue']; $data['cod_orders'] = $this->_getNumCodOrders($all_orders); $data['online_orders'] = $this->_getNumOnlineOrders($all_orders); $data['is_admin'] = $is_admin; $data['latest_order'] = $latest_order; //Get Statewise Orders data $state_info = $this->_getStateWiseOrderData(); $data['states'] = $state_info['states']; $data['states_sales'] = $state_info['states_sales']; //Get Game Sepcific Sales Data $games_data = $this->database->GetDataForGameSalesChart(); foreach ($games_data as $key => $value) { $data['game_sales_data'][] = (int) $value['product_qty_sold']; } $all_games = $this->database->GetAllSuportedGames(); foreach ($all_games as $key => $value) { $data['all_games'][] = $value['product_game']; } display('insights', $data); }
function orders($order_id = null) { $this->_validate_user(); $orders = array(); if ($order_id) { $ord = $this->database->GetOrderById($order_id); if ($ord) { $orders = array($ord); } } else { //If no order_id is given show pending/returned orders $orders = $this->database->GetPendingReturnedOrders(); } //As $orders is an array if (count($orders)) { _add_address_and_user_to_orders($orders); } $data['orders'] = $orders; $data['num_shipped_orders'] = $this->database->NumShippedOrders(); $data['num_orders'] = count($orders); $data['orders_table'] = $this->_generate_orders_table($orders); display('admin_orders', $data); }