Merge branch 'ticket-13166-ReturnProcess' into develop

This commit is contained in:
Marion Muszynski 2017-05-29 16:18:14 +02:00
commit 518c5d4329
4 changed files with 1632 additions and 115 deletions

View File

@ -1568,9 +1568,8 @@ class AdminOrders extends AdminTab
}
if(count($returnable) > 0) {
$instructions = array(
1 => 'Remboursement + Mise en stock',
2 => 'Échange',
3 => 'Défectueux',
1 => 'Commande à ré-expédier',
2 => 'Commande à rembourser',
);
$reasons = array(
// 1 => 'CLIENT : Annulation pré-envoi',

View File

@ -4,6 +4,17 @@ if(!defined('_PS_VERSION_')) {
}
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
global $logistics_carriers;
foreach(array_map(function($value) {
return str_replace('.', '', $value);
}, array_diff(scandir(dirname(__FILE__).'/carriers'), array('.', '..'))) as $lg) {
if(is_dir(dirname(__FILE__).'/carriers/'.$lg)) {
include dirname(__FILE__).'/carriers/'.$lg.'/'.$lg.'.php';
$name = ucfirst($lg).'Carrier';
$logistics_carriers[$lg] = new $name();
}
}
class AdminAntReturnprocess extends AdminTab
{
private function printLabel($data) {
@ -46,7 +57,7 @@ class AdminAntReturnprocess extends AdminTab
$redis->publish(
Configuration::get('LOGISTICS_QUEUE_'.(int) $cookie->id_employee),
json_encode(array('data' => base64_encode(
/*chr(2).'n'."\n" // Inch mode
chr(2).'n'."\n" // Inch mode
.chr(2).'O0100'."\n" // Start position
.chr(2).'L'."\n"
.'C0000'."\n"
@ -54,8 +65,7 @@ class AdminAntReturnprocess extends AdminTab
.chr(2).'L'."\n"
.$this->isoreplace($data)
.'Q0001'."\n" // Number of labels to print
.'E'."\n" // End*/
$data
.'E'."\n" // End
)))
);
@ -64,7 +74,7 @@ class AdminAntReturnprocess extends AdminTab
public function postProcess()
{
global $currentIndex, $cookie;
global $currentIndex, $cookie, $logistics_carriers;;
if (Tools::isSubmit('deleteorder_return_detail'))
{
@ -540,19 +550,77 @@ class AdminAntReturnprocess extends AdminTab
HelperFormBootstrap::displaySuccess('Remboursement Effectué');
}
} elseif(Tools::isSubmit('submitResendParcel') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
HelperFormBootstrap::displaySuccess('Option en cours de developpement...');
// $products = Tools::getValue('resendQuantity');
// if(!empty($products)) {
// $result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight);
// if($result[0] != '') {
// $this->_html .= $result[0];
// return;
// }
$products = Tools::getValue('resendQuantity');
$parcel_carrier = Tools::getValue('parcel_carrier');
$weight = Tools::getValue('weight');
// $render = $logistics_carriers[$parcel_carrier]->renderLabel($order, $weight, $result[1]);
// HelperFormBootstrap::displaySuccess('Etiquette envoyée à l\'imprimante');
// }
if($parcel_carrier == 'mondialrelay') {
HelperFormBootstrap::displayWarning('Option en cours de developpement...');
return;
}
if(!empty($products)) {
if($weight < 0.24) {
$weight = 0.24;
}
$qty_to_send = 0;
foreach ($products as $k => $qty) {
$qty_to_send+=$qty;
}
if($qty_to_send==0) {
HelperFormBootstrap::displayWarning('Aucune quantité renseignée');
return;
}
$result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight);
if($result[0] != '') {
HelperFormBootstrap::displayErrors($result[0]);
return;
}
$render = $logistics_carriers[$parcel_carrier]->renderLabel($order, $weight, $result[1]);
if($render === 'pr_error') {
HelperFormBootstrap::displayErrors($this->l('Unknown delivery point'));
} elseif($render === 'route_error') {
HelperFormBootstrap::displayErrors($this->l('Route not found'));
} elseif($render !== FALSE) {
//$this->printLabel($render); // comment in dev
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'
&& substr($_SERVER['REMOTE_ADDR'], 0, 2) != '37') {
$products_sent = '';
$products_names = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_order_detail`, `product_name`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order_detail` IN ('.implode(', ', array_keys($products)).')
') as $p) {
$products_names[(int) $p['id_order_detail']] = $p['product_name'];
}
$logistics_carriers[$parcel_carrier]->logParcel($result[1], $products, $id_order_return);
foreach($products as $k => $v) {
if($v > 0) {
$products_sent .= '<br />'."\r\n".$v.' x '.(isset($products_names[$k])? $products_names[$k]: '--');
}
}
$logistics_carriers[$parcel_carrier]->addOrderHistory($result[1], $order, $products_sent);
}
HelperFormBootstrap::displaySuccess('Etiquette envoyée à l\'imprimante');
} else {
HelperFormBootstrap::displayErrors($this->l('An error happened during the label rendering'));
}
} else {
HelperFormBootstrap::displayWarning('Aucune quantité renseignée');
}
}
}
@ -577,7 +645,7 @@ class AdminAntReturnprocess extends AdminTab
FROM `'._DB_PREFIX_.'order_return`
WHERE `id_order` = "'.(int)($return_order).'"
')) {
if($returns && count($returns) ==1) {
if($returns && count($returns) == 1) {
header('Location: /adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $returns[0]['id_order_return'].'&updateorder_return&token='.Tools::getValue('token'));
exit;
}
@ -624,6 +692,25 @@ class AdminAntReturnprocess extends AdminTab
}
}
$instructions = array(
1 => 'Commande à ré-expédier',
2 => 'Commande à rembourser',
);
$reasons = array(
// 1 => 'CLIENT : Annulation pré-envoi',
2 => 'CLIENT : Rétractation post-envoi',
11 => 'CLIENT : Annulation pour ré-achat',
4 => 'FEUR : Problème SAV',
5 => 'FEUR : Produit manquant',
3 => 'BBB : Erreur Achat / Prod',
6 => 'BBB : Erreur Logistique',
8 => 'BBB : Pbme Site / Paiment',
12 => 'BBB : Suspicion de fraude',
9 => 'TRANS : Colis détruit',
10 => 'TRANS : Colis perdu',
7 => 'Autre'
);
$carriers_socol = explode(',', Configuration::get('ANT_CARRIERS_SOCOL'));
$carriers_mr = explode(',', Configuration::get('ANT_CARRIERS_MR'));
$order = new Order($orderReturn->id_order);
@ -673,6 +760,14 @@ class AdminAntReturnprocess extends AdminTab
);
}
$parcel_sent = Db::getInstance()->ExecuteS('
SELECT lpr.*, od.`product_name`
FROM '._DB_PREFIX_.'lapostews_return lpr
LEFT JOIN '._DB_PREFIX_.'order_detail od ON (lpr.id_order_detail = od.id_order_detail)
WHERE lpr.id_order_return = '.(int)($orderReturn->id).'
ORDER BY lpr.date_add DESC'
);
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
$returnProducts = OrderReturn::getOrdersReturnProducts($orderReturn->id, $order);
$orderReturnState = new OrderReturnState($orderReturn->state);
@ -708,7 +803,7 @@ class AdminAntReturnprocess extends AdminTab
</div>
<div class="panel-content">
<div class="row">
<div class="col-md-6">
<div class="col-md-7">
<div>';
$return_link = Db::getInstance()->getRow('
SELECT `return_number`, `link`
@ -722,6 +817,7 @@ class AdminAntReturnprocess extends AdminTab
<tr>
<th>'.$this->l('Produit').'</th>
<th align="center">'.$this->l('Qté').'</th>
<th align="center">'.$this->l('Instructions').'</th>
<th align="center">'.$this->l('Action').'</th>
</tr>
</thead>
@ -740,6 +836,13 @@ class AdminAntReturnprocess extends AdminTab
$image_obj = new Image((int)$img['id_image']);
$img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
}
$return_details = Db::getInstance()->getRow('
SELECT reason, instruction
FROM `'._DB_PREFIX_.'order_return_detail_qty`
WHERE id_order_return = '.(int)$orderReturn->id.'
AND id_order_detail = '.(int)$product['id_order_detail']
);
if (!isset($quantityDisplayed[(int)($product['id_order_detail'])]) OR (int)($product['product_quantity']) > (int)($quantityDisplayed[(int)($product['id_order_detail'])])) {
$html .='
<tr>
@ -750,6 +853,7 @@ class AdminAntReturnprocess extends AdminTab
</a>
</td>
<td align="center" style="vertical-align:middle;color:#444;">'.$product['product_quantity'].'</td>
<td align="center" style="vertical-align:middle;color:#444;">'.$instructions[(int)$return_details['instruction']].'</td>
<td align="center" style="vertical-align:middle;color:#444;"><a style="color:#504d8b;" href="'.$currentIndex.'&deleteorder_return_detail&id_order_detail='.$product['id_order_detail'].'&id_order_return='.$orderReturn->id.'&token='.$this->token.'"><span class="anticon anticon-bin"></span></a></td>
</tr>';
}
@ -757,7 +861,7 @@ class AdminAntReturnprocess extends AdminTab
$html .='</tbody>
</table>
</div>
<div class="col-md-offset-2 col-md-4">
<div class="col-md-offset-1 col-md-4">
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">'.$this->l('Changer le statut du retour').'</h5>
<form style="padding:10px 20px;background:#efefef;" action="'.$currentIndex.'&submitAddorder_return=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
<input type="hidden" name="id_order" value="'.$orderReturn->id_order.'" />
@ -787,9 +891,9 @@ class AdminAntReturnprocess extends AdminTab
<tr>
<th style="background:#efefef;color:#504d8b;"># Retour</th>
<th style="background:#efefef;color:#504d8b;">'.$this->l('Produit').'</th>
<th style="background:#efefef;color:#504d8b;" align="center">'.$this->l('Qté').'</th>
<th style="background:#efefef;color:#504d8b;" align="center">'.$this->l('Statut').'</th>
<th style="background:#efefef;color:#504d8b;" align="center">'.$this->l('Action').'</th>
<th style="background:#efefef;color:#504d8b;text-align:center;">'.$this->l('Qté').'</th>
<th style="background:#efefef;color:#504d8b;text-align:center;">'.$this->l('Statut').'</th>
<th style="background:#efefef;color:#504d8b;text-align:center;">'.$this->l('Action').'</th>
</tr>
</thead>
<tbody>';
@ -1049,14 +1153,14 @@ class AdminAntReturnprocess extends AdminTab
<input type="hidden" name="id_order" value="'.$order->id.'" />
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
<div class="col-md-4 center">
<select class="form-control input-sm">
<select class="form-control input-sm" name="parcel_carrier">
<option value="laposte">La poste</option>
<option value="mondialrelay">Mondial Relay</option>
<option value="mondialrelay" disabled>Mondial Relay</option>
</select>
</div>
<div class="col-md-4 center">
<div class="input-group input-group-sm">
<input class="form-control input-sm" type="text" name="weght" value="0.24"/>
<input class="form-control input-sm" type="text" name="weight" value="0.24"/>
<span class="input-group-addon">Kg</span>
</div>
@ -1070,6 +1174,43 @@ class AdminAntReturnprocess extends AdminTab
</div>
</div>
</div>
<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-box-remove"></span> Historique des colis renvoyés</h2>
<div class="clearfix"></div>
</div>
<div class="panel-content">
<div class="row">
<div class="col-md-12">';
if($parcel_sent && !empty($parcel_sent)) {
$html .= '
<table class="table">
<thead>
<tr>
<th>'.$this->l('Produit').'</th>
<th style="text-align:center;">'.$this->l('Qté').'</th>
<th style="text-align:center;">'.$this->l('Shipping number').'</th>
<th style="text-align:center;">'.$this->l('date envoi').'</th>
</tr>
</thead>
<tbody>';
foreach ($parcel_sent as $key => $parcel) {
$html .= '
<tr>
<td>'.$parcel['product_name'].'</td>
<td style="text-align:center;">'.$parcel['quantity'].'</td>
<td style="text-align:center;">'.$parcel['shipping_number'].'</td>
<td style="text-align:center;">'.date('d/m/Y H:i',strtotime($parcel['date_add'])).'</td>
</tr>';
}
$html .= '</tbody>
</table>';
}
$html .='
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel">
@ -1212,6 +1353,10 @@ class AdminAntReturnprocess extends AdminTab
ORDER BY a.date_upd ASC'
);
if(Tools::getValue('return_order') && empty($order_returns) && empty($ended_order_returns)) {
HelperFormBootstrap::displayWarning('Aucun retour trouvé');
}
$colorStates = array(
1 => "anticon anticon-hour-glass text-orange",
2 => "anticon anticon-hour-glass text-orange",
@ -1260,98 +1405,114 @@ class AdminAntReturnprocess extends AdminTab
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-loop"></span> Liste des Retours</h2>
<div class="clearfix"></div>
</div>';
if(!empty($order_returns) && (!Tools::getValue('show_history') || Tools::getValue('return_order'))) {
$html.='
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-loop"></span> Liste des Retours</h2>
'.(Tools::getValue('return_order')?
'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Les retours en cours</a>'
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Voir retours terminés</a>'
).'
<div class="clearfix"></div>
</div>
<div class="panel-content">
<div class="table-responsive">
<table class="table table-custombordered">
<thead>
<tr>
<th>'.$this->l('#').'</th>
<th>'.$this->l('# Order').'</th>
<th>'.$this->l('# Customer').'</th>
<th>'.$this->l('Status').'</th>
<th>'.$this->l('Date').'</th>
<th class="text-center">'.$this->l('Action').'</th>
</tr>
</thead>
<tbody>';
foreach ($order_returns as $key => $return) {
$html .= '
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
<td><strong>'.$return['id_order_return'].'</strong></td>
<td><strong> '.$return['id_order'].'</strong></td>
<td><strong>'.$return['id_customer'].'</strong></td>
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
<td align="center">
<div class="input-group-btn" role="group">
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
</div>
</td>
</tr>
';
}
$html .= '</tbody>
</table>
</div>
</div>
</div>
<div class="panel-content">
<div class="table-responsive">
<table class="table table-custombordered">
<thead>
<tr>
<th>'.$this->l('#').'</th>
<th>'.$this->l('# Order').'</th>
<th>'.$this->l('# Customer').'</th>
<th>'.$this->l('Status').'</th>
<th>'.$this->l('Date').'</th>
<th class="text-center">'.$this->l('Action').'</th>
</tr>
</thead>
<tbody>';
foreach ($order_returns as $key => $return) {
$html .= '
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
<td><strong>'.$return['id_order_return'].'</strong></td>
<td><strong> '.$return['id_order'].'</strong></td>
<td><strong>'.$return['id_customer'].'</strong></td>
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
<td align="center">
<div class="input-group-btn" role="group">
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
</div>
</td>
</tr>
';
}
$html .= '</tbody>
</table>
<div>
</div>';
}
if(!empty($ended_order_returns) && (Tools::getValue('show_history') || Tools::getValue('return_order'))) {
$html.='
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-loop"></span> Retours Terminés</h2>
'.(Tools::getValue('return_order')?
'<a href="/adm/index.php?tab=AdminAntReturnprocess&show_history=1&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Les retours terminés</a>'
:'<a href="/adm/index.php?tab=AdminAntReturnprocess&token='.Tools::getValue('token').'" class="pull-right btn btn-default">Voir retours en cours</a>'
).'
<div class="clearfix"></div>
</div>
<div class="panel-content">
<div class="table-responsive">
<table class="table table-custombordered">
<thead>
<tr>
<th>'.$this->l('#').'</th>
<th>'.$this->l('# Order').'</th>
<th>'.$this->l('# Customer').'</th>
<th>'.$this->l('Status').'</th>
<th>'.$this->l('Date').'</th>
<th class="text-center">'.$this->l('Action').'</th>
</tr>
</thead>
<tbody>';
foreach ($ended_order_returns as $key => $return) {
$html .= '
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
<td><strong>'.$return['id_order_return'].'</strong></td>
<td><strong> '.$return['id_order'].'</strong></td>
<td><strong>'.$return['id_customer'].'</strong></td>
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
<td align="center">
<div class="input-group-btn" role="group">
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
</div>
</td>
</tr>
';
}
$html .= '</tbody>
</table>
</div>
</div>
</div>
</div>
<div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-loop"></span> Retours Terminés</h2>
<div class="clearfix"></div>
</div>
<div class="panel-content">
<div class="table-responsive">
<table class="table table-custombordered">
<thead>
<tr>
<th>'.$this->l('#').'</th>
<th>'.$this->l('# Order').'</th>
<th>'.$this->l('# Customer').'</th>
<th>'.$this->l('Status').'</th>
<th>'.$this->l('Date').'</th>
<th class="text-center">'.$this->l('Action').'</th>
</tr>
</thead>
<tbody>';
foreach ($ended_order_returns as $key => $return) {
$html .= '
<tr '.(Tools::getValue('return_order') == $return['id_order']? 'class="info"':'').'>
<td><strong>'.$return['id_order_return'].'</strong></td>
<td><strong> '.$return['id_order'].'</strong></td>
<td><strong>'.$return['id_customer'].'</strong></td>
<td><span class="'.$colorStates[$return['state']].'"></span> '.$return['name'].'</td>
<td>'.date('d/m/Y H:i',strtotime($return['date_add'])).'</td>
<td align="center">
<div class="input-group-btn" role="group">
<a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&updateorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-edit"></span></a>
<!--a class="btn btn-default" href="/adm/index.php?tab=AdminAntReturnprocess&id_order_return='.(int) $return['id_order_return'].'&deleteorder_return&token='.Tools::getValue('token').'"><span style="font-size:12px;" class="text-purple-dark glyphicon glyphicon-trash"></span></a-->
</div>
</td>
</tr>
';
}
$html .= '</tbody>
</table>
</div>
</div>
</div>
<div>
</div>
<div class="clearfix"></div>';
<div>';
}
$html .= '<div class="clearfix"></div>';
$helper->_js .= '
<script type="text/javascript">

