context = Context::getContext(); $this->className = 'ColissimoSuiviModel'; $this->table = 'colissimo_suivi'; $this->identifier = 'id_colissimo_suivi'; $this->addRowAction('delete'); $this->lang = false; $this->bootstrap = true; $this->list_no_link = true; parent::__construct(); $this->_select = ' o.`reference`, o.id_carrier, a.`tracking` as tracking, a.`tracking` as status_suivi, country_lang.`name` as `cname`, ad.`postcode`, CONCAT(c.`firstname`, \' \', c.`lastname`) AS `customer`'; $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` = o.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.`id_address` = o.`id_address_delivery`) INNER JOIN `'._DB_PREFIX_.'country` country ON (ad.id_country = country.id_country) INNER JOIN `'._DB_PREFIX_.'country_lang` country_lang ON (country.`id_country` = country_lang.`id_country` AND country_lang.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; $this->fields_list = array( 'id_order' => array( 'title' => $this->l('ID'), 'class' => 'fixed-width-xs', 'havingFilter' => true, 'align' => 'center', 'type' => 'int', 'callback' => 'getOrderLink' ), 'reference' => array( 'title' => $this->l('Reference'), 'class' => 'fixed-width-xs', ), 'customer' => array( 'title' => $this->l('Customer'), 'havingFilter' => true, ), 'postcode' => array( 'title' => $this->l('Postcode'), 'class' => 'fixed-width-xs', ), 'cname' => array( 'title' => $this->l('Country'), 'havingFilter' => true, ), 'tracking' => array( 'title' => $this->l('Tracking N°'), 'callback' => 'getTrackingLink' ), 'event_libelle' => array( 'title' => $this->l('Status'), ), 'event_site' => array( 'title' => $this->l('Location'), ), 'event_date' => array( 'title' => $this->l('Date'), 'align' => 'text-right', 'class' => 'fixed-width-sm', 'type' => 'date', ) ); if (version_compare(_PS_VERSION_, '1.6.0.0', '<')) { $this->toolbar_btn['refresh'] = array( 'href' => $this->context->link->getAdminLink(Tools::getValue('controller')).'&ajax=1&action=refresh', 'desc' => $this->l('Refresh'), 'icon' => 'process-icon-refresh' ); $this->toolbar_btn['clean'] = array( 'href' => $this->context->link->getAdminLink(Tools::getValue('controller')).'&ajax=1&action=clean', 'desc' => $this->l('Clean delivered orders'), 'icon' => 'process-icon-refresh' ); $this->toolbar_btn['configuration'] = array( 'href' => $this->context->link->getAdminLink('AdminModules').'&configure=colissimosuivi', 'desc' => $this->l('Configuration'), 'icon' => 'process-icon-cogs' ); } } public function initPageHeaderToolbar() { if (empty($this->display)) { $this->page_header_toolbar_btn['refresh'] = array( 'href' => $this->context->link->getAdminLink(Tools::getValue('controller')).'&ajax=1&action=refresh', 'desc' => $this->l('Refresh'), 'icon' => 'process-icon-refresh' ); $this->page_header_toolbar_btn['clean'] = array( 'href' => $this->context->link->getAdminLink(Tools::getValue('controller')).'&ajax=1&action=clean', 'desc' => $this->l('Clean delivered orders'), 'icon' => 'process-icon-refresh' ); $this->page_header_toolbar_btn['configuration'] = array( 'href' => $this->context->link->getAdminLink('AdminModules').'&configure=colissimosuivi', 'desc' => $this->l('Configuration'), 'icon' => 'process-icon-cogs' ); } parent::initPageHeaderToolbar(); } public function ajaxProcessRefresh() { $this->module->updateOrdersStatus(); Tools::redirectAdmin($this->context->link->getAdminLink('AdminColissimoSuivi')); } public function ajaxProcessClean() { Db::getInstance()->execute(' DELETE FROM `'._DB_PREFIX_.'colissimo_suivi` WHERE `event_code` = \'LIVCFM\' OR `event_code` = \'LIVGAR\'' ); Tools::redirectAdmin($this->context->link->getAdminLink('AdminColissimoSuivi')); } /** * @param int $id_order * @return string */ public function getOrderLink($id_order) { return ''.$id_order.''; } /** * @param int $tracking * @param int $details * @return string */ public function getTrackingLink($tracking, $details) { $detail_suivi = new ColissimoSuiviModel($details['id_colissimo_suivi']); $ret = $tracking; if (Validate::isLoadedObject($detail_suivi)) { $ret = ''.$detail_suivi->getTrackingFormatted().''; } return $ret; } }