示例#1
0
    public function __construct()
    {
        global $cookie;
        $this->table = 'kiala_order';
        $this->className = 'KialaOrder';
        $this->edit = true;
        $this->noAdd = true;
        if (!($id_lang = $cookie->id_lang)) {
            $id_lang = Configuration::get('PS_LANG_DEFAULT');
        }
        $this->fieldsDisplay = array('id_kiala_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'exported' => array('title' => $this->l('Exported'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'exported', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'enabled.gif')), 'customer' => array('title' => $this->l('Customer'), 'width' => 120, 'filter_key' => 'customer', 'tmpTableFilter' => true), 'country' => array('title' => $this->l('Country'), 'width' => 80, 'filter_key' => 'country', 'tmpTableFilter' => true), 'kiala_point' => array('title' => $this->l('Kiala point'), 'width' => 60), 'total_paid' => array('title' => $this->l('Total'), 'width' => 60, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true), 'osname' => array('title' => $this->l('Payment'), 'width' => 90), 'date_add' => array('title' => $this->l('Order date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'), 'invoice_date' => array('title' => $this->l('Invoice date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!invoice_date'));
        $this->_select = 'o.total_paid, o.id_currency, o.date_add, o.invoice_date, CONCAT(c.firstname, \' \', c.lastname) as customer, cl.name as country, osl.`name` AS `osname`';
        $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.`id_order` = a.`id_order`)
						LEFT JOIN ' . _DB_PREFIX_ . 'customer c ON (c.id_customer = a.id_customer)
						LEFT JOIN ' . _DB_PREFIX_ . 'country_lang cl ON (cl.id_country = a.id_country_delivery) AND (cl.id_lang = ' . (int) $id_lang . ')
						LEFT JOIN `' . _DB_PREFIX_ . 'order_history` oh ON (oh.`id_order` = a.`id_order`)
						LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
						LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int) $cookie->id_lang . ')';
        $this->_where = 'AND a.id_order != 0 AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `' . _DB_PREFIX_ . 'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';
        $this->_orderWay = 'DESC';
        // Clean old empty kiala orders
        KialaOrder::cleanEmptyOrders();
        parent::__construct();
    }