View File

@ -0,0 +1,845 @@
<?php
if(!defined('_PS_VERSION_')) {
exit;
}
include dirname(__FILE__).'/webservice_wsu.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(!$result || !is_array($result) && get_class($result) == 'SoapFault' || !$result['data']) {
$html .= $this->l('An error happened during the parcel registration process');
} else {
if(isset($result['data']->messages->type) && $result['data']->messages->type == 'ERROR') {
$html .= strip_tags((string) $result['data']->messages->messageContent);
} 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();
}
}
}
return array($html, $result);
}
public function renderLabel($order, $weight, $shipping_data) {
global $cookie, $laposte_formats;
/**
* @Override laposte WSU
*/
return $shipping_data['label'];
}
public function logParcel($shipping_data, $products, $id_order_return) {
global $cookie;
/**
* @Override laposte WSU return
*/
foreach($products as $id_order_detail => $qty) {
if($v > 0) {
Db::getInstance()->ExecuteS('
INSERT `'._DB_PREFIX_.'lapostews_return` VALUES (
'.(int) $id_order_return.',
'.(int) $id_order_detail.',
'.(int) $cookie->id_employee.',
'.(int) $qty.',
"'.pSQL($shipping_data['data']->labelResponse->parcelNumber).'",
NOW()
)
');
}
}
return;
}
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
*/
$shipping_number = $shipping_data['data']->labelResponse->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;
}
$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
);
}
}

