This commit is contained in:
Michael RICOIS 2018-03-21 10:27:58 +01:00
parent 6b863fe940
commit 76b26ac6b4

View File

@ -1,13 +1,14 @@
<?php <?php
if(!defined('_PS_VERSION_')) { if (!defined('_PS_VERSION_')) {
exit; exit;
} }
class Logistics extends Module
class Logistics extends Module { {
public $_html = ''; public $_html = '';
public function __construct() { public function __construct()
{
$this->name = 'logistics'; $this->name = 'logistics';
$this->tab = 'shipping_logistics'; $this->tab = 'shipping_logistics';
$this->version = '2.0'; $this->version = '2.0';
@ -20,7 +21,8 @@ class Logistics extends Module {
$this->description = $this->l('Allows to manage parcels'); $this->description = $this->l('Allows to manage parcels');
} }
public function install() { public function install()
{
# Add admin tabs # Add admin tabs
$tabs_i18n = array( $tabs_i18n = array(
'fr' => 'Gestion des envois', 'fr' => 'Gestion des envois',
@ -34,7 +36,7 @@ class Logistics extends Module {
$t->module = 'logistics'; $t->module = 'logistics';
$t->class_name = 'AdminLogistics'; $t->class_name = 'AdminLogistics';
foreach(Language::getLanguages() as $lang) { foreach(Language::getLanguages() as $lang) {
if(isset($tabs_i18n[$lang['iso_code']])) { if (isset($tabs_i18n[$lang['iso_code']])) {
$t->name[$lang['id_lang']] = $tabs_i18n[$lang['iso_code']]; $t->name[$lang['id_lang']] = $tabs_i18n[$lang['iso_code']];
} else { } else {
$t->name[$lang['id_lang']] = $tabs_i18n['en']; $t->name[$lang['id_lang']] = $tabs_i18n['en'];
@ -47,7 +49,8 @@ class Logistics extends Module {
&& $this->registerHook('updateCarrier'); && $this->registerHook('updateCarrier');
} }
private function installCarriers() { private function installCarriers()
{
return return
// La Poste // La Poste
Db::getInstance()->Execute(' Db::getInstance()->Execute('
@ -150,7 +153,8 @@ class Logistics extends Module {
'); ');
} }
private function uninstallCarriers() { private function uninstallCarriers()
{
/*Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews`'); /*Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews`');
Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews_pr`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews_pr`');
Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws`');
@ -161,14 +165,16 @@ class Logistics extends Module {
return TRUE; return TRUE;
} }
public function uninstall() { public function uninstall()
{
return $this->uninstallCarriers() && parent::uninstall(); return $this->uninstallCarriers() && parent::uninstall();
} }
public function getContent() { public function getContent()
{
global $cookie; global $cookie;
if(Tools::isSubmit('submitUpdate')) { if (Tools::isSubmit('submitUpdate')) {
/* La Poste */ /* La Poste */
Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize(Tools::getValue('laposte_carriers', array()))); Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize(Tools::getValue('laposte_carriers', array())));
@ -822,7 +828,7 @@ class Logistics extends Module {
foreach(Employee::getEmployees() as $employee) { foreach(Employee::getEmployees() as $employee) {
$value = Configuration::get('LOGISTICS_QUEUE_'.(int) $employee['id_employee']); $value = Configuration::get('LOGISTICS_QUEUE_'.(int) $employee['id_employee']);
// if($value === FALSE) { // if ($value === FALSE) {
// $value = Configuration::get('LAPOSTEWS_EMPL_'.(int) $employee['id_employee']); // $value = Configuration::get('LAPOSTEWS_EMPL_'.(int) $employee['id_employee']);
// } // }
@ -834,7 +840,7 @@ class Logistics extends Module {
} }
$lock = Configuration::get('LOGISTICS_LOCK'); $lock = Configuration::get('LOGISTICS_LOCK');
if($lock === FALSE || empty($lock)) { if ($lock === false || empty($lock)) {
$lock = serialize(array()); $lock = serialize(array());
} }
@ -862,21 +868,21 @@ class Logistics extends Module {
$carriers = Configuration::get('LAPOSTEWS_CARRIERS'); $carriers = Configuration::get('LAPOSTEWS_CARRIERS');
if(in_array((int) $params['id_carrier'], $carriers)) { if (in_array((int) $params['id_carrier'], $carriers)) {
$carriers[] = (int) $new_carrier_id; $carriers[] = (int) $new_carrier_id;
Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize($carriers)); Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize($carriers));
} }
$carriers = Configuration::get('EXAPAQWS_CARRIERS'); $carriers = Configuration::get('EXAPAQWS_CARRIERS');
if(in_array((int) $params['id_carrier'], $carriers)) { if (in_array((int) $params['id_carrier'], $carriers)) {
$carriers[] = (int) $new_carrier_id; $carriers[] = (int) $new_carrier_id;
Configuration::updateValue('EXAPAQWS_CARRIERS', serialize($carriers)); Configuration::updateValue('EXAPAQWS_CARRIERS', serialize($carriers));
} }
$carriers = Configuration::get('MONDIALRELAYWS_CARRIERS'); $carriers = Configuration::get('MONDIALRELAYWS_CARRIERS');
if(in_array((int) $params['id_carrier'], $carriers)) { if (in_array((int) $params['id_carrier'], $carriers)) {
$carriers[] = (int) $new_carrier_id; $carriers[] = (int) $new_carrier_id;
Configuration::updateValue('MONDIALRELAYWS_CARRIERS', serialize($carriers)); Configuration::updateValue('MONDIALRELAYWS_CARRIERS', serialize($carriers));
} }