1685 lines
68 KiB
PHP
1685 lines
68 KiB
PHP
<?php
|
||
if(!defined('_PS_VERSION_')) {
|
||
exit;
|
||
}
|
||
|
||
if((int)Configuration::get('LAPOSTEWS_WSU_ENABLE') == 1) {
|
||
include dirname(__FILE__).'/webservice_wsu.php';
|
||
} else {
|
||
include dirname(__FILE__).'/webservice.php';
|
||
}
|
||
|
||
|
||
global $laposte_formats;
|
||
$laposte_formats = array(
|
||
// SO à domicile
|
||
'DOM' =>
|
||
'rDOM'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603150330Code Porte 1 : {DOOR_0}'."\n"
|
||
.'4911A0603150340Code Porte 2 : {DOOR_1}'."\n"
|
||
.'4911A0603150350Interphone : {INTERPH_0}'."\n"
|
||
.'4911A0603150360{INTERPH_1}'."\n"
|
||
.'4911A0603150370Telephone Portable : {DPHONE_CELL}'."\n"
|
||
.'4911A0603150380Telephone : {DPHONE}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DADDR_0}'."\n"
|
||
.'1311A0802520027{DADDR_1}'."\n"
|
||
.'1311A0802340027{DADDR_2}'."\n"
|
||
.'1311A0802160027{DADDR_3}'."\n"
|
||
.'1311A0801980027{DADDR_4}'."\n"
|
||
.'1111A0801500027T'.chr(130).'l : {DADDR_5}'."\n"
|
||
.'1611A2401650027{DADDR_6}'."\n"
|
||
.'1411A1001700120{DADDR_7}'."\n"
|
||
.'1411A1001500180{DADDR_8}'."\n"
|
||
.'1111A0601420027{DADDR_INST}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// SO sur RDV
|
||
'RDV' =>
|
||
'rRDV'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603150330Code Porte 1 : {DOOR_0}'."\n"
|
||
.'4911A0603150340Code Porte 2 : {DOOR_1}'."\n"
|
||
.'4911A0603150350Interphone : {INTERPH_0}'."\n"
|
||
.'4911A0603150360{INTERPH_1}'."\n"
|
||
.'4911A0603150370Telephone Portable : {DPHONE_CELL}'."\n"
|
||
.'4911A0603150380Telephone : {DPHONE}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DADDR_0}'."\n"
|
||
.'1311A0802520027{DADDR_1}'."\n"
|
||
.'1311A0802340027{DADDR_2}'."\n"
|
||
.'1311A0802160027{DADDR_3}'."\n"
|
||
.'1311A0801980027{DADDR_4}'."\n"
|
||
.'1111A0801500027T'.chr(130).'l : {DADDR_5}'."\n"
|
||
.'1611A2401650027{DADDR_6}'."\n"
|
||
.'1411A1001700120{DADDR_7}'."\n"
|
||
.'1411A1001500180{DADDR_8}'."\n"
|
||
.'1111A0601420027{DADDR_INST}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// SO en bureau de poste
|
||
'BPR' =>
|
||
'rBPR'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603120305{DADDR_0}'."\n"
|
||
.'4911A0603120315{DADDR_1}'."\n"
|
||
.'4911A0603120325{DADDR_2}'."\n"
|
||
.'4911A0603120335{DADDR_3}'."\n"
|
||
.'4911A0603120345'."\n"
|
||
.'4211A0603120355{DADDR_4}'."\n"
|
||
.'4211A0603120365{DADDR_5}'."\n"
|
||
.'4911A0603120375T'.chr(130).'l'.chr(130).'phone portable : {DPHONE_CELL}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DBPR_0}'."\n"
|
||
.'1311A0802520027{DBPR_1}'."\n"
|
||
.'1311A0802340027{DBPR_2}'."\n"
|
||
.'1311A0802160027{DBPR_3}'."\n"
|
||
.'1311A0801980027{DBPR_4}'."\n"
|
||
.'1611A2401650027{DBPR_5}'."\n"
|
||
.'1411A1001700120{DBPR_6}'."\n"
|
||
.'1411A1001500180{DBPR_7}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// SO en agence ColiPoste
|
||
'ACP' =>
|
||
'rBPR'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603120305{DADDR_0}'."\n"
|
||
.'4911A0603120315{DADDR_1}'."\n"
|
||
.'4911A0603120325{DADDR_2}'."\n"
|
||
.'4911A0603120335{DADDR_3}'."\n"
|
||
.'4911A0603120345'."\n"
|
||
.'4211A0603120355{DADDR_4}'."\n"
|
||
.'4211A0603120365{DADDR_5}'."\n"
|
||
.'4911A0603120375T'.chr(130).'l'.chr(130).'phone portable : {DPHONE_CELL}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DBPR_0}'."\n"
|
||
.'1311A0802520027{DBPR_1}'."\n"
|
||
.'1311A0802340027{DBPR_2}'."\n"
|
||
.'1311A0802160027{DBPR_3}'."\n"
|
||
.'1311A0801980027{DBPR_4}'."\n"
|
||
.'1611A2401650027{DBPR_5}'."\n"
|
||
.'1411A1001700120{DBPR_6}'."\n"
|
||
.'1411A1001500180{DBPR_7}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// SO en centre de distribution
|
||
'CDI' =>
|
||
'rBPR'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603120305{DADDR_0}'."\n"
|
||
.'4911A0603120315{DADDR_1}'."\n"
|
||
.'4911A0603120325{DADDR_2}'."\n"
|
||
.'4911A0603120335{DADDR_3}'."\n"
|
||
.'4911A0603120345'."\n"
|
||
.'4211A0603120355{DADDR_4}'."\n"
|
||
.'4211A0603120365{DADDR_5}'."\n"
|
||
.'4911A0603120375T'.chr(130).'l'.chr(130).'phone portable : {DPHONE_CELL}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DBPR_0}'."\n"
|
||
.'1311A0802520027{DBPR_1}'."\n"
|
||
.'1311A0802340027{DBPR_2}'."\n"
|
||
.'1311A0802160027{DBPR_3}'."\n"
|
||
.'1311A0801980027{DBPR_4}'."\n"
|
||
.'1611A2401650027{DBPR_5}'."\n"
|
||
.'1411A1001700120{DBPR_6}'."\n"
|
||
.'1411A1001500180{DBPR_7}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// SO en commerce de proximité
|
||
'A2P' =>
|
||
'rA2P'."\n"
|
||
.'1911A0605000242{SADDR_0}'."\n"
|
||
.'1911A0604900242{SADDR_1}'."\n"
|
||
.'1911A0604800242{SADDR_2}'."\n"
|
||
.'1911A0604700242{SADDR_3}'."\n"
|
||
.'1911A0604600242{SADDR_4}'."\n"
|
||
.'1911A0604500242T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0604300244COMPTE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0604200244SITE PCH :{SITE}'."\n"
|
||
.'1911A0604100244N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0604000244Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0603900244Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150010R'.chr(130).'f Client: EXP{CUST_REF}'."\n"
|
||
.'1e2310704000025B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803830030N'.chr(248).' Colis: {TRACKING_0}'."\n"
|
||
.'1911A0803700027DESTINATAIRE'."\n"
|
||
.'1311A0803500027{DBPR_0}'."\n"
|
||
.'1311A0803320027{DBPR_1}'."\n"
|
||
.'1311A0803160027{DBPR_2}'."\n"
|
||
.'1311A0802980027{DBPR_3}'."\n"
|
||
.'1311A0802800027{DBPR_4}'."\n"
|
||
.'1611A240248002791500'."\n"
|
||
.'1411A1002500120HUB RELAIS'."\n"
|
||
.'1111A0602420027N'.chr(248).' de tel portable : {DPHONE_CELL}'."\n"
|
||
.'1e2310401350050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0801170130N'.chr(248).' de PCH: {HANDLING_0}'."\n"
|
||
.'1911A1800890030{DBPRCODE_0}'."\n"
|
||
.'1911A1400900150SA13 REL'."\n"
|
||
.'1911A1800890300{DBPRCODE_1}'."\n"
|
||
.'1911A0800000100{DHUB_CODE_0}'."\n"
|
||
.'1e2308000110025B%&D{DHUB_CODE_1}&EM&D{DHUB_CODE_2}'."\n"
|
||
,
|
||
|
||
// SO à domicile (+?)
|
||
'MRL' => 'rMRL'."\n",
|
||
|
||
// SO en cityssimo
|
||
'CIT' =>
|
||
'rCIT'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0601440262{DADDR_0}'."\n"
|
||
.'4911A0601440272{DADDR_1}'."\n"
|
||
.'4911A0601440282{DADDR_2}'."\n"
|
||
.'4911A0601440292{DADDR_3}'."\n"
|
||
.'4911A0601440302'."\n"
|
||
.'4211A0601440312{DADDR_4}'."\n"
|
||
.'4211A0601440322{DADDR_5}'."\n"
|
||
.'4911A0601440332T'.chr(130).'l'.chr(130).'phone portable : {DPHONE_CELL}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1211A1202700027{DBPR_0}'."\n"
|
||
.'1211A0802520027{DBPR_1}'."\n"
|
||
.'1211A0802340027{DBPR_2}'."\n"
|
||
.'1211A0802160027{DBPR_3}'."\n"
|
||
.'1211A0801980027{DBPR_4}'."\n"
|
||
.'1511A2401650027{DBPR_5}'."\n"
|
||
.'1411A1001680088{DBPR_6}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// SO à domicile contre signature
|
||
'DOS' =>
|
||
'rDOS'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603150330Code Porte 1 : {DOOR_0}'."\n"
|
||
.'4911A0603150340Code Porte 2 : {DOOR_1}'."\n"
|
||
.'4911A0603150350Interphone : {INTERPH_0}'."\n"
|
||
.'4911A0603150360{INTERPH_1}'."\n"
|
||
.'4911A0603150370Telephone Portable : {DPHONE_CELL}'."\n"
|
||
.'4911A0603150380Telephone : {DPHONE}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DADDR_0}'."\n"
|
||
.'1311A0802520027{DADDR_1}'."\n"
|
||
.'1311A0802340027{DADDR_2}'."\n"
|
||
.'1311A0802160027{DADDR_3}'."\n"
|
||
.'1311A0801980027{DADDR_4}'."\n"
|
||
.'1111A0801500027T'.chr(130).'l : {DADDR_5}'."\n"
|
||
.'1611A2401650027{DADDR_6}'."\n"
|
||
.'1411A1001700120{DADDR_7}'."\n"
|
||
.'1411A1001500180{DADDR_8}'."\n"
|
||
.'1111A0601420027{DADDR_INST}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// Colissimo Expert Inter
|
||
'COLI' =>
|
||
'ySPM'."\n"
|
||
.'191100501440011'."\n"
|
||
.'1X1100005510274P00100010365027404590310'."\n" // barré expéditeur
|
||
.'1X1100005510346P00100010459031003650346'."\n" // barré expéditeur
|
||
.'1X1100002210002b0384036100010001'."\n" // boîte générale
|
||
.'191100105670281EXPEDITEUR /'."\n"
|
||
.'191100105550291SENDER'."\n"
|
||
.'1X1100003650002b0272005200010001'."\n" // boîte compte client
|
||
.'192200401880003{DEPOT}'."\n"
|
||
.'141100101960086{ROUTING}'."\n"
|
||
.'121100101960220{TRACKING_KEY}'."\n"
|
||
.'191100101850007Track'."\n"
|
||
.'1X1100001590009b0018002500010001'."\n"
|
||
.'141100402010218 {SERVICE}'."\n"
|
||
.'110100001940352Service'."\n"
|
||
.'125500101490033{ID_DEST1}'."\n"
|
||
.'132200601210100{ID_DEST2}'."\n"
|
||
.'102200101130132{DATE}'."\n"
|
||
.'132200401130015{TRIEXPORT}'."\n"
|
||
.'132200401130{IMPORT_ALIGN}{TRIIMPORT}'."\n"
|
||
.'192200401050290'."\n"
|
||
.'121100100000080{HANDLING_0}'."\n"
|
||
.'1e2310000110020B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1X1100001100020l03450002'."\n" // barre cab handling
|
||
.'191100202420026N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'1e2310702560023B{TRACKING_1}&D{TRACKING_2}&E{TRACKING_3}'."\n"
|
||
.'1X1100002550023l02310002'."\n" // barre cab suivi
|
||
.'1Y1100003750355EXPERTAS'."\n"
|
||
.'1Y2200002280231CAMERA'."\n"
|
||
.'1Y1100002230010LAPOSTEI'."\n"
|
||
.'100100003680351CP71 France'."\n"
|
||
.'1X1100003650346l00010216'."\n" // barre expediteur
|
||
.'1X1100003650274l00010216'."\n" // barre expediteur
|
||
.'202200105480335{SADDR_0}'."\n"
|
||
.'202200105480325{SADDR_1}'."\n"
|
||
.'202200105480317{SADDR_2}'."\n"
|
||
.'202200105480299Tel : {SADDR_5}'."\n"
|
||
.'202200105480289{SADDR_4}'."\n"
|
||
.'202200105480279FRANCE-FR'."\n"
|
||
.'1X1100005520002l03450001'."\n" // barre site dépôt
|
||
.'1X1100003650274l01120001'."\n" // barre bas logo
|
||
.'1X1100004160015l00010136'."\n" // barre destinataire
|
||
.'191100104010007COMPTE CLIENT : {CONTRACT}'."\n"
|
||
.'191100103860007Return to sender as priority parcel'."\n"
|
||
.'191100103720007r'.chr(130).'f client : {CUST_REF}'."\n"
|
||
.'191100105700061Site dépôt : {SITE_0}'."\n"
|
||
.'191100105620061{SITE_1}'."\n"
|
||
.'191100105530061{SITE_2}'."\n"
|
||
.'1X1100003650211l00010051'."\n" // barre poids
|
||
.'191100104010217Livraison : 1/1'."\n"
|
||
.'191100103870228Poids :'."\n"
|
||
.'192200003700217{WEIGHT} kg'."\n"
|
||
.'191100405380013'."\n"
|
||
.'491100104210014DESTINATAIRE / ADDRESSEE'."\n"
|
||
.'191100205380025{DADDR_0}'."\n"
|
||
.'191100205240025{DADDR_1}'."\n"
|
||
.'191100205100025{DADDR_2}'."\n"
|
||
.'191100204960025{DADDR_3}'."\n"
|
||
.'191100204820025{DADDR_4}'."\n"
|
||
.'190000504570025{DADDR_5}'."\n"
|
||
.'190000504190025{DADDR_6}'."\n"
|
||
.'191100204430025TEL : {DADDR_7}'."\n"
|
||
,
|
||
|
||
// Colissimo Expert France
|
||
'COL' =>
|
||
'rCOL'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603150330Code Porte 1 : {DOOR_0}'."\n"
|
||
.'4911A0603150340Code Porte 2 : {DOOR_1}'."\n"
|
||
.'4911A0603150350Interphone : {INTERPH_0}'."\n"
|
||
.'4911A0603150360{INTERPH_1}'."\n"
|
||
.'4911A0603150370Telephone Portable : {DPHONE_CELL}'."\n"
|
||
.'4911A0603150380Telephone : {DPHONE}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DADDR_0}'."\n"
|
||
.'1311A0802520027{DADDR_1}'."\n"
|
||
.'1311A0802340027{DADDR_2}'."\n"
|
||
.'1311A0802160027{DADDR_3}'."\n"
|
||
.'1311A0801980027{DADDR_4}'."\n"
|
||
.'1111A0801500027T'.chr(130).'l : {DADDR_5}'."\n"
|
||
.'1611A2401650027{DADDR_6}'."\n"
|
||
.'1411A1001700120{DADDR_7}'."\n"
|
||
.'1411A1001500180{DADDR_8}'."\n"
|
||
.'1111A0601420027{DADDR_INST}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// Colissimo Access France
|
||
'COLD' =>
|
||
/* 'rCOLD' */'rDOM'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804880015{SADDR_1}'."\n"
|
||
.'1911A0804760015{SADDR_2}'."\n"
|
||
.'1911A0804640015{SADDR_3}'."\n"
|
||
.'1911A0804520015{SADDR_4}'."\n"
|
||
.'1911A0804420015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1911A0805150130R'.chr(130).'f Client'."\n"
|
||
.'1911A0805150180EXP{CUST_REF}'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'4911A0603150330Code Porte 1 : {DOOR_0}'."\n"
|
||
.'4911A0603150340Code Porte 2 : {DOOR_1}'."\n"
|
||
.'4911A0603150350Interphone : {INTERPH_0}'."\n"
|
||
.'4911A0603150360{INTERPH_1}'."\n"
|
||
.'4911A0603150370Telephone Portable : {DPHONE_CELL}'."\n"
|
||
.'4911A0603150380Telephone : {DPHONE}'."\n"
|
||
.'1911A0802900027DESTINATAIRE'."\n"
|
||
.'1311A1202700027{DADDR_0}'."\n"
|
||
.'1311A0802520027{DADDR_1}'."\n"
|
||
.'1311A0802340027{DADDR_2}'."\n"
|
||
.'1311A0802160027{DADDR_3}'."\n"
|
||
.'1311A0801980027{DADDR_4}'."\n"
|
||
.'1111A0801500027T'.chr(130).'l : {DADDR_5}'."\n"
|
||
.'1611A2401650027{DADDR_6}'."\n"
|
||
.'1411A1001700120{DADDR_7}'."\n"
|
||
.'1411A1001500180{DADDR_8}'."\n"
|
||
.'1111A0601420027{DADDR_INST}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
,
|
||
|
||
// Colissimo Access OM // TODO
|
||
'COM' =>
|
||
'rCOM'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804900015{SADDR_1}'."\n"
|
||
.'1911A0804800015{SADDR_2}'."\n"
|
||
.'1911A0804700015{SADDR_3}'."\n"
|
||
.'1911A0804600015{SADDR_4}'."\n"
|
||
.'1911A0804390015FRANCE'."\n"
|
||
.'1911A0804500015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
//.'1X1101103400150P0010001040001500400020003400200'."\n"
|
||
.'1e2310703250030B{TRACKING_1}&D{TRACKING_2}'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'1911A0802900027DESTINATAIRE ref. destinataire : EXP{CUST_REF}'."\n"
|
||
.'1311A1202700027{DADDR_0}'."\n"
|
||
.'1311A0802520027{DADDR_1}'."\n"
|
||
.'1311A0802340027{DADDR_2}'."\n"
|
||
.'1311A0802160027{DADDR_3}'."\n"
|
||
.'1311A0801980027{DADDR_4}'."\n"
|
||
.'1611A2401650027{DADDR_5}'."\n"
|
||
.'1411A1001700120{DADDR_6}'."\n"
|
||
.'1111A0801500027T'.chr(130).'l : {DPHONE}'."\n"
|
||
.'1111A0601420027{DADDR_INST}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
//.'1X1101100150150P'."\n"
|
||
//.'0010001011501500'."\n"
|
||
//.'115020000150200'."\n"
|
||
,
|
||
|
||
// Colissimo Expert OM // TODO
|
||
'CDS' =>
|
||
'rCDS'."\n"
|
||
.'1911A0805000015{SADDR_0}'."\n"
|
||
.'1911A0804900015{SADDR_1}'."\n"
|
||
.'1911A0804800015{SADDR_2}'."\n"
|
||
.'1911A0804700015{SADDR_3}'."\n"
|
||
.'1911A0804600015{SADDR_4}'."\n"
|
||
.'1911A0804390015FRANCE'."\n"
|
||
.'1911A0804500015T'.chr(130).'l : {SADDR_5}'."\n"
|
||
.'1911A0805000210CODE CLIENT: {CONTRACT}'."\n"
|
||
.'1911A0804880210SITE PCH: {SITE}'."\n"
|
||
.'1911A0804760210N'.chr(248).' Colis : {TRACKING_0}'."\n"
|
||
.'1911A0804640210Poids : {WEIGHT} kg'."\n"
|
||
.'1911A0804520210Edit'.chr(130).' le : {DATE}'."\n"
|
||
.'1e2310703250030B7A5&D3894390207'."\n"
|
||
.'1911A0803080030N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
//.'1X110110340 0150P0010'."\n"
|
||
//.'001040001500400020003400200'."\n"
|
||
.'1911A0802900027DESTINATAIRE ref. destinataire : EXP{CUST_REF}'."\n"
|
||
.'1311A1202700027{DADDR_0}'."\n"
|
||
.'1311A0802520027{DADDR_1}'."\n"
|
||
.'1311A0802340027{DADDR_2}'."\n"
|
||
.'1311A0802160027{DADDR_3}'."\n"
|
||
.'1311A0801980027{DADDR_4}'."\n"
|
||
.'1611A2401650027{DADDR_5}'."\n"
|
||
.'1411A1001700120{DADDR_6}'."\n"
|
||
.'1111A0801500027T'.chr(130).'l : {DPHONE}'."\n"
|
||
.'1111A0601420027{DADDR_INST}'."\n"
|
||
.'1e2310800300050B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1911A0800150130N'.chr(248).' de PCH : {HANDLING_0}'."\n"
|
||
.'1X1101100150'."\n"
|
||
.'150P001000101150'."\n"
|
||
.'1500115020000150200'."\n"
|
||
,
|
||
|
||
// Colissimo Belgique
|
||
'BELG' =>
|
||
'ySPM'."\n"
|
||
.'191100501440011'."\n"
|
||
.'1X1100002210000b0386036100010001'."\n" // boîte générale
|
||
|
||
.'192200401880003{DEPOT}'."\n"
|
||
.'141100101960086{ROUTING}'."\n"
|
||
.'121100101960220{TRACKING_KEY}'."\n"
|
||
.'191100101850007Track'."\n"
|
||
.'1X1100001590009b0018002500010001'."\n"
|
||
.'141100402010218 {SERVICE}'."\n"
|
||
.'110100001940352Service'."\n"
|
||
.'125500101490033{ID_DEST1}'."\n"
|
||
.'132200601210100{ID_DEST2}'."\n"
|
||
.'102200101130132{DATE}'."\n"
|
||
.'132200401130015{TRIEXPORT}'."\n"
|
||
.'132200401130{IMPORT_ALIGN}{TRIIMPORT}'."\n"
|
||
.'192200401050290'."\n"
|
||
.'121100100000080{HANDLING_0}'."\n"
|
||
.'1e2310000110020B{HANDLING_1}&D{HANDLING_2}'."\n"
|
||
.'1X1100001100020l03450002'."\n" // barre cab handling
|
||
.'1Y1100002230010LAPOSTEI'."\n"
|
||
.'1Y2200002240358CAMERA'."\n"
|
||
.'1Y1100002470278{DELIVERYMODE}'."\n"
|
||
//.'100100002630298{CP71}'."\n"
|
||
.'191100202260123N'.chr(248).' de colis : {TRACKING_0}'."\n"
|
||
.'1e2308502450022B{TRACKING_1}&D{TRACKING_2}&E{TRACKING_3}'."\n"
|
||
.'1X1100002440022l02310002'."\n" // barre cab suivi
|
||
.'191100103250277Compte client : {CONTRACT}'."\n"
|
||
.'191100103150277Site PCH : {SITE_0}'."\n"
|
||
.'191100103050277{SITE_1}'."\n"
|
||
.'191100102950277Poids : {WEIGHT} kg'."\n"
|
||
.'1X1100002920274b0109004400010001'."\n" // boîte poids
|
||
|
||
.'1X1100005240082l00010057'."\n" // barre top 1
|
||
.'1X1100005240165l00010057'."\n" // barre top 2
|
||
.'1X1100005050246l00010075'."\n" // barre top 3
|
||
|
||
.'1X1100004300328l00010151'."\n" // barre expé gauche
|
||
|
||
.'1X1100004300329l00580001'."\n" // barre bas addr source
|
||
.'1X1100005590329l00580001'."\n" // barre haut addr source
|
||
|
||
.'1X1100003370371l00150001'."\n" // barre dest droite
|
||
.'1X1100003370000l00170001'."\n" // barre dest gauche
|
||
|
||
.'1X1100005040000l03280001'."\n" // barre sous pakket
|
||
.'1X1100005240000l02470001'."\n" // barre sur pakket
|
||
|
||
.'192200405390198{SIGNATURE}'."\n"
|
||
.'191100105570263Retouradres :'."\n"
|
||
.'191100105310261EMC Brucargo'."\n"
|
||
.'191100105190269EMC 1934'."\n"
|
||
.'191100305060075Paquet - Pakket'."\n"
|
||
.'191100305360017{PUGO}'."\n"
|
||
.'191100405380013'."\n"
|
||
|
||
.'191100105690329EXPEDITEUR /'."\n"
|
||
.'191100105610340SENDER'."\n"
|
||
.'201200105540376{SADDR_0}'."\n"
|
||
.'201200105540367{SADDR_1}'."\n"
|
||
.'201200105540358{SADDR_2}'."\n"
|
||
.'201200105540349Tel : {SADDR_5}'."\n"
|
||
.'201200105540340{SADDR_4}'."\n"
|
||
.'201200105540331FRANCE-FR'."\n"
|
||
.'1X1100005590328P00100010431032804950356'."\n" // barré addr source
|
||
.'1X1100005590385P00100010495035604310385'."\n" // barré addr source
|
||
|
||
.'193300304480001P'."\n"
|
||
.'131100404300078{TRACKING_PARTNER}'."\n"
|
||
.'1e2305604470053C{TRACKING_PARTNER}'."\n"
|
||
|
||
.'1X1100003370016b0355009000010001'."\n" // boîte destinataire
|
||
.'491100103420013DESTINATAIRE'."\n"
|
||
.'191100204120035{DADDR_0}'."\n"
|
||
.'191100204000035{DADDR_1}'."\n"
|
||
.'191100203880035{DADDR_2}'."\n"
|
||
.'191100203760035{DADDR_3}'."\n"
|
||
.'191100203640035{DADDR_4}'."\n"
|
||
.'191100203520035{DADDR_5}'."\n"
|
||
.'191100203400035{DADDR_6}'."\n"
|
||
,
|
||
);
|
||
|
||
|
||
class LaposteCarrier {
|
||
public $displayName = 'La Poste';
|
||
|
||
public function l($string, $specific = false, $id_lang = null) {
|
||
global $_MODULES, $_MODULE, $cookie;
|
||
|
||
if ($id_lang == null)
|
||
$id_lang = (!isset($cookie) OR !is_object($cookie)) ? (int)(Configuration::get('PS_LANG_DEFAULT')) : (int)($cookie->id_lang);
|
||
$file = _PS_MODULE_DIR_.'logistics/'.Language::getIsoById($id_lang).'.php';
|
||
if (Tools::file_exists_cache($file) AND include_once($file))
|
||
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
|
||
|
||
$source = $specific ? $specific : 'logistics';
|
||
$string = str_replace('\'', '\\\'', $string);
|
||
$ret = Module::findTranslation('logistics', $string, $source);
|
||
return $ret;
|
||
}
|
||
|
||
public function checkavailability() {
|
||
//return trim(file_get_contents('http://ws.colissimo.fr/supervision-pudo-frame/supervision.jsp')) === '[OK]';
|
||
return trim(file_get_contents('http://ws.colissimo.fr/supervisionWSShipping/supervision.jsp')) === '[OK]';
|
||
}
|
||
|
||
public function __toString() {
|
||
return $this->displayName;
|
||
}
|
||
|
||
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',
|
||
htmlentities($str, ENT_NOQUOTES, 'UTF-8')
|
||
);
|
||
}
|
||
|
||
public function registerParcel($order, $products, $weight) {
|
||
global $cookie;
|
||
|
||
$html = '';
|
||
|
||
$parcel = new Parcel();
|
||
$parcel->attachOrder((int) $order->id);
|
||
$parcel->setWeight($weight);
|
||
|
||
$products_names = array();
|
||
|
||
$result = $parcel->send();
|
||
|
||
/**
|
||
* @Override laposte WSU
|
||
*/
|
||
if((int)Configuration::get('LAPOSTEWS_WSU_ENABLE') == 1) {
|
||
if(!$result || !is_array($result) && get_class($result) == 'SoapFault' || !$result['data']) {
|
||
$html .= '<p class="error">'.$this->l('An error happened during the parcel registration process').'</p><br />';
|
||
} else {
|
||
if(isset($result['data']->messages->type) && $result['data']->messages->type == 'ERROR') {
|
||
$html .= '<p class="error">'.strip_tags((string) $result['data']->messages->messageContent).'</p><br />';
|
||
} else {
|
||
if($_SERVER['REMOTE_ADDR'] != '109.190.53.175' && $_SERVER['REMOTE_ADDR'] != '78.226.56.137' && $_SERVER['REMOTE_ADDR'] != '88.163.22.223' && $_SERVER['REMOTE_ADDR'] != '37.160.139.229') {
|
||
$socolissimo_carrier = Db::getInstance()->getRow('
|
||
SELECT `id_carrier`
|
||
FROM `'._DB_PREFIX_.'carrier`
|
||
WHERE `external_module_name` = "socolissimo"
|
||
AND `deleted` = 0
|
||
ORDER BY `id_carrier` DESC
|
||
');
|
||
|
||
$order->shipping_number = $result['data']->labelResponse->parcelNumber;
|
||
|
||
if($socolissimo_carrier) {
|
||
$order->id_carrier_shipping = (int) $socolissimo_carrier['id_carrier'];
|
||
}
|
||
$order->update();
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
if(!$result || $result && (get_class($result) == 'SoapFault')) {
|
||
$html .= '<p class="error">'.$this->l('An error happened during the parcel registration process').'</p><br />';
|
||
} else {
|
||
if(isset($result->getLetterColissimoReturn) && $result->getLetterColissimoReturn->errorID != 0 && ((string) $result->getLetterColissimoReturn->error) != '') {
|
||
$html .= '<p class="error">'.$result->getLetterColissimoReturn->error.'</p><br />';
|
||
} elseif(isset($result->genererEtiquetteBic3Response) && ($result->genererEtiquetteBic3Response->message->type) == 'ERROR') {
|
||
$html .= '<p class="error">'.$result->genererEtiquetteBic3Response->message->libelle.'</p><br />';
|
||
} else {
|
||
if($_SERVER['REMOTE_ADDR'] != '109.190.53.175' && $_SERVER['REMOTE_ADDR'] != '78.226.56.137' && $_SERVER['REMOTE_ADDR'] != '88.163.22.223' && $_SERVER['REMOTE_ADDR'] != '37.160.139.229') {
|
||
$socolissimo_carrier = Db::getInstance()->getRow('
|
||
SELECT `id_carrier`
|
||
FROM `'._DB_PREFIX_.'carrier`
|
||
WHERE `external_module_name` = "socolissimo"
|
||
AND `deleted` = 0
|
||
ORDER BY `id_carrier` DESC
|
||
');
|
||
|
||
if(isset($result->genererEtiquetteBic3Response)) {
|
||
$order->shipping_number = $result->genererEtiquetteBic3Response->parcelNumber;
|
||
} else {
|
||
$order->shipping_number = $result->getLetterColissimoReturn->parcelNumber;
|
||
}
|
||
if($socolissimo_carrier) {
|
||
$order->id_carrier_shipping = (int) $socolissimo_carrier['id_carrier'];
|
||
}
|
||
$order->update();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return array($html, $result);
|
||
}
|
||
|
||
public function renderLabel($order, $weight, $shipping_data) {
|
||
global $cookie, $laposte_formats;
|
||
|
||
/**
|
||
* @Override laposte WSU
|
||
*/
|
||
if((int)Configuration::get('LAPOSTEWS_WSU_ENABLE') == 1) {
|
||
return $shipping_data['label'];
|
||
}
|
||
|
||
$id_order = (int) $order->id;
|
||
$weight = 0.24;
|
||
|
||
$delivery_address = new Address($order->id_address_delivery);
|
||
$invoice_address = new Address($order->id_address_invoice);
|
||
|
||
|
||
if($delivery_address->id_country == 8
|
||
|| $delivery_address->id_country == 40
|
||
|| $delivery_address->id_country == 148
|
||
) {
|
||
if(is_string($shipping_data)) {
|
||
$shipping_number = $shipping_data;
|
||
} else {
|
||
$shipping_number = $shipping_data->getLetterColissimoReturn->parcelNumber;
|
||
}
|
||
|
||
if(strlen($invoice_address->phone) > 10) {
|
||
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $invoice_address->phone)) {
|
||
$invoice_address->phone = '0'.substr(substr($invoice_address->phone, -10), 1);
|
||
}
|
||
}
|
||
if(strlen($invoice_address->phone_mobile) > 10) {
|
||
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $invoice_address->phone_mobile)) {
|
||
$invoice_address->phone_mobile = '0'.substr(substr($invoice_address->phone_mobile, -10), 1);
|
||
}
|
||
}
|
||
if(strlen($delivery_address->phone) > 10) {
|
||
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $delivery_address->phone)) {
|
||
$delivery_address->phone = '0'.substr(substr($delivery_address->phone, -10), 1);
|
||
}
|
||
}
|
||
if(strlen($delivery_address->phone_mobile) > 10) {
|
||
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $delivery_address->phone_mobile)) {
|
||
$delivery_address->phone_mobile = '0'.substr(substr($delivery_address->phone_mobile, -10), 1);
|
||
}
|
||
}
|
||
|
||
if($deliveryInfos = Db::getInstance()->getRow('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
|
||
WHERE `id_cart` = '.(int) $order->id_cart.'
|
||
')) {
|
||
$parceltype = $deliveryInfos['delivery_mode'];
|
||
|
||
if(in_array($parceltype, array('ACP', 'BPR', 'CDI', 'A2P', 'CIT'))) {
|
||
$dest_company = $invoice_address->company;
|
||
$dest_gender = ''; // '', 'M.', 'Mme', 'Mlle'
|
||
$dest_firstname = $invoice_address->firstname;
|
||
$dest_lastname = $invoice_address->lastname;
|
||
$dest_lines = array();
|
||
if(strlen($invoice_address->address1) > 34) {
|
||
$dest_lines[] = substr($invoice_address->address1, 0, 34);
|
||
$dest_lines[] = substr($invoice_address->address1, 34);
|
||
} else {
|
||
$dest_lines[] = $invoice_address->address1;
|
||
}
|
||
if(strlen($invoice_address->address2) > 34) {
|
||
$dest_lines[] = substr($invoice_address->address2, 0, 34);
|
||
$dest_lines[] = substr($invoice_address->address2, 34);
|
||
} else {
|
||
$dest_lines[] = $invoice_address->address2;
|
||
}
|
||
$dest_line1 = isset($dest_lines[0])? $dest_lines[0]: '';
|
||
$dest_line2 = isset($dest_lines[1])? $dest_lines[1]: '';
|
||
$dest_line3 = isset($dest_lines[2])? $dest_lines[2]: '';
|
||
$dest_line4 = isset($dest_lines[3])? $dest_lines[3]: '';
|
||
$dest_postal = $invoice_address->postcode;
|
||
$dest_postal_cab = $delivery_address->postcode;
|
||
$dest_city = $invoice_address->city;
|
||
$dest_phone = (!empty($invoice_address->phone)? $invoice_address->phone: $invoice_address->phone_mobile);
|
||
$dest_mobile = $invoice_address->phone_mobile;
|
||
$dest_code1 = '';
|
||
$dest_code2 = '';
|
||
$dest_interphone = '';
|
||
$dest_instructions = '';
|
||
|
||
$dest_bpr_infos = Db::getInstance()->getRow('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'lapostews_pr`
|
||
WHERE `id_pr` = "'.pSQL($deliveryInfos['prid']).'"
|
||
');
|
||
|
||
if(!$dest_bpr_infos) {
|
||
return 'pr_error';
|
||
}
|
||
|
||
$dest_bpr_gender = '';
|
||
$dest_bpr_firstname = $deliveryInfos['cefirstname'];
|
||
$dest_bpr_lastname = $deliveryInfos['cename'];
|
||
|
||
$dest_bpr_name = $dest_bpr_infos['name'];
|
||
$bpr_lines = array();
|
||
if(!empty($dest_bpr_infos['address1'])) {
|
||
$bpr_lines[] = $dest_bpr_infos['address1'];
|
||
}
|
||
if(!empty($dest_bpr_infos['address2'])) {
|
||
$bpr_lines[] = $dest_bpr_infos['address2'];
|
||
}
|
||
if(!empty($dest_bpr_infos['address3'])) {
|
||
$bpr_lines[] = $dest_bpr_infos['address3'];
|
||
}
|
||
if(!empty($dest_bpr_infos['address4'])) {
|
||
$bpr_lines[] = $dest_bpr_infos['address4'];
|
||
}
|
||
|
||
$dest_bpr_line1 = isset($bpr_lines[0])? $bpr_lines[0]: '';
|
||
$dest_bpr_line2 = isset($bpr_lines[1])? $bpr_lines[1]: '';
|
||
$dest_bpr_line3 = isset($bpr_lines[2])? $bpr_lines[2]: '';
|
||
$dest_bpr_postal = $dest_bpr_infos['postcode'];
|
||
$dest_bpr_city = $dest_bpr_infos['city'];
|
||
|
||
$dest_bpr_code1 = $dest_bpr_infos['code1'];
|
||
$dest_bpr_code2 = $dest_bpr_infos['code2'];
|
||
} else {
|
||
if($deliveryInfos['prfirstname'] == 'So Colissimo' && $deliveryInfos['delivery_mode'] == 'BPR') {
|
||
$dest_company = $deliveryInfos['prname'];
|
||
$dest_gender = ''; // '', 'M.', 'Mme', 'Mlle'
|
||
$dest_firstname = $delivery_address->firstname;
|
||
$dest_lastname = $delivery_address->lastname;
|
||
} else {
|
||
$dest_company = !empty($deliveryInfos['cecompanyname'])? $deliveryInfos['cecompanyname']: $deliveryInfos['prcompladress'];
|
||
$dest_gender = ''; // '', 'M.', 'Mme', 'Mlle'
|
||
$dest_firstname = $deliveryInfos['prfirstname'];
|
||
$dest_lastname = $deliveryInfos['prname'];
|
||
}
|
||
$dest_line1 = $deliveryInfos['pradress1'];
|
||
$dest_line2 = $deliveryInfos['pradress2'];
|
||
$dest_line3 = $deliveryInfos['pradress3'];
|
||
$dest_line4 = $deliveryInfos['pradress4'];
|
||
$dest_postal = $deliveryInfos['przipcode'];
|
||
$dest_postal_cab = $deliveryInfos['przipcode'];
|
||
$dest_city = $deliveryInfos['prtown'];
|
||
$dest_phone = (!empty($deliveryInfos['cephonenumber'])? $deliveryInfos['cephonenumber']: '');
|
||
$dest_mobile = $deliveryInfos['cephonenumber'];
|
||
|
||
if(strlen($dest_phone) > 10) {
|
||
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $dest_phone)) {
|
||
$dest_phone = '0'.substr(substr($dest_phone, -10), 1);
|
||
}
|
||
}
|
||
if(strlen($dest_mobile) > 10) {
|
||
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $$dest_mobile)) {
|
||
$dest_mobile = '0'.substr(substr($dest_mobile, -10), 1);
|
||
}
|
||
}
|
||
|
||
$dest_code1 = $deliveryInfos['cedoorcode1'];
|
||
$dest_code2 = $deliveryInfos['cedoorcode2'];
|
||
$dest_interphone = '';
|
||
$dest_instructions = $this->stripaccents(str_replace(array("\r", "\n", ''), ' ', $deliveryInfos['cedeliveryinformation']));
|
||
|
||
$dest_bpr_gender = '';
|
||
$dest_bpr_firstname = '';
|
||
$dest_bpr_lastname = '';
|
||
|
||
$dest_bpr_name = '';
|
||
$dest_bpr_line1 = '';
|
||
$dest_bpr_line2 = '';
|
||
$dest_bpr_line3 = '';
|
||
$dest_bpr_postal = '';
|
||
$dest_bpr_city = '';
|
||
}
|
||
} else {
|
||
$parceltype = 'COLD';
|
||
|
||
$dest_company = $delivery_address->company;
|
||
$dest_gender = ''; // '', 'M.', 'Mme', 'Mlle'
|
||
$dest_firstname = $delivery_address->firstname;
|
||
$dest_lastname = $delivery_address->lastname;
|
||
$dest_lines = array();
|
||
if(strlen($delivery_address->address1) > 34) {
|
||
$dest_lines[] = substr($delivery_address->address1, 0, 34);
|
||
$dest_lines[] = substr($delivery_address->address1, 34);
|
||
} else {
|
||
$dest_lines[] = $delivery_address->address1;
|
||
}
|
||
if(strlen($delivery_address->address2) > 34) {
|
||
$dest_lines[] = substr($delivery_address->address2, 0, 34);
|
||
$dest_lines[] = substr($delivery_address->address2, 34);
|
||
} else {
|
||
$dest_lines[] = $delivery_address->address2;
|
||
}
|
||
$dest_line1 = isset($dest_lines[0])? $dest_lines[0]: '';
|
||
$dest_line2 = isset($dest_lines[1])? $dest_lines[1]: '';
|
||
$dest_line3 = isset($dest_lines[2])? $dest_lines[2]: '';
|
||
$dest_line4 = isset($dest_lines[3])? $dest_lines[3]: '';
|
||
$dest_postal = $delivery_address->postcode;
|
||
$dest_postal_cab = $delivery_address->postcode;
|
||
$dest_city = $delivery_address->city;
|
||
$dest_phone = (!empty($delivery_address->phone)? $delivery_address->phone: $delivery_address->phone_mobile);
|
||
$dest_mobile = $delivery_address->phone_mobile;
|
||
$dest_code1 = '';
|
||
$dest_code2 = '';
|
||
$dest_interphone = '';
|
||
$dest_instructions = '';
|
||
|
||
$dest_bpr_gender = '';
|
||
$dest_bpr_firstname = '';
|
||
$dest_bpr_lastname = '';
|
||
|
||
$dest_bpr_name = '';
|
||
$dest_bpr_line1 = '';
|
||
$dest_bpr_line2 = '';
|
||
$dest_bpr_line3 = '';
|
||
$dest_bpr_postal = '';
|
||
$dest_bpr_city = '';
|
||
}
|
||
|
||
$ref_client = $order->id;
|
||
|
||
$sender_lines = array();
|
||
|
||
$exp_firstname = Configuration::get('LAPOSTEWS_EXP_FIRSTNAME');
|
||
$exp_lastname = Configuration::get('LAPOSTEWS_EXP_LASTNAME');
|
||
$exp_company = Configuration::get('LAPOSTEWS_EXP_COMPANY');
|
||
|
||
if(!empty($exp_firstname)) {
|
||
$sender_lines[] = $exp_firstname.' '.$exp_lastname;
|
||
}
|
||
if(!empty($exp_company)) {
|
||
$sender_lines[] = $exp_company;
|
||
}
|
||
$sender_lines[] = Configuration::get('LAPOSTEWS_EXP_ADDR1');
|
||
$sender_lines[] = Configuration::get('LAPOSTEWS_EXP_ADDR2');
|
||
|
||
$sender_line1 = isset($sender_lines[0])? $sender_lines[0]: '';
|
||
$sender_line2 = isset($sender_lines[1])? $sender_lines[1]: '';
|
||
$sender_line3 = isset($sender_lines[2])? $sender_lines[2]: '';
|
||
$sender_line4 = isset($sender_lines[3])? $sender_lines[3]: '';
|
||
$sender_postal = Configuration::get('LAPOSTEWS_EXP_POSTALCODE');
|
||
$sender_city = Configuration::get('LAPOSTEWS_EXP_CITY');
|
||
$sender_phone = Configuration::get('LAPOSTEWS_EXP_PHONE');
|
||
|
||
$contract = Configuration::get('LAPOSTEWS_API_CONTRACT');
|
||
$site = Configuration::get('LAPOSTEWS_SHIPPING_SITE');
|
||
|
||
$lines = array();
|
||
if(!empty($dest_lastname)) {
|
||
$lines[] = $this->stripaccents((!empty($dest_gender)? $dest_gender.' ': '').$dest_lastname.' '.$dest_firstname);
|
||
}
|
||
if(!empty($dest_company)) {
|
||
$lines[] = $dest_company;
|
||
}
|
||
$lines[] = $dest_line1; // etage
|
||
$lines[] = $dest_line2; // batiment
|
||
$lines[] = $dest_line3; // rue
|
||
$lines[] = $dest_line4; // lieu dit
|
||
|
||
$tracking = $shipping_number;
|
||
$tracking_fmt = substr($tracking, 0, 2).' '.substr($tracking, 2, 5).' '.substr($tracking, 7, 5).' '.substr($tracking, 12);
|
||
|
||
/* Format:
|
||
0..2 : Code produit => Valeur fixe : 6..
|
||
3 : Reconnaissance de tri => Valeur fixe : 1
|
||
4..9 : Code postal de livraison (ex : 72240 en FRANCE) ou (ex : AD100 en ANDORRE)
|
||
10..16 : Identifiant du client (ex : 900001)
|
||
17..20 : Poids exprimé en décagrammes (ex : 0860 = 8,6 kg)
|
||
21..22 : Tranche d'Assurance Ad Valorem ou niveau de recommandation : de 00 = 0 euro à 10 = 1500 euros,
|
||
21= R1, 22 = R2, 23 = R3
|
||
23 : Non mécanisable (0 = NON, 1 = OUI)
|
||
24 : (Zone réservée) => Valeur fixe : 0
|
||
25 : Lien de contrôle entre les 2 codes à barres de l’étiquette (suivi et prise en charge). Ce chiffre est égal au 12ème caractère du code de suivi
|
||
26 : Clé sur les 15 précédents caractères (à partir de la droite du lien de contrôle jusqu’à l’identifiant du client
|
||
compris)
|
||
|
||
La détermination du rang des caractères se fait à partir de la droite de la série de chiffres, c'est à dire de la position de la clé de
|
||
contrôle, qui reçoit le rang 1.
|
||
|
||
1. Somme de tous les chiffres de rang pair en partant de la droite
|
||
2. Multiplication de cette somme par 3
|
||
3. Somme des chiffres de rang impair en partant du caractère de rang 3
|
||
4. Somme des résultats obtenus en 2 et 3
|
||
5. Différence entre le résultat 4 et la dizaine supérieure. Le résultat de cette opération est la valeur de la clé de contrôle. Si le résultat est égal à 10 la clé prend la valeur 0.
|
||
*/
|
||
$handling = substr($tracking, 0, 2).'1'.($parceltype == 'A2P'? '91500': $dest_postal_cab).$contract.sprintf('%04d', $weight * 100).'00'.'0'.'0'.substr($tracking, 11, 1);
|
||
|
||
$key_chunks = str_split(substr(strrev($handling), 0, 15));$key_chunks_e = ($key_chunks[0] + $key_chunks[2] + $key_chunks[4] + $key_chunks[6] + $key_chunks[8] + $key_chunks[10] + $key_chunks[12] + $key_chunks[14]) * 3;
|
||
$key_chunks_o = $key_chunks[1] + $key_chunks[3] + $key_chunks[5] + $key_chunks[7] + $key_chunks[9] + $key_chunks[11] + $key_chunks[13];
|
||
$key_chunks_eo = $key_chunks_e + $key_chunks_o;
|
||
$handling_key = ((ceil($key_chunks_eo / 10) * 10) - $key_chunks_eo) % 10;
|
||
|
||
$handling .= $handling_key;
|
||
|
||
$handling_fmt = substr($handling, 0, 3).' '.substr($handling, 3, 5).' '.substr($handling, 8, 6).' '.substr($handling, 14, 4).' '.substr($handling, 18);
|
||
|
||
$result = '';
|
||
|
||
$format = str_replace(
|
||
array(
|
||
'{SADDR_0}',
|
||
'{SADDR_1}',
|
||
'{SADDR_2}',
|
||
'{SADDR_3}',
|
||
'{SADDR_4}',
|
||
'{SADDR_5}',
|
||
'{CONTRACT}',
|
||
'{WEIGHT}',
|
||
'{DATE}',
|
||
'{SITE}',
|
||
'{TRACKING_0}',
|
||
'{TRACKING_1}',
|
||
'{TRACKING_2}',
|
||
'{TRACKING_3}',
|
||
'{HANDLING_0}',
|
||
'{HANDLING_1}',
|
||
'{HANDLING_2}',
|
||
'{CUST_REF}',
|
||
'{INTERPH_0}',
|
||
'{INTERPH_1}',
|
||
'{DPHONE}',
|
||
'{DPHONE_CELL}',
|
||
'{DOOR_0}',
|
||
'{DOOR_1}',
|
||
'{DADDR_INST}',
|
||
),
|
||
array(
|
||
mb_strtoupper(substr($sender_line1, 0, 24)),
|
||
mb_strtoupper(substr($sender_line2, 0, 26)),
|
||
mb_strtoupper(substr($sender_line3, 0, 26)),
|
||
mb_strtoupper(substr($sender_line4, 0, 26)),
|
||
mb_strtoupper(substr($sender_postal.' '.$sender_city, 0, 24)),
|
||
mb_strtoupper(substr($sender_phone, 0, 18)),
|
||
$contract,
|
||
sprintf('%.02f', $weight),
|
||
date('d/m/Y'),
|
||
mb_strtoupper(substr($site, 0, 16)),
|
||
$tracking_fmt,
|
||
substr($tracking, 0, 3),
|
||
substr($tracking, 3),
|
||
'',
|
||
$handling_fmt,
|
||
substr($handling, 0, 2),
|
||
substr($handling, 2),
|
||
mb_strtoupper(substr($ref_client, 0, 16)),
|
||
mb_strtoupper(substr($dest_interphone, 0, 11)),
|
||
mb_strtoupper(substr($dest_interphone, 11, 19)),
|
||
mb_strtoupper(substr($dest_phone, 0, 14)),
|
||
mb_strtoupper(substr($dest_mobile, 0, 14)),
|
||
mb_strtoupper(substr($dest_code1, 0, 8)),
|
||
mb_strtoupper(substr($dest_code2, 0, 8)),
|
||
mb_strtoupper(substr($dest_instructions, 0, 70)),
|
||
),
|
||
$laposte_formats[$parceltype]
|
||
);
|
||
|
||
if(in_array($parceltype, array('ACP', 'BPR', 'CDI'))) {
|
||
$format = str_replace(
|
||
array(
|
||
'{DADDR_0}',
|
||
'{DADDR_1}',
|
||
'{DADDR_2}',
|
||
'{DADDR_3}',
|
||
'{DADDR_4}',
|
||
'{DADDR_5}',
|
||
|
||
'{DBPR_0}',
|
||
'{DBPR_1}',
|
||
'{DBPR_2}',
|
||
'{DBPR_3}',
|
||
'{DBPR_4}',
|
||
'{DBPR_5}',
|
||
'{DBPR_6}',
|
||
'{DBPR_7}',
|
||
),
|
||
array(
|
||
$this->stripaccents(mb_strtoupper(substr($dest_line1, 0, 28))),
|
||
$this->stripaccents(mb_strtoupper(substr($dest_line2, 0, 28))),
|
||
mb_strtoupper(substr($dest_line3, 0, 28)),
|
||
mb_strtoupper(substr($dest_line4, 0, 28)),
|
||
$dest_postal.' '.mb_strtoupper(substr($this->stripaccents($dest_city), 0, 16)),
|
||
mb_strtoupper(substr($this->stripaccents($dest_city), 16, 22)),
|
||
|
||
$this->stripaccents(mb_strtoupper(substr($dest_bpr_name, 0, 44))),
|
||
$this->stripaccents(mb_strtoupper(substr((!empty($dest_bpr_gender)? $dest_bpr_gender.' ': '').$dest_bpr_lastname.' '.$dest_bpr_firstname, 0, 44))),
|
||
mb_strtoupper(substr($dest_bpr_line1, 0, 34)),
|
||
mb_strtoupper(substr($dest_bpr_line2, 0, 34)),
|
||
mb_strtoupper(substr($dest_bpr_line3, 0, 34)),
|
||
substr($dest_bpr_postal, 0, 5),
|
||
mb_strtoupper(substr($dest_bpr_city, 0, 22)),
|
||
mb_strtoupper(substr($dest_bpr_city, 22, 13)),
|
||
),
|
||
$format
|
||
);
|
||
} elseif(in_array($parceltype, array('DOM', 'DOS', 'COL', 'COLD', 'RDV'))) {
|
||
$format = str_replace(
|
||
array(
|
||
'{DADDR_0}',
|
||
'{DADDR_1}',
|
||
'{DADDR_2}',
|
||
'{DADDR_3}',
|
||
'{DADDR_4}',
|
||
'{DADDR_5}',
|
||
'{DADDR_6}',
|
||
'{DADDR_7}',
|
||
'{DADDR_8}',
|
||
),
|
||
array(
|
||
mb_strtoupper(substr($lines[0], 0, 38)),
|
||
mb_strtoupper(substr($lines[1], 0, 44)),
|
||
mb_strtoupper(substr($lines[2], 0, 34)),
|
||
mb_strtoupper(substr($lines[3], 0, 34)),
|
||
mb_strtoupper(substr($lines[4], 0, 34)),
|
||
mb_strtoupper(substr($dest_phone, 0, 14)),
|
||
substr($dest_postal, 0, 5),
|
||
mb_strtoupper(substr($this->stripaccents($dest_city), 0, 22)),
|
||
mb_strtoupper(substr($this->stripaccents($dest_city), 22, 13)),
|
||
),
|
||
$format
|
||
);
|
||
} elseif($parceltype == 'A2P') {
|
||
$hub_barcode = sprintf('%07d', $dest_bpr_postal).$tracking.'0'.'849'.'250';
|
||
$hub_key = '';
|
||
$iso = array(
|
||
0 => '0', 1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5',
|
||
6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => 'A', 11 => 'B',
|
||
12 => 'C', 13 => 'D', 14 => 'E', 15 => 'F', 16 => 'G', 17 => 'H',
|
||
18 => 'I', 19 => 'J', 20 => 'K', 21 => 'L', 22 => 'M', 23 => 'N',
|
||
24 => 'O', 25 => 'P', 26 => 'Q', 27 => 'R', 28 => 'S', 29 => 'T',
|
||
30 => 'U', 31 => 'V', 32 => 'W', 33 => 'X', 34 => 'Y', 35 => 'Z',
|
||
);
|
||
$hub_barcode_chunks = str_split($hub_barcode);
|
||
$hub_mod = 36;
|
||
$hub_cs = 36;
|
||
for($i=0, $l=count($hub_barcode_chunks); $i<$l; $i++) {
|
||
$y = array_search($hub_barcode_chunks[$i], $iso);
|
||
$hub_cs += $y;
|
||
if($hub_cs > $hub_mod) {
|
||
$hub_cs -= $hub_mod;
|
||
}
|
||
$hub_cs *= 2;
|
||
if($hub_cs > $hub_mod) {
|
||
$hub_cs -= $hub_mod - 1;
|
||
}
|
||
}
|
||
|
||
$hub_cs = $hub_mod + 1 - $hub_cs;
|
||
if($hub_cs == $hub_mod) {
|
||
$hub_cs = 0;
|
||
}
|
||
|
||
$hub_key = $iso[$hub_cs];
|
||
|
||
$format = str_replace(
|
||
array(
|
||
'{DBPR_0}',
|
||
'{DBPR_1}',
|
||
'{DBPR_2}',
|
||
'{DBPR_3}',
|
||
'{DBPR_4}',
|
||
'{DBPR_5}',
|
||
|
||
'{DBPRCODE_0}',
|
||
'{DBPRCODE_1}',
|
||
|
||
'{DHUB_CODE_0}',
|
||
'{DHUB_CODE_1}',
|
||
'{DHUB_CODE_2}',
|
||
),
|
||
array(
|
||
mb_strtoupper(substr($dest_bpr_name, 0, 38)),
|
||
$this->stripaccents(mb_strtoupper(substr((!empty($dest_bpr_gender)? $dest_bpr_gender.' ': '').$dest_bpr_lastname.' '.$dest_bpr_firstname, 0, 44))),
|
||
mb_strtoupper(substr($dest_bpr_line1, 0, 34)),
|
||
mb_strtoupper(substr($dest_bpr_line2, 0, 34)),
|
||
substr($dest_bpr_postal, 0, 5).' '.mb_strtoupper(substr($dest_bpr_city, 0, 28)),
|
||
substr($dest_mobile, 0, 16),
|
||
|
||
$dest_bpr_code1,
|
||
$dest_bpr_code2,
|
||
|
||
substr($hub_barcode, 0, 4).' '.substr($hub_barcode, 4, 4).' '.substr($hub_barcode, 8, 4).' '.substr($hub_barcode, 12, 4).' '.substr($hub_barcode, 16, 4).' '.substr($hub_barcode, 20, 4).' '.substr($hub_barcode, 24).$hub_key,
|
||
substr($hub_barcode, 0, 8),
|
||
substr($hub_barcode, 8),
|
||
),
|
||
$format
|
||
);
|
||
} elseif($parceltype == 'CIT') {
|
||
$format = str_replace(
|
||
array(
|
||
'{DADDR_0}',
|
||
'{DADDR_1}',
|
||
'{DADDR_2}',
|
||
'{DADDR_3}',
|
||
'{DADDR_4}',
|
||
'{DADDR_5}',
|
||
'{DADDR_6}',
|
||
'{DADDR_7}',
|
||
|
||
'{DBPR_0}',
|
||
'{DBPR_1}',
|
||
'{DBPR_2}',
|
||
'{DBPR_3}',
|
||
'{DBPR_4}',
|
||
'{DBPR_5}',
|
||
'{DBPR_6}',
|
||
),
|
||
array(
|
||
$this->stripaccents(mb_strtoupper(substr($lines[0], 0, 38))),
|
||
$this->stripaccents(mb_strtoupper(substr($lines[1], 0, 44))),
|
||
mb_strtoupper(substr($lines[2], 0, 34)),
|
||
mb_strtoupper(substr($lines[3], 0, 34)),
|
||
mb_strtoupper(substr($lines[4], 0, 34)),
|
||
substr($dest_postal, 0, 5).' '.mb_strtoupper(substr($this->stripaccents($dest_city), 0, 22)),
|
||
mb_strtoupper(substr($this->stripaccents($dest_city), 22, 28)),
|
||
mb_strtoupper(substr($dest_phone, 0, 14)),
|
||
|
||
$this->stripaccents(mb_strtoupper(substr($dest_bpr_name, 0, 38))),
|
||
$this->stripaccents(mb_strtoupper(substr((!empty($dest_bpr_gender)? $dest_bpr_gender.' ': '').$dest_bpr_lastname.' '.$dest_bpr_firstname, 0, 44))),
|
||
mb_strtoupper(substr($dest_bpr_line1, 0, 34)),
|
||
mb_strtoupper(substr($dest_bpr_line2, 0, 34)),
|
||
mb_strtoupper(substr($dest_bpr_line3, 0, 34)),
|
||
substr($dest_bpr_postal, 0, 5),
|
||
mb_strtoupper(substr($dest_bpr_city, 0, 28)),
|
||
),
|
||
$format
|
||
);
|
||
}
|
||
} else {
|
||
$shipping_number = $shipping_data->genererEtiquetteBic3Response->parcelNumber;
|
||
$parcelNumberPartner = $shipping_data->genererEtiquetteBic3Response->parcelNumberPartenaire;
|
||
$shipping_number_fmt = substr($shipping_number, 0, 2).' '.substr($shipping_number, 2, 4).' '.substr($shipping_number, 6, 4).' '.substr($shipping_number, 10, 1).' '.substr($shipping_number, 11);
|
||
$handling_fmt = substr(sprintf('%08d', $delivery_address->postcode), 0, 4).' '.substr(sprintf('%08d', $delivery_address->postcode), 4).' 1153 '.substr($parcelNumberPartner, 10, 4).' '.substr($parcelNumberPartner, 14, 4).' '.substr($parcelNumberPartner, 18, 2).' 101 056 ';
|
||
$handling = str_replace(' ', '', $handling_fmt);
|
||
|
||
$delivery_infos = Db::getInstance()->getRow('
|
||
SELECT *
|
||
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
|
||
WHERE `id_cart` = '.(int) $order->id_cart.'
|
||
');
|
||
|
||
if($delivery_address->id_country == 3) {
|
||
/*if($_SERVER['REMOTE_ADDR'] != '78.226.56.137' && !in_array((int) $cookie->id_employee, array(70, 77))) {
|
||
return false;
|
||
}*/
|
||
$format = str_replace(
|
||
array(
|
||
'{TRACKING_PARTNER}',
|
||
'{ID_DEST1}',
|
||
'{ID_DEST2}',
|
||
'{DATE}',
|
||
'{HANDLING_0}',
|
||
'{HANDLING_1}',
|
||
'{HANDLING_2}',
|
||
'{TRACKING_0}',
|
||
'{TRACKING_1}',
|
||
'{TRACKING_2}',
|
||
'{TRACKING_3}',
|
||
'{SADDR_0}',
|
||
'{SADDR_1}',
|
||
'{SADDR_2}',
|
||
'{SADDR_5}',
|
||
'{SADDR_4}',
|
||
'{DADDR_0}',
|
||
'{DADDR_1}',
|
||
'{DADDR_2}',
|
||
'{DADDR_3}',
|
||
'{DADDR_4}',
|
||
'{DADDR_5}',
|
||
'{DADDR_6}',
|
||
'{CONTRACT}',
|
||
'{SITE_0}',
|
||
'{SITE_1}',
|
||
'{WEIGHT}',
|
||
'{SERVICE}',
|
||
'{TRIEXPORT}',
|
||
'{TRIIMPORT}',
|
||
'{DEPOT}',
|
||
'{TRACKING_KEY}',
|
||
'{DELIVERYMODE}',
|
||
'{ROUTING}',
|
||
'{SIGNATURE}',
|
||
'{CP71}',
|
||
'{PUGO}',
|
||
'{IMPORT_ALIGN}',
|
||
),
|
||
array(
|
||
$shipping_data->genererEtiquetteBic3Response->parcelNumberPartenaire,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->identificationDestination1,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->identificationDestination2,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->dateImpression.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->heureImpression.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->routingVersion.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->numeroVersionWS,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneCABRoutage->numeroColisRoutage,
|
||
substr($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneCABRoutage->codeBarreRoutage, 0, 6),
|
||
substr($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneCABRoutage->codeBarreRoutage, 6),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 0, 2).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 2, 4).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 6, 4).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 10, 1).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 11),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 0, 3),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 3, 8),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 11),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->companyName)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->line2)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->line3)),
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->phone,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->postalCode.' '.mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->city)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName: $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Name.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Surname)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Name.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Surname: $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line2)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line2: $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line3)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line3: '')),
|
||
'',
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->postalCode.' '.mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->city)),
|
||
'BELGIQUE - BE',
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->contractNumber,
|
||
substr($shipping_data->genererEtiquetteBic3Response->xmlResponse->sitePCH->libelle, 0, 12),
|
||
substr($shipping_data->genererEtiquetteBic3Response->xmlResponse->sitePCH->libelle, 12, 22),
|
||
sprintf('%.02f', $weight),
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->typeServiceLivraison,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triExport,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->rDepot,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->cleControleNumeroSuivi,
|
||
$delivery_infos? 'SOBEL': ($shipping_date->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->etiquetteBelgique->codeVas->signature == '!'? 'COLISSIMOI': 'COLISSIMOACCI'),
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->numeroSuiviCABRoutage,
|
||
$shipping_date->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->etiquetteBelgique->codeVas->signature,
|
||
$delivery_infos? '': 'CP71 France',
|
||
$shipping_date->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->etiquetteBelgique->codeVas->livraison,
|
||
strlen($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport) == 1? '355': (strlen($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport) == 2? '340': (strlen($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport) == 3? '325': '310')),
|
||
),
|
||
$laposte_formats['BELG']
|
||
);
|
||
//mail('perron@antadis.com', 'test belg', $shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneCABRoutage->codeBarreRoutage);
|
||
} else {
|
||
$format = str_replace(
|
||
array(
|
||
'{TRACKING_PARTNER}',
|
||
'{ID_DEST1}',
|
||
'{ID_DEST2}',
|
||
'{DATE}',
|
||
'{CUST_REF}',
|
||
'{HANDLING_0}',
|
||
'{HANDLING_1}',
|
||
'{HANDLING_2}',
|
||
'{TRACKING_0}',
|
||
'{TRACKING_1}',
|
||
'{TRACKING_2}',
|
||
'{TRACKING_3}',
|
||
'{SADDR_0}',
|
||
'{SADDR_1}',
|
||
'{SADDR_2}',
|
||
'{SADDR_5}',
|
||
'{SADDR_4}',
|
||
'{DADDR_0}',
|
||
'{DADDR_1}',
|
||
'{DADDR_2}',
|
||
'{DADDR_3}',
|
||
'{DADDR_4}',
|
||
'{DADDR_5}',
|
||
'{DADDR_6}',
|
||
'{DADDR_7}',
|
||
'{CONTRACT}',
|
||
'{SITE_0}',
|
||
'{SITE_1}',
|
||
'{SITE_2}',
|
||
'{WEIGHT}',
|
||
'{SERVICE}',
|
||
'{TRIIMPORT}',
|
||
'{TRIEXPORT}',
|
||
'{IMPORT_ALIGN}',
|
||
'{DEPOT}',
|
||
'{TRACKING_KEY}',
|
||
'{ROUTING}',
|
||
'{COUNTRYCODE}',
|
||
),
|
||
array(
|
||
$shipping_data->genererEtiquetteBic3Response->parcelNumberPartenaire,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->identificationDestination1,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->identificationDestination2,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->dateImpression.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->heureImpression.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->routingVersion.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->numeroVersionWS,
|
||
$order->id,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneCABRoutage->numeroColisRoutage,
|
||
substr($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneCABRoutage->codeBarreRoutage, 0, 6),
|
||
substr($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneCABRoutage->codeBarreRoutage, 6),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 0, 2).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 2, 4).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 6, 4).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 10, 1).' '.substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 11),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 0, 3),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 3, 8),
|
||
substr($shipping_data->genererEtiquetteBic3Response->parcelNumber, 11),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->companyName)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->line2)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->line3)),
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->phone,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->postalCode.' '.mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->expediteur->addressVO->city)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName: $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Name.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Surname)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Name.' '.$shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->Surname: $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line2)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line2: $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line3)),
|
||
mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->companyName != ''? $shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->line3: '')),
|
||
'',
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->postalCode.' '.mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->city)),
|
||
str_replace('REPUBLIQUE', 'REP.', mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->country)).'-'.mb_strtoupper($shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->countryCode)),
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->destinataire->addressVO->MobileNumber,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->contractNumber,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->sitePCH->adresse->line0,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->sitePCH->adresse->line2,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->sitePCH->adresse->postalCode.' '.mb_strtoupper($this->stripaccents($shipping_data->genererEtiquetteBic3Response->xmlResponse->sitePCH->adresse->city)),
|
||
sprintf('%.02f', $weight),
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->typeServiceLivraison,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triExport,
|
||
strlen($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport) == 1? '355': (strlen($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport) == 2? '340': (strlen($shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->triImport) == 3? '325': '310')),
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->rDepot,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->cleControleNumeroSuivi,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->numeroSuiviCABRoutage,
|
||
$shipping_data->genererEtiquetteBic3Response->xmlResponse->zoneRoutage->zoneInfosRoutage->identificationDestination1,
|
||
),
|
||
$laposte_formats['COLI']
|
||
);
|
||
}
|
||
}
|
||
|
||
return $format;
|
||
}
|
||
|
||
public function logParcel($shipping_data, $products) {
|
||
global $cookie;
|
||
|
||
/**
|
||
* @Override laposte WSU
|
||
*/
|
||
if((int)Configuration::get('LAPOSTEWS_WSU_ENABLE') == 1) {
|
||
foreach($products as $k => $v) {
|
||
if($v > 0) {
|
||
Db::getInstance()->ExecuteS('
|
||
INSERT `'._DB_PREFIX_.'lapostews` VALUES (
|
||
'.(int) $k.',
|
||
'.(int) $cookie->id_employee.',
|
||
'.(int) $v.',
|
||
"'.pSQL($shipping_data['data']->labelResponse->parcelNumber).'",
|
||
NOW()
|
||
)
|
||
');
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
|
||
if(isset($shipping_data->getLetterColissimoReturn)) {
|
||
foreach($products as $k => $v) {
|
||
if($v > 0) {
|
||
Db::getInstance()->ExecuteS('
|
||
INSERT `'._DB_PREFIX_.'lapostews` VALUES (
|
||
'.(int) $k.',
|
||
'.(int) $cookie->id_employee.',
|
||
'.(int) $v.',
|
||
"'.pSQL($shipping_data->getLetterColissimoReturn->parcelNumber).'",
|
||
NOW()
|
||
)
|
||
');
|
||
}
|
||
}
|
||
} else {
|
||
foreach($products as $k => $v) {
|
||
if($v > 0) {
|
||
Db::getInstance()->ExecuteS('
|
||
INSERT `'._DB_PREFIX_.'lapostews` VALUES (
|
||
'.(int) $k.',
|
||
'.(int) $cookie->id_employee.',
|
||
'.(int) $v.',
|
||
"'.pSQL($shipping_data->genererEtiquetteBic3Response->parcelNumber).'",
|
||
NOW()
|
||
)
|
||
');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public function addOrderHistory($shipping_data, $order, $products_sent) {
|
||
global $cookie;
|
||
|
||
$socolissimo_carrier_id = (int) Configuration::get('SOCOLISSIMO_CARRIER_ID');
|
||
|
||
$carrier = new Carrier($socolissimo_carrier_id? $socolissimo_carrier_id: (int) $order->id_carrier, (int) $order->id_lang);
|
||
$customer = new Customer((int) $order->id_customer);
|
||
|
||
if((int) $order->id_lang == 3) {
|
||
$carrier->url .= '&language=es_ES';
|
||
$content_html = '<strong>Contenido del paquete:</strong>';
|
||
$content_txt = 'Contenido del paquete:';
|
||
} else {
|
||
$content_html = '<strong>Contenu du colis :</strong>';
|
||
$content_txt = 'Contenu du colis :';
|
||
}
|
||
|
||
/**
|
||
* @Override laposte WSU
|
||
*/
|
||
if((int)Configuration::get('LAPOSTEWS_WSU_ENABLE') == 1) {
|
||
$shipping_number = $shipping_data['data']->labelResponse->parcelNumber;
|
||
} else {
|
||
if(isset($shipping_data->genererEtiquetteBic3Response)) {
|
||
$shipping_number = $shipping_data->genererEtiquetteBic3Response->parcelNumber;
|
||
} else {
|
||
$shipping_number = $shipping_data->getLetterColissimoReturn->parcelNumber;
|
||
}
|
||
}
|
||
|
||
$templateVars = array(
|
||
'{followup}' => str_replace('@', $shipping_number, $carrier->url),
|
||
'{firstname}' => $customer->firstname,
|
||
'{lastname}' => $customer->lastname,
|
||
'{id_order}' => (int) $order->id,
|
||
'{product_list}' => !empty($products_sent)? $content_html.$products_sent: '',
|
||
'{product_list_txt}' => !empty($products_sent)? $content_txt.strip_tags($products_sent): '',
|
||
);
|
||
|
||
$history = new OrderHistory();
|
||
$history->id_order = (int) $order->id;
|
||
|
||
$fully_sent = TRUE;
|
||
$products_sent = array();
|
||
$to_send = array();
|
||
$shipping_numbers = array();
|
||
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT d.`id_order_detail`, IF(
|
||
(d.`product_quantity` - IF(
|
||
d.`product_quantity_return` > 0, d.`product_quantity_return`, d.`product_quantity_refunded`
|
||
) - IFNULL(SUM(s.`quantity`), 0)) > 0, 1, 0
|
||
) AS `remain`, s.`shipping_number`
|
||
FROM `'._DB_PREFIX_.'order_detail` d
|
||
LEFT OUTER JOIN `'._DB_PREFIX_.'lapostews` s
|
||
ON s.`id_order_detail` = d.`id_order_detail`
|
||
WHERE d.`id_order` = '.(int) $order->id.'
|
||
GROUP BY d.`id_order_detail`
|
||
') as $quantity_remain) {
|
||
if($quantity_remain['shipping_number']) {
|
||
$shipping_numbers[] = pSQL($quantity_remain['shipping_number']);
|
||
}
|
||
if((int) $quantity_remain['remain'] > 0) {
|
||
$fully_sent = FALSE;
|
||
$to_send[] = (int) $quantity_remain['id_order_detail'];
|
||
}
|
||
}
|
||
$_to_send = array();
|
||
foreach($to_send as $p) {
|
||
$id_sale = (int) Db::getInstance()->getValue('
|
||
SELECT `id_sale`
|
||
FROM `'._DB_PREFIX_.'product_ps_cache`
|
||
WHERE `id_product` = (
|
||
SELECT `product_id`
|
||
FROM `'._DB_PREFIX_.'order_detail`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
AND `id_order_detail` = '.(int) $p.'
|
||
)
|
||
');
|
||
|
||
if(!Db::getInstance()->getValue('
|
||
SELECT `id_order`
|
||
FROM `'._DB_PREFIX_.'shipping_history`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
AND `id_sale` = '.(int) $id_sale.'
|
||
AND `shipping_number` NOT IN ("'.implode('", "', $shipping_numbers).'")
|
||
')) {
|
||
$_to_send[] = $p;
|
||
}
|
||
}
|
||
|
||
if(count($_to_send) === 0) {
|
||
$fully_sent = TRUE;
|
||
}
|
||
|
||
//mail('perron@antadis.com', 'test logistics', (int) $order->id);
|
||
|
||
/*$order_sales = array();
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT DISTINCT `id_sale`
|
||
FROM `'._DB_PREFIX_.'product_ps_cache`
|
||
WHERE `id_product` IN (
|
||
SELECT `product_id`
|
||
FROM `'._DB_PREFIX_.'order_detail`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
'.(count($products_sent) > 0? ' AND `id_order_detail` NOT IN ('.implode(', ', $products_sent).')': '').'
|
||
)
|
||
') as $order_sale) {
|
||
$order_sales[] = (int) $order_sale['id_sale'];
|
||
}
|
||
|
||
if(in_array(0, $order_sales)) {
|
||
$order_sales[] = 999999;
|
||
}*/
|
||
|
||
/*if(Db::getInstance()->getRow('
|
||
SELECT `product_id`
|
||
FROM `'._DB_PREFIX_.'order_detail`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
'.(count($products_sent) > 0? ' AND `id_order_detail` NOT IN ('.implode(', ', $products_sent).')': '').'
|
||
AND `product_id` IN (
|
||
SELECT `id_product` FROM `'._DB_PREFIX_.'product_ps_cache` WHERE `id_sale` = 0
|
||
)
|
||
')) {
|
||
$order_sales[] = 999999;
|
||
}*/
|
||
|
||
/*if(count($order_sales) > 0) {
|
||
$cpt = array(1 => 0, 2 => 0);
|
||
|
||
foreach(Db::getInstance()->ExecuteS('
|
||
SELECT `id_shipping`, COUNT(`id_sale`) AS `sale_count`
|
||
FROM `'._DB_PREFIX_.'privatesale_shipping_sale`
|
||
WHERE `id_sale` IN ('.implode(', ', $order_sales).')
|
||
AND `id_sale` NOT IN (
|
||
SELECT `id_sale`
|
||
FROM `'._DB_PREFIX_.'shipping_history`
|
||
WHERE `id_order` = '.(int) $order->id.'
|
||
AND `id_sale` IN ('.implode(', ', $order_sales).')
|
||
)
|
||
GROUP BY `id_shipping`
|
||
') as $cpt_sale) {
|
||
$cpt[(int) $cpt_sale['id_shipping']] = (int) $cpt_sale['sale_count'];
|
||
}
|
||
|
||
if($cpt[1] == 0 && $cpt[2] == 0) {
|
||
$fully_sent = TRUE;
|
||
}
|
||
}*/
|
||
|
||
$history->changeIdOrderState(($fully_sent? Configuration::get('PS_OS_SHIPPING'): 17), (int) $order->id);
|
||
$history->id_employee = (int) $cookie->id_employee;
|
||
$history->addWithemail(TRUE, $templateVars);
|
||
|
||
global $_LANGMAIL;
|
||
$subject = 'Package in transit';
|
||
if((int) $order->id_lang == 3) {
|
||
$subject = 'Paquete en tránsito';
|
||
} else {
|
||
$subject = 'Package in transit';
|
||
}
|
||
|
||
Mail::Send(
|
||
intval($order->id_lang),
|
||
'in_transit',
|
||
(
|
||
(is_array($_LANGMAIL) && key_exists($subject, $_LANGMAIL))
|
||
? $_LANGMAIL[$subject]
|
||
: $subject
|
||
),
|
||
$templateVars,
|
||
$customer->email,
|
||
$customer->firstname.' '.$customer->lastname
|
||
);
|
||
}
|
||
}
|