table = 'order'; $this->className = 'Order'; $this->identifier = 'id_order'; $this->lang = false; $this->deleted = false; $this->bootstrap = true; $this->toolbar_title = $this->l('Channel Manager Bookings'); $this->context = Context::getContext(); parent::__construct(); // 'a' is the orders row itself now (no separate booking table) — an order is CM-sourced // if id_channel_manager_booking is set, OR its source isn't the shop's own domain (covers // CM bookings where the channel manager never sent id_channel_manager_booking). $this->_where = ' AND ( ( a.`id_channel_manager_booking` IS NOT NULL AND a.`id_channel_manager_booking` != \'\' ) OR a.`source` != \''.pSQL(Configuration::get('PS_SHOP_DOMAIN')).'\' ) '; $this->_orderBy = 'date_add'; $this->_orderWay = 'DESC'; $this->fields_list = array( 'id_order' => array( 'title' => $this->l('Id order'), 'align' => 'text-center', 'class' => 'fixed-width-xs', 'filter_key' => 'a!id_order', 'callback' => 'getOrderLink', ), 'source' => array( 'title' => $this->l('Channel'), 'align' => 'text-center', 'filter_key' => 'a!source', ), 'total_paid' => array( 'title' => $this->l('Order total'), 'align' => 'text-center', 'type' => 'range', 'validation' => 'isFloat', 'filter_key' => 'a!total_paid', 'callback' => 'setPriceCurrency', ), 'total_paid_real' => array( 'title' => $this->l('Received amount'), 'align' => 'text-center', 'type' => 'range', 'validation' => 'isFloat', 'filter_key' => 'a!total_paid_real', 'callback' => 'setPriceCurrencyWithBadge', ), 'date_add' => array( 'title' => $this->l('Created on'), 'align' => 'text-center', 'type' => 'datetime', 'filter_key' => 'a!date_add', ), ); $this->list_no_link = true; } public function getOrderLink($idOrder, $row) { $displayData = ''; if ($idOrder) { $displayData .= '#'.$idOrder; } return $displayData; } public function setPriceCurrency($value, $row) { return Tools::displayPrice($value, (int)$row['id_currency']); } public function setPriceCurrencyWithBadge($value, $row) { $displayData = ''; $displayData .= ''; $displayData .= Tools::displayPrice($value, (int)$row['id_currency']); $displayData .= ''; return $displayData; } public function displayViewLink($token, $idRow, $name = null) { return ' '.$this->l('View Order Detail').''; } public function renderList() { if (QcmcChannelManagerOrder::isChannelManagerConnected()) { $this->context->smarty->assign( array ( 'toolbar_title' => 'icon-list', 'last_booking_datetime' => Tools::displayDate(QcmcChannelManagerOrder::getLastChannelManagerBookingDate(), null, true), 'is_cm_connected' => QcmcChannelManagerOrder::isChannelManagerConnected(), ) ); // because in helper list tpl_vars is given priority and we need different List title than list title // In HelperList.php assigned: 'title' => array_key_exists('title', $this->tpl_vars) ? $this->tpl_vars['title'] : $this->title $this->tpl_list_vars['title'] = $this->l('Channel Manager Bookings'); unset($this->toolbar_btn['new']); $this->addRowAction('view'); return parent::renderList(); } else { $this->context->smarty->assign( array ( 'module_dir' => _MODULE_DIR_, 'current_datetime' => Tools::displayDate(date('Y-m-d H:i:s'), null, true), 'is_cm_connected' => QcmcChannelManagerOrder::isChannelManagerConnected(), ) ); $this->content .= $this->context->smarty->fetch( _PS_MODULE_DIR_. 'qlocmconnector/views/templates/admin/qloapps_channel_manager_connector/qcmc_channel_manager_connect_info.tpl' ); } } public function setMedia() { parent::setMedia(); if (QcmcChannelManagerOrder::isChannelManagerConnected()) { $this->addJS(_MODULE_DIR_.'qlocmconnector/views/js/admin/qcmc_cm_booking_list.js'); } else { $this->addCSS(_MODULE_DIR_.'qlocmconnector/views/css/admin/qcmc_cm_info.css'); } } }