Merge branch 'ticket-14739-PackLogistic' into develop

This commit is contained in:
Michael RICOIS 2018-01-30 11:59:02 +01:00
commit 1b5f1efbc0
5 changed files with 167 additions and 189 deletions

View File

@ -1,5 +1,5 @@
<?php
if(!defined('_PS_VERSION_')) {
if (!defined('_PS_VERSION_')) {
exit;
}
@ -17,10 +17,12 @@ foreach(array_map(function($value) {
include _PS_ROOT_DIR_.'/modules/privatesales/Sale.php';
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
class AdminAntLogistic extends AdminTab {
class AdminAntLogistic 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',
@ -28,7 +30,8 @@ class AdminAntLogistic extends AdminTab {
);
}
private function isoreplace($str) {
private function isoreplace($str)
{
// ISO/CEI 646
return str_replace(array(
'Ç', 'ü', 'é', 'â', 'ä', 'à',
@ -80,39 +83,9 @@ class AdminAntLogistic extends AdminTab {
), $str);
}
private function printLabel($data, $mr=false) {
private function printLabel($data, $mr=false)
{
global $cookie;
echo '<pre>';var_dump($data);echo '</pre>';die();
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/OptionInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/AbstractOption.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/PrefixableCommandInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/CommandInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/AbstractCommand.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/PrefixableCommand.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Command/PubSubPublish.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/SingleConnectionInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/AbstractConnection.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/StreamConnection.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionParametersInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionParameters.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionFactoryInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Connection/ConnectionFactory.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Profile/ServerProfileInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Profile/ServerProfile.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Profile/ServerVersion26.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientCluster.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientPrefix.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientExceptions.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientReplication.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientConnectionFactory.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientProfile.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientOptionsInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Option/ClientOptions.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/BasicClientInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/ClientInterface.php';
require_once _PS_ROOT_DIR_.'/modules/logistics/libs/predis/lib/Predis/Client.php';
$redis = new Predis\Client();
@ -144,13 +117,15 @@ class AdminAntLogistic extends AdminTab {
return TRUE;
}
public function postProcess() {
public function postProcess()
{
global $cookie, $logistics_carriers;
if(
((int) $cookie->profile == 1 || (int) $cookie->profile == 9 || (int) $cookie->profile == 7 || (int) $cookie->profile == 14)
&& ($delete_number = Tools::getValue('delete_number'))
){
// Delete number
if(( in_array((int)$cookie->profile, array(1,9,7,13,14)) )
&& ( $delete_number = Tools::getValue('delete_number') )) {
// Suppression LAPOSTE
if($delete = (int) Tools::getValue('delete_laposte')) {
Db::getInstance()->ExecuteS('
DELETE FROM `'._DB_PREFIX_.'lapostews`
@ -172,7 +147,9 @@ class AdminAntLogistic 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.'
@ -190,7 +167,9 @@ class AdminAntLogistic 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.'
@ -209,7 +188,28 @@ class AdminAntLogistic 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`
@ -250,7 +250,7 @@ class AdminAntLogistic extends AdminTab {
// Generate a new shipping number for product sent with many parcels
if( (Tools::isSubmit('submitReprintShip'))
&& ((int) $cookie->profile == 1 || (int) $cookie->profile == 9 || (int) $cookie->profile == 7 || (int) $cookie->profile == 14)
&& in_array((int)$cookie->profile, array(1,9,7,13,14))
&& (
($id_order = Tools::getValue('id_order_reprint'))
&& ($products = Tools::getValue('products_reprint'))
@ -260,8 +260,8 @@ class AdminAntLogistic 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") {
$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];

View File

@ -1,5 +1,5 @@
<?php
include_once dirname(__FILE__).'/../../config/config.inc.php';
require_once dirname(__FILE__).'/../../config/config.inc.php';
$laposte_modes = array(
'DOM' => 'SO à domicile',
@ -44,9 +44,10 @@ $laposte_carriers = array_map('intval',explode(',', Configuration::get('ANT_CARR
$ooh = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_OOH')));
if(($id_order = (int) Tools::getValue('id_order'))
&& (Tools::getValue('token') === Tools::getAdminToken('AdminAntLogistic'.(int) Tab::getIdFromClassName('AdminAntLogistic').(int) Tools::getValue('id_employee')))) {
&& (Tools::getValue('token') === Tools::getAdminToken('AdminAntLogistic'.(int) Tab::getIdFromClassName('AdminAntLogistic').(int) Tools::getValue('id_employee')))) {
$profile = Tools::getValue('id_profile');
$order = new Order($id_order);
$profile = Tools::getValue('id_profil');
if(Validate::isLoadedObject($order)) {
$locked_products = array();
$_locked_products = Configuration::get('LOGISTICS_LOCK');
@ -89,9 +90,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
AND cl.`id_lang` = 2
');
} elseif(in_array((int) $order->id_carrier, $mr_carriers)) {
/**
* @Override MondialRelay
*/
// MondialRelay
$delivery_infos_mr = Db::getInstance()->getRow('
SELECT mr_s.*, mr_m.*, cl.`name` AS `country_name`
FROM `'._DB_PREFIX_.'mr_selected` mr_s
@ -109,7 +108,6 @@ if(($id_order = (int) Tools::getValue('id_order'))
WHERE s.`id_cart` = '.(int) $order->id_cart.'
');
}
// $delivery_infos_laposte = FALSE;
}
$delivery_infos_exapaq = Db::getInstance()->getRow('
@ -151,41 +149,39 @@ if(($id_order = (int) Tools::getValue('id_order'))
$link = new Link(2);
$products = array();
foreach($order->getProductsDetail() as $p) {
// --- Get quantity sent
// LaPoste
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'lapostews`
WHERE `id_order_detail` = '.(int) $p['id_order_detail'].'
');
// Exapaq
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'exapaqws`
WHERE `id_order_detail` = '.(int) $p['id_order_detail'].'
');
/**
* @Override MondialRelay
*/
// MondialRelay
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'mondialrelay_parcel`
WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . '
');
/**
* @Override Philea
*/
// Philea
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'philea_parcel`
WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . '
');
/**
* @Override Dropshipping
*/
// DropShipping
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'ant_dropshipping_parcel`
WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . '
');
// Image
$p['id_image'] = 0;
if((int) $p['product_attribute_id'] != 0) {
@ -237,45 +233,42 @@ if(($id_order = (int) Tools::getValue('id_order'))
$p['carriers'] = $sales_carriers[(int) $p['id_sale']];
$p['location'] = isset($locations[(int) $p['product_id'].'-'.(int) $p['product_attribute_id']])? $locations[(int) $p['product_id'].'-'.(int) $p['product_attribute_id']]: '';
// --- Get Shipping Numbers
$shipping_numbers = array();
// Philea
foreach(Db::getInstance()->ExecuteS('
SELECT l.`shipping_number`
FROM `'._DB_PREFIX_.'lapostews` l
FROM `'._DB_PREFIX_.'philea_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'order_history` h ON (h.`id_order` = d.`id_order`)
WHERE h.`id_order` = '.(int) $order->id.'
') as $row) {
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
// LaPoste
foreach(Db::getInstance()->ExecuteS('
SELECT e.`shipping_number`
FROM `'._DB_PREFIX_.'exapaqws` e
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = e.`id_order_detail`)
SELECT l.`shipping_number`
FROM `'._DB_PREFIX_.'lapostews` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'order_history` h ON (h.`id_order` = d.`id_order`)
WHERE h.`id_order` = '.(int) $order->id.'
') as $row) {
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
/*
* @Override MondialRelay
*/
// Exapaq
foreach(Db::getInstance()->ExecuteS('
SELECT l.`shipping_number`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`)
SELECT e.`shipping_number`
FROM `'._DB_PREFIX_.'exapaqws` e
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = e.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'order_history` h ON (h.`id_order` = d.`id_order`)
WHERE h.`id_order` = '.(int) $order->id.'
') as $row) {
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
/*
* @Override Philea
*/
// MondialRelay
foreach(Db::getInstance()->ExecuteS('
SELECT l.`shipping_number`
FROM `'._DB_PREFIX_.'philea_parcel` l
FROM `'._DB_PREFIX_.'mondialrelay_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`)
LEFT JOIN `'._DB_PREFIX_.'order_history` h ON (h.`id_order` = d.`id_order`)
WHERE h.`id_order` = '.(int) $order->id.'
@ -283,15 +276,15 @@ if(($id_order = (int) Tools::getValue('id_order'))
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
if(((int) $p['product_quantity_sent'] === 0)
&& Db::getInstance()->getRow('
if(((int) $p['product_quantity_sent'] === 0) && Db::getInstance()->getRow('
SELECT h.`id_sale`
FROM `'._DB_PREFIX_.'shipping_history` h
WHERE h.`id_sale` = '.((int) $p['id_sale'] === 999999? 0: (int) $p['id_sale']).'
AND h.`id_order` = '.(int) $order->id.'
'.(count($shipping_numbers) > 0? 'AND h.`shipping_number` NOT IN ('.implode(', ', $shipping_numbers).')': '').'
')) {
$p['product_quantity_sent'] = $p['product_quantity'] - ($p['product_quantity_return'] > 0? $p['product_quantity_return']: $p['product_quantity_refunded']);
$p['product_quantity_sent'] = $p['product_quantity'] - ( $p['product_quantity_return'] > 0 ?
$p['product_quantity_return']: $p['product_quantity_refunded'] );
}
/* Pack */
@ -317,64 +310,78 @@ if(($id_order = (int) Tools::getValue('id_order'))
$carriers[(int) $row['id_carrier']] = $row['name'];
}
if(count($id_order_details) > 0) {
if (count($id_order_details) > 0) {
$logs = array();
// Send by PHILEA
if($l = Db::getInstance()->ExecuteS('
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "laposte" AS `carrier`
FROM `'._DB_PREFIX_.'lapostews` l
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Philea" as firstname,
(CASE c.`external_module_name` WHEN "soflexibilite" THEN "laposte" ELSE c.`external_module_name` END) as carrier,
"1" as philea
FROM `'._DB_PREFIX_.'philea_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail`
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'carrier` c ON c.`id_carrier` = o.`id_carrier`
WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).')
AND l.`quantity` > 0
ORDER BY l.`date_add` DESC
')) {
$logs = array_merge($logs, $l);
}
// Send by LAPOSTE
if($l = Db::getInstance()->ExecuteS('
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`,
e.`firstname`, e.`lastname`, "laposte" as carrier, "0" as philea
FROM `'._DB_PREFIX_.'lapostews` l
LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee`
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail`
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
LEFT JOIN `ps_carrier` c ON c.`id_carrier` = o.`id_carrier`
WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).')
AND l.`quantity` > 0
ORDER BY l.`date_add` DESC
')) {
$logs = array_merge($logs, $l);
}
// Send by EXAPAQ
if($l = Db::getInstance()->ExecuteS('
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "exapaq" AS `carrier`
FROM `'._DB_PREFIX_.'exapaqws` l
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`,
e.`firstname`, e.`lastname`, "exapaq" as carrier, "0" as philea
FROM `'._DB_PREFIX_.'exapaqws` l
LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee`
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail`
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'carrier` c ON c.`id_carrier` = o.`id_carrier`
WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).')
AND l.`quantity` > 0
ORDER BY l.`date_add` DESC
')) {
$logs = array_merge($logs, $l);
}
/*
* @Override MondialRelay
*/
// Send by MONDIAL RELAY
if($l = Db::getInstance()->ExecuteS('
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, e.`firstname`, e.`lastname`, "mondialrelay" AS `carrier`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` l
LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee`
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`,
e.`firstname`, e.`lastname`, "mondialrelay" as carrier, "0" as philea
FROM `'._DB_PREFIX_.'mondialrelay_parcel` l
LEFT JOIN `'._DB_PREFIX_.'employee` e ON l.`id_employee` = e.`id_employee`
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail`
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
LEFT JOIN `ps_carrier` c ON c.`id_carrier` = o.`id_carrier`
WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).')
AND l.`quantity` > 0
ORDER BY l.`date_add` DESC
')) {
$logs = array_merge($logs, $l);
}
/*
* @Override Dropshipping
*/
// Send by DROPSHIPPING
if($l = Db::getInstance()->ExecuteS('
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Dropshipping" as firstname
FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail`
WHERE l.`id_order_detail` IN ('.implode(', ', $id_order_details).')
AND l.`quantity` > 0
ORDER BY l.`date_add` DESC
')) {
$logs = array_merge($logs, $l);
}
/*
* @Override Philea
*/
if($l = Db::getInstance()->ExecuteS('
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`, "Philea" as firstname, c.`name` as carrier
FROM `'._DB_PREFIX_.'philea_parcel` l
SELECT l.*, d.`product_name`, d.`product_reference`, d.`product_supplier_reference`,
"Dropshipping" as firstname, "0" as philea
FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON d.`id_order_detail` = l.`id_order_detail`
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'carrier` c ON c.`id_carrier` = o.`id_carrier`
@ -452,20 +459,20 @@ if(($id_order = (int) Tools::getValue('id_order'))
$html_products = '';
foreach($products as $key => $p) {
$html_products.='
<tr data-weight="'.((float)($products[$key]['product_weight']) == 0.001? 0.24: $products[$key]['product_weight']).'" data-carrier="'.implode(',',$products[$key]['carriers']).'" rel="'.($products[$key]['product_ean13']? $products[$key]['product_ean13']: '').'"
<tr data-weight="'.((float)($products[$key]['product_weight']) == 0.001 ? 0.24 : $products[$key]['product_weight']).'" data-carrier="'.implode(',',$products[$key]['carriers']).'" rel="'.($products[$key]['product_ean13'] ? $products[$key]['product_ean13'] : '').'"
class="'
.($products[$key]['id_shipping'] == 2? 'fed_ship': '')
.(in_array($products[$key]['product_id'], $locked_products)? 'blocked': '')
.(($products[$key]['product_quantity'] - ($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent'] > 0) && (in_array((int)($products[$key]['id_sale']), $sales_list))? '': 'grey')
.(max(in_array($products[$key]['product_id'], $locked_products)? 0: ($products[$key]['product_quantity'] - ($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent']), 0) > 1? ' blue': '').'"';
.($products[$key]['id_shipping'] == 2 ? 'fed_ship' : '')
.(in_array($products[$key]['product_id'], $locked_products) ? 'blocked' : '')
.(($products[$key]['product_quantity'] - ($products[$key]['product_quantity_refunded'] > 0 ? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent'] > 0) && (in_array((int)($products[$key]['id_sale']), $sales_list)) ? '' : 'grey')
.(max(in_array($products[$key]['product_id'], $locked_products)? 0: ($products[$key]['product_quantity'] - ($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent']), 0) > 1 ? ' blue' : '')
.'"';
if(isset($p['items_pack'])){
foreach($p['items_pack'] as $item){
$html_products.='data-pack_'.$item['id_product'].'="'.$item['pack_quantity'].'"';
}
}
$html_products.='
>
>
<td>'.(isset($p['items_pack'])?'<strong>LOT</strong>':'<img src="'.$products[$key]['image'].'" alt="" width="200" height="200" />').'</td>
<td style="font-size:16px;"><strong>'.str_replace(' - ','<br>',$products[$key]['product_name']).'</strong></td>
<td class="right">'.($products[$key]['product_reference']? $products[$key]['product_reference'].'<br />': '').($products[$key]['product_ean13']? $products[$key]['product_ean13']: '').($products[$key]['location']?'<br /><span class="location">'.$products[$key]['location'].'</span>': '').'</td>
@ -476,7 +483,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
<td class="shipped text-center">';
if ($products[$key]['id_shipping'] != 2
|| ($products[$key]['id_shipping'] == 2 && ($profile == 1 || $profile == 7))
|| ($products[$key]['id_shipping'] == 2 && in_array((int)$profile, array(1,7)))
) {
if(isset($p['items_pack'])){
$html_products.='<input class="input_quantity" readonly="true" onchange="checkParcelCarrier($(this));" name="shipped['.$products[$key]['id_order_detail'].']" type="text" value="0" autocomplete="off" />';
@ -514,7 +521,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
<td></td>
<td class="shipped text-center">';
if ($products[$key]['id_shipping'] != 2
|| ($products[$key]['id_shipping'] == 2 && ($profile == 1 || $profile == 7))
|| ($products[$key]['id_shipping'] == 2 && in_array((int)$profile, array(1,7)))
) {
$html_products.='<input data-item="'.$item['id_product'].'" class="input_quantity" readonly="true" onchange="checkQuantityPack($(this),'.$item['id_product'].','.$p['id_order_detail'].','.$item['pack_quantity'].','.(in_array($products[$key]['product_id'], $locked_products)? 0: max(($products[$key]['product_quantity']*$item['pack_quantity'] - ($products[$key]['product_quantity_refunded']*$item['pack_quantity'] > 0? $products[$key]['product_quantity_refunded']*$item['pack_quantity']: $products[$key]['product_quantity_return']*$item['pack_quantity']) - $products[$key]['product_quantity_sent']*$item['pack_quantity']), 0)).');" type="text" value="0" autocomplete="off" /><span class="qtyblock"><a onclick="qtyUp($(this), '.(in_array($products[$key]['product_id'], $locked_products)? 0: max(($products[$key]['product_quantity']*$item['pack_quantity'] - ($products[$key]['product_quantity_refunded']*$item['pack_quantity'] > 0? $products[$key]['product_quantity_refunded']*$item['pack_quantity']: $products[$key]['product_quantity_return']*$item['pack_quantity']) - $products[$key]['product_quantity_sent']*$item['pack_quantity']), 0)).'); return false;">+</a><a class="qty_down" onclick="qtyDown($(this)); return false;">-</a></span>';
}
@ -538,18 +545,18 @@ if(($id_order = (int) Tools::getValue('id_order'))
<td>'.$logs[$key]['product_supplier_reference'].'</td>
<td>'.$logs[$key]['shipping_number'].'</td>
<td>'.(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ? $carrier_names[$logs[$key]['carrier']] : $logs[$key]['carrier']) .'</td>
'.(((int) $profile == 1 || (int) $profile == 9 || (int) $profile == 7 || (int) $profile == 14)?
(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ?'<td><a class="need_token" href="/adm/index.php?tab=AdminAntLogistic&id_order='.$order->id.'&delete_'.$logs[$key]['carrier'].'='.$logs[$key]['id_order_detail'].'&delete_number='.$logs[$key]['shipping_number'].'"><span class="anticon anticon-bin"></span></a></td>': '<td></td>'):'<td></td>').'
'.(((int) $profile == 1 || (int) $profile == 9 || (int) $profile == 7 || (int) $profile == 14)?
(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ?'<td><a title="Re print" data-toggle="modal" data-target="#modalRePrint" class="reprint" data-product="'.str_replace(" - ", "<br />",$logs[$key]['product_name']).'" data-weight="'.((float)$logs[$key]['weight']>0?(float)$logs[$key]['weight']:0.24).'" data-ref="'.$logs[$key]['product_reference'] .'" data-id_order="'.$order->id.'" data-carrier="'.$logs[$key]['carrier'].'" data-id_order_detail="'.$logs[$key]['id_order_detail'].'"><span class="anticon anticon-printer"></span></a></td>': '<td></td>'):'<td></td>').'
'.(( in_array((int)$profile, array(1,9,7,13,14)) ) ?
(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ? '<td><a class="need_token" href="/adm/index.php?tab=AdminAntLogistic&id_order='.$order->id.'&delete_'.$logs[$key]['carrier'].'='.$logs[$key]['id_order_detail'].'&delete_number='.$logs[$key]['shipping_number'].'"><span class="anticon anticon-bin"></span></a></td>': '<td></td>'):'<td></td>').'
'.(( in_array((int)$profile, array(1,9,7,13,14)) )?
(($logs[$key]['carrier'] == "laposte" || $logs[$key]['carrier'] == "mondialrelay") ? '<td><a title="Re print" data-toggle="modal" data-target="#modalRePrint" class="reprint" data-product="'.str_replace(" - ", "<br />",$logs[$key]['product_name']).'" data-weight="'.((float)$logs[$key]['weight']>0?(float)$logs[$key]['weight']:0.24).'" data-ref="'.$logs[$key]['product_reference'] .'" data-id_order="'.$order->id.'" data-carrier="'.$logs[$key]['carrier'].'" data-id_order_detail="'.$logs[$key]['id_order_detail'].'"><span class="anticon anticon-printer"></span></a></td>': '<td></td>'):'<td></td>').'
</tr>';
}
$html_form ='<div class="form-inline">';
if(
(in_array($order->id_carrier, $laposte_carriers) || in_array($order->id_carrier, $mr_carriers))
&& in_array((int)($delivery_address->id_country), array(1, 2, 3, 6, 8, 10, 12, 13, 15, 17, 26, 40, 148, 245))
){
if((in_array($order->id_carrier, $laposte_carriers)
|| in_array($order->id_carrier, $mr_carriers))
&& in_array((int)($delivery_address->id_country),
array(1, 2, 3, 6, 8, 10, 12, 13, 15, 17, 26, 40, 148, 245)) ){
$html_form.=
'<div class="form-group">
<label for="parcel_carrier">Transporteur :</label>
@ -571,13 +578,13 @@ if(($id_order = (int) Tools::getValue('id_order'))
</div>';
echo json_encode(array(
'errors' => FALSE,
'html_detail' => (String)$html_detail,
'html_invoice_address' => (String)$html_invoice_address,
'html_delivery_address' => (String)$html_delivery_address,
'html_products' => (String)$html_products,
'html_logs' => (String)$html_logs,
'html_form' => (String)$html_form,
'errors' => false,
'html_detail' => (string)$html_detail,
'html_invoice_address' => (string)$html_invoice_address,
'html_delivery_address' => (string)$html_delivery_address,
'html_products' => (string)$html_products,
'html_logs' => (string)$html_logs,
'html_form' => (string)$html_form,
'order' => $order,
'products' => $products,
'status' => $status['name'],

View File

@ -234,32 +234,32 @@ function checkEAN() {
clearTimeout(ean_timeout);
ean_timeout = setTimeout(function() {
var eanval = $("#eaninput").val();
if(eanval != "") {
var eanval_item = $("#button_form tbody tr").filter(function() {
if($(this).attr("rel") != eanval) {
if (eanval != "") {
/* Select simple product */
var eanval_item = $("#button_form tbody tr").filter(function() {
if ($(this).attr("rel") != eanval) {
return $(this).attr("rel") == '0'+eanval;
}
return $(this).attr("rel") == eanval;
});
if(eanval_item.length > 0) {
if (eanval_item.length > 0) {
$(eanval_item).each(function(id, el) {
var current_val = parseInt($(el).find(".shipped input").val());
var max_val = parseInt($(el).find(".toship strong").text());
if(current_val < max_val) {
if (current_val < max_val) {
qtyUp($(el).find(".shipped a")[0], max_val);
} else {
var eanval_item_pack = $("#button_form tbody tr").filter(function() {
if($(this).attr("rel") != eanval+'_pack') {
if ($(this).attr("rel") != eanval+'_pack') {
return $(this).attr("rel") == '0'+eanval+'_pack';
}
return $(this).attr("rel") == eanval+'_pack';
});
if(eanval_item_pack.length > 0) {
if (eanval_item_pack.length > 0) {
$(eanval_item_pack).each(function(id_pack, el_pack) {
var current_val = parseInt($(el_pack).find(".shipped input").val());
var max_val = parseInt($(el_pack).find(".toship strong").text());
if(current_val < max_val) {
if (current_val < max_val) {
qtyUp($(el_pack).find(".shipped a")[0], max_val);
} else {
confirm("Quantité à envoyer déjà atteinte pour ce produit");
@ -270,18 +270,20 @@ function checkEAN() {
}
}
});
} else {
}
/* Select pack product */
else {
var eanval_item_pack = $("#button_form tbody tr").filter(function() {
if($(this).attr("rel") != eanval+'_pack') {
if ($(this).attr("rel") != eanval+'_pack') {
return $(this).attr("rel") == '0'+eanval+'_pack';
}
return $(this).attr("rel") == eanval+'_pack';
});
if(eanval_item_pack.length > 0) {
});
if (eanval_item_pack.length > 0) {
$(eanval_item_pack).each(function(id_pack, el_pack) {
var current_val = parseInt($(el_pack).find(".shipped input").val());
var max_val = parseInt($(el_pack).find(".toship strong").text());
if(current_val < max_val) {
if (current_val < max_val) {
qtyUp($(el_pack).find(".shipped a")[0], max_val);
} else {
confirm("Quantité à envoyer déjà atteinte pour ce produit");

View File

@ -1,22 +1,18 @@
<?php
if(!defined('_PS_VERSION_')) {
if (!defined('_PS_VERSION_')) {
exit;
}
global $logistics_carriers;
foreach(array_map(function($value) {
return str_replace('.', '', $value);
},
array_diff(scandir(dirname(__FILE__).'/carriers'), array('.', '..'))) as $lg
) {
}, array_diff(scandir(dirname(__FILE__).'/carriers'), array('.', '..'))) as $lg) {
if(is_dir(dirname(__FILE__).'/carriers/'.$lg)) {
include dirname(__FILE__).'/carriers/'.$lg.'/'.$lg.'.php';
$name = ucfirst($lg).'Carrier';
$logistics_carriers[$lg] = new $name();
}
}
//include dirname(__FILE__).'/carriers/laposte/laposte.php';
//$logistics_carriers['laposte'] = new LaposteCarrier();
include _PS_ROOT_DIR_.'/modules/privatesales/Sale.php';
@ -112,16 +108,7 @@ class AdminLogistics extends AdminTab
$redis->publish(
Configuration::get('LOGISTICS_QUEUE_'.(int) $cookie->id_employee),
json_encode(array('data' => base64_encode(
/*chr(2).'n'."\n" // Inch mode
.chr(2).'O0100'."\n" // Start position
.chr(2).'L'."\n"
.'C0000'."\n"
.'D11'."\n"
.chr(2).'L'."\n"
.$this->isoreplace($data)
.'Q0001'."\n" // Number of labels to print
.'E'."\n" // End*/
$data
$data
)))
);
}
@ -325,24 +312,12 @@ class AdminLogistics extends AdminTab
$logistics_carriers[$parcel_carrier]->addOrderHistory($result[1], $order, $products_sent);
}
} else {
$this->html .= '<p class="error">'.$this->l('An error happened during the label rendering').'</p><br />';
$this->_html .= '<p class="error">'.$this->l('An error happened during the label rendering').'</p><br />';
}
}
// elseif($parcel_carrier=='mondialrelay'
// && (
// ($id_order_detail = Tools::getValue('id_order_detail_reprint'))
// && ($weight = Tools::getValue('weight_reprint'))
// )
// ){
// $result = $logistics_carriers['mondialrelay']->_getRegisteredParcel(new Order($id_order), $id_order_detail, $products, $weight);
// $render = $logistics_carriers['mondialrelay']->renderLabel(new Order($id_order), $weight, $result[1]);
// $this->printLabel($render,true);
// }
}
//$this->printLabel($logistics_carriers['laposte']->renderLabel(new Order((int) $id_order), $weight, $reprint_number));
} elseif(Tools::isSubmit('submitTestLaposte')) {
$this->_html .= '<p class="conf">'.$this->l('Registration complete, label sent to printer').'</p><br />';
//$this->printLabel($logistics_carriers['laposte']->renderLabel(new Order(23336), 0.24, '6A12345123451'));
$this->printLabel($logistics_carriers['laposte']->renderLabel(new Order(223001), 0.24, '6J12345123451'));
} elseif(Tools::isSubmit('submitTestExapaq')) {
$this->_html .= '<p class="conf">'.$this->l('Registration complete, label sent to printer').'</p><br />';
@ -500,10 +475,6 @@ class AdminLogistics extends AdminTab
public function display() {
global $cookie, $logistics_carriers;
/*if(!in_array($cookie->id_employee, array(1, 2, 3, 10, 68, 70, 89, 91))) {
echo 'Fonctionnalité indisponible actuellement'; return;
}*/
$unavailable_carriers = array();
foreach($logistics_carriers as $name => $class) {

View File

@ -1,5 +1,5 @@
<?php
include dirname(__FILE__).'/../../config/config.inc.php';
include_once dirname(__FILE__).'/../../config/config.inc.php';
$laposte_modes = array(
'DOM' => 'SO à domicile',
@ -42,8 +42,9 @@ function stripaccents($str) {
$mr_carriers = array_map('intval',explode(',', Configuration::get('ANT_CARRIERS_MR')));
if(($id_order = (int) Tools::getValue('id_order'))
&& (Tools::getValue('token') === Tools::getAdminToken('AdminLogistics'.(int) Tab::getIdFromClassName('AdminLogistics').(int) Tools::getValue('id_employee')))) {
$order = new Order($id_order);
&& (Tools::getValue('token') === Tools::getAdminToken('AdminLogistics'.(int) Tab::getIdFromClassName('AdminLogistics').(int) Tools::getValue('id_employee')))) {
$order = new Order($id_order);
if(Validate::isLoadedObject($order)) {
$customer = Db::getInstance()->getRow('
@ -68,9 +69,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
AND cl.`id_lang` = 2
');
} elseif(in_array((int) $order->id_carrier, $mr_carriers)) {
/**
* @Override MondialRelay
*/
// MondialRelay
$delivery_infos_mr = Db::getInstance()->getRow('
SELECT mr_s.*, mr_m.*, cl.`name` AS `country_name`
FROM `'._DB_PREFIX_.'mr_selected` mr_s
@ -88,7 +87,6 @@ if(($id_order = (int) Tools::getValue('id_order'))
WHERE s.`id_cart` = '.(int) $order->id_cart.'
');
}
// $delivery_infos_laposte = FALSE;
}
$delivery_infos_exapaq = Db::getInstance()->getRow('
@ -387,7 +385,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
);
echo json_encode(array(
'errors' => FALSE,
'errors' => false,
'order' => $order,
'products' => $products,
'status' => $status['name'],