/** * - . . . sort_order * . * */ function generateCreditCardTypeSortOrder() { global $application; $tables = $this->getTables(); $columns = $tables['credit_card_settings']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($columns['sort_order']), 'max'); $result = $application->db->getDB_Result($query); return $result[0]['max'] + 1; }
function __getMaxSortOrderOfProductImages($product_id) { global $application; $tables = $this->getTables(); $imgs_table = $tables['pi_images']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($imgs_table['sort_order']), 'max_sort_order'); $query->WhereValue($imgs_table['product_id'], DB_EQ, $product_id); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order']; }
function getNextTopicOrder() { global $application; $table = 'subscription_topic'; $query = new DB_Select(); $query->addSelectTable($table); $query->addSelectField(DB_Select::fMax('sort_order'), 'max_sort_order'); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order'] + 1; }
function __getMaxSortOrderOfManufacturers() { global $application; $tables = $this->getTables(); $mnf_table = $tables['manufacturers']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($mnf_table['sort_order']), 'max_sort_order'); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order']; }
function __getMaxFPSortOrderForCategory($category_id) { global $application; $tables = $this->getTables(); $fp_table = $tables['fp_links']['columns']; $query = new DB_Select(); $query->addSelectTable('fp_links'); $query->addSelectField($query->fMax($fp_table['sort_order']), 'max_so'); $query->WhereValue($fp_table['category_id'], DB_EQ, $category_id); $res = $application->db->getDB_Result($query); if (count($res) == 1) { return $res[0]['max_so']; } else { return 0; } }
function getNextNum() { global $application; $tables = $this->getTables(); $table = 'newsletter_unsubscribe'; $columns = $tables[$table]['columns']; $query = new DB_Select($table); $query->addSelectField(DB_Select::fMax($columns['delivery_num']), 'num'); $res = $application->db->getDB_Result($query); return $res[0]['num'] + 1; }
function __getMaxInventorySortOrder($parent_entity, $entity_id) { global $application; $tables = $this->getTables(); $ex_table = $tables['po_inventory']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($ex_table['sort_order']), 'max_sort_order'); $query->WhereValue($ex_table['parent_entity'], DB_EQ, $parent_entity); $query->WhereAND(); $query->WhereValue($ex_table['entity_id'], DB_EQ, $entity_id); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order']; }
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); }