Merge branch 'ticket-11985-MondialRelay_part2' into develop

This commit is contained in:
Marion Muszynski 2017-02-15 11:39:15 +01:00
commit 8a61a09988
4 changed files with 79 additions and 26 deletions

View File

@ -0,0 +1,45 @@
<?php
if(isset($_SERVER['REMOTE_ADDR'])) {
exit;
}
$_SERVER['HTTP_PORT'] = 80;
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
include dirname(__FILE__).'/../../../../config/config.inc.php';
## GET agences.txt FILE
$fname = 'agences.txt';
$filename = dirname(__FILE__) . '/' . $fname;
$file = fopen($filename, 'w+');
$remote_file = $fname;
$ftp = ftp_connect(Configuration::get('MONDIALRELAYWS_FTP_HOST'));
ftp_login($ftp, Configuration::get('MONDIALRELAYWS_FTP_LOGIN'), Configuration::get('MONDIALRELAYWS_FTP_PASSWORD'));
ftp_chdir($ftp, 'depuismrelay');
if (!ftp_fget($ftp, $file, $remote_file, FTP_BINARY))
die('An error occures while downloading remote file : ' . $fname);
$file = fopen($filename, 'r');
$content = fgets($file);
if (!$content)
die('File is empty : ' . $fname);
## Update DB
Db::getInstance()->ExecuteS('
TRUNCATE TABLE `'._DB_PREFIX_.'mondialrelay_agencies`
');
while($line = fgets($file)) {
if(substr($line, 1, 1) == '1') {
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'mondialrelay_agencies`
VALUES (
"'.pSQl(substr($line, 6, 4)).'",
"'.pSQl(substr($line, 10)).'",
)
');
}
}

View File

@ -48,12 +48,12 @@ function phone_format($phone, $id_country = 8){
$phone = '0' . $phone;
}
// add spaces
$_phone = '';
for($i=0; $i<strlen($phone); $i++){
$_phone .= $phone[$i];
if (($i+1)%2==0)
$_phone .= ' ';
}
// $_phone = '';
// for($i=0; $i<strlen($phone); $i++){
// $_phone .= $phone[$i];
// if (($i+1)%2==0)
// $_phone .= ' ';
// }
$phone = $_phone;
// set format
@ -152,7 +152,7 @@ if(count($lines)) {
$cpt = 0;
foreach($lines as $line) {
if (!in_array($line['mode'], array('24R', '24L', '24X', 'DRI')))
if (!in_array($line['mode'], array('24R', '24L', '24X', 'DRI','LD1','LDR','LDS','HOM')))
continue;
$cpt++;
@ -173,14 +173,21 @@ if(count($lines)) {
case 'DOM':
case 'HOM':
case 'LD1':
$mr_liv_mode['DISCOL'] = 'D';
$mr_liv_mode['SERCOL'] = '1';
$mr_liv_mode['COLMOD'] = 'CDR';
case 'LDR':
$mr_liv_mode['DISCOL'] = '';
$mr_liv_mode['SERCOL'] = '2';
$mr_liv_mode['COLMOD'] = 'CCC';
// $mr_liv_mode['DISCOL'] = 'D';
// $mr_liv_mode['SERCOL'] = '1';
// $mr_liv_mode['COLMOD'] = 'CDR';
break;
case 'LDS':
$mr_liv_mode['DISCOL'] = 'D';
$mr_liv_mode['SERCOL'] = '2';
$mr_liv_mode['COLMOD'] = 'CDS';
$mr_liv_mode['DISCOL'] = '';
$mr_liv_mode['SERCOL'] = '2';
$mr_liv_mode['COLMOD'] = 'CCC';
// $mr_liv_mode['DISCOL'] = 'D';
// $mr_liv_mode['SERCOL'] = '2';
// $mr_liv_mode['COLMOD'] = 'CDS';
break;
case 'LCC':
$mr_liv_mode['DISCOL'] = 'D';
@ -221,7 +228,7 @@ if(count($lines)) {
array(17, 8, 'A', 'CDEST', !empty($line['idrelay'])? $line['idrelay']: $address['postcode']),
array(25, 4, 'N', 'TRANS', $line['modexp']),
array(29, 5, 'N', 'TOURNE', $line['direction']),
array(34, 1, 'N', 'TYPSER', ($line['mode'] == 'DOM' || $line['mode'] == 'HOM'? '1': ($line['mode'] == 'LD1'? '1': ($line['mode'] == 'LDS' || $line['mode'] == 'LCC'? '2': '3')))),
array(34, 1, 'N', 'TYPSER', ($line['mode'] == 'DOM' || $line['mode'] == 'HOM'? '0': ($line['mode'] == 'LD1'? '1': ($line['mode'] == 'LDS' || $line['mode'] == 'LCC'? '2': '3')))),
array(35, 3, 'A', 'LIVMOD', $line['mode']),
array(38, 10, 'DT', 'DATREM', date('d.m.Y')),
array(48, 4, 'A', 'SIGLE', ''),
@ -238,8 +245,8 @@ if(count($lines)) {
array(234, 2, 'A', 'LVCPAY', $line['cppay']),
array(236, 5, 'A', 'LVCPOS', $address['postcode']),
array(241, 5, 'A', 'LVXPOS', ''),
array(246, 20, 'A', 'LVTEL1', phone_format($address['phone'])),
array(266, 20, 'A', 'LVTEL2', phone_format($address['phone_mobile'])),
array(246, 20, 'A', 'LVTEL1', str_replace(' ','',phone_format($address['phone']))),
array(266, 20, 'A', 'LVTEL2', str_replace(' ','',phone_format($address['phone_mobile']))),
array(286, 70, 'A', 'LVEMAI', $line['email']),
array(356, 31, 'A', 'INSLIV1', $address['other']),
array(387, 31, 'A', 'INSLIV2', $address['other']),
@ -295,7 +302,7 @@ if(count($lines)) {
array(828, 2, 'A', 'EXCPAY', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_country)),
array(830, 5, 'A', 'EXCPOS', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_postcode)),
array(835, 5, 'A', 'EXXCPO', ''),
array(840, 20, 'A', 'EXNTEL', phone_format($exp_phone, (int) $exp_country)),
array(840, 20, 'A', 'EXNTEL', str_replace(' ','',phone_format($exp_phone, (int) $exp_country))),
array(860, 70, 'A', 'EXEMAI', $exp_email),
array(930, 2, 'A', 'LNGCOL', 'FR'),
array(932, 9, 'N', 'RECOL', '999999999'),

View File

@ -7,7 +7,7 @@ global $mondialrelay_formats;
$mondialrelay_formats = array(
'FR' => chr(2).'m'.'
1911S2611800050P080P040{SHIPPING_NUMBER_C25I}
1e1325011800052C{SHIPPING_NUMBER128}
131110011200180{SHIPPING_NUMBER}
1X1100009400050b0480015000010001
1X1100005500050b0480035000010001
@ -68,7 +68,7 @@ A2
'.chr(2).'n
',
'EN' => chr(2).'m'.'
1911S2611800050P080P040{SHIPPING_NUMBER_C25I}
1e1325011800052C{SHIPPING_NUMBER128}
131110011200180{SHIPPING_NUMBER}
1X1100009400050b0480015000010001
1X1100005500050b0480035000010001
@ -129,7 +129,7 @@ A2
'.chr(2).'n
',
'ES' => chr(2).'m'.'
1911S2611800050P080P040{SHIPPING_NUMBER_C25I}
1e1325011800052C{SHIPPING_NUMBER128}
131110011200180{SHIPPING_NUMBER}
1X1100009400050b0480015000010001
1X1100005500050b0480035000010001
@ -340,7 +340,7 @@ class MondialrelayCarrier {
$format = str_replace(
array(
'{SHIPPING_NUMBER_C25I}',
'{SHIPPING_NUMBER128}',
'{SHIPPING_NUMBER}',
'{EXP_COMPANY}',
'{EXP_ADDR1}',
@ -372,7 +372,7 @@ class MondialrelayCarrier {
'{INSTRUCTIONS}',
),
array(
$shipping_data['shipping_number_c25i'],
$shipping_data['shipping_number'],
$shipping_data['shipping_number_fmt'],
$exp_company,
$exp_address1,
@ -496,23 +496,23 @@ class MondialrelayCarrier {
AND (
`livmod` = "'.pSQL($mode_tri).'"
OR `livmod` = "HOM"
)
) ORDER BY `livmod` DESC
');
if(!$plantri) {
$plantri = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'mondialrelay_tri`
WHERE `destyp` = "CP"
WHERE `destyp` = "DT"
AND `destex` = "'.pSQL(substr($postcode, 0, 2)).'"
AND `cppay` = "'.pSQL($country).'"
AND (
`livmod` = "'.pSQL($mode_tri).'"
OR `livmod` = "HOM"
)
) ORDER BY `livmod` DESC
');
}
if($plantri) {
$mode = $plantri['livmod'];
$mode = ($plantri['livmod'] == 'LDR'?'LD1':$plantri['livmod']);
}
} else {
$mr_relais = Db::getInstance()->getRow('

View File

@ -419,6 +419,7 @@
ON c.`iso_code` = s.`MR_Selected_Pays`
WHERE m.`id_carrier` = ' . (int) $order->id_carrier . '
AND s.`id_cart` = ' . (int) $order->id_cart . '
AND s.`MR_Selected_Num` IS NOT NULL
AND m.`id_mr_method` IS NOT NULL
')) {
$delivery->firstname = $mr['MR_Selected_LgAdr1'];