View File

@ -0,0 +1,512 @@
<?php
if(!defined('_PS_VERSION_')) {
exit;
}
class SoapResponse {
const CONTENT_TYPE = 'Content-Type: application/xop+xml;';
const UUID = '/--uuid:/'; //This is the separator of each part of the response
const CONTENT = 'Content-';
public $attachments = array ();
public $soapResponse = array ();
public $uuid = NULL;
public function __construct($response)
{
if(strpos($response, self::CONTENT_TYPE ) !== FALSE) {
$this->parseResponse($response);
} else {
throw new Exception('This response is not '.self::CONTENT_TYPE);
}
}
private function parseResponse($response)
{
$content = array ();
$matches = array ();
preg_match_all(self::UUID, $response, $matches, PREG_OFFSET_CAPTURE);
for($i = 0; $i < count ($matches[0]) - 1; $i++) {
if ($i + 1 < count ( $matches [0] )) {
$content[$i] = substr($response, $matches[0][$i][1], $matches[0][$i + 1][1] - $matches[0][$i][1]);
} else {
$content[$i] = substr($response, $matches[0][$i][1], strlen($response));
}
}
foreach ( $content as $part ) {
if($this->uuid == NULL){
$uuidStart = 0;
$uuidEnd = 0;
$uuidStart = strpos($part, self::UUID, 0) + strlen(self::UUID);
$uuidEnd = strpos($part, "\r\n", $uuidStart);
$this->uuid = substr($part, $uuidStart, $uuidEnd-$uuidStart);
}
$header = $this->extractHeader($part);
if(count($header) > 0){
if(strpos($header['Content-Type'], 'type="text/xml"') !== FALSE) {
$this->soapResponse['header'] = $header;
$this->soapResponse['data'] = trim(substr($part, $header['offsetEnd']));
} else {
$attachment['header'] = $header;
$attachment['data'] = trim(substr($part, $header['offsetEnd']));
array_push($this->attachments, $attachment);
}
}
}
}
/**
* Exclude the header from the Web Service response
* @param string $part
* @return array $header
*/
private function extractHeader($part)
{
$header = array();
$headerLineStart = strpos($part, self::CONTENT, 0);
$endLine = 0;
while($headerLineStart !== FALSE){
$header['offsetStart'] = $headerLineStart;
$endLine = strpos($part, "\r\n", $headerLineStart);
$headerLine = explode(': ', substr($part, $headerLineStart, $endLine - $headerLineStart));
$header[$headerLine[0]] = $headerLine[1];
$headerLineStart = strpos($part, self::CONTENT, $endLine);
}
$header['offsetEnd'] = $endLine;
return $header;
}
}
class Parcel {
public function addArticle($description, $qty, $weight, $value, $wco_nom) {}
public function getShippingNumber() {}
public function attachOrder($id_order, $id_carrier, $id_address_delivery=false)
{
$this->order = new Order($id_order);
if(Validate::isLoadedObject($this->order)) {
$this->product_type = '';
$dst_customer = new Customer($this->order->id_customer);
if($id_address_delivery) {
$dst_address = new Address($id_address_delivery);
} else {
$dst_address = new Address($this->order->id_address_delivery);
}
$dst_country = new Country($dst_address->id_country);
$langs = array(
1 => 'EN',
2 => 'FR',
3 => 'ES',
5 => 'IT',
6 => 'EN',
);
$this->dst_address = array(
'companyName' => '',
'lastName' => '',
'firstName' => '',
'line0' => '',
'line1' => '',
'line2' => '',
'line3' => '',
'countryCode' => '',
'city' => '',
'zipCode' => '',
'phoneNumber' => '',
'mobileNumber' => '',
'doorCode1' => '',
'doorCode2' => '',
'email' => '',
'intercom' => '',
'language' => $langs[(int) $this->order->id_lang],
);
$this->prid = '';
$this->instructions = '';
$unicode_ack = json_decode('"\u0006"');
$unicode_ack2 = json_decode('"\u00ad"');
if(Module::isInstalled('socolissimo')
&& ($so_data = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
WHERE `id_cart` = '.(int) $this->order->id_cart.'
AND `id_customer` = '.(int) $this->order->id_customer.'
'))
&& (
(strpos(Db::getInstance()->getValue('
SELECT `name`
FROM `'._DB_PREFIX_.'carrier`
WHERE `id_carrier` = '.(int) $id_carrier.'
'), 'La Poste') !== FALSE)
|| (strpos(Db::getInstance()->getValue('
SELECT `name`
FROM `'._DB_PREFIX_.'carrier`
WHERE `id_carrier` = '.(int) $id_carrier.'
'), 'Colissimo') !== FALSE)
)) {
$this->product_type = $so_data['delivery_mode'];
if($this->product_type == 'BOM') {
$this->product_type = 'DOM';
}
if($so_data['cecountry'] == 'ES' && $this->product_type == 'DOM') {
$this->product_type = 'DOS';
}
if(!in_array($so_data['cecountry'], array('ES', 'BE', 'AD', 'MC', 'FR', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
$this->product_type = 'DOS';
}
if($so_data['cecountry'] == 'IT'){
$this->product_type = 'COLI';
}
$this->dst_address['email'] = $so_data['ceemail'];
if(empty($this->dst_address['email'])) {
$this->dst_address['email'] = $dst_customer->email;
}
if(!empty($so_data['cename'])) {
$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(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(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['cefirstname']), 0, 29);
} else {
$this->dst_address['firstName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['prfirstname']), 0, 29);
}
if(!empty($so_data['cecompanyname'])) {
$this->dst_address['companyName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['cecompanyname']), 0, 35);
}
$address_lines = array();
for($i = 1; $i < 5; $i++) {
if(($line = (string) mb_substr($so_data['pradress'.$i], 0, 32)) != '') {
$address_lines[] = trim($line);
}
}
if(count($address_lines) == 1) {
$this->dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]);
} elseif(count($address_lines) == 2) {
if(strtolower($so_data['cecountry']) == 'be') {
$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]);
} else {
$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', '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', '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'];
if(strtolower($so_data['cecountry']) == 'sl') {
$this->dst_address['zipCode'] = (string) str_ireplace(array('SI-', 'SL-'), '', mb_substr($so_data['przipcode'], 0, 5));
} elseif(strtolower($so_data['cecountry']) == 'pt') {
$this->dst_address['zipCode'] = (string) $so_data['przipcode'];
} else {
$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(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(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';
}
if(($doorcode = (string) mb_substr($so_data['cedoorcode1'], 0, 8)) != '') {
$this->dst_address['doorCode1'] = (string) mb_substr($so_data['cedoorcode1'], 0, 8);
}
if(($doorcode = (string) mb_substr($so_data['cedoorcode2'], 8, 8)) != '') {
$this->dst_address['doorCode2'] = (string) mb_substr($so_data['cedoorcode1'], 8, 8);
}
$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), 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);
} else {
$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('GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
$this->dst_address['countryCode'] = 'FR';
} else {
$this->dst_address['countryCode'] = (string) $dst_country->iso_code;
}
$this->dst_address['line2'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), (string) $dst_address->address1);
$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', '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)) {
$this->dst_address['phoneNumber'] = (string) $dst_address->phone_mobile;
}
if(strlen($this->dst_address['phoneNumber']) > 10) {
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $this->dst_address['phoneNumber'])) {
$this->dst_address['phoneNumber'] = '0'.mb_substr(mb_substr($this->dst_address['phoneNumber'], -10), 1);
}
}
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);
}
}
} else {
if($dst_country->iso_code == 'BE') {
if($dst_address->phone != '') {
$this->dst_address['phoneNumber'] = (string) $dst_address->phone;
} else {
$this->dst_address['phoneNumber'] = (string) $dst_address->phone_mobile;
}
$this->dst_address['mobileNumber'] = '';
} else {
if($dst_address->phone != '') {
$this->dst_address['phoneNumber'] = (string) $dst_address->phone;
}
if($dst_address->phone_mobile != '') {
$this->dst_address['mobileNumber'] = (string) $dst_address->phone_mobile;
}
}
}
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';
}
}
}
}
private function array_to_xml($array, $xml)
{
foreach($array as $key => $value) {
if(is_array($value)) {
if(!is_numeric($key)){
$subnode = $xml->addChild("$key");
$this->array_to_xml($value, $subnode);
}
else{
$subnode = $xml->addChild("item$key");
$this->array_to_xml($value, $subnode);
}
}
else {
$xml->addChild("$key",htmlspecialchars("$value"));
}
}
}
private function xml_to_array($xml, $array=array())
{
foreach((array) $xml as $index => $node) {
$array[$index] = (is_object($node))? $this->xml_to_array($node): $node;
}
return $array;
}
public function setWeight($weight=0)
{
$this->weight = rtrim((string) $weight, '0');
}
public function send()
{
if(Validate::isLoadedObject($this->order)) {
global $cookie;
$carrier_config = array(
'api' => array(
'wsu' => array(
'contract' => (int) Configuration::get('LAPOSTEWS_API_CONTRACT_WSU'),
'password' => Configuration::get('LAPOSTEWS_API_PASSWORD_WSU'),
)
),
'exp_commercial_name' => Configuration::get('LAPOSTEWS_COMMERCIALNAME'),
'exp_firstname' => Configuration::get('LAPOSTEWS_EXP_FIRSTNAME'),
'exp_lastname' => Configuration::get('LAPOSTEWS_EXP_LASTNAME'),
'exp_company' => Configuration::get('LAPOSTEWS_EXP_COMPANY'),
'exp_address1' => Configuration::get('LAPOSTEWS_EXP_ADDR1'),
'exp_address2' => Configuration::get('LAPOSTEWS_EXP_ADDR2'),
'exp_city' => Configuration::get('LAPOSTEWS_EXP_CITY'),
'exp_postcode' => Configuration::get('LAPOSTEWS_EXP_POSTALCODE'),
'exp_email' => Configuration::get('LAPOSTEWS_EXP_EMAIL'),
'exp_country' => Configuration::get('LAPOSTEWS_EXP_COUNTRY'),
'exp_phone' => Configuration::get('LAPOSTEWS_EXP_PHONE'),
);
$c = new SoapClient(
'https://ws.colissimo.fr/sls-ws/SlsServiceWS?wsdl',
array(
'trace' => 0,
'exceptions' => 1,
'cache_wsdl' => 0? WSDL_CACHE_MEMORY: WSDL_CACHE_NONE,
)
);
try {
$exp_country = new Country((int) $carrier_config['exp_country']);
if(in_array($exp_country->iso_code, array('GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) {
$countryCode = 'FR';
} else {
$countryCode = (string) $exp_country->iso_code;
}
$phone = $carrier_config['exp_phone'];
if(strlen($phone) > 10) {
if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $phone)) {
$phone = '0'.mb_substr(mb_substr($phone, -10), 1);
}
}
$soap = new SimpleXMLElement('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" />');
$soap->addChild('soapenv:Header');
$children = $soap->addChild('soapenv:Body');
$children = $children->addChild('sls:generateLabel', NULL, 'http://sls.ws.coliposte.fr');
$children = $children->addChild('generateLabelRequest', NULL, '');
$this->array_to_xml(array(
'contractNumber' => $carrier_config['api']['wsu']['contract'],
'password' => $carrier_config['api']['wsu']['password'],
'outputFormat' => array(
'x' => 0,
'y' => 0,
'outputPrintingType' => 'DPL_10x15_203dpi', // DPL_10x15_300dpi / PDF_10x15_300dpi / PDF_A4_300dpi
),
'letter' => array(
'service' => array(
/*
COLD = Colissimo Access FR
COL = Colissimo Expert FR
COM = Colissimo Access FR
CDS = Colissimo Expert OM
COLI = Colissimo Expert Inter
DOM = SoCol Dom SS
DOS = SoCol Dom AS
BPR = Socol Bureau de poste FR
A2P = Socol Commerçant FR
CMT = Socol commercant FR
BDP = Socol Bureau de poste inter
*/
'productCode' => $this->product_type,
'depositDate' => date('Y-m-d'),
'transportationAmount' => (int) ($this->order->total_shipping * 100),
'orderNumber' => (string) $this->order->id,
'commercialName' => $carrier_config['exp_commercial_name'],
'returnTypeChoice' => 3, // 2 = return, 3 = do not return
),
'parcel' => array(
'weight' => 0.24,
'instructions' => $this->instructions,
'pickupLocationId' => $this->prid,
),
'customsDeclarations' => array(
),
'sender' => array(
'senderParcelRef' => 'REF'.$this->order->id,
'address' => array(
'companyName' => (string) mb_substr($carrier_config['exp_company'], 0, 35),
'line2' => (string) mb_substr(strtoupper($carrier_config['exp_address1']), 0, 35),
'line3' => (string) mb_substr(strtoupper($carrier_config['exp_address2']), 0, 35),
'countryCode' => $countryCode,
'city' => (string) mb_substr(strtoupper($carrier_config['exp_city']), 0, 35),
'zipCode' => (string) mb_substr($carrier_config['exp_postcode'], 0, 5),
'phoneNumber' => $phone,
'email' => mb_substr((string) $carrier_config['exp_email'], 0, 80),
'language' => 'FR',
),
),
'addressee' => array(
'address' => $this->dst_address,
),
),
), $children);
$authorized_ip = array(
'88.163.22.99',
'90.63.178.63',
'217.64.63.215',
);
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(
array(
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:generateLabelResponse xmlns:ns2="http://sls.ws.coliposte.fr">',
'</ns2:generateLabelResponse></soap:Body></soap:Envelope>',
),
'',
$response->soapResponse['data']
)
),
'label' => $response->attachments[0]['data'],
);
} catch(Exception $e) {
$authorized_ip = array(
'88.163.22.99',
'90.63.178.63',
'217.64.63.215',
);
if (in_array($_SERVER['REMOTE_ADDR'], $authorized_ip)) {
mail('marion@antadis.com', 'BBB LOG WSU Exception', serialize($e));
}
return $e;
}
}
}
}