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(); }
<?php include dirname(__FILE__) . '/../../../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../../../init.php'; include dirname(__FILE__) . '/kiala.php'; // make sure a point was selected if (!isset($_REQUEST['shortkpid'])) { echo 'Kiala did not return anything'; var_dump($_REQUEST); exit; } // $kiala = new CartAPI_Module_Kiala(); // kiala does not have code to parse a Point class from $_REQUEST (only from xml), so parse manually // code taken from module kiala kiala.php displayPoint $kiala_order = KialaOrder::getEmptyKialaOrder($cart->id); $kiala_order->point_short_id = $_REQUEST['shortkpid']; $kiala_order->point_name = $_REQUEST['kpname']; $kiala_order->point_street = $_REQUEST['street']; $kiala_order->point_zip = $_REQUEST['zip']; $kiala_order->point_city = $_REQUEST['city']; $kiala_order->point_location_hint = $_REQUEST['locationhint']; $kiala_order->id_cart = (int) $cart->id; $kiala_order->save(); Tools::redirect('');
/** * Display order tracking info * * @param array $params (order, cart) * @return string template rendering */ public function hookOrderDetailDisplayed($params) { global $smarty; $kiala_order = KialaOrder::getByOrder($params['order']->id); if (!Validate::isLoadedObject($kiala_order)) { return false; } $address = new Address($params['order']->id_address_delivery); $kiala_country = KialaCountry::getByIdCountry($address->id_country); $search_by = Configuration::get('KIALA_SEARCH_BY'); if ($search_by == 'customer') { $id = $kiala_order->id_customer; } elseif ($search_by == 'order') { $id = Configuration::get('KIALA_NUMBER_PREFIX') . $kiala_order->id; } else { return false; } $kiala_request = new KialaRequest(); $url = $kiala_request->getTrackingRequest($address, $kiala_country, $params['order']->id_lang, $id, $search_by); $smarty->assign('url_tracking', Tools::safeOutput($url)); return $this->display(__FILE__, 'orderDetail.tpl'); }