Merge branch 'ticket-11985-MondialRelay_part2' into develop

This commit is contained in:
Marion Muszynski 2017-01-19 15:21:22 +01:00
commit 3118610fb1
3 changed files with 43 additions and 21 deletions

View File

@ -550,6 +550,23 @@ class AdminLogistics extends AdminTab {
if(loaded) { if(loaded) {
var loaded = $.parseJSON(loaded); var loaded = $.parseJSON(loaded);
isRelay = $.inArray(parseInt(loaded.delivery_address.id_country), [1, 2, 3, 6, 10, 12, 13, 17, 26, 40, 148, 245]) != -1? 0: (loaded.delivery_infos_laposte? (loaded.delivery_infos_laposte.delivery_mode != \'DOM\'? 1: 0): (loaded.delivery_infos_exapaq? 2: 0)); isRelay = $.inArray(parseInt(loaded.delivery_address.id_country), [1, 2, 3, 6, 10, 12, 13, 17, 26, 40, 148, 245]) != -1? 0: (loaded.delivery_infos_laposte? (loaded.delivery_infos_laposte.delivery_mode != \'DOM\'? 1: 0): (loaded.delivery_infos_exapaq? 2: 0));
isRelay = $.inArray(parseInt(loaded.delivery_address.id_country), [1, 2, 3, 6, 10, 12, 13, 17, 26, 40, 148, 245]) != -1
? 0
: (loaded.delivery_infos_laposte
? (loaded.delivery_infos_laposte.delivery_mode != \'DOM\'
? 1
: 0 )
: (loaded.delivery_infos_exapaq
? 2
: (loaded.delivery_infos_mr
? (loaded.delivery_infos_mr.dlv_mode != \'LD1\' && loaded.delivery_infos_mr.dlv_mode != \'LDS\' && loaded.delivery_infos_mr.dlv_mode != \'HOM\'
? 3
: 0
)
: 0
)
)
);
lockPrint = false; lockPrint = false;
if(!loaded.errors) { if(!loaded.errors) {

View File

@ -247,7 +247,7 @@ if(count($lines)) {
array(428, 7, 'N', 'POIDS', (float) $line['weight'] * $mr_account_details['MR_WEIGHT_COEFFICIENT']), array(428, 7, 'N', 'POIDS', (float) $line['weight'] * $mr_account_details['MR_WEIGHT_COEFFICIENT']),
array(435, 7, 'N', 'VOLU', ''), array(435, 7, 'N', 'VOLU', ''),
array(442, 3, 'N', 'LONG', ''), array(442, 3, 'N', 'LONG', ''),
array(445, 6, 'A', 'ORIG', 'BRICOP'), array(445, 6, 'A', 'ORIG', 'BEBEBO'),
array(451, 7, 'N', 'VENTE', ''), array(451, 7, 'N', 'VENTE', ''),
array(458, 3, 'A', 'DEVVTE', 'EUR'), array(458, 3, 'A', 'DEVVTE', 'EUR'),
array(461, 7, 'N', 'CRT', (int) $crt_amount * 100), array(461, 7, 'N', 'CRT', (int) $crt_amount * 100),
@ -342,7 +342,7 @@ if(count($lines)) {
// .sprintf('%07d', (float) $line['weight'] * $mr_account_details['MR_WEIGHT_COEFFICIENT']) // .sprintf('%07d', (float) $line['weight'] * $mr_account_details['MR_WEIGHT_COEFFICIENT'])
// .str_pad('', 7) // .str_pad('', 7)
// .str_pad('', 3) // .str_pad('', 3)
// .str_pad(mb_substr(Configuration::get('MONDIALRELAY_ORIGIN_CODE', 'BRICOP'), 0, 6), 6) // .str_pad(mb_substr(Configuration::get('MONDIALRELAY_ORIGIN_CODE', 'BEBEBO'), 0, 6), 6)
// .str_pad('', 7) // .str_pad('', 7)
// .'EUR' // .'EUR'
// .sprintf('%07d', (int) $crt_amount * 100) // .sprintf('%07d', (int) $crt_amount * 100)

View File

@ -438,7 +438,7 @@ class MondialrelayCarrier {
$last_update = Db::getInstance()->getValue('SELECT DATE_ADD(`date_upd`, INTERVAL 1 YEAR) FROM `' . _DB_PREFIX_ . 'mondialrelay_expedition_numbers` WHERE `sequence` = ' . (int) $sequence); $last_update = Db::getInstance()->getValue('SELECT DATE_ADD(`date_upd`, INTERVAL 1 YEAR) FROM `' . _DB_PREFIX_ . 'mondialrelay_expedition_numbers` WHERE `sequence` = ' . (int) $sequence);
if ($last_update && $last_update > date('Y-m-d H:i:s')){ if ($last_update && $last_update > date('Y-m-d H:i:s')){
$content = 'Le numéro d\'expédition ' . $sequence . ' a été affecté il y a moins d\'un an.' . "\n" . 'Impossible d\'affecter un nouveau numéro d\'expédition'; $content = 'Le numéro d\'expédition ' . $sequence . ' a été affecté il y a moins d\'un an.' . "\n" . 'Impossible d\'affecter un nouveau numéro d\'expédition';
mail('coppee@antadis.com', '[MONDIAL RELAY] Numéro d\'expédition', $content, 'Content-Type: text/plain; charset="utf-8"'."\r\n".'From: commande@bricoprive.com'."\r\n".'Reply-To: coppee@antadis.com'."\r\n".'Return-Path: coppee@antadis.com'."\r\n"); mail('marion@antadis.com', '[BBB MONDIAL RELAY] Numéro d\'expédition', $content, 'Content-Type: text/plain; charset="utf-8"'."\r\n".'From: commande@bebeboutik.com'."\r\n".'Reply-To: marion@antadis.com'."\r\n".'Return-Path: marion@antadis.com'."\r\n");
return false; return false;
} }
Db::getInstance()->execute(' Db::getInstance()->execute('
@ -463,9 +463,10 @@ class MondialrelayCarrier {
global $cookie; global $cookie;
$delivery_infos = Db::getInstance()->getRow(' $delivery_infos = Db::getInstance()->getRow('
SELECT * SELECT s.*, m.`dlv_mode`
FROM `'._DB_PREFIX_.'mr_selected` FROM `'._DB_PREFIX_.'mr_selected` s
WHERE `id_order` = '.(int) $order->id.' LEFT JOIN `'._DB_PREFIX_.'mr_method` m ON (s.`id_method` = m.`id_mr_method`)
WHERE s.`id_order` = '.(int) $order->id.'
'); ');
// Hack 5 numbers relay num // Hack 5 numbers relay num
@ -473,8 +474,9 @@ class MondialrelayCarrier {
$delivery_infos['MR_Selected_Num'] = substr($delivery_infos['MR_Selected_Num'], -5); $delivery_infos['MR_Selected_Num'] = substr($delivery_infos['MR_Selected_Num'], -5);
} }
if(!$delivery_infos) { if(!$delivery_infos|| in_array($delivery_infos['dlv_mode'], array('LDS', 'LD1', 'HOM'))) {
$mode = 'LD1'; $mode = $delivery_infos? $delivery_infos['dlv_mode']: 'LD1';
$address = Db::getInstance()->getRow(' $address = Db::getInstance()->getRow('
SELECT a.`postcode`, UPPER(c.`iso_code`) AS `iso_code` SELECT a.`postcode`, UPPER(c.`iso_code`) AS `iso_code`
FROM `'._DB_PREFIX_.'address` a FROM `'._DB_PREFIX_.'address` a
@ -484,13 +486,7 @@ class MondialrelayCarrier {
'); ');
$country = $address['iso_code']; $country = $address['iso_code'];
$postcode = $address['postcode']; $postcode = $address['postcode'];
} else {
$mode = $delivery_infos['id_method'] == 0? 'LD1': '24R';
$country = $delivery_infos['MR_Selected_Pays'];
$postcode = $delivery_infos['MR_Selected_CP'];
}
if($mode == 'LD1') {
$plantri = Db::getInstance()->getRow(' $plantri = Db::getInstance()->getRow('
SELECT * SELECT *
FROM `'._DB_PREFIX_.'mondialrelay_tri` FROM `'._DB_PREFIX_.'mondialrelay_tri`
@ -498,12 +494,10 @@ class MondialrelayCarrier {
AND `destex` = "'.pSQL($postcode).'" AND `destex` = "'.pSQL($postcode).'"
AND `cppay` = "'.pSQL($country).'" AND `cppay` = "'.pSQL($country).'"
AND ( AND (
`livmod` = "LD1" `livmod` = "'.pSQL($mode).'"
OR `livmod` = "HOM" OR `livmod` = "HOM"
) )
'); ');
if(!$plantri) { if(!$plantri) {
$plantri = Db::getInstance()->getRow(' $plantri = Db::getInstance()->getRow('
SELECT * SELECT *
@ -512,23 +506,34 @@ class MondialrelayCarrier {
AND `destex` = "'.pSQL(substr($postcode, 0, 2)).'" AND `destex` = "'.pSQL(substr($postcode, 0, 2)).'"
AND `cppay` = "'.pSQL($country).'" AND `cppay` = "'.pSQL($country).'"
AND ( AND (
`livmod` = "LD1" `livmod` = "'.pSQL($mode).'"
OR `livmod` = "HOM" OR `livmod` = "HOM"
) )
'); ');
} }
if($plantri) { if($plantri) {
$mode = $plantri['livmod']; $mode = $plantri['livmod'];
} }
} else { } else {
$mrrelais = Db::getInstance()->getRow(' $mr_relais = Db::getInstance()->getRow('
SELECT * SELECT *
FROM `'._DB_PREFIX_.'mondialrelay_relais` FROM `'._DB_PREFIX_.'mondialrelay_relais`
WHERE 1 WHERE 1
AND `direction` = "'.pSQL($delivery_infos['MR_Selected_Num']).'" AND `direction` = "'.pSQL($delivery_infos['MR_Selected_Num']).'"
AND `prpay` = "'.pSQL($country).'" AND `prpay` = "'.pSQL($delivery_infos['MR_Selected_Pays']).'"
'); ');
$mode = $delivery_infos['dlv_mode'];
if($mode == '24R') {
if($mr_relais['narel'] == 'F') {
$mode = '24X';
} elseif($mr_relais['narel'] == 'E') {
$mode = '24L';
} else {
$mode = '24R';
}
}
$country = $delivery_infos['MR_Selected_Pays'];
$postcode = $delivery_infos['MR_Selected_CP'];
$plantri = Db::getInstance()->getRow(' $plantri = Db::getInstance()->getRow('
SELECT * SELECT *
FROM `'._DB_PREFIX_.'mondialrelay_tri` FROM `'._DB_PREFIX_.'mondialrelay_tri`