function __loadOrdersSummary() { if (!$this->search_completed or empty($this->orders_ids)) { return; } // : // , // main_store_currency . // main_store_currency, // . // main_store_currency. global $application; $co_tables = modApiStaticFunc('Checkout', 'getTables'); $orders_table = $co_tables['orders']['columns']; $order_prices_table = $co_tables['order_prices']['columns']; $query = new DB_Select(); $query->addSelectTable('orders'); $query->addSelectField($order_prices_table['order_total'], 'order_total'); $query->addSelectField($orders_table['payment_status_id'], 'payment_status_id'); $query->addSelectField($order_prices_table['currency_code'], 'currency_code'); $query->WhereValue($order_prices_table['currency_type'], DB_EQ, CURRENCY_TYPE_MAIN_STORE_CURRENCY); $query->WhereAnd(); $query->Where($orders_table['id'], DB_IN, "('" . implode("','", $this->orders_ids) . "')"); $query->addLeftJoin('order_prices', $orders_table['id'], DB_EQ, $order_prices_table['order_id']); $rows = $application->db->getDB_Result($query); $amount = 0.0; $fully_paid_amount = 0.0; $main_store_currency = modApiFunc("Localization", "getCurrencyCodeById", modApiFunc("Localization", "getMainStoreCurrency")); foreach ($rows as $order_info) { $order_main_currency = $order_info['currency_code']; $order_total = $order_info['order_total']; if ($order_main_currency != $main_store_currency) { $order_total = modApiFunc('Currency_Converter', 'convert', $order_total, $order_main_currency, $main_store_currency); } $amount += $order_total; if ($order_info['payment_status_id'] == ORDER_PAYMENT_STATUS_FULLY_PAID) { $fully_paid_amount += $order_total; } } $query = new DB_Select(); $query->addSelectTable('orders'); $query->addSelectField($query->fMax($orders_table['date']), 'max_date'); $query->addSelectField($query->fMin($orders_table['date']), 'min_date'); $query->Where($orders_table['id'], DB_IN, "('" . implode("','", $this->orders_ids) . "')"); $res = $application->db->getDB_Result($query); $this->orders_summary = array('amount' => $amount, 'max_date' => $res[0]['max_date'], 'min_date' => $res[0]['min_date'], 'fully_paid_amount' => $fully_paid_amount); }