diff --git a/modules/logistics/AdminLogistics.php b/modules/logistics/AdminLogistics.php index 98a8bce8..5a7ccda0 100644 --- a/modules/logistics/AdminLogistics.php +++ b/modules/logistics/AdminLogistics.php @@ -20,11 +20,12 @@ foreach(array_map(function($value) { include _PS_ROOT_DIR_.'/modules/privatesales/Sale.php'; - -class AdminLogistics extends AdminTab { +class AdminLogistics extends AdminTab +{ public $_html = ''; - private function stripaccents($str) { + private function stripaccents($str) + { return preg_replace( '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i', '$1', @@ -32,7 +33,8 @@ class AdminLogistics extends AdminTab { ); } - private function isoreplace($str) { + private function isoreplace($str) + { // ISO/CEI 646 return str_replace(array( 'Ç', 'ü', 'é', 'â', 'ä', 'à', @@ -84,41 +86,10 @@ class AdminLogistics extends AdminTab { ), $str); } - private function printLabel($data, $mr=false) { + private function printLabel($data, $mr=false) + { global $cookie; - //require dirname(__FILE__).'/libs/predis/autoload.php'; // Conflicts with Prestashop autoload - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/OptionInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/AbstractOption.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PrefixableCommandInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/CommandInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/AbstractCommand.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PrefixableCommand.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PubSubPublish.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/SingleConnectionInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/AbstractConnection.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/StreamConnection.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionParametersInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionParameters.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionFactoryInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionFactory.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerProfileInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerProfile.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerVersion26.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientCluster.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientPrefix.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientExceptions.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientReplication.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientConnectionFactory.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientProfile.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientOptionsInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientOptions.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/BasicClientInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/ClientInterface.php'; - require_once dirname(__FILE__).'/libs/predis/lib/Predis/Client.php'; - $redis = new Predis\Client(); if($mr){ @@ -158,13 +129,16 @@ class AdminLogistics extends AdminTab { return TRUE; } - public function postProcess() { + public function postProcess() + { global $cookie, $logistics_carriers; + // Delete number if(( in_array((int)$cookie->profile, array(1,9,7,13,14)) ) && ( $delete_number = Tools::getValue('delete_number') )) { - if($delete = (int) Tools::getValue('delete_laposte')) { + // Suppression LAPOSTE + if ($delete = (int) Tools::getValue('delete_soflexibilite')) { Db::getInstance()->ExecuteS(' DELETE FROM `'._DB_PREFIX_.'lapostews` WHERE `id_order_detail` = '.$delete.' @@ -185,7 +159,9 @@ class AdminLogistics extends AdminTab { AND `shipping_number` = "'.pSQL($delete_number).'" '); } - } elseif($delete = (int) Tools::getValue('delete_exapaq')) { + } + // Suppression EXAPAQ + elseif ($delete = (int) Tools::getValue('delete_exapaq')) { Db::getInstance()->ExecuteS(' DELETE FROM `'._DB_PREFIX_.'exapaqws` WHERE `id_order_detail` = '.$delete.' @@ -203,7 +179,9 @@ class AdminLogistics extends AdminTab { AND `shipping_number` = "'.pSQL($delete_number).'" '); } - } elseif($delete = (int) Tools::getValue('delete_mondialrelay')) { + } + // Suppression MONDIAL RELAY + elseif ($delete = (int) Tools::getValue('delete_mondialrelay')) { Db::getInstance()->ExecuteS(' DELETE FROM `'._DB_PREFIX_.'mondialrelay_parcel` WHERE `id_order_detail` = '.$delete.' @@ -222,7 +200,28 @@ class AdminLogistics extends AdminTab { '); } } + // Suppression PHILEA + elseif ($delete = (int) Tools::getValue('delete_philea')) { + Db::getInstance()->ExecuteS(' + DELETE FROM `'._DB_PREFIX_.'philea_parcel` + WHERE `id_order_detail` = '.$delete.' + AND `shipping_number` = "'.pSQL($delete_number).'" + '); + + if(!Db::getInstance()->getRow(' + SELECT `shipping_number` + FROM `'._DB_PREFIX_.'philea_parcel` + WHERE `shipping_number` = "'.pSQL($delete_number).'" + ')) { + Db::getInstance()->ExecuteS(' + DELETE FROM `'._DB_PREFIX_.'shipping_history` + WHERE `id_order` = '.(int) Tools::getValue('id_order').' + AND `shipping_number` = "'.pSQL($delete_number).'" + '); + } + } + // Pour les commandes et les articles mise à jours en commande non envoyé, simplement payé $id_order_details = array(); foreach(Db::getInstance()->ExecuteS(' SELECT `id_order_detail` @@ -273,9 +272,9 @@ class AdminLogistics extends AdminTab { ) { $weight = 0.24; $order = new Order((int) $id_order); - if(Validate::isLoadedObject($order)) { - $parcel_carrier == 'laposte'? $weight = 0.24: TRUE; - if($parcel_carrier == "laposte" || $parcel_carrier == "mondialrelay") { + if (Validate::isLoadedObject($order)) { + $parcel_carrier == 'laposte' ? $weight = 0.24 : true; + if ($parcel_carrier == "laposte" || $parcel_carrier == "mondialrelay") { $result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight); if($result[0] != '') { $this->_html .= $result[0]; @@ -301,10 +300,10 @@ class AdminLogistics extends AdminTab { $this->_html .= '
'.$this->l('Registration complete, label sent to printer').'