195 lines
6.9 KiB
PHP
195 lines
6.9 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to a commercial license.
|
|
* Use, copy, modification or distribution of this source file without written
|
|
* license agreement is strictly forbidden.
|
|
* In order to obtain a license, please contact us: simon@daig.re
|
|
* ...........................................................................
|
|
* INFORMATION SUR LA LICENCE D'UTILISATION
|
|
*
|
|
* L'utilisation de ce fichier source est soumise a une licence commerciale.
|
|
* Toute utilisation, reproduction, modification ou distribution du present
|
|
* fichier source sans contrat de licence ecrit est expressement interdite.
|
|
* Pour obtenir une licence, veuillez nous contacter a l'adresse: simon@daig.re
|
|
*
|
|
* @package La Poste Colissimo Suivi
|
|
* @author Agencya
|
|
* @copyright Copyright(c) 2015-2018
|
|
* @license See Readme.md
|
|
* Contact by Email : simon@daig.re
|
|
*/
|
|
|
|
/**
|
|
* Class AdminColissimoSuiviController
|
|
*/
|
|
class AdminColissimoSuiviController extends ModuleAdminController
|
|
{
|
|
/** @var ColissimoSuivi|string */
|
|
public $module = 'colissimosuivi';
|
|
|
|
/**
|
|
* AdminColissimoSuiviController constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->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 '<a target="_blank" href="'.$this->context->link->getAdminLink('AdminOrders').'&vieworder&id_order='.$id_order.'">'.$id_order.'</a>';
|
|
}
|
|
|
|
/**
|
|
* @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 = '<a target="_blank" href="'.$detail_suivi->getTrackingUrl().'">'.$detail_suivi->getTrackingFormatted().'</a>';
|
|
}
|
|
|
|
return $ret;
|
|
}
|
|
}
|