Merge branch 'ticket-10580-FixBugWSU'
This commit is contained in:
commit
14a00cb64a
@ -152,6 +152,9 @@ class Parcel {
|
||||
if($this->product_type == 'BOM') {
|
||||
$this->product_type = 'DOM';
|
||||
}
|
||||
if(!in_array($so_data['cecountry'], array('BE', 'AD', 'MC', 'FR', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
|
||||
$this->product_type = 'DOS';
|
||||
}
|
||||
|
||||
$this->dst_address['email'] = $so_data['ceemail'];
|
||||
if(empty($this->dst_address['email'])) {
|
||||
@ -159,15 +162,15 @@ class Parcel {
|
||||
}
|
||||
|
||||
if(!empty($so_data['cename'])) {
|
||||
$this->dst_address['lastName'] = mb_substr($so_data['cename'], 0, 35);
|
||||
$this->dst_address['lastName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','İ'), array(' ', '', '', '', 'a', 'a','a','A','l','i'), $so_data['cename']), 0, 35);
|
||||
} else {
|
||||
$this->dst_address['lastName'] = mb_substr($so_data['prname'], 0, 35);
|
||||
$this->dst_address['lastName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','İ'), array(' ', '', '', '', 'a', 'a','a','A','l','i'), $so_data['prname']), 0, 35);
|
||||
}
|
||||
|
||||
if(!empty($so_data['cefirstname'])) {
|
||||
$this->dst_address['firstName'] = mb_substr(str_replace('', ' ', $so_data['cefirstname']), 0, 29);
|
||||
$this->dst_address['firstName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['cefirstname']), 0, 29);
|
||||
} else {
|
||||
$this->dst_address['firstName'] = mb_substr(str_replace('', ' ', $so_data['prfirstname']), 0, 29);
|
||||
$this->dst_address['firstName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['prfirstname']), 0, 29);
|
||||
}
|
||||
|
||||
$address_lines = array();
|
||||
@ -178,19 +181,19 @@ class Parcel {
|
||||
}
|
||||
|
||||
if(count($address_lines) == 1) {
|
||||
$this->dst_address['line2'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[0]);
|
||||
$this->dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]);
|
||||
} elseif(count($address_lines) == 2) {
|
||||
$this->dst_address['line2'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[0]);
|
||||
$this->dst_address['line3'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[1]);
|
||||
$this->dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]);
|
||||
$this->dst_address['line3'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[1]);
|
||||
} elseif(count($address_lines) == 3) {
|
||||
$this->dst_address['line0'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[0]);
|
||||
$this->dst_address['line2'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[1]);
|
||||
$this->dst_address['line3'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[2]);
|
||||
$this->dst_address['line0'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]);
|
||||
$this->dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[1]);
|
||||
$this->dst_address['line3'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[2]);
|
||||
} else {
|
||||
$this->dst_address['line0'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[0]);
|
||||
$this->dst_address['line1'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[1]);
|
||||
$this->dst_address['line2'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[2]);
|
||||
$this->dst_address['line3'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), $address_lines[3]);
|
||||
$this->dst_address['line0'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]);
|
||||
$this->dst_address['line1'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[1]);
|
||||
$this->dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[2]);
|
||||
$this->dst_address['line3'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[3]);
|
||||
}
|
||||
|
||||
$this->dst_address['countryCode'] = $so_data['cecountry'];
|
||||
@ -201,14 +204,30 @@ class Parcel {
|
||||
$this->dst_address['zipCode'] = (string) mb_substr($so_data['przipcode'], 0, 5);
|
||||
}
|
||||
$this->dst_address['city'] = (string) mb_substr($so_data['prtown'], 0, 35);
|
||||
$this->dst_address['mobileNumber'] = (string) mb_substr($so_data['cephonenumber'], 0, 32);
|
||||
|
||||
$this->dst_address['mobileNumber'] = (string) mb_substr(str_replace(array('.','°', '|', ' ', '',"/"),'',$so_data['cephonenumber']), 0, 32);
|
||||
if(strlen($this->dst_address['mobileNumber']) > 10) {
|
||||
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $this->dst_address['mobileNumber'])) {
|
||||
$this->dst_address['mobileNumber'] = '0'.mb_substr(mb_substr($this->dst_address['mobileNumber'], -10), 1);
|
||||
}
|
||||
if(strtolower($so_data['cecountry']) == 'be' && preg_match('/^(0032|32)[0-9]{9,10}$/', $this->dst_address['mobileNumber'])) {
|
||||
$this->dst_address['mobileNumber'] = '+32'.mb_substr(mb_substr($this->dst_address['mobileNumber'], -10), 1);
|
||||
}
|
||||
} elseif(strtolower($so_data['cecountry']) == 'fr' && preg_match('/^[0-9]{9,10}$/', $this->dst_address['mobileNumber'])) {
|
||||
if(strlen($this->dst_address['mobileNumber']) == 9) {
|
||||
$this->dst_address['mobileNumber'] = '0'.$this->dst_address['mobileNumber'];
|
||||
} elseif(strlen($this->dst_address['mobileNumber']) == 10) {
|
||||
$this->dst_address['mobileNumber'] = '0'.mb_substr(mb_substr($this->dst_address['mobileNumber'], -10), 1);
|
||||
}
|
||||
} elseif(strtolower($so_data['cecountry']) == 'be' && preg_match('/^[0-9]{9,10}$/', $this->dst_address['mobileNumber'])) {
|
||||
if(strlen($this->dst_address['mobileNumber']) == 9) {
|
||||
$this->dst_address['mobileNumber'] = '+32'.$this->dst_address['mobileNumber'];
|
||||
} elseif(strlen($this->dst_address['mobileNumber']) == 10) {
|
||||
$this->dst_address['mobileNumber'] = '+32'.mb_substr(mb_substr($this->dst_address['mobileNumber'], -10), 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(mb_substr($this->dst_address['mobileNumber'], 0, 2) != '06' && mb_substr($this->dst_address['mobileNumber'], 0, 2) != '07') {
|
||||
if(strtolower($so_data['cecountry']) == 'fr' && mb_substr($this->dst_address['mobileNumber'], 0, 2) != '06' && mb_substr($this->dst_address['mobileNumber'], 0, 2) != '07') {
|
||||
$this->dst_address['mobileNumber'] = '0600000000';
|
||||
}
|
||||
|
||||
@ -222,9 +241,9 @@ class Parcel {
|
||||
$this->instructions = trim(str_replace(array('°', '|', ' ', '', "\n", "\r"), ' ', (string) $so_data['cedeliveryinformation']));
|
||||
$this->prid = $so_data['prid'];
|
||||
} else {
|
||||
$this->dst_address['companyName'] = (string) mb_substr(str_replace(array('', $unicode_ack, $unicode_ack2), ' ', $dst_address->company), 0, 35);
|
||||
$this->dst_address['lastName'] = (string) mb_substr(str_replace(array('', $unicode_ack, $unicode_ack2), ' ', $dst_address->firstname), 0, 35);
|
||||
$this->dst_address['firstName'] = (string) mb_substr(strtoupper(str_replace(array('', $unicode_ack, $unicode_ack2), ' ', $dst_address->lastname)), 0, 29);
|
||||
$this->dst_address['companyName'] = (string) mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ', $unicode_ack, $unicode_ack2), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i',' ',' '), $dst_address->company), 0, 35);
|
||||
$this->dst_address['lastName'] = (string) mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ', $unicode_ack, $unicode_ack2), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i',' ',' '), $dst_address->firstname), 0, 35);
|
||||
$this->dst_address['firstName'] = (string) mb_substr(strtoupper(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ', $unicode_ack, $unicode_ack2), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i',' ',' '), $dst_address->lastname)), 0, 29);
|
||||
$this->dst_address['email'] = (string) $dst_customer->email;
|
||||
if($dst_address->id_country == 193) {
|
||||
$this->dst_address['zipCode'] = mb_substr((string) str_ireplace(array('SI-', 'SL-'), '', $dst_address->postcode), 0, 5);
|
||||
@ -232,7 +251,7 @@ class Parcel {
|
||||
$this->dst_address['zipCode'] = mb_substr((string) str_replace(array(' ', '-'), '', $dst_address->postcode), 0, 5);
|
||||
}
|
||||
$this->dst_address['city'] = (string) mb_substr(strtoupper($dst_address->city), 0, 35);
|
||||
if(in_array($dst_country->iso_code, array('MO', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
|
||||
if(in_array($dst_country->iso_code, array('GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
|
||||
$this->dst_address['countryCode'] = 'FR';
|
||||
} else {
|
||||
$this->dst_address['countryCode'] = (string) $dst_country->iso_code;
|
||||
@ -241,7 +260,10 @@ class Parcel {
|
||||
$this->dst_address['line3'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), (string) $dst_address->address2);
|
||||
$this->instructions = trim(str_replace(array('°', '|', ' ', '', "\n", "\r"), ' ', (string) $dst_address->other));
|
||||
|
||||
if(in_array($dst_country->iso_code, array('FR', 'AD', 'MO', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
|
||||
if(in_array($dst_country->iso_code, array('FR', 'AD', 'MC', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
|
||||
|
||||
$dst_address->phone = ($dst_address->phone != ''? (string) str_replace(array('.','°', '|', ' ', '',"/"),'',$dst_address->phone) : '');
|
||||
$dst_address->phone_mobile = ($dst_address->phone_mobile != ''? (string) str_replace(array('.','°', '|', ' ', '',"/"),'',$dst_address->phone_mobile) : '');
|
||||
if($dst_address->phone != '' && preg_match('/^0[67][0-9]+$/', $dst_address->phone)) {
|
||||
$this->dst_address['phoneNumber'] = (string) $dst_address->phone;
|
||||
} elseif($dst_address->phone_mobile != '' && preg_match('/^0[67][0-9]+$/', $dst_address->phone_mobile)) {
|
||||
@ -276,8 +298,9 @@ class Parcel {
|
||||
}
|
||||
}
|
||||
|
||||
if($dst_country->iso_code == 'FR') {
|
||||
$this->product_type = 'COLD';
|
||||
if($dst_country->iso_code == 'FR' || $dst_country->iso_code == 'MC' || $dst_country->iso_code == 'BE') {
|
||||
//$this->product_type = 'COLD'; // Amené a disparaitre
|
||||
$this->product_type = 'DOM';
|
||||
} else {
|
||||
$this->product_type = 'COLI';
|
||||
}
|
||||
@ -325,8 +348,8 @@ class Parcel {
|
||||
$carrier_config = array(
|
||||
'api' => array(
|
||||
'wsu' => array(
|
||||
'contract' => (int) Configuration::get('LAPOSTEWS_API_CONTRACT_WSU');,
|
||||
'password' => Configuration::get('LAPOSTEWS_API_PASSWORD_WSU');,
|
||||
'contract' => (int) Configuration::get('LAPOSTEWS_API_CONTRACT_WSU'),
|
||||
'password' => Configuration::get('LAPOSTEWS_API_PASSWORD_WSU'),
|
||||
)
|
||||
),
|
||||
'exp_commercial_name' => Configuration::get('LAPOSTEWS_COMMERCIALNAME'),
|
||||
@ -352,7 +375,7 @@ class Parcel {
|
||||
);
|
||||
try {
|
||||
$exp_country = new Country((int) $carrier_config['exp_country']);
|
||||
if(in_array($exp_country->iso_code, array('MO', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
|
||||
if(in_array($exp_country->iso_code, array('GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
|
||||
$countryCode = 'FR';
|
||||
} else {
|
||||
$countryCode = (string) $exp_country->iso_code;
|
||||
@ -424,7 +447,20 @@ class Parcel {
|
||||
),
|
||||
),
|
||||
), $children);
|
||||
|
||||
$authorized_ip = array(
|
||||
'88.163.22.99',
|
||||
'90.63.178.63',
|
||||
);
|
||||
if (in_array($_SERVER['REMOTE_ADDR'], $authorized_ip)) {
|
||||
mail('marion@antadis.com', 'BBB LOG WSU xml', serialize($soap->asXML()));
|
||||
}
|
||||
|
||||
$response = new SoapResponse($c->__doRequest($soap->asXML(), 'https://ws.colissimo.fr/sls-ws/SlsServiceWS', 'generateLabel', '2.0', 0));
|
||||
if (in_array($_SERVER['REMOTE_ADDR'], $authorized_ip)) {
|
||||
mail('marion@antadis.com', 'BBB LOG WSU reponse', serialize($response));
|
||||
}
|
||||
|
||||
return array(
|
||||
'data' => new SimpleXMLElement(
|
||||
'<?xml version=\'1.0\' standalone=\'yes\'?>'.str_replace(
|
||||
@ -439,6 +475,13 @@ class Parcel {
|
||||
'label' => $response->attachments[0]['data'],
|
||||
);
|
||||
} catch(Exception $e) {
|
||||
$authorized_ip = array(
|
||||
'88.163.22.99',
|
||||
'90.63.178.63',
|
||||
);
|
||||
if (in_array($_SERVER['REMOTE_ADDR'], $authorized_ip)) {
|
||||
mail('marion@antadis.com', 'BBB LOG WSU Exception', serialize($e));
|
||||
}
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user