addition of crons and admin_order tpl for Mondial Relay
This commit is contained in:
parent
5192561bac
commit
c4cbe24bb5
334
adm/mraddressedit.php
Normal file
334
adm/mraddressedit.php
Normal file
@ -0,0 +1,334 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__).'/../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/init.php');
|
||||
|
||||
if($cookie->isLoggedBack() && $cart = Tools::getValue('id_cart')) {
|
||||
$address = Db::getInstance()->getRow('
|
||||
SELECT s.*, m.*, r.`narel`
|
||||
FROM `'._DB_PREFIX_.'mr_selected` s
|
||||
INNER JOIN `'._DB_PREFIX_.'mr_method` m
|
||||
ON m.`id_mr_method` = s.`id_method`
|
||||
LEFT JOIN `'._DB_PREFIX_.'mondialrelay_relais` r
|
||||
ON SUBSTRING(s.`MR_Selected_Num`, 2) = r.`direction`
|
||||
AND s.`MR_Selected_Pays` = r.`prpay`
|
||||
WHERE `id_cart` = '.pSQL(intval(Tools::getValue('id_cart'))).'
|
||||
');
|
||||
if($address['MR_Selected_Pays'] == 'F' || $address['MR_Selected_Pays'] == '') {
|
||||
$address['MR_Selected_Pays'] = 'FR';
|
||||
}
|
||||
$deliv_address = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||
ON a.`id_address` = o.`id_address_delivery`
|
||||
WHERE o.`id_cart` = '.(int) Tools::getValue('id_cart').'
|
||||
');
|
||||
if($address) {
|
||||
if(isset($_POST['submitMR'])) {
|
||||
$num = Tools::getValue('MR_Selected_Num', '');
|
||||
if($num != '') {
|
||||
$rel = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_relais`
|
||||
WHERE `direction` = "'.pSQL(sprintf('%05d', (int) ((string) substr($num, -5)))).'"
|
||||
AND `prpay` = "'.pSQL($address['MR_Selected_Pays']).'"
|
||||
');
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'mr_selected`
|
||||
SET `MR_Selected_Num` = "'.pSQL($num).'",
|
||||
`MR_Selected_LgAdr1` = "'.pSQL(trim($rel['colnom'])).'",
|
||||
`MR_Selected_LgAdr2` = "'.pSQL(trim($rel['colbat'])).'",
|
||||
`MR_Selected_LgAdr3` = "'.pSQL(trim($rel['colrue'])).'",
|
||||
`MR_Selected_LgAdr4` = "'.pSQL(trim($rel['coldit'])).'",
|
||||
`MR_Selected_CP` = "'.pSQL(trim($rel['codpos'])).'",
|
||||
`MR_Selected_Ville` = "'.pSQL(trim($rel['libbp'])).'",
|
||||
`MR_Selected_Pays` = "'.pSQL(trim($rel['prpay'])).'"
|
||||
WHERE `id_cart` = '.(int) Tools::getValue('id_cart').'
|
||||
');
|
||||
}
|
||||
}
|
||||
$order = Db::getInstance()->getRow('
|
||||
SELECT `id_carrier`, `id_order`, `id_address_delivery`
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_cart` = '.(int) Tools::getValue('id_cart').'
|
||||
');
|
||||
$weight = (float) Db::getInstance()->getValue('
|
||||
SELECT SUM(`product_weight` * `product_quantity`)
|
||||
FROM `'._DB_PREFIX_.'order_detail`
|
||||
WHERE `id_order` = '.(int) $order['id_order'].'
|
||||
');
|
||||
require_once _PS_MODULE_DIR_.'mondialrelay/classes/MRGetRelayPoint.php';
|
||||
require_once _PS_MODULE_DIR_.'mondialrelay/classes/MRRelayDetail.php';
|
||||
$mr = new MondialRelay();
|
||||
$delivery_mode = $address['dlv_mode'];
|
||||
$params = array(
|
||||
'action' => $delivery_mode,
|
||||
'id_carrier' => $order['id_carrier'],
|
||||
'weight' => Tools::ps_round($weight, 2),
|
||||
'id_address_delivery' => $order['id_address_delivery'],
|
||||
);
|
||||
$api = new MRGetRelayPoint($params, $mr);
|
||||
$api->init();
|
||||
$api->send();
|
||||
$result = $api->getResult();
|
||||
$relay_points = array();
|
||||
if(count($result['error']) === 0) {
|
||||
$success = (array)$result['success'];
|
||||
ksort($success);
|
||||
$relay_points = array_values($success);
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html><head>
|
||||
<meta charset="utf-8" />
|
||||
<style type="text/css">
|
||||
body {
|
||||
overflow: auto;
|
||||
font-size: 12px;
|
||||
color: #222222;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
label {
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
fieldset {
|
||||
overflow: auto;
|
||||
float: left;
|
||||
width: 200px;
|
||||
}
|
||||
p {
|
||||
overflow: auto;
|
||||
}
|
||||
#map_canvas {
|
||||
width: 470px;
|
||||
height: 300px;
|
||||
display: inline-block;
|
||||
}
|
||||
h1 {
|
||||
clear: both;
|
||||
font-size: 16px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
#pr_list {
|
||||
width: 200px;
|
||||
height: 300px;
|
||||
overflow-y: auto;
|
||||
display: inline-block;
|
||||
margin-left: 10px;
|
||||
}
|
||||
#pr_chooser {
|
||||
clear: both;
|
||||
}
|
||||
#pr_chooser ul {
|
||||
list-style: outside none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
#pr_chooser li {
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
margin: 10px 10px 10px 0px;
|
||||
padding: 10px;
|
||||
}
|
||||
#pr_chooser li:hover {
|
||||
background: #ccddee;
|
||||
}
|
||||
.maplink {
|
||||
color: #1122ff;
|
||||
cursor: pointer;
|
||||
}
|
||||
.maplink:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
|
||||
<script type="text/javascript" src="/js/jquery/jquery-1.4.4.min.js"></script>
|
||||
<script type="text/javascript" src="/js/jquery/jquery.ui.map.js"></script>
|
||||
<script type="text/javascript" src="/js/jquery/jquery.ui.map.services.js"></script>
|
||||
</head><body onload="<?php if(isset($_POST['submitMR'])) { ?>window.close();<?php } ?>">
|
||||
<?php
|
||||
if($order['id_carrier'] == 216) {
|
||||
echo '<p style="border: 1px solid #ff0000; background: #ffeeee; font-weight: bold; padding: 10px 20px;">La modification des livraisons en point relais XL n\'est pas possible.</p>';
|
||||
} else {
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<p>
|
||||
<label>Nom destinataire</label>
|
||||
<span style="display: block; min-height: 1em;"><?php echo htmlentities($deliv_address['lastname'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?></span>
|
||||
</p>
|
||||
<p>
|
||||
<label>Prénom destinataire</label>
|
||||
<span style="display: block; min-height: 1em;"><?php echo htmlentities($deliv_address['firstname'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?></span>
|
||||
</p>
|
||||
<p>
|
||||
<label>Entreprise</label>
|
||||
<span style="display: block; min-height: 1em;"><?php echo htmlentities($deliv_address['company'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?></span>
|
||||
</p>
|
||||
<p>
|
||||
<label>Téléphone</label>
|
||||
<span style="display: block; min-height: 1em;"><?php echo htmlentities($deliv_address['phone'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?></span>
|
||||
</p>
|
||||
<p>
|
||||
<label>Email</label>
|
||||
<span style="display: block; min-height: 1em;"><?php echo htmlentities($deliv_address['email'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?></span>
|
||||
</p>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<p style="display: none;">
|
||||
<label>Mode de livraison</label>
|
||||
<select autocomplete="off" name="delivery_mode">
|
||||
<?php
|
||||
$modes = array('24R' => 'Point relais (24R)',
|
||||
'24L' => 'Point relais XL (24L)', '24X' => 'Point relais XXL (24X)', 'HOM' => 'Livraison à domicile Home (HOM)', 'LD1' => 'Livraison à domicile 1 personne (LD1)',
|
||||
'LDS' => 'Livraison à domicile 2 personnes (LDS)', 'DRI' => 'Livraison Colis Drive (DRI)');
|
||||
foreach($modes as $k => $v) {
|
||||
echo '<option value="'.$k.'"'.($delivery_mode == $k? ' selected="selected"': '').'>'.$v.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label>Adresse 1</label>
|
||||
<input autocomplete="off" type="text" name="MR_Selected_LgAdr1" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr1'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Adresse 2</label>
|
||||
<input autocomplete="off" type="text" name="MR_Selected_LgAdr2" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr2'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Adresse 3</label>
|
||||
<input autocomplete="off" type="text" name="MR_Selected_LgAdr3" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr3'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Adresse 4</label>
|
||||
<input autocomplete="off" type="text" name="MR_Selected_LgAdr4" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr4'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Code postal</label>
|
||||
<input autocomplete="off" type="text" name="MR_Selected_CP" readonly="true" value="<?php echo htmlentities($address['MR_Selected_CP'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Ville</label>
|
||||
<input autocomplete="off" type="text" name="MR_Selected_Ville" readonly="true" value="<?php echo htmlentities($address['MR_Selected_Ville'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label>ID point retrait</label>
|
||||
<input autocomplete="off" type="text" name="MR_Selected_Num" readonly="true" value="<?php echo htmlentities($address['MR_Selected_Num'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
||||
</p>
|
||||
<p><input type="submit" value="Envoyer" name="submitMR" /></p>
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
markers = [];
|
||||
-->
|
||||
</script>
|
||||
<div id="pr_chooser"><h1>Livraison hors domicile - Recherche d\'un point de retrait</h1>
|
||||
<div id="map_canvas"></div><div id="pr_list"><ul></ul></div>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function updateForm(delivery_mode, address1, address2, address3, address4, postcode, city, prid) {
|
||||
$("select[name=delivery_mode]").val("");
|
||||
$("input[name=MR_Selected_LgAdr1]").val("");
|
||||
$("input[name=MR_Selected_LgAdr2]").val("");
|
||||
$("input[name=MR_Selected_LgAdr3]").val("");
|
||||
$("input[name=MR_Selected_LgAdr4]").val("");
|
||||
$("input[name=MR_Selected_CP]").val("");
|
||||
$("input[name=MR_Selected_Ville]").val("");
|
||||
$("input[name=MR_Selected_Num]").val("");
|
||||
$("select[name=delivery_mode]").val(delivery_mode);
|
||||
$("input[name=MR_Selected_LgAdr1]").val(address1);
|
||||
$("input[name=MR_Selected_LgAdr2]").val(address2);
|
||||
$("input[name=MR_Selected_LgAdr3]").val(address3);
|
||||
$("input[name=MR_Selected_LgAdr4]").val(address4);
|
||||
$("input[name=MR_Selected_CP]").val(postcode);
|
||||
$("input[name=MR_Selected_Ville]").val(city);
|
||||
$("input[name=MR_Selected_Num]").val(prid);
|
||||
}
|
||||
$(document).ready(function() {
|
||||
delivery_modes = {};
|
||||
$("select[name=delivery_mode] option").each(function(id, el) {
|
||||
delivery_modes[$(el).attr("value")] = $(el).text();
|
||||
});
|
||||
$("#map_canvas").gmap('.($pr_coords? '{ "center": "'.(float) $pr_coords['xcoords'].','.(float) $pr_coords['ycoords'].'" }': '').').bind("init", function(ev, map) {';
|
||||
$current_address = htmlentities(preg_replace('/(, ){2,}/', ', ', preg_replace('/(, ){2,}/', ', ', implode(', ', array(trim($deliv_address['address1']), trim($deliv_address['address2'])))).', '.trim($deliv_address['postcode']).' '.$deliv_address['city'].', '.Country::getNameById(2, $deliv_address['id_country'])), ENT_COMPAT | ENT_HTML401, 'UTF-8');
|
||||
echo '
|
||||
$("#map_canvas").gmap("search", {"address": "'.$current_address.'"}, function(results, status) {
|
||||
if ( status === "OK" ) {
|
||||
var lat = null;
|
||||
var lng = null;
|
||||
if(results[0].geometry.location.H) {
|
||||
lat = results[0].geometry.location.H;
|
||||
lng = results[0].geometry.location.L;
|
||||
} else if(results[0].geometry.location.G) {
|
||||
lat = results[0].geometry.location.G;
|
||||
lng = results[0].geometry.location.K;
|
||||
} else {
|
||||
var loc = results[0].geometry.location.toString().replace("(", "").replace(")", "").replace(" ", "").split(",");
|
||||
lat = loc[0];
|
||||
lng = loc[1];
|
||||
}
|
||||
$("#map_canvas").gmap("addMarker", {"icon": "http://static.privatesportshop.com/img/admin/marker_home.png", "idpr": "pr_home", "position": lat + "," + lng, "bounds": true}).click(function() {
|
||||
$("#map_canvas").gmap("openInfoWindow", {"content": "Adresse actuelle"}, this);
|
||||
});
|
||||
';
|
||||
for($i= 0, $l = count($relay_points); $i < $l; $i++) {
|
||||
$relay = $relay_points[$i];
|
||||
if($relay->Pays == "") {
|
||||
continue;
|
||||
}
|
||||
echo '
|
||||
$("#map_canvas").gmap("search", {"address": "'.htmlentities(preg_replace('/(, ){2,}/', ', ', preg_replace('/(, ){2,}/', ', ', implode(', ', array(trim($relay->LgAdr3), trim($relay->LgAdr2), trim($relay->LgAdr4), trim($relay->CP).' '.trim($relay->Ville), Country::getNameById(2, $relay->Pays != 'FR'? Country::getByIso($relay->Pays): 8))))), ENT_COMPAT | ENT_HTML401, 'UTF-8').'"}, function(results, status) {
|
||||
if ( status === "OK" ) {
|
||||
var lat = null;
|
||||
var lng = null;
|
||||
if(results[0].geometry.location.H) {
|
||||
lat = results[0].geometry.location.H;
|
||||
lng = results[0].geometry.location.L;
|
||||
} else if(results[0].geometry.location.G) {
|
||||
lat = results[0].geometry.location.G;
|
||||
lng = results[0].geometry.location.K;
|
||||
} else {
|
||||
var loc = results[0].geometry.location.toString().replace("(", "").replace(")", "").replace(" ", "").split(",");
|
||||
lat = loc[0];
|
||||
lng = loc[1];
|
||||
}
|
||||
var prtext = ["", "'.htmlentities(trim($relay->LgAdr1), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->LgAdr2), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->LgAdr3), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->LgAdr4), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities($relay->CP, ENT_COMPAT | ENT_HTML401, 'UTF-8').' '.htmlentities($relay->Ville, ENT_COMPAT | ENT_HTML401, 'UTF-8').'"].filter(function(x) { return x != ""; }).join("<br />");
|
||||
var prtext_action = "<br /><a class=\"maplink\" onclick=\"$(\'#pr_list li[data-index='.$i.']\').trigger(\'click\'); return false;\">Sélectionner</a>";
|
||||
markers.push($("#map_canvas").gmap("addMarker", { "id": "pr_'.htmlentities($relay->Num, ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "position": lat + "," +lng, "bounds": true, "content": prtext + prtext_action }));
|
||||
markers[markers.length - 1].click(function() {
|
||||
$("#map_canvas").gmap("openInfoWindow", {"content": $(this).attr("content")}, this);
|
||||
});
|
||||
var litem = $("<li />").attr("data-index", '.$i.').html(prtext).click(function() {
|
||||
$.each(markers, function(id, el) {
|
||||
if(el[0].id == "pr_'.htmlentities(trim($relay->Num), ENT_COMPAT | ENT_HTML401, 'UTF-8').'") {
|
||||
google.maps.event.trigger(el[0], "click");
|
||||
}
|
||||
});
|
||||
$("#map_canvas").gmap("option", "center", markers[parseInt($(this).attr("data-index"))][0].getPosition());
|
||||
updateForm("24R", "'.htmlentities(trim($relay->LgAdr1), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->LgAdr2), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->LgAdr3), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->LgAdr4), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->CP), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->Ville), ENT_COMPAT | ENT_HTML401, 'UTF-8').'", "'.htmlentities(trim($relay->Num), ENT_COMPAT | ENT_HTML401, 'UTF-8').'");
|
||||
});
|
||||
$("#pr_list ul").append(litem);
|
||||
}
|
||||
});
|
||||
';
|
||||
}
|
||||
echo '
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
-->
|
||||
</script>
|
||||
</div>';
|
||||
}
|
||||
?>
|
||||
</body></html>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
41
modules/logistics/carriers/mondialrelay/ajax_summary.php
Executable file
41
modules/logistics/carriers/mondialrelay/ajax_summary.php
Executable file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
include dirname(__FILE__).'/../../../../config/config.inc.php';
|
||||
|
||||
|
||||
if(($date = Tools::getValue('date'))
|
||||
&& (Tools::getValue('token') === Tools::getAdminToken('AdminMondialRelaySummary'.(int) Tab::getIdFromClassName('AdminMondialRelaySummary').(int) Tools::getValue('id_employee')))) {
|
||||
$carts = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT o.`id_cart`
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_parcel` w, `'._DB_PREFIX_.'order_detail` d, `'._DB_PREFIX_.'orders` o
|
||||
WHERE w.`id_order_detail` = d.`id_order_detail`
|
||||
AND d.`id_order` = o.`id_order`
|
||||
AND w.`date_add` > "'.pSQL(date('Y-m-d 00:00:00', strtotime($date))).'"
|
||||
AND w.`date_add` <= "'.pSQL(date('Y-m-d 23:59:59', strtotime($date))).'"
|
||||
') as $cart) {
|
||||
$carts[] = (int) $cart['id_cart'];
|
||||
}
|
||||
|
||||
$modes = array();
|
||||
$dom = Db::getInstance()->getRow('
|
||||
SELECT COUNT(o.*) AS `total`
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
WHERE o.`id_cart` IN ('.implode(', ', $carts).'
|
||||
AND o.`id_cart` NOT IN (
|
||||
SELECT i.`id_cart`
|
||||
FROM `'._DB_PREFIX_.'mr_selected` i
|
||||
)
|
||||
');
|
||||
if($dom['total'] > 0) {
|
||||
$modes[] = 'dom';
|
||||
}
|
||||
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT `dlv_mode`
|
||||
FROM `'._DB_PREFIX_.'mr_method`
|
||||
') as $dm) {
|
||||
$modes[] = strtolower($dm['dlv_mode']);
|
||||
}
|
||||
|
||||
echo json_encode(array_unique($modes));
|
||||
}
|
87
modules/logistics/carriers/mondialrelay/cron_relais.php
Executable file
87
modules/logistics/carriers/mondialrelay/cron_relais.php
Executable file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SERVER['HTTP_PORT'] = 80;
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
include dirname(__FILE__).'/../../../../config/config.inc.php';
|
||||
|
||||
## GET relais.txt FILE
|
||||
$fname = 'relais.txt';
|
||||
$filename = dirname(__FILE__) . '/' . $fname;
|
||||
$file = fopen($filename, 'w+');
|
||||
$remote_file = $fname;
|
||||
|
||||
$ftp = ftp_connect(Configuration::get('MONDIALRELAYWS_FTP_HOST'));
|
||||
ftp_login($ftp, Configuration::get('MONDIALRELAYWS_FTP_LOGIN'), Configuration::get('MONDIALRELAYWS_FTP_PASSWORD'));
|
||||
ftp_chdir($ftp, 'depuismrelay');
|
||||
if (!ftp_fget($ftp, $file, $remote_file, FTP_BINARY))
|
||||
die('An error occures while downloading remote file : ' . $fname);
|
||||
|
||||
$file = fopen($filename, 'r');
|
||||
$content = fgets($file);
|
||||
if (!$content)
|
||||
die('File is empty : ' . $fname);
|
||||
|
||||
## Update DB
|
||||
Db::getInstance()->ExecuteS('
|
||||
TRUNCATE TABLE `'._DB_PREFIX_.'mondialrelay_relais`
|
||||
');
|
||||
while($line = fgets($file)) {
|
||||
if(substr($line, 1, 1) == '1') {
|
||||
$datouv = explode('.', substr($line, 62, 10));
|
||||
if(count($datouv) > 1) {
|
||||
$datouv = $datouv[2].'-'.$datouv[1].'-'.$datouv[0];
|
||||
} else {
|
||||
$datouv = '0000-00-00';
|
||||
}
|
||||
$datfer = explode('.', substr($line, 72, 10));
|
||||
if(count($datfer) > 1) {
|
||||
$datfer = $datfer[2].'-'.$datfer[1].'-'.$datfer[0];
|
||||
} else {
|
||||
$datfer = '0000-00-00';
|
||||
}
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'mondialrelay_relais`
|
||||
VALUES (
|
||||
"'.pSQl(substr($line, 4, 5)).'",
|
||||
"'.pSQl(substr($line, 9, 1)).'",
|
||||
"'.pSQl(substr($line, 10, 31)).'",
|
||||
"'.pSQl(substr($line, 41, 5)).'",
|
||||
"'.pSQl(substr($line, 46, 5)).'",
|
||||
"'.pSQl(substr($line, 51, 5)).'",
|
||||
"'.pSQl(substr($line, 56, 5)).'",
|
||||
"'.pSQl(substr($line, 61, 1)).'",
|
||||
"'.pSQl($datouv).'",
|
||||
"'.pSQl($datfer).'",
|
||||
"'.pSQl(substr($line, 202, 30)).'",
|
||||
"'.pSQl(substr($line, 232, 31)).'",
|
||||
"'.pSQl(substr($line, 325, 4)).'",
|
||||
"'.pSQl(substr($line, 336, 31)).'",
|
||||
"'.pSQl(substr($line, 367, 31)).'",
|
||||
"'.pSQl(substr($line, 398, 31)).'",
|
||||
"'.pSQl(substr($line, 429, 31)).'",
|
||||
"'.pSQl(substr($line, 460, 5)).'",
|
||||
"'.pSQl(substr($line, 465, 26)).'",
|
||||
"'.pSQl(substr($line, 491, 5)).'",
|
||||
"'.pSQl(substr($line, 613, 1)).'",
|
||||
"'.pSQl(substr($line, 614, 1)).'",
|
||||
"'.pSQl(substr($line, 615, 1)).'",
|
||||
"'.pSQl(substr($line, 616, 1)).'",
|
||||
"'.pSQl(substr($line, 617, 1)).'",
|
||||
"'.pSQl(substr($line, 618, 1)).'",
|
||||
"'.pSQl(substr($line, 619, 1)).'",
|
||||
"'.pSQl(substr($line, 620, 2)).'",
|
||||
"'.pSQl(substr($line, 622, 5)).'",
|
||||
"'.pSQl(substr($line, 627, 20)).'",
|
||||
"'.pSQl(substr($line, 652, 1)).'",
|
||||
"'.pSQl(substr($line, 653, 6)).'",
|
||||
"'.pSQl(substr($line, 659, 3)).'",
|
||||
"'.pSQl(substr($line, 662, 6)).'"
|
||||
)
|
||||
');
|
||||
}
|
||||
}
|
580
modules/logistics/carriers/mondialrelay/cron_shipping.php
Executable file
580
modules/logistics/carriers/mondialrelay/cron_shipping.php
Executable file
@ -0,0 +1,580 @@
|
||||
<?php
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SERVER['HTTP_PORT'] = 80;
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
include dirname(__FILE__).'/../../../../config/config.inc.php';
|
||||
|
||||
$call_prefix = array();
|
||||
foreach(Db::getInstance()->executeS('
|
||||
SELECT `id_country`, `call_prefix`
|
||||
FROM `' . _DB_PREFIX_ . 'country`
|
||||
') as $row){
|
||||
$call_prefix[(int) $row['id_country']] = $row['call_prefix'];
|
||||
}
|
||||
|
||||
// $str = 'aaAAäãØÃ#$()+@';
|
||||
function str_format($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')
|
||||
// );
|
||||
return preg_replace(
|
||||
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i',
|
||||
'$1',
|
||||
preg_replace('~&sup([\w]+);~',
|
||||
'$1',
|
||||
htmlentities($str, ENT_NOQUOTES, 'UTF-8')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function phone_format($phone, $id_country = 8){
|
||||
global $call_prefix;
|
||||
|
||||
$prefix = '+' . (isset($call_prefix[$id_country]) ? $call_prefix[$id_country] : '33');
|
||||
// normalize phone
|
||||
$phone = str_replace(array(' ', '+'), '', $phone);
|
||||
if (strlen($phone) > '10'){
|
||||
if ($phone[0] != 0 && $phone[1] == 0)
|
||||
$phone = substr($phone, 1);
|
||||
$phone = substr($phone, 0, 10);
|
||||
}
|
||||
if (strlen($phone) == 9){
|
||||
$phone = '0' . $phone;
|
||||
}
|
||||
// add spaces
|
||||
$_phone = '';
|
||||
for($i=0; $i<strlen($phone); $i++){
|
||||
$_phone .= $phone[$i];
|
||||
if (($i+1)%2==0)
|
||||
$_phone .= ' ';
|
||||
}
|
||||
$phone = $_phone;
|
||||
|
||||
// set format
|
||||
$phone = $prefix . substr($phone, 1);
|
||||
return $phone;
|
||||
}
|
||||
|
||||
function mb_str_pad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT)
|
||||
{
|
||||
$diff = strlen( $input ) - mb_strlen( $input );
|
||||
return str_pad( $input, $pad_length + $diff, $pad_string, $pad_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* array(
|
||||
* 0 => position,
|
||||
* 1 => size,
|
||||
* 2 => type,
|
||||
* 3 => code,
|
||||
* 4 => value
|
||||
*/
|
||||
function addRows($data_rows = array()){
|
||||
if (!is_array($data_rows) || !count($data_rows))
|
||||
return '';
|
||||
$data_result = '';
|
||||
foreach ($data_rows as $row) {
|
||||
|
||||
switch ($row[2]) {
|
||||
case 'N':
|
||||
if (isset($row[4]) && is_numeric($row[4]))
|
||||
$val = sprintf('%0'.(int) $row[1].'d', $row[4]);
|
||||
else
|
||||
$val = mb_str_pad(mb_substr(str_format($row[4]), 0, (int) $row[1]), (int) $row[1]);
|
||||
break;
|
||||
case 'A':
|
||||
case 'DT':
|
||||
default:
|
||||
$val = mb_str_pad(mb_substr(str_format($row[4]), 0, (int) $row[1]), (int) $row[1]);
|
||||
break;
|
||||
}
|
||||
$data_result .= $val;
|
||||
}
|
||||
$data_result .= "\n";
|
||||
return $data_result;
|
||||
}
|
||||
|
||||
$last_sync = date('Y-m-d H:i:s', strtotime((Configuration::get('MONDIALRELAY_LASTSYNC') ? Configuration::get('MONDIALRELAY_LASTSYNC') : '0000-00-00 00:00:00')));
|
||||
Configuration::updateValue('MONDIALRELAY_LASTSYNC', date('Y-m-d H:i:s'));
|
||||
|
||||
$sql = '
|
||||
SELECT p.*, o.`id_lang`, o.`id_order`, o.`id_customer`, o.`id_address_delivery`, c.`email`
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_parcel` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
||||
ON p.`id_order_detail` = d.`id_order_detail`
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||
ON d.`id_order` = o.`id_order`
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c
|
||||
ON c.`id_customer` = o.`id_customer`
|
||||
WHERE p.`date_add` > "'.pSQL($last_sync).'"
|
||||
AND d.`id_order_detail` IS NOT NULL
|
||||
AND o.`id_order` IS NOT NULL
|
||||
GROUP BY p.`shipping_number`
|
||||
';
|
||||
$lines = Db::getInstance()->ExecuteQ($sql);
|
||||
|
||||
if(count($lines)) {
|
||||
$mr_account_details = unserialize(Configuration::get('MR_ACCOUNT_DETAIL'));
|
||||
|
||||
$crt_amount = 0.00; // contre remboursement en EUR
|
||||
|
||||
$exp_company = Configuration::get('MONDIALRELAY_EXP_COMPANY');
|
||||
$exp_addr1 = Configuration::get('MONDIALRELAY_EXP_ADDR1');
|
||||
$exp_addr2 = Configuration::get('MONDIALRELAY_EXP_ADDR2');
|
||||
$exp_postcode = Configuration::get('MONDIALRELAY_EXP_POSTALCODE');
|
||||
$exp_city = Configuration::get('MONDIALRELAY_EXP_CITY');
|
||||
$exp_country = Db::getInstance()->getValue('
|
||||
SELECT `iso_code`
|
||||
FROM `'._DB_PREFIX_.'country`
|
||||
WHERE `id_country` = '.(int) Configuration::get('MONDIALRELAY_EXP_COUNTRY').'
|
||||
');
|
||||
$exp_phone = Configuration::get('MONDIALRELAY_EXP_PHONE');
|
||||
$exp_email = Configuration::get('MONDIALRELAY_EXP_EMAIL');
|
||||
|
||||
$collection_agency = Db::getInstance()->getValue('
|
||||
SELECT `modexp`
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_tri`
|
||||
WHERE `cppay` = "'.pSQL(Db::getInstance()->getValue('
|
||||
SELECT `iso_code`
|
||||
FROM `'._DB_PREFIX_.'country`
|
||||
WHERE `id_country` = '.(int) $exp_country.'
|
||||
')).'"
|
||||
AND `destex` = "'.pSQL($exp_postcode).'"
|
||||
');
|
||||
|
||||
$result = '';
|
||||
$cpt = 0;
|
||||
|
||||
foreach($lines as $line) {
|
||||
if (!in_array($line['mode'], array('24R', '24L', '24X', 'DRI')))
|
||||
continue;
|
||||
$cpt++;
|
||||
|
||||
|
||||
// $mr_liv_mode = array(
|
||||
// 'DISCOL' => (in_array($line['mode'], array('DOM', 'HOM', 'LD1', 'LDS', 'LCC'))? 'D': 'R'),
|
||||
// 'SERCOL' => (in_array($line['mode'], array('DOM', 'HOM', 'LD1'))? '1': (in_array($line['mode'], array('LDS', 'LCC'))? '2': '3')),
|
||||
// 'COLMOD' => (in_array($line['mode'], array('DOM', 'HOM', 'LD1'))? 'CDR': ($line['mode'] == 'LDS'? 'CDS': ($line['mode'] == 'LCC'? 'CCC': 'REL')))
|
||||
// );
|
||||
|
||||
$mr_liv_mode = array(
|
||||
'DISCOL' => 'R',
|
||||
'SERCOL' => '2',
|
||||
'COLMOD' => 'CCC'
|
||||
);
|
||||
|
||||
switch ($line['mode']) {
|
||||
case 'DOM':
|
||||
case 'HOM':
|
||||
case 'LD1':
|
||||
$mr_liv_mode['DISCOL'] = 'D';
|
||||
$mr_liv_mode['SERCOL'] = '1';
|
||||
$mr_liv_mode['COLMOD'] = 'CDR';
|
||||
break;
|
||||
case 'LDS':
|
||||
$mr_liv_mode['DISCOL'] = 'D';
|
||||
$mr_liv_mode['SERCOL'] = '2';
|
||||
$mr_liv_mode['COLMOD'] = 'CDS';
|
||||
break;
|
||||
case 'LCC':
|
||||
$mr_liv_mode['DISCOL'] = 'D';
|
||||
$mr_liv_mode['SERCOL'] = '2';
|
||||
$mr_liv_mode['COLMOD'] = 'CCC';
|
||||
case '24R':
|
||||
case '24L':
|
||||
case '24X':
|
||||
case 'DRI':
|
||||
$mr_liv_mode['DISCOL'] = '';
|
||||
$mr_liv_mode['SERCOL'] = '2';
|
||||
$mr_liv_mode['COLMOD'] = 'CCC';
|
||||
default:
|
||||
$mr_liv_mode['DISCOL'] = 'R';
|
||||
$mr_liv_mode['SERCOL'] = '2';
|
||||
$mr_liv_mode['COLMOD'] = 'CCC';
|
||||
break;
|
||||
}
|
||||
|
||||
$address = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'address`
|
||||
WHERE `id_address` = '.(int) $line['id_address_delivery'].'
|
||||
');
|
||||
|
||||
|
||||
// $code_marque = mb_substr($line['expedition_number'], 0, 2);
|
||||
// $expe_number = mb_substr($line['expedition_number'], 2, 8);
|
||||
|
||||
$data_rows = array(
|
||||
array(1, 1, 'A', 'CODFIC', 'A'),
|
||||
array(2, 1, 'A', 'CODENR', '1'),
|
||||
array(3, 1, 'A', 'SSCODE', '0'),
|
||||
array(4, 2, 'A', 'MARQUE', 'F1'),
|
||||
array(6, 8, 'A', 'NEXPE', $line['expedition_number']),
|
||||
array(14, 2, 'N', 'NBCOLIS', '01'),
|
||||
array(16, 1, 'A', 'DISTRI', 'D'),
|
||||
array(17, 8, 'A', 'CDEST', !empty($line['idrelay'])? $line['idrelay']: $address['postcode']),
|
||||
array(25, 4, 'N', 'TRANS', $line['modexp']),
|
||||
array(29, 5, 'N', 'TOURNE', $line['direction']),
|
||||
array(34, 1, 'N', 'TYPSER', ($line['mode'] == 'DOM' || $line['mode'] == 'HOM'? '1': ($line['mode'] == 'LD1'? '1': ($line['mode'] == 'LDS' || $line['mode'] == 'LCC'? '2': '3')))),
|
||||
array(35, 3, 'A', 'LIVMOD', $line['mode']),
|
||||
array(38, 10, 'DT', 'DATREM', date('d.m.Y')),
|
||||
array(48, 4, 'A', 'SIGLE', ''),
|
||||
array(52, 28, 'A', 'LVADR1', $address['lastname'].' '.$address['firstname']),
|
||||
array(80, 30, 'A', 'LVADR2', $address['company']),
|
||||
array(110, 2, 'A', 'Libre', ''),
|
||||
array(112, 30, 'A', 'LVADR3', $address['address1']),
|
||||
array(142, 2, 'A', 'Libre', ''),
|
||||
array(144, 30, 'A', 'LVADR4', $address['address2']),
|
||||
array(174, 2, 'A', 'Libre', ''),
|
||||
array(176, 30, 'A', 'LVADR5', ''),
|
||||
array(206, 2, 'A', 'Libre', ''),
|
||||
array(208, 26, 'A', 'LVADR6', $address['city']),
|
||||
array(234, 2, 'A', 'LVCPAY', $line['cppay']),
|
||||
array(236, 5, 'A', 'LVCPOS', $address['postcode']),
|
||||
array(241, 5, 'A', 'LVXPOS', ''),
|
||||
array(246, 20, 'A', 'LVTEL1', phone_format($address['phone'])),
|
||||
array(266, 20, 'A', 'LVTEL2', phone_format($address['phone_mobile'])),
|
||||
array(286, 70, 'A', 'LVEMAI', $line['email']),
|
||||
array(356, 31, 'A', 'INSLIV1', $address['other']),
|
||||
array(387, 31, 'A', 'INSLIV2', $address['other']),
|
||||
array(418, 10, 'A', 'libre', ''),
|
||||
array(428, 7, 'N', 'POIDS', (float) $line['weight'] * $mr_account_details['MR_WEIGHT_COEFFICIENT']),
|
||||
array(435, 7, 'N', 'VOLU', ''),
|
||||
array(442, 3, 'N', 'LONG', ''),
|
||||
array(445, 6, 'A', 'ORIG', 'BRICOP'),
|
||||
array(451, 7, 'N', 'VENTE', ''),
|
||||
array(458, 3, 'A', 'DEVVTE', 'EUR'),
|
||||
array(461, 7, 'N', 'CRT', (int) $crt_amount * 100),
|
||||
array(468, 3, 'A', 'DEVCRT', 'EUR'),
|
||||
array(471, 15, 'A', 'REFEXT', 'EXP'.$line['id_order']),
|
||||
array(486, 9, 'A', 'REFCLI', $line['id_customer']),
|
||||
array(495, 10, 'DT', 'DATFAC', date('d.m.Y')),
|
||||
array(505, 10, 'DT', 'DATCDE', date('d.m.Y')),
|
||||
array(515, 5, 'A', 'CALPHA', $address['lastname']),
|
||||
array(520, 5, 'A', 'PRTMIS', ''),
|
||||
array(525, 1, 'A', 'COLLEC', ''),
|
||||
array(526, 1, 'A', 'TOPMDM', 'N'),
|
||||
array(527, 2, 'A', 'TOPEMB', ''),
|
||||
array(529, 2, 'N', 'QTLGAR', ''),
|
||||
array(531, 10, 'DT', 'DATRDV', ''),
|
||||
array(541, 2, 'A', 'CODCRNRDV', ''),
|
||||
array(543, 2, 'A', 'DEBCRNLIVANN', ''),
|
||||
array(545, 2, 'A', 'FINCRNLIVANN', ''),
|
||||
array(547, 10, 'A', 'Libre', ''),
|
||||
array(557, 1, 'A', 'TOPAVI', ''),
|
||||
array(558, 7, 'N', 'TAXAFF', ''),
|
||||
array(565, 7, 'N', 'TAXCRT', ''),
|
||||
array(572, 2, 'A', 'Libre', ''),
|
||||
array(574, 3, 'A', 'TOPKDO', ''),
|
||||
array(577, 3, 'N', 'TOTDIM', ''),
|
||||
array(580, 33, 'A', 'Libre', ''),
|
||||
array(613, 7, 'A', 'TOP-POSIT', ''),
|
||||
array(620, 1, 'A', 'DISCOL', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $mr_liv_mode['DISCOL'])),
|
||||
array(621, 8, 'A', 'CCOLL', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : (!empty($line['idrelay'])? $line['idrelay']: $address['postcode']))),
|
||||
array(629, 4, 'A', 'AGPEC', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $collection_agency)),
|
||||
array(633, 5, 'A', 'TRNCOL', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $line['direction'])),
|
||||
array(638, 1, 'A', 'SERCOL', ($mr_liv_mode['SERCOL'] ? $mr_liv_mode['SERCOL'] : 2)),
|
||||
array(639, 3, 'A', 'COLMOD', ($mr_liv_mode['COLMOD'] ? $mr_liv_mode['COLMOD'] : 'CCC')),
|
||||
array(642, 4, 'A', 'SIGLE', ''),
|
||||
array(646, 28, 'A', 'EXADR1', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_company)),
|
||||
array(674, 30, 'A', 'EXADR2', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : mb_substr($exp_company, 28, 30))),
|
||||
array(704, 2, 'A', 'Libre', ''),
|
||||
array(706, 30, 'A', 'EXADR3', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_addr1)),
|
||||
array(736, 2, 'A', 'Libre', ''),
|
||||
array(738, 30, 'A', 'EXADR4', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_addr2)),
|
||||
array(768, 2, 'A', 'Libre', ''),
|
||||
array(770, 30, 'A', 'EXADR5', ''),
|
||||
array(800, 2, 'A', 'Libre', ''),
|
||||
array(802, 26, 'A', 'EXADR6', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_city)),
|
||||
array(828, 2, 'A', 'EXCPAY', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_country)),
|
||||
array(830, 5, 'A', 'EXCPOS', ($mr_liv_mode['COLMOD'] === 'CCC' ? '' : $exp_postcode)),
|
||||
array(835, 5, 'A', 'EXXCPO', ''),
|
||||
array(840, 20, 'A', 'EXNTEL', phone_format($exp_phone, (int) $exp_country)),
|
||||
array(860, 70, 'A', 'EXEMAI', $exp_email),
|
||||
array(930, 2, 'A', 'LNGCOL', 'FR'),
|
||||
array(932, 9, 'N', 'RECOL', '999999999'),
|
||||
array(941, 1, 'A', 'TASSU', ''),
|
||||
array(942, 2, 'A', 'LNGLIV', ($line['id_lang'] == 3? 'ES': ($line['id_lang'] == 2? 'FR': 'EN'))),
|
||||
array(944, 58, 'A', 'Linre', '')
|
||||
);
|
||||
$result .= addRows($data_rows);
|
||||
|
||||
// $result .=
|
||||
// 'A'
|
||||
// .'1'
|
||||
// .'0'
|
||||
// .str_pad(mb_substr('F1', 0, 2), 2)
|
||||
// .str_pad(mb_substr($line['expedition_number'], 0, 8), 8)
|
||||
// .'01'
|
||||
// .'D'
|
||||
// .str_pad(mb_substr(!empty($line['idrelay'])? $line['idrelay']: $address['postcode'], 0, 8), 8)
|
||||
// .str_pad(mb_substr($line['modexp'], 0, 4), 4)
|
||||
// .str_pad(mb_substr($line['direction'], 0, 5), 5)
|
||||
// .($line['mode'] == 'DOM' || $line['mode'] == 'HOM'? '1': ($line['mode'] == 'LD1'? '1': ($line['mode'] == 'LDS' || $line['mode'] == 'LCC'? '2': '3')))
|
||||
// .str_pad(substr($line['mode'], 0, 3), 3)
|
||||
// .date('d.m.Y')
|
||||
// .str_pad('', 4)
|
||||
// .str_pad(mb_substr($address['lastname'].' '.$address['firstname'], 0, 28), 28)
|
||||
// .str_pad(mb_substr($address['company'], 0, 30), 30)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad(mb_substr($address['address1'], 0, 30), 30)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad(mb_substr($address['address2'], 0, 30), 30)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad('', 30)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad(mb_substr($address['city'], 0, 26), 26)
|
||||
// .str_pad(mb_substr($line['cppay'], 0, 2), 2)
|
||||
// .str_pad(mb_substr($address['postcode'], 0, 5), 5)
|
||||
// .str_pad(mb_substr($address['postcode'], 5, 5), 5)
|
||||
// .str_pad(mb_substr($address['phone'], 0, 20), 20)
|
||||
// .str_pad(mb_substr($address['phone_mobile'], 0, 20), 20)
|
||||
// .str_pad(mb_substr($line['email'], 0, 70), 70)
|
||||
// .str_pad(mb_substr($address['other'], 0, 31), 31)
|
||||
// .str_pad(mb_substr($address['other'], 31, 31), 31)
|
||||
// .str_pad(' ', 10)
|
||||
// .sprintf('%07d', (float) $line['weight'] * $mr_account_details['MR_WEIGHT_COEFFICIENT'])
|
||||
// .str_pad('', 7)
|
||||
// .str_pad('', 3)
|
||||
// .str_pad(mb_substr(Configuration::get('MONDIALRELAY_ORIGIN_CODE', 'BRICOP'), 0, 6), 6)
|
||||
// .str_pad('', 7)
|
||||
// .'EUR'
|
||||
// .sprintf('%07d', (int) $crt_amount * 100)
|
||||
// .'EUR'
|
||||
// .str_pad(mb_substr('EXP'.$line['id_order'], 0, 15), 15)
|
||||
// .str_pad(mb_substr($line['id_customer'], 0, 9), 9)
|
||||
// .date('d.m.Y')
|
||||
// .date('d.m.Y')
|
||||
// .str_pad(mb_substr($address['lastname'], 0, 5), 5)
|
||||
// .str_pad('', 5)
|
||||
// .str_pad('', 1)
|
||||
// .'N'
|
||||
// .str_pad('', 2)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad('', 10)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad('', 10)
|
||||
// .str_pad('', 1)
|
||||
// .str_pad('', 7)
|
||||
// .str_pad('', 7)
|
||||
// .str_pad('', 2)
|
||||
// .str_pad('', 3)
|
||||
// .str_pad('', 3)
|
||||
// .str_pad('', 33)
|
||||
// .str_pad('', 7)
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? ' ' : $mr_liv_mode['DISCOL'])
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? ' ' : str_pad(mb_substr(!empty($line['idrelay'])? $line['idrelay']: $address['postcode'], 0, 8), 8))
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? ' ' : mb_substr($collection_agency, 0, 4))
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? ' ' : str_pad($line['direction'], 5))
|
||||
// .($mr_liv_mode['SERCOL'] ? $mr_liv_mode['SERCOL'] : 2)
|
||||
// .($mr_liv_mode['COLMOD'] ? $mr_liv_mode['COLMOD'] : 'CCC')
|
||||
// //.'CCC'
|
||||
// .' '
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? str_pad('', 28) : str_pad(mb_substr($exp_company, 0, 28), 28))
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? str_pad('', 30) : str_pad(mb_substr($exp_company, 28, 30), 30))
|
||||
// .' '
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? str_pad('', 30) : str_pad(mb_substr($exp_addr1, 0, 30), 30))
|
||||
// .' '
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? str_pad('', 30) : str_pad(mb_substr($exp_addr2, 0, 30), 30))
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? str_pad('', 26) : str_pad(mb_substr($exp_city, 0, 26), 26))
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? str_pad('', 2) : str_pad(mb_substr($exp_country, 0, 2), 2))
|
||||
// .($mr_liv_mode['COLMOD'] === 'CCC' ? str_pad('', 5) : str_pad(mb_substr($exp_postcode, 0, 5), 5))
|
||||
// .str_pad(' ', 5)
|
||||
// .str_pad(mb_substr($exp_phone, 0, 20), 20)
|
||||
// .str_pad(mb_substr($exp_email, 0, 70), 70)
|
||||
// .'FR'
|
||||
// //.(in_array($line['mode'], array('DOM', 'HOM', 'LD1'))? ' ': ($line['mode'] == 'LDS'? ' ': ($line['mode'] == 'LCC'? '999999999': ' '))) // TODO ref expéditeur
|
||||
// .'999999999'
|
||||
// .' '
|
||||
// .($line['id_lang'] == 3? 'ES': ($line['id_lang'] == 2? 'FR': 'EN'))
|
||||
// .' '
|
||||
// ."\n";
|
||||
|
||||
$i = 0;
|
||||
foreach(Db::getInstance()->ExecuteQ('
|
||||
SELECT d.*, p.`quantity`
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_parcel` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
||||
ON p.`id_order_detail` = d.`id_order_detail`
|
||||
WHERE p.`shipping_number` = "'.pSQL($line['shipping_number']).'"
|
||||
AND p.`date_add` = "'.pSQL($line['date_add']).'"
|
||||
') as $art) {
|
||||
$cpt++;
|
||||
$i++;
|
||||
$data_rows = array(
|
||||
array(1, 1, 'A', 'CODFIC', 'A'),
|
||||
array(2, 1, 'A', 'CODENR', '1'),
|
||||
array(3, 1, 'A', 'SSCODE', '1'),
|
||||
array(4, 2, 'A', 'MARQUE', 'F1'),
|
||||
array(6, 8, 'A', 'NEXPE', $line['expedition_number']),
|
||||
array(14, 2, 'N', 'SEQCAR', $i),
|
||||
array(16, 1, 'N', 'CODART', '1'),
|
||||
array(17, 1, 'A', 'FILLER', ''),
|
||||
array(18, 5, 'N', 'QTART', (int) $art['quantity']),
|
||||
array(23, 28, 'A', 'LIB', $art['product_name']),
|
||||
array(51, 7, 'N', 'POIDS', (int) (Db::getInstance()->getValue('
|
||||
SELECT `weight`
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE `id_product` = '.(int) $art['product_id'].'
|
||||
') * $mr_account_details['MR_WEIGHT_COEFFICIENT'])),
|
||||
array(58, 5, 'N', 'VOLUME', '0'),
|
||||
array(63, 3, 'N', 'LONG', '0'),
|
||||
array(66, 2, 'N', 'NBCOLI', '1'),
|
||||
array(68, 5, 'N', 'Filler', ''),
|
||||
array(73, 1, 'A', 'Filler', ''),
|
||||
array(74, 1, 'A', 'Filler', ''),
|
||||
array(75, 1, 'A', 'TOPSE1', ''),
|
||||
array(76, 5, 'N', 'QTESE1', ''),
|
||||
array(81, 1, 'A', 'TOPSE2', ''),
|
||||
array(82, 5, 'N', 'QTESE2', ''),
|
||||
array(87, 1, 'A', 'TOPSE3', ''),
|
||||
array(88, 5, 'N', 'QTESE3', ''),
|
||||
array(93, 1, 'A', 'TOPSE4', ''),
|
||||
array(94, 5, 'N', 'QTESE4', ''),
|
||||
array(99, 1, 'A', 'TOPSE5', ''),
|
||||
array(100, 5, 'N', 'QTESE5', ''),
|
||||
array(105, 1, 'A', 'TOPSE6', ''),
|
||||
array(106, 5, 'N', 'QTESE6', ''),
|
||||
array(111, 1, 'A', 'TOPSE7', ''),
|
||||
array(112, 5, 'N', 'QTESE7', ''),
|
||||
array(117, 1, 'A', 'TOPSE8', ''),
|
||||
array(118, 5, 'N', 'QTESE8', ''),
|
||||
array(123, 378, 'A', 'libre', '')
|
||||
);
|
||||
$result .= addRows($data_rows);
|
||||
// $result .= 'A11'
|
||||
// .'F1'
|
||||
// .$line['expedition_number']
|
||||
// .sprintf('%02d', $i)
|
||||
// .'1'
|
||||
// .' '
|
||||
// .sprintf('%05d', (int) $art['quantity'])
|
||||
// .mb_substr($art['product_name'], 0, 28)
|
||||
// .sprintf('%07d', (int) (Db::getInstance()->getValue('
|
||||
// SELECT `weight`
|
||||
// FROM `'._DB_PREFIX_.'product`
|
||||
// WHERE `id_product` = '.(int) $art['product_id'].'
|
||||
// ') * $mr_account_details['MR_WEIGHT_COEFFICIENT']) )
|
||||
// .'00000'
|
||||
// .'000'
|
||||
// .'01'
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// .' '
|
||||
// ."\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$data_rows = array(
|
||||
array(1, 1, 'A', 'CODFIC', 'A'),
|
||||
array(2, 1, 'A', 'CODENR', '0'),
|
||||
array(3, 3, 'A', 'SOCEMET', 'MR '),
|
||||
array(6, 3, 'A', 'SOCDEST', 'FRA'),
|
||||
array(9, 5, 'N', 'SEQFIC', 1),
|
||||
array(14, 7, 'N', 'NBENR', $cpt + 1),
|
||||
array(21, 10, 'DT', 'DTTRAN', date('d.m.Y')),
|
||||
array(31, 5, 'A', 'VERSION', '04.00'),
|
||||
array(36, 965, 'A', 'libre', ''),
|
||||
);
|
||||
$data = addRows($data_rows);
|
||||
$data .= mb_substr($result, 0, -1);
|
||||
|
||||
|
||||
// $data = 'A0FRAMR 00001'
|
||||
// .sprintf('%07d', $cpt + 1)
|
||||
// .date('d.m.Y')
|
||||
// .'04.00'
|
||||
// .str_pad(' ', 965)
|
||||
// ."\n"
|
||||
// .mb_substr($result, 0, -1);
|
||||
|
||||
$fileName = 'dpc.D' . date('ymd') . 'H' . date('His') . '.txt';
|
||||
// $fileName = 'dpc.test.txt';
|
||||
$repo_dpc = dirname(__FILE__) . '/dpc/';
|
||||
$repo_archive = dirname(__FILE__) . '/archives/dpc/';
|
||||
$repo_paths = array(date('Y'), date('m'));
|
||||
foreach ($repo_paths as $repo_path) {
|
||||
$repo_archive .= $repo_path . '/';
|
||||
if (!file_exists($repo_archive))
|
||||
mkdir($repo_archive);
|
||||
}
|
||||
|
||||
// file_put_contents($repo_dpc . $fileName, "\xEF\xBB\xBF".utf8_encode($w1252_data));
|
||||
// file_put_contents($repo_archive . $fileName, "\xEF\xBB\xBF".utf8_encode($w1252_data));
|
||||
|
||||
// file_put_contents($repo_dpc . $fileName, mb_convert_encoding($data, "WINDOWS-1252", "UTF-8"));
|
||||
// file_put_contents($repo_archive . $fileName, mb_convert_encoding($data, "WINDOWS-1252", "UTF-8"));
|
||||
// file_put_contents($repo_dpc . $fileName, $data);
|
||||
// file_put_contents($repo_archive . $fileName, $data);
|
||||
$iconv = iconv('UTF-8', 'Windows-1252//TRANSLIT', $data);
|
||||
if (!$iconv)
|
||||
$iconv = $data;
|
||||
file_put_contents($repo_dpc . $fileName, $iconv);
|
||||
file_put_contents($repo_archive . $fileName, $iconv);
|
||||
}
|
||||
// echo 'A0FRAMR00001'.sprintf('%07d', $cpt + 1).date('d.m.Y').'04.00'."\n".mb_substr($result, 0, -1);
|
||||
|
||||
|
||||
|
||||
// SEND TO FTP
|
||||
$mr_ftp_conf = Configuration::getMultiple(array(
|
||||
'MONDIALRELAYWS_FTP_HOST',
|
||||
'MONDIALRELAYWS_FTP_LOGIN',
|
||||
'MONDIALRELAYWS_FTP_PASSWORD'
|
||||
));
|
||||
|
||||
$id_ftp = ftp_connect($mr_ftp_conf['MONDIALRELAYWS_FTP_HOST']);
|
||||
|
||||
if (!ftp_login($id_ftp, $mr_ftp_conf['MONDIALRELAYWS_FTP_LOGIN'], $mr_ftp_conf['MONDIALRELAYWS_FTP_PASSWORD']))
|
||||
die('erreur lors de l\'identification FTP'.chr(10).chr(10));
|
||||
|
||||
//activation du mode passif
|
||||
// if (!ftp_pasv($id_ftp, true))
|
||||
// die('erreur lors de l\'activation du mode passif'.chr(10).chr(10));
|
||||
|
||||
$repo_dpc = dirname(__FILE__) . '/dpc/';
|
||||
$mr_repo_in = 'versmrelay/';
|
||||
//envoie du fichier
|
||||
$list = scandir($repo_dpc);
|
||||
foreach($list as $file)
|
||||
{
|
||||
if (!preg_match('/^dpc\..+\.txt$/', $file))
|
||||
continue;
|
||||
if ($file == '.' || $file == '..')
|
||||
continue;
|
||||
if (!ftp_put ($id_ftp, $mr_repo_in . $file, $repo_dpc . $file, FTP_BINARY))
|
||||
print('erreur lors de l\'ouverture du fichier : ' . $file . chr(10));
|
||||
else
|
||||
unlink($repo_dpc . $file);
|
||||
}
|
||||
ftp_close($id_ftp);
|
287
modules/logistics/carriers/mondialrelay/cron_trace.php
Executable file
287
modules/logistics/carriers/mondialrelay/cron_trace.php
Executable file
@ -0,0 +1,287 @@
|
||||
<?php
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SERVER['HTTP_PORT'] = 80;
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
include dirname(__FILE__).'/../../../../config/config.inc.php';
|
||||
|
||||
$regex = '/^trc\.(.*)\.txt$/';
|
||||
|
||||
## GET trc.Daammjj.Hhhmmss.txt FILE
|
||||
$id_ftp = ftp_connect(Configuration::get('MONDIALRELAYWS_FTP_HOST'));
|
||||
ftp_login($id_ftp, Configuration::get('MONDIALRELAYWS_FTP_LOGIN'), Configuration::get('MONDIALRELAYWS_FTP_PASSWORD'));
|
||||
ftp_chdir($id_ftp, 'depuismrelay');
|
||||
$list = ftp_nlist($id_ftp, '.');
|
||||
foreach($list as $name_file)
|
||||
{
|
||||
$name_file;
|
||||
if(!preg_match($regex, $name_file))
|
||||
continue;
|
||||
touch(dirname(__FILE__) . '/trace/' . $name_file);
|
||||
chmod(dirname(__FILE__) . '/trace/' . $name_file, 0777);
|
||||
$handle = fopen(dirname(__FILE__) . '/trace/' . $name_file, 'w+');
|
||||
if (!ftp_fget($id_ftp, $handle, $name_file, FTP_BINARY)){
|
||||
die('erreur lors de l\'ouverture du fichier : ' . $name_file . chr(10));
|
||||
}
|
||||
else{
|
||||
ftp_delete($id_ftp, $name_file);
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
ftp_close($id_ftp);
|
||||
|
||||
## PROCESS FOR ALL "TRACE" FILES
|
||||
$inFolder = dirname(__FILE__) . '/trace/';
|
||||
$iterator = new DirectoryIterator($inFolder);
|
||||
if(!is_object($iterator) || !count($iterator))
|
||||
die('No file');
|
||||
|
||||
foreach ($iterator as $fileinfo) {
|
||||
|
||||
if (!$fileinfo->isFile() || $fileinfo->getFilename() == '..' || $fileinfo->getFilename() == '.')
|
||||
continue;
|
||||
if (!preg_match( $regex, $fileinfo->getFilename() ))
|
||||
continue;
|
||||
|
||||
$file = fopen(dirname(__FILE__).'/trace/'.$fileinfo->getFilename(), 'r');
|
||||
$trc_data = array();
|
||||
$expeditions = array();
|
||||
while($line = fgets($file)) {
|
||||
if (substr($line, 1, 1) != '2')
|
||||
continue;
|
||||
$expedition_number = substr($line, 16, 8);
|
||||
$situation = substr($line, 54, 3);
|
||||
$info = substr($line, 57, 3);
|
||||
$new_expedition_number = substr($line, 62, 15);
|
||||
$date = explode('.', substr($line, 30, 10));
|
||||
$date = $date[2].'-'.$date[1].'-'.$date[0].' '.substr($line, 50, 2).':'.substr($line, 52, 2).':00';
|
||||
$trc_data[$expedition_number] = array(
|
||||
'expedition_number' => $expedition_number,
|
||||
'situation' => $situation,
|
||||
'info' => $info,
|
||||
'new_expedition_number' => $new_expedition_number,
|
||||
'date' => $date
|
||||
);
|
||||
|
||||
if ($situation == 'DPC')
|
||||
$expeditions[] = $expedition_number;
|
||||
}
|
||||
if (!count($expeditions))
|
||||
continue;
|
||||
|
||||
$expedition_orders = array();
|
||||
$expedition_order_details = array();
|
||||
$expedition_shipping = array();
|
||||
$order_detail_qty = array();
|
||||
foreach (Db::getInstance()->executeS('
|
||||
SELECT d.`id_order`, s.`expedition_number`, s.`shipping_number`, d.`id_order_detail`, s.`quantity`
|
||||
FROM `' . _DB_PREFIX_ . 'mondialrelay_parcel` s
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'order_detail` d
|
||||
ON d.`id_order_detail` = s.`id_order_detail`
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_current` osc
|
||||
ON osc.`id_order` = d.`id_order`
|
||||
WHERE s.`expedition_number` IN (' . implode(', ', $expeditions) . ')
|
||||
AND osc.`id_order_state` IN (2, 3, 12, 13, 17, 25)
|
||||
') as $row) {
|
||||
$expedition_shipping[$row['expedition_number']] = $row['shipping_number'];
|
||||
$expedition_orders[$row['expedition_number']] = (int) $row['id_order'];
|
||||
if (!isset($expedition_order_details[$row['expedition_number']]))
|
||||
$expedition_order_details[$row['expedition_number']] = array();
|
||||
$expedition_order_details[$row['expedition_number']][] = (int) $row['id_order_detail'];
|
||||
$order_detail_qty[(int) $row['id_order_detail']] = (int) $row['quantity'];
|
||||
}
|
||||
|
||||
$mr_carriers = array();
|
||||
foreach (Db::getInstance()->executeS('
|
||||
SELECT `id_carrier`
|
||||
FROM `' . _DB_PREFIX_ . 'mr_method`
|
||||
ORDER BY `is_deleted` ASC') as $carrier) {
|
||||
$mr_carriers[] = (int) $carrier['id_carrier'];
|
||||
}
|
||||
|
||||
foreach ($expedition_orders as $expedition_number => $id_order) {
|
||||
|
||||
if (!isset($expedition_shipping[$expedition_number]) || !$expedition_shipping[$expedition_number])
|
||||
continue;
|
||||
$shipping_number = $expedition_shipping[$expedition_number];
|
||||
|
||||
if (!isset($expedition_order_details[$expedition_number]))
|
||||
continue;
|
||||
$order_details = $expedition_order_details[$expedition_number];
|
||||
|
||||
if (!isset($expedition_orders[$expedition_number]))
|
||||
continue;
|
||||
$order = new Order((int) $id_order);
|
||||
if (!Validate::isLoadedObject($order))
|
||||
continue;
|
||||
|
||||
$fully_sent = FALSE;
|
||||
$products_sent = 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`
|
||||
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((int) $quantity_remain['remain'] == 0) {
|
||||
$products_sent[] = (int) $quantity_remain['id_order_detail'];
|
||||
}
|
||||
}
|
||||
|
||||
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`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'exapaqws` 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((int) $quantity_remain['remain'] == 0) {
|
||||
$products_sent[] = (int) $quantity_remain['id_order_detail'];
|
||||
}
|
||||
}
|
||||
|
||||
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`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'mondialrelay_parcel` 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((int) $quantity_remain['remain'] == 0) {
|
||||
$products_sent[] = (int) $quantity_remain['id_order_detail'];
|
||||
}
|
||||
}
|
||||
|
||||
$remaining = array();
|
||||
foreach($order_details as $d) {
|
||||
if(!in_array($d, $products_sent)) {
|
||||
$remaining[] = (int) $d;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($remaining) == 0) {
|
||||
$fully_sent = TRUE;
|
||||
} else {
|
||||
$id_sales = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT c.`id_sale`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
||||
ON c.`id_product` = d.`product_id`
|
||||
WHERE d.`id_order_detail` IN ('.implode(', ', $remaining).')
|
||||
') as $row) {
|
||||
$id_sales[] = (int) $row['id_sale'];
|
||||
}
|
||||
|
||||
$sent_sales = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT `id_sale`
|
||||
FROM `'._DB_PREFIX_.'shipping_history`
|
||||
WHERE `id_order` = '.(int) $order->id.'
|
||||
AND `id_sale` IN ('.implode(', ', $id_sales).')
|
||||
') as $row) {
|
||||
$sent_sales[] = (int) $row['id_sale'];
|
||||
}
|
||||
|
||||
$remaining = array();
|
||||
foreach($id_sales as $s) {
|
||||
if(!in_array($s, $sent_sales)) {
|
||||
$remaining[] = (int) $s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$fully_sent = (count($remaining) == 0);
|
||||
}
|
||||
|
||||
$html_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(', ', $order_details).')
|
||||
') as $p) {
|
||||
if (isset($order_detail_qty[(int) $p['id_order_detail']]))
|
||||
$html_products_sent .= '<br />'."\r\n".$order_detail_qty[(int) $p['id_order_detail']] . 'x' . ' ' . $p['product_name'];
|
||||
}
|
||||
|
||||
$id_carrier = (int) $order->id_carrier;
|
||||
if (!in_array($id_carrier, $mr_carriers))
|
||||
$id_carrier = $mr_carriers[0];
|
||||
$carrier = new Carrier($id_carrier, (int) $order->id_lang);
|
||||
$customer = new Customer((int) $order->id_customer);
|
||||
|
||||
if((int) $order->id_lang == 3) {
|
||||
$content_html = '<strong>Contenido del paquete:</strong>';
|
||||
$content_txt = 'Contenido del paquete:';
|
||||
} elseif((int) $order->id_lang == 5) {
|
||||
$content_html = '<strong>Contenuto del package:</strong>';
|
||||
$content_txt = 'Contenuto del package:';
|
||||
} else {
|
||||
$content_html = '<strong>Contenu du colis :</strong>';
|
||||
$content_txt = 'Contenu du colis :';
|
||||
}
|
||||
|
||||
$templateVars = array(
|
||||
'{followup}' => str_replace('@', $shipping_number, $carrier->url),
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{id_order}' => (int) $order->id,
|
||||
'{product_list}' => !empty($html_products_sent)? $content_html.$html_products_sent: '',
|
||||
'{product_list_txt}' => !empty($html_products_sent)? $content_txt.strip_tags($html_products_sent): '',
|
||||
);
|
||||
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int) $order->id;
|
||||
|
||||
$history->changeIdOrderState(($fully_sent? Configuration::get('PS_OS_SHIPPING'): 17), (int) $order->id);
|
||||
$history->id_employee = 0;
|
||||
$history->addWithemail(TRUE, $templateVars);
|
||||
|
||||
global $_LANGMAIL;
|
||||
$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
|
||||
);
|
||||
}
|
||||
|
||||
## ARCHIVE FILE
|
||||
$repo_archive = dirname(__FILE__) . '/archives/trace/';
|
||||
$repo_paths = array(date('Y'), date('m'));
|
||||
foreach ($repo_paths as $repo_path) {
|
||||
$repo_archive .= $repo_path . '/';
|
||||
if (!file_exists($repo_archive))
|
||||
mkdir($repo_archive);
|
||||
}
|
||||
rename(dirname(__FILE__).'/trace/'.$fileinfo->getFilename(), $repo_archive . $fileinfo->getFilename());
|
||||
}
|
62
modules/logistics/carriers/mondialrelay/cron_tri.php
Executable file
62
modules/logistics/carriers/mondialrelay/cron_tri.php
Executable file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$_SERVER['HTTP_PORT'] = 80;
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
include dirname(__FILE__).'/../../../../config/config.inc.php';
|
||||
|
||||
|
||||
## GET pltri.txt FILE
|
||||
$fname = 'pltri.txt';
|
||||
$filename = dirname(__FILE__) . '/' . $fname;
|
||||
$file = fopen($filename, 'w+');
|
||||
$remote_file = $fname;
|
||||
|
||||
$ftp = ftp_connect(Configuration::get('MONDIALRELAYWS_FTP_HOST'));
|
||||
ftp_login($ftp, Configuration::get('MONDIALRELAYWS_FTP_LOGIN'), Configuration::get('MONDIALRELAYWS_FTP_PASSWORD'));
|
||||
ftp_chdir($ftp, 'depuismrelay');
|
||||
if (!ftp_fget($ftp, $file, $remote_file, FTP_BINARY))
|
||||
die('An error occures while downloading remote file : ' . $fname);
|
||||
|
||||
$file = fopen($filename, 'r');
|
||||
$content = fgets($file);
|
||||
if (!$content)
|
||||
die('File is empty : ' . $fname);
|
||||
|
||||
## Update DB
|
||||
Db::getInstance()->ExecuteS('
|
||||
TRUNCATE TABLE `'._DB_PREFIX_.'mondialrelay_tri`
|
||||
');
|
||||
|
||||
while($line = fgets($file)) {
|
||||
if(substr($line, 1, 1) == '1') {
|
||||
$datdeb = explode('.', substr($line, 36, 10));
|
||||
$datdeb = $datdeb[2].'-'.$datdeb[1].'-'.$datdeb[0];
|
||||
$datfin = explode('.', substr($line, 46, 10));
|
||||
$datfin = $datfin[2].'-'.$datfin[1].'-'.$datfin[0];
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'mondialrelay_tri`
|
||||
VALUES (
|
||||
"'.pSQl(substr($line, 2, 2)).'",
|
||||
"'.pSQl(substr($line, 4, 8)).'",
|
||||
"'.pSQl(substr($line, 12, 1)).'",
|
||||
"'.pSQl(substr($line, 13, 3)).'",
|
||||
"'.pSQl(substr($line, 16, 4)).'",
|
||||
'.(int) substr($line, 20, 1).',
|
||||
"'.pSQl(substr($line, 21, 5)).'",
|
||||
"'.pSQl(substr($line, 26, 1)).'",
|
||||
"'.pSQl(substr($line, 27, 3)).'",
|
||||
"'.pSQl(substr($line, 30, 2)).'",
|
||||
"'.pSQl(substr($line, 32, 4)).'",
|
||||
"'.pSQl($datdeb).'",
|
||||
"'.pSQl($datfin).'",
|
||||
"'.pSQl(substr($line, 56, 2)).'",
|
||||
"'.pSQl(substr($line, 58, 2)).'"
|
||||
)
|
||||
');
|
||||
}
|
||||
}
|
19
modules/logistics/carriers/mondialrelay/getsummary.php
Executable file
19
modules/logistics/carriers/mondialrelay/getsummary.php
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
include dirname(__FILE__).'/../../../../config/config.inc.php';
|
||||
|
||||
|
||||
if((Tools::getValue('token') === Tools::getAdminToken('AdminMondialRelaySummary'.(int) Tab::getIdFromClassName('AdminMondialRelaySummary').(int) Tools::getValue('id_employee')))
|
||||
&& ($pdf_date = Tools::getValue('date')) && ($pdf_dm = Tools::getValue('dm')) && in_array($pdf_dm, array('24r', 'dri', 'ld1', 'lds', 'hom'))) {
|
||||
$pdf_date = (string) (int) $pdf_date;
|
||||
$pdf_date = substr($pdf_date, 0, 4).'-'.substr($pdf_date, 4, 2).'-'.substr($pdf_date, 6);
|
||||
|
||||
if(is_file(dirname(__FILE__).'/summaries/'.$pdf_date.'_'.$pdf_dm.'.pdf')) {
|
||||
header('Content-type: application/pdf');
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Content-disposition: inline; filename="'.$pdf_date.'_'.$pdf_dm.'.pdf"');
|
||||
readfile(dirname(__FILE__).'/summaries/'.$pdf_date.'_'.$pdf_dm.'.pdf');
|
||||
} else {
|
||||
echo 'ERROR - File not found';
|
||||
}
|
||||
}
|
867
modules/logistics/carriers/mondialrelay/mondialrelay.php
Executable file
867
modules/logistics/carriers/mondialrelay/mondialrelay.php
Executable file
@ -0,0 +1,867 @@
|
||||
<?php
|
||||
if(!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $mondialrelay_formats;
|
||||
|
||||
$mondialrelay_formats = array(
|
||||
'FR' => chr(2).'m'.'
|
||||
1911S2611800050P080P040{SHIPPING_NUMBER_C25I}
|
||||
131110011200180{SHIPPING_NUMBER}
|
||||
1X1100009400050b0480015000010001
|
||||
1X1100005500050b0480035000010001
|
||||
1X1100004100050b0510009000010001
|
||||
1X1100002940050b0510009000010001
|
||||
1X1100003450585b0200011000010001
|
||||
1X1100008370050l04800001
|
||||
1X1100004500050l05100001
|
||||
1X1100003370050l05100001
|
||||
1X1100004050585l02000001
|
||||
1X1100004100210l00010090
|
||||
1X1100004100350l00010090
|
||||
1X1100002940210l00010090
|
||||
1X1100002940350l00010090
|
||||
1X1100009400051P001000110870525
|
||||
1X1100009400525P001000110870051
|
||||
1911S2410500065P010P010{EXP_COMPANY}
|
||||
1911S2310200065P008P008{EXP_ADDR1}
|
||||
1911S2309900065P008P008{EXP_ADDR2}
|
||||
1911S2309600065P008P008{EXP_POSTCODE} {EXP_CITY}
|
||||
1911S2408550065P010P010Destinataire
|
||||
1911S2407940065P010P010{DEST_ADDR1}
|
||||
1911S2307640065P006P006{DEST_ADDR2}
|
||||
1911S2307370065P006P006{DEST_ADDR3}
|
||||
1911S2307100065P006P006{DEST_ADDR4}
|
||||
1911S2306830065P006P006{DEST_ADDR5}
|
||||
1911S2406440065P010P010{DEST_POSTCODE}
|
||||
1911S2306440180P010P010{DEST_CITY}
|
||||
1911S2306060065P010P010{DEST_PHONE}
|
||||
1911S2305700065P010P010{DEST_OTHER}
|
||||
1911S2410100570P025P014{SHIPPING_1} /
|
||||
1911S2410180700P020P012{SHIPPING_2}
|
||||
1911S2409200570P025P014AG {SHIPPING_3}
|
||||
1911S2408400570P020P012N {SHIPPING_4} -
|
||||
A5
|
||||
1911S2408400710P020P012{SHIPPING_5}
|
||||
A2
|
||||
1911S2407600570P020P012T {SHIPPING_6}
|
||||
1911S2406700570P025P014{SHIPPING_7}
|
||||
1911S2406750850P020P0121/1
|
||||
1911S2405700570P025P014{SHIPPING_8}
|
||||
1911S2404650065P007P006N'.chr(248).' exp'.chr(130).'dition
|
||||
1911S2404650220P007P006Date d\'envoi
|
||||
1911S2404650360P007P006Agence de collecte
|
||||
1911S2304220080P007P007{EXPEDITION_NUMBER}
|
||||
1911S2304220220P007P007{DATE}
|
||||
1911S2304220420P007P007{AGENCY_CODE}
|
||||
1911S2404180595P009P009A Encaisser
|
||||
1911S2403630661P010P0100 '.chr(255).'
|
||||
1Y0000003240820MONDIALR
|
||||
1911S2403500080P007P006Poids (kg)
|
||||
1911S2403500225P007P006Volume (L)
|
||||
1911S2403500410P007P006N'.chr(248).' Colis
|
||||
1911S2303060085P007P007{WEIGHT}
|
||||
1911S2303060265P007P007{VOLUME}
|
||||
1911S2303060430P007P0071/1
|
||||
1911S2302400050P007P007{INSTRUCTIONS}
|
||||
'.chr(2).'n
|
||||
',
|
||||
'EN' => chr(2).'m'.'
|
||||
1911S2611800050P080P040{SHIPPING_NUMBER_C25I}
|
||||
131110011200180{SHIPPING_NUMBER}
|
||||
1X1100009400050b0480015000010001
|
||||
1X1100005500050b0480035000010001
|
||||
1X1100004100050b0510009000010001
|
||||
1X1100002940050b0510009000010001
|
||||
1X1100003450585b0200011000010001
|
||||
1X1100008370050l04800001
|
||||
1X1100004500050l05100001
|
||||
1X1100003370050l05100001
|
||||
1X1100004050585l02000001
|
||||
1X1100004100210l00010090
|
||||
1X1100004100350l00010090
|
||||
1X1100002940210l00010090
|
||||
1X1100002940350l00010090
|
||||
1X1100009400051P001000110870525
|
||||
1X1100009400525P001000110870051
|
||||
1911S2410500065P010P010{EXP_COMPANY}
|
||||
1911S2310200065P008P008{EXP_ADDR1}
|
||||
1911S2309900065P008P008{EXP_ADDR2}
|
||||
1911S2309600065P008P008{EXP_POSTCODE} {EXP_CITY}
|
||||
1911S2408550065P010P010Consignee
|
||||
1911S2407940065P010P010{DEST_ADDR1}
|
||||
1911S2307640065P006P006{DEST_ADDR2}
|
||||
1911S2307370065P006P006{DEST_ADDR3}
|
||||
1911S2307100065P006P006{DEST_ADDR4}
|
||||
1911S2306830065P006P006{DEST_ADDR5}
|
||||
1911S2406440065P010P010{DEST_POSTCODE}
|
||||
1911S2306440180P010P010{DEST_CITY}
|
||||
1911S2306060065P010P010{DEST_PHONE}
|
||||
1911S2305700065P010P010{DEST_OTHER}
|
||||
1911S2410100570P025P014{SHIPPING_1} /
|
||||
1911S2410180700P020P012{SHIPPING_2}
|
||||
1911S2409200570P025P014AG {SHIPPING_3}
|
||||
1911S2408400570P020P012N {SHIPPING_4} -
|
||||
A5
|
||||
1911S2408400710P020P012{SHIPPING_5}
|
||||
A2
|
||||
1911S2407600570P020P012T {SHIPPING_6}
|
||||
1911S2406700570P025P014{SHIPPING_7}
|
||||
1911S2406750850P020P0121/1
|
||||
1911S2405700570P025P014{SHIPPING_8}
|
||||
1911S2404650065P007P006No. Shipment
|
||||
1911S2404650220P007P006Sending Date
|
||||
1911S2404650360P007P006Connection Agency
|
||||
1911S2304220080P007P007{EXPEDITION_NUMBER}
|
||||
1911S2304220220P007P007{DATE}
|
||||
1911S2304220420P007P007{AGENCY_CODE}
|
||||
1911S2404180595P009P009C.O.D.
|
||||
1911S2403630661P010P0100 '.chr(255).'
|
||||
1Y0000003240820MONDIALR
|
||||
1911S2403500080P007P006Weight (kg)
|
||||
1911S2403500225P007P006Volume (L)
|
||||
1911S2403500410P007P006No. Parcel
|
||||
1911S2303060085P007P007{WEIGHT}
|
||||
1911S2303060265P007P007{VOLUME}
|
||||
1911S2303060430P007P0071/1
|
||||
1911S2302400050P007P007{INSTRUCTIONS}
|
||||
'.chr(2).'n
|
||||
',
|
||||
'ES' => chr(2).'m'.'
|
||||
1911S2611800050P080P040{SHIPPING_NUMBER_C25I}
|
||||
131110011200180{SHIPPING_NUMBER}
|
||||
1X1100009400050b0480015000010001
|
||||
1X1100005500050b0480035000010001
|
||||
1X1100004100050b0510009000010001
|
||||
1X1100002940050b0510009000010001
|
||||
1X1100003450585b0200011000010001
|
||||
1X1100008370050l04800001
|
||||
1X1100004500050l05100001
|
||||
1X1100003370050l05100001
|
||||
1X1100004050585l02000001
|
||||
1X1100004100210l00010090
|
||||
1X1100004100350l00010090
|
||||
1X1100002940210l00010090
|
||||
1X1100002940350l00010090
|
||||
1X1100009400051P001000110870525
|
||||
1X1100009400525P001000110870051
|
||||
1911S2410500065P010P010{EXP_COMPANY}
|
||||
1911S2310200065P008P008{EXP_ADDR1}
|
||||
1911S2309900065P008P008{EXP_ADDR2}
|
||||
1911S2309600065P008P008{EXP_POSTCODE} {EXP_CITY}
|
||||
1911S2408550065P010P010Destinario
|
||||
1911S2407940065P010P010{DEST_ADDR1}
|
||||
1911S2307640065P006P006{DEST_ADDR2}
|
||||
1911S2307370065P006P006{DEST_ADDR3}
|
||||
1911S2307100065P006P006{DEST_ADDR4}
|
||||
1911S2306830065P006P006{DEST_ADDR5}
|
||||
1911S2406440065P010P010{DEST_POSTCODE}
|
||||
1911S2306440180P010P010{DEST_CITY}
|
||||
1911S2306060065P010P010{DEST_PHONE}
|
||||
1911S2305700065P010P010{DEST_OTHER}
|
||||
1911S2410100570P025P014{SHIPPING_1} /
|
||||
1911S2410180700P020P012{SHIPPING_2}
|
||||
1911S2409200570P025P014AG {SHIPPING_3}
|
||||
1911S2408400570P020P012N {SHIPPING_4} -
|
||||
A5
|
||||
1911S2408400710P020P012{SHIPPING_5}
|
||||
A2
|
||||
1911S2407600570P020P012T {SHIPPING_6}
|
||||
1911S2406700570P025P014{SHIPPING_7}
|
||||
1911S2406750850P020P0121/1
|
||||
1911S2405700570P025P014{SHIPPING_8}
|
||||
1911S2404650065P007P006N'.chr(248).' d\'exp'.chr(130).'dicion
|
||||
1911S2404650220P007P006Fetcha de envio
|
||||
1911S2404650360P007P006Agencia de Cobros
|
||||
1911S2304220080P007P007{EXPEDITION_NUMBER}
|
||||
1911S2304220220P007P007{DATE}
|
||||
1911S2304220420P007P007{AGENCY_CODE}
|
||||
1911S2404180595P009P009A Cobrar
|
||||
1911S2403630661P010P0100 '.chr(255).'
|
||||
1Y0000003240820MONDIALR
|
||||
1911S2403500080P007P006Peso (kg)
|
||||
1911S2403500225P007P006Volumen (L)
|
||||
1911S2403500410P007P006N'.chr(248).' Paquete
|
||||
1911S2303060085P007P007{WEIGHT}
|
||||
1911S2303060265P007P007{VOLUME}
|
||||
1911S2303060430P007P0071/1
|
||||
1911S2302400050P007P007{INSTRUCTIONS}
|
||||
'.chr(2).'n
|
||||
',
|
||||
);
|
||||
|
||||
|
||||
class MondialrelayCarrier {
|
||||
public $displayName = 'Mondial Relay';
|
||||
|
||||
public function checkavailability() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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_QUOTES, 'UTF-8')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function renderLabel($order, $weight, $shipping_data) {
|
||||
global $cookie, $mondialrelay_formats;
|
||||
|
||||
$agencies = array(
|
||||
'0637' => 'BRIVE',
|
||||
'0606' => 'BORDEAUX',
|
||||
'0655' => 'CAEN',
|
||||
'0676' => 'CLERMONT-F',
|
||||
'0221' => 'CHAMBERY',
|
||||
'0603' => 'AJACCIO',
|
||||
'0677' => 'DIJON',
|
||||
'0662' => 'HEM',
|
||||
'0688' => 'ST OUEN',
|
||||
'0254' => 'LIEUSAINT',
|
||||
'0300' => 'LILLE',
|
||||
'0715' => 'LYON',
|
||||
'0648' => 'MARSEILLE',
|
||||
'0717' => 'METZ',
|
||||
'0718' => 'MONTPELLIE',
|
||||
'0719' => 'NANTES',
|
||||
'0301' => 'NICE',
|
||||
'0720' => 'MER',
|
||||
'0511' => 'REIMS',
|
||||
'0722' => 'RENNES',
|
||||
'0729' => 'ROUEN',
|
||||
'0737' => 'STRASBOURG',
|
||||
'0743' => 'TOULOUSE',
|
||||
'0749' => 'ORLEANS',
|
||||
'0930' => 'MONTREUIL',
|
||||
'0265' => 'VALENCE',
|
||||
'0975' => 'DOM TOM',
|
||||
'3010' => 'PORTUGAL',
|
||||
'3210' => 'ASM PT',
|
||||
'4010' => 'SPAIN',
|
||||
'4210' => 'ASM ES',
|
||||
'5010' => 'BELGIUM',
|
||||
'5199' => 'MONTREUIL',
|
||||
'5210' => 'BELGIQUE',
|
||||
'5310' => 'BPOST BE',
|
||||
'6610' => 'HERMES DE',
|
||||
'6620' => 'HERMES IT',
|
||||
'6630' => 'HERMES AT',
|
||||
'6640' => 'HERMES UK',
|
||||
'7210' => 'TNT NL',
|
||||
'8210' => 'DINTEC LU',
|
||||
);
|
||||
|
||||
$exp_company = Configuration::get('MONDIALRELAY_EXP_COMPANY');
|
||||
$exp_address1 = Configuration::get('MONDIALRELAY_EXP_ADDR1');
|
||||
$exp_address2 = Configuration::get('MONDIALRELAY_EXP_ADDR2');
|
||||
$exp_postal = Configuration::get('MONDIALRELAY_EXP_POSTALCODE');
|
||||
$exp_city = Configuration::get('MONDIALRELAY_EXP_CITY');
|
||||
$exp_country = Configuration::get('MONDIALRELAY_EXP_COUNTRY');
|
||||
|
||||
$delivery_address = new Address((int) $order->id_address_delivery);
|
||||
|
||||
if(!Validate::isLoadedObject($delivery_address)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$delivery_infos = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mr_selected`
|
||||
WHERE `id_order` = '.(int) $order->id.'
|
||||
');
|
||||
|
||||
// Hack 5 numbers relay num
|
||||
if (isset($delivery_infos['MR_Selected_Num']) && $delivery_infos['MR_Selected_Num'])
|
||||
$delivery_infos['MR_Selected_Num'] = substr($delivery_infos['MR_Selected_Num'], -5);
|
||||
|
||||
if(!$delivery_infos) {
|
||||
$shipping = array(
|
||||
$delivery_address->firstname.' '.$delivery_address->lastname,
|
||||
$delivery_address->company,
|
||||
$delivery_address->address1,
|
||||
$delivery_address->address2,
|
||||
$delivery_address->postcode,
|
||||
$delivery_address->city,
|
||||
'',
|
||||
empty($delivery_address->phone)? $delivery_address->phone_mobile: $delivery_address->phone,
|
||||
trim(str_replace('|', ' ', $delivery_address->other)),
|
||||
);
|
||||
$dest_country = $delivery_address->id_country;
|
||||
} else {
|
||||
$mr_relais = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_relais`
|
||||
WHERE 1
|
||||
AND `direction` = "'.pSQL($delivery_infos['MR_Selected_Num']).'"
|
||||
AND `prpay` = "'.pSQL($delivery_infos['MR_Selected_Pays']).'"
|
||||
');
|
||||
|
||||
$mode = $delivery_infos['id_method'] == 0? 'LD1': '24R';
|
||||
|
||||
if ($mode == 'LD1'){
|
||||
$shipping = array(
|
||||
$delivery_address->firstname.' '.$delivery_address->lastname,
|
||||
$mr_relais['colnom'],
|
||||
$mr_relais['colbat'],
|
||||
$mr_relais['colrue'],
|
||||
$mr_relais['coldit'],
|
||||
$mr_relais['codpos'],
|
||||
$mr_relais['libbp'],
|
||||
empty($delivery_address->phone)? $delivery_address->phone_mobile: $delivery_address->phone,
|
||||
'',
|
||||
);
|
||||
}
|
||||
else{ // 24R
|
||||
$shipping = array(
|
||||
$delivery_address->firstname.' '.$delivery_address->lastname,
|
||||
$mr_relais['colnom'],
|
||||
$mr_relais['colbat'],
|
||||
$mr_relais['colrue'],
|
||||
$mr_relais['coldit'],
|
||||
$mr_relais['codpos'],
|
||||
$mr_relais['libbp'],
|
||||
empty($delivery_address->phone)? $delivery_address->phone_mobile: $delivery_address->phone,
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
$dest_country = (int) Db::getInstance()->getValue('
|
||||
SELECT `id_country`
|
||||
FROM `'._DB_PREFIX_.'country`
|
||||
WHERE `iso_code` = "'.pSQL($delivery_infos['MR_Selected_Pays']).'"
|
||||
');
|
||||
}
|
||||
$format = str_replace(
|
||||
array(
|
||||
'{SHIPPING_NUMBER_C25I}',
|
||||
'{SHIPPING_NUMBER}',
|
||||
'{EXP_COMPANY}',
|
||||
'{EXP_ADDR1}',
|
||||
'{EXP_ADDR2}',
|
||||
'{EXP_POSTCODE}',
|
||||
'{EXP_CITY}',
|
||||
'{DEST_ADDR1}',
|
||||
'{DEST_ADDR2}',
|
||||
'{DEST_ADDR3}',
|
||||
'{DEST_ADDR4}',
|
||||
'{DEST_ADDR5}',
|
||||
'{DEST_POSTCODE}',
|
||||
'{DEST_CITY}',
|
||||
'{DEST_PHONE}',
|
||||
'{DEST_OTHER}',
|
||||
'{SHIPPING_1}',
|
||||
'{SHIPPING_2}',
|
||||
'{SHIPPING_3}',
|
||||
'{SHIPPING_4}',
|
||||
'{SHIPPING_5}',
|
||||
'{SHIPPING_6}',
|
||||
'{SHIPPING_7}',
|
||||
'{SHIPPING_8}',
|
||||
'{EXPEDITION_NUMBER}',
|
||||
'{DATE}',
|
||||
'{AGENCY_CODE}',
|
||||
'{WEIGHT}',
|
||||
'{VOLUME}',
|
||||
'{INSTRUCTIONS}',
|
||||
),
|
||||
array(
|
||||
$shipping_data['shipping_number_c25i'],
|
||||
$shipping_data['shipping_number_fmt'],
|
||||
$exp_company,
|
||||
$exp_address1,
|
||||
$exp_address2,
|
||||
$exp_postal,
|
||||
$exp_city,
|
||||
$shipping[0],
|
||||
$shipping[1],
|
||||
$shipping[2],
|
||||
$shipping[3],
|
||||
$shipping[4],
|
||||
$shipping[5],
|
||||
$shipping[6],
|
||||
$shipping[7],
|
||||
$shipping[8],
|
||||
$shipping_data['plantri']['cppay'],
|
||||
$shipping_data['plantri']['nogroup'],
|
||||
$shipping_data['plantri']['modexp'],
|
||||
$shipping_data['plantri']['pretri'], // N ...
|
||||
$shipping_data['plantri']['navette'],
|
||||
$shipping_data['plantri']['direction'], // T ...
|
||||
$shipping_data['mode'],
|
||||
$agencies[$shipping_data['plantri']['modexp']],
|
||||
$shipping_data['expedition_number'],
|
||||
date('d/m/Y'),
|
||||
Db::getInstance()->getValue('
|
||||
SELECT `modexp`
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_tri`
|
||||
WHERE `cppay` = "'.pSQL(Db::getInstance()->getValue('
|
||||
SELECT `iso_code`
|
||||
FROM `'._DB_PREFIX_.'country`
|
||||
WHERE `id_country` = '.(int) $exp_country.'
|
||||
')).'"
|
||||
AND `destex` = "'.pSQL($exp_postal).'"
|
||||
'),
|
||||
number_format((float) $shipping_data['weight'], 2, ',', ''),
|
||||
'NC',
|
||||
'',
|
||||
),
|
||||
$mondialrelay_formats[$dest_country == 6? 'ES': (in_array($dest_country, array(3, 8, 12))? 'FR': 'EN')]
|
||||
);
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
public function getShippingNumber($id_order) {
|
||||
Db::getInstance()->Execute('SET AUTOCOMMIT = 0');
|
||||
Db::getInstance()->Execute('START TRANSACTION');
|
||||
$res = Db::getInstance()->ExecuteS('
|
||||
SELECT `value`
|
||||
FROM `'._DB_PREFIX_.'logistics_shipping`
|
||||
WHERE `carrier` = "MONDIALRELAY"
|
||||
FOR UPDATE
|
||||
');
|
||||
|
||||
$sequence = (int) $res[0]['value'] + 1;
|
||||
// LOOP SHIPPING SEQUENCE
|
||||
if ($sequence < Configuration::get('MONDIALRELAY_SHIPPINGLOW') || $sequence > Configuration::get('MONDIALRELAY_SHIPPINGHIGH'))
|
||||
$sequence = Configuration::get('MONDIALRELAY_SHIPPINGLOW');
|
||||
|
||||
// CHECK UNICITY
|
||||
$last_update = Db::getInstance()->getValue('SELECT DATE_ADD(`date_upd`, INTERVAL 1 YEAR) FROM `' . _DB_PREFIX_ . 'mondialrelay_expedition_numbers` WHERE `sequence` = ' . (int) $sequence);
|
||||
if ($last_update && $last_update > date('Y-m-d H:i:s')){
|
||||
$content = 'Le numéro d\'expédition ' . $sequence . ' a été affecté il y a moins d\'un an.' . "\n" . 'Impossible d\'affecter un nouveau numéro d\'expédition';
|
||||
mail('coppee@antadis.com', '[MONDIAL RELAY] Numéro d\'expédition', $content, 'Content-Type: text/plain; charset="utf-8"'."\r\n".'From: commande@bricoprive.com'."\r\n".'Reply-To: coppee@antadis.com'."\r\n".'Return-Path: coppee@antadis.com'."\r\n");
|
||||
return false;
|
||||
}
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO ' . _DB_PREFIX_ . 'mondialrelay_expedition_numbers (`sequence`, `date_upd`)
|
||||
VALUES (' . (int) $sequence . ', "' . pSQL(date('Y-m-d H:i:s')) . '")
|
||||
ON DUPLICATE KEY UPDATE date_upd="' . pSQL(date('Y-m-d H:i:s')) . '";
|
||||
');
|
||||
|
||||
Db::getInstance()->ExecuteS('
|
||||
UPDATE `'._DB_PREFIX_.'logistics_shipping`
|
||||
SET `value` = "'.(int) $sequence.'"
|
||||
WHERE `carrier` = "MONDIALRELAY"
|
||||
');
|
||||
|
||||
Db::getInstance()->Execute('COMMIT');
|
||||
Db::getInstance()->Execute('SET AUTOCOMMIT = 1');
|
||||
|
||||
return $sequence;
|
||||
}
|
||||
|
||||
public function registerParcel($order, $products, $weight) {
|
||||
global $cookie;
|
||||
|
||||
$delivery_infos = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mr_selected`
|
||||
WHERE `id_order` = '.(int) $order->id.'
|
||||
');
|
||||
|
||||
// Hack 5 numbers relay num
|
||||
if (isset($delivery_infos['MR_Selected_Num']) && $delivery_infos['MR_Selected_Num']) {
|
||||
$delivery_infos['MR_Selected_Num'] = substr($delivery_infos['MR_Selected_Num'], -5);
|
||||
}
|
||||
|
||||
if(!$delivery_infos) {
|
||||
$mode = 'LD1';
|
||||
$address = Db::getInstance()->getRow('
|
||||
SELECT a.`postcode`, UPPER(c.`iso_code`) AS `iso_code`
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c
|
||||
ON a.`id_country` = c.`id_country`
|
||||
WHERE a.`id_address` = '.(int) $order->id_address_delivery.'
|
||||
');
|
||||
$country = $address['iso_code'];
|
||||
$postcode = $address['postcode'];
|
||||
} else {
|
||||
$mode = $delivery_infos['id_method'] == 0? 'LD1': '24R';
|
||||
$country = $delivery_infos['MR_Selected_Pays'];
|
||||
$postcode = $delivery_infos['MR_Selected_CP'];
|
||||
}
|
||||
|
||||
if($mode == 'LD1') {
|
||||
$plantri = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_tri`
|
||||
WHERE `destyp` = "CP"
|
||||
AND `destex` = "'.pSQL($postcode).'"
|
||||
AND `cppay` = "'.pSQL($country).'"
|
||||
AND (
|
||||
`livmod` = "LD1"
|
||||
OR `livmod` = "HOM"
|
||||
)
|
||||
');
|
||||
|
||||
|
||||
if(!$plantri) {
|
||||
$plantri = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_tri`
|
||||
WHERE `destyp` = "CP"
|
||||
AND `destex` = "'.pSQL(substr($postcode, 0, 2)).'"
|
||||
AND `cppay` = "'.pSQL($country).'"
|
||||
AND (
|
||||
`livmod` = "LD1"
|
||||
OR `livmod` = "HOM"
|
||||
)
|
||||
');
|
||||
}
|
||||
|
||||
if($plantri) {
|
||||
$mode = $plantri['livmod'];
|
||||
}
|
||||
} else {
|
||||
$mrrelais = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_relais`
|
||||
WHERE 1
|
||||
AND `direction` = "'.pSQL($delivery_infos['MR_Selected_Num']).'"
|
||||
AND `prpay` = "'.pSQL($country).'"
|
||||
');
|
||||
$plantri = Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'mondialrelay_tri`
|
||||
WHERE `destyp` = "RL"
|
||||
AND `destex` = "'.pSQL($delivery_infos['MR_Selected_Num']).'"
|
||||
AND `cppay` = "'.pSQL($country).'"
|
||||
');
|
||||
}
|
||||
|
||||
if(!$plantri) {
|
||||
// TODO: error handling
|
||||
return;
|
||||
}
|
||||
|
||||
$sequence = $this->getShippingNumber((int) $order->id);
|
||||
if (!$sequence){
|
||||
return array('<p class="error">Unicité du numéro d\'expédition non respecté</p><br />', array());
|
||||
}
|
||||
$expedition_number = sprintf('%08d', $sequence);
|
||||
|
||||
$mr_info = Configuration::get('MR_ACCOUNT_DETAIL');
|
||||
$mr_info = unserialize($mr_info);
|
||||
|
||||
// $shipping_number_1 = Configuration::get('MONDIALRELAY_ENSIGN_CODE').$expedition_number.'0101';
|
||||
$shipping_number_1 = $mr_info['MR_CODE_MARQUE'].$expedition_number.'0101';
|
||||
$control_number_1 = 11 - ((int) substr($shipping_number_1, 13, 1) * 2 + (int) substr($shipping_number_1, 12, 1) * 3 + (int) substr($shipping_number_1, 11, 1) * 4 + (int) substr($shipping_number_1, 10, 1) * 5 + (int) substr($shipping_number_1, 9, 1) * 6 + (int) substr($shipping_number_1, 8, 1) * 7 + (int) substr($shipping_number_1, 7, 1) * 2 + (int) substr($shipping_number_1, 6, 1) * 3 + (int) substr($shipping_number_1, 5, 1) * 4 + (int) substr($shipping_number_1, 4, 1) * 5 + (int) substr($shipping_number_1, 3, 1) * 6 + (int) substr($shipping_number_1, 2, 1) * 7 + (int) substr($shipping_number_1, 1, 1) * 2 + (int) substr($shipping_number_1, 0, 1) * 3) % 11;
|
||||
if($control_number_1 == 10 || $control_number_1 == 11) {
|
||||
$control_number_1 = 0;
|
||||
}
|
||||
|
||||
$shipping_number_2 = $plantri['modexp'].$plantri['service'].$plantri['direction'];
|
||||
$control_number_2 = 11 - ((int) substr($shipping_number_2, 9, 1) * 2 + (int) substr($shipping_number_2, 8, 1) * 3 + (int) substr($shipping_number_2, 7, 1) * 4 + (int) substr($shipping_number_2, 6, 1) * 5 + (int) substr($shipping_number_2, 5, 1) * 6 + (int) substr($shipping_number_2, 4, 1) * 7 + (int) substr($shipping_number_2, 3, 1) * 2 + (int) substr($shipping_number_2, 2, 1) * 3 + (int) substr($shipping_number_2, 1, 1) * 4 + (int) substr($shipping_number_2, 0, 1) * 5) % 11;
|
||||
if($control_number_2 == 10 || $control_number_2 == 11) {
|
||||
$control_number_2 = 0;
|
||||
}
|
||||
|
||||
$shipping_number = $shipping_number_1.$control_number_1.$shipping_number_2.$control_number_2;
|
||||
|
||||
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'] != '90.63.178.63') {
|
||||
$order->shipping_number = $shipping_number;
|
||||
$order->update();
|
||||
}
|
||||
return array('', array(
|
||||
'idrelay' => $delivery_infos? $delivery_infos['MR_Selected_Num']: '',
|
||||
'shipping_number' => $shipping_number,
|
||||
'shipping_number_fmt' => substr($shipping_number, 0, 2).' '.substr($shipping_number, 2, 8).' '.substr($shipping_number, 10, 4).' '.substr($shipping_number, 14, 1).' '.substr($shipping_number, 15, 4).' '.substr($shipping_number, 19, 1).' '.substr($shipping_number, 20, 5).' '.substr($shipping_number, 25, 1),
|
||||
'shipping_number_c25i' => $this->isoreplace($this->c25I($shipping_number)),
|
||||
'weight' => $weight,
|
||||
'plantri' => $plantri,
|
||||
'mode' => $mode,
|
||||
'expedition_number' => $expedition_number,
|
||||
));
|
||||
}
|
||||
|
||||
private function c25I($string, $checksum=FALSE) {
|
||||
if(strlen($string) == 0 || strlen($string) % 2 != 0 || !is_numeric($string)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if($checksum) {
|
||||
$i = strlen($string) - 1;
|
||||
$checksum = 0;
|
||||
for($i=strlen($string) - 1; $i >= 0; $i -= 2) {
|
||||
$checksum += (int) substr($string, $i, 1);
|
||||
}
|
||||
$checksum = $checksum * 3;
|
||||
for($i=strlen($string) - 2; $i >= 0; $i -= 2) {
|
||||
$checksum += (int) substr($string, $i, 1);
|
||||
}
|
||||
$string = $string.((10 - ($checksum % 10)) % 10);
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
for($i=0, $l=strlen($string); $i < $l; $i += 2) {
|
||||
$dummy = (int) substr($string, $i, 2);
|
||||
$dummy += ($dummy < 94? 33: 101);
|
||||
$result .= chr($dummy);
|
||||
|
||||
}
|
||||
|
||||
return '«'.$result.'»';
|
||||
}
|
||||
|
||||
private function isoreplace($str) {
|
||||
// ISO/CEI 646
|
||||
return str_replace(array(
|
||||
'Ç', 'ü', 'é', 'â', 'ä', 'à',
|
||||
'å', 'ç', 'ê', 'ë', 'è', 'ï',
|
||||
'î', 'ì', 'Ä', 'Å', 'É', 'æ',
|
||||
'Æ', 'ô', 'ö', 'ò', 'û', 'ù',
|
||||
'ÿ', 'Ö', 'Ü', '¢', '£', '¥',
|
||||
'₧', 'ƒ', 'á', 'í', 'ó', 'ú',
|
||||
'ñ', 'Ñ', 'ª', 'º', '¿', '⌐',
|
||||
'¬', '½', '¼', '¡', '«', '»',
|
||||
'░', '▒', '▓', '│', '┤', '╡',
|
||||
'╢', '╖', '╕', '╣', '║', '╗',
|
||||
'╝', '╜', '╛', '┐', '└', '┴',
|
||||
'┬', '├', '─', '┼', '╞', '╟',
|
||||
'╚', '╔', '╩', '╦', '╠', '═',
|
||||
'╬', '╧', '╨', '╤', '╥', '╙',
|
||||
'╘', '╒', '╓', '╫', '╪', '┘',
|
||||
'┌', '█', '▄', '▌', '▐', '▀',
|
||||
'α', 'ß', 'Γ', 'π', 'Σ', 'σ',
|
||||
'µ', 'τ', 'Φ', 'Θ', 'Ω', 'δ',
|
||||
'∞', 'φ', 'ε', '∩', '≡', '±',
|
||||
'≥', '≤', '⌠', '⌡', '÷', '≈',
|
||||
'°', '∙', '·', '√', 'ⁿ', '²',
|
||||
'■', 'Ê',
|
||||
), array(
|
||||
chr(128), chr(129), chr(130), chr(131), chr(132), chr(133),
|
||||
chr(134), chr(135), chr(136), chr(137), chr(138), chr(139),
|
||||
chr(140), chr(141), chr(142), chr(143), chr(144), chr(145),
|
||||
chr(146), chr(147), chr(148), chr(149), chr(150), chr(151),
|
||||
chr(152), chr(153), chr(154), chr(155), chr(156), chr(157),
|
||||
chr(158), chr(159), chr(160), chr(161), chr(162), chr(163),
|
||||
chr(164), chr(165), chr(166), chr(167), chr(165), chr(166),
|
||||
chr(167), chr(168), chr(169), chr(170), chr(174), chr(175),
|
||||
chr(173), chr(174), chr(175), chr(176), chr(177), chr(178),
|
||||
chr(179), chr(180), chr(181), chr(182), chr(183), chr(184),
|
||||
chr(185), chr(186), chr(187), chr(188), chr(189), chr(190),
|
||||
chr(191), chr(192), chr(193), chr(194), chr(195), chr(196),
|
||||
chr(197), chr(198), chr(199), chr(200), chr(201), chr(202),
|
||||
chr(203), chr(204), chr(205), chr(206), chr(207), chr(208),
|
||||
chr(209), chr(210), chr(211), chr(209), chr(210), chr(211),
|
||||
chr(212), chr(213), chr(214), chr(215), chr(216), chr(217),
|
||||
chr(218), chr(219), chr(220), chr(221), chr(222), chr(223),
|
||||
chr(224), chr(225), chr(226), chr(227), chr(228), chr(229),
|
||||
chr(230), chr(231), chr(232), chr(233), chr(234), chr(235),
|
||||
chr(236), chr(237), chr(238), chr(239), chr(240), chr(241),
|
||||
chr(242), chr(243), chr(244), chr(245), chr(246), chr(247),
|
||||
chr(248), chr(249), chr(250), chr(251), chr(252), chr(253),
|
||||
chr(254), chr(210),
|
||||
), $str);
|
||||
}
|
||||
|
||||
public function logParcel($shipping_data, $products) {
|
||||
global $cookie;
|
||||
|
||||
foreach($products as $id_order_detail => $qty) {
|
||||
if($qty > 0) {
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'mondialrelay_parcel` VALUES (
|
||||
'.(int) $id_order_detail.',
|
||||
'.(int) $cookie->id_employee.',
|
||||
'.(int) $qty.',
|
||||
"'.pSQL($shipping_data['shipping_number']).'",
|
||||
"'.pSQL($shipping_data['idrelay']).'",
|
||||
"'.pSQL($shipping_data['plantri']['cppay']).'",
|
||||
"'.pSQL($shipping_data['plantri']['nogroup']).'",
|
||||
"'.pSQL($shipping_data['plantri']['modexp']).'",
|
||||
"'.pSQL($shipping_data['plantri']['pretri']).'",
|
||||
"'.pSQL($shipping_data['plantri']['navette']).'",
|
||||
"'.pSQL($shipping_data['plantri']['direction']).'",
|
||||
"'.pSQL($shipping_data['mode']).'",
|
||||
"'.pSQL($shipping_data['expedition_number']).'",
|
||||
'.(float) $shipping_data['weight'].',
|
||||
NOW(),
|
||||
"0000-00-00 00:00:00"
|
||||
)
|
||||
');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addOrderHistory($shipping_data, $order, $products_sent) {
|
||||
}
|
||||
|
||||
public function __addOrderHistory($shipping_data, $order, $products_sent) {
|
||||
global $cookie;
|
||||
|
||||
// $MONDIALRELAY_carrier_id = unserialize(Configuration::get('MONDIALRELAY_CARRIERS'));
|
||||
// $MONDIALRELAY_carrier_id = (int) array_pop($exapaq_carrier_id);
|
||||
$id_carrier = (int) $order->id_carrier;
|
||||
$mr_carriers = array();
|
||||
foreach (Db::getInstance()->executeS('
|
||||
SELECT `id_carrier`
|
||||
FROM `' . _DB_PREFIX_ . 'mr_method`
|
||||
ORDER BY `is_deleted` ASC') as $carrier) {
|
||||
$mr_carriers = (int) $carrier['id_carrier'];
|
||||
}
|
||||
if (!in_array($id_carrier, $mr_carriers))
|
||||
$id_carrier = $mr_carriers[0];
|
||||
|
||||
|
||||
$carrier = new Carrier($id_carrier, (int) $order->id_lang);
|
||||
$customer = new Customer((int) $order->id_customer);
|
||||
|
||||
if((int) $order->id_lang == 3) {
|
||||
$content_html = '<strong>Contenido del paquete:</strong>';
|
||||
$content_txt = 'Contenido del paquete:';
|
||||
} elseif((int) $order->id_lang == 5) {
|
||||
$content_html = '<strong>Contenuto del package:</strong>';
|
||||
$content_txt = 'Contenuto del package:';
|
||||
} else {
|
||||
$content_html = '<strong>Contenu du colis :</strong>';
|
||||
$content_txt = 'Contenu du colis :';
|
||||
}
|
||||
|
||||
$templateVars = array(
|
||||
'{followup}' => str_replace('@', $shipping_data['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 = FALSE;
|
||||
$products_sent = array();
|
||||
|
||||
$order_details = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT `id_order_detail`
|
||||
FROM `'._DB_PREFIX_.'order_detail`
|
||||
WHERE `id_order` = '.(int) $order->id.'
|
||||
') as $row) {
|
||||
$order_details[] = (int) $row['id_order_detail'];
|
||||
}
|
||||
|
||||
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`
|
||||
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((int) $quantity_remain['remain'] == 0) {
|
||||
$products_sent[] = (int) $quantity_remain['id_order_detail'];
|
||||
}
|
||||
}
|
||||
|
||||
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`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'exapaqws` 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((int) $quantity_remain['remain'] == 0) {
|
||||
$products_sent[] = (int) $quantity_remain['id_order_detail'];
|
||||
}
|
||||
}
|
||||
|
||||
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`
|
||||
FROM `'._DB_PREFIX_.'order_detail` d
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'mondialrelay_parcel` 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((int) $quantity_remain['remain'] == 0) {
|
||||
$products_sent[] = (int) $quantity_remain['id_order_detail'];
|
||||
}
|
||||
}
|
||||
|
||||
$remaining = array();
|
||||
foreach($order_details as $d) {
|
||||
if(!in_array($d, $products_sent)) {
|
||||
$remaining[] = (int) $d;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($remaining) == 0) {
|
||||
$fully_sent = TRUE;
|
||||
} else {
|
||||
$id_sales = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT c.`id_sale`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
|
||||
ON c.`id_product` = d.`product_id`
|
||||
WHERE d.`id_order_detail` IN ('.implode(', ', $remaining).')
|
||||
') as $row) {
|
||||
$id_sales[] = (int) $row['id_sale'];
|
||||
}
|
||||
|
||||
$sent_sales = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT `id_sale`
|
||||
FROM `'._DB_PREFIX_.'shipping_history`
|
||||
WHERE `id_order` = '.(int) $order->id.'
|
||||
AND `id_sale` IN ('.implode(', ', $id_sales).')
|
||||
') as $row) {
|
||||
$sent_sales[] = (int) $row['id_sale'];
|
||||
}
|
||||
|
||||
$remaining = array();
|
||||
foreach($id_sales as $s) {
|
||||
if(!in_array($s, $sent_sales)) {
|
||||
$remaining[] = (int) $s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$fully_sent = (count($remaining) == 0);
|
||||
}
|
||||
|
||||
$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';
|
||||
// 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
|
||||
// );
|
||||
}
|
||||
}
|
56952
modules/logistics/carriers/mondialrelay/pltri.txt
Executable file
56952
modules/logistics/carriers/mondialrelay/pltri.txt
Executable file
File diff suppressed because it is too large
Load Diff
192
modules/logistics/carriers/mondialrelay/print_summary.tpl
Normal file
192
modules/logistics/carriers/mondialrelay/print_summary.tpl
Normal file
@ -0,0 +1,192 @@
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">{literal}
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: sans-serif;
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
thead th, .bar {
|
||||
background: #cccccc;
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
thead th, tbody td {
|
||||
padding: 2px 4px;
|
||||
}
|
||||
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.width1 {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.width0 {
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.border td {
|
||||
width: 250px;
|
||||
border: 1px solid #000000;
|
||||
padding: 10px;
|
||||
}
|
||||
{/literal}</style>
|
||||
</head>
|
||||
<body>
|
||||
{literal}
|
||||
<!--mpdf
|
||||
<htmlpagefooter name="myfooter">
|
||||
<div style="text-align: right;">
|
||||
Page {PAGENO}/{nb}
|
||||
</div>
|
||||
</htmlpagefooter>
|
||||
|
||||
<sethtmlpagefooter name="myfooter" value="on" />
|
||||
mpdf-->
|
||||
{/literal}
|
||||
<table>
|
||||
<tr>
|
||||
<td>SITE DE PRISE EN CHARGE : {$site_code}</td>
|
||||
<td class="right strong">BORDEREAU DE REMISE Offre Entreprises So Colissimo</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">LIBELLE SITE DE PRISE EN CHARGE : {$site}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="width1">N° CLIENT</td><td class="width0">:</td><td>{$contract}</td>
|
||||
<td class="right">EDITE LE {$date}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="width1">LIBELLE CLIENT</td><td class="width0">:</td>
|
||||
<td colspan="2">{foreach $sender_lines as $line}{$line}<br />{/foreach}
|
||||
{$sender_postal} {$sender_city}<br /><br /><br /><br /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="width1">N° BORDEREAU</td><td class="width0">:</td><td colspan="2">{$summary_number} du {$date}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="strong" colspan="3"><br />{$title} - Compte de facturation : {$contract}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{assign var=i value=1}
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Ref exped</th><th>Adresse destinataire</th><th>N° colis</th><th>CPOST</th><th>CPAYS</th><th>Poids</th><th>N</th><th>CRBT</th><th>VA</th>
|
||||
</th>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr><td class="bar" colspan="9"></td></tr>
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
<br />
|
||||
NOMBRE DES COLIS DE LA PAGE : {if $count_orders <= 46}
|
||||
{$count_orders}
|
||||
{else}
|
||||
46
|
||||
{/if}
|
||||
<br />
|
||||
POIDS DES COLIS DE LA PAGE : {if $count_orders <= 46}
|
||||
{$total_weight|number_format:2:',':''}
|
||||
{else}
|
||||
{(0.24*46)|number_format:2:',':''}
|
||||
{/if} KG<br />
|
||||
TOTAL CRBT DE LA PAGE : 0,00 EUR<br />
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
{foreach $orders as $order name=orders}
|
||||
<tr>
|
||||
<td>EXP{$order.id_order}</td>
|
||||
<td>{$order.lastname|cat:' - '|cat:$order.address1|truncate:60:''}</td>
|
||||
<td>{$order.shipping_number}</td>
|
||||
<td>{$order.postcode}</td>
|
||||
<td>FR</td>
|
||||
<td>0,24</td>
|
||||
<td>0</td>
|
||||
<td>000.00</td>
|
||||
<td>00</td>
|
||||
</tr>
|
||||
{if $smarty.foreach.orders.iteration % 46 == 0 && $smarty.foreach.orders.iteration != $smarty.foreach.orders.total}
|
||||
{assign var=i value=$i+1}
|
||||
</tbody>
|
||||
</table>
|
||||
<formfeed />
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Ref exped</th><th>Adresse destinataire</th><th>N° colis</th><th>CPOST</th><th>CPAYS</th><th>Poids</th><th>N</th><th>CRBT</th><th>VA</th>
|
||||
</th>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr><td class="bar" colspan="9"></td></tr>
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
<br />
|
||||
NOMBRE DES COLIS DE LA PAGE : {if $smarty.foreach.orders.iteration + 46 > $smarty.foreach.orders.total}
|
||||
{$smarty.foreach.orders.total - $smarty.foreach.orders.iteration}
|
||||
{else}
|
||||
46
|
||||
{/if}<br />
|
||||
POIDS DES COLIS DE LA PAGE : {if $smarty.foreach.orders.iteration + 46 > $smarty.foreach.orders.total}
|
||||
{(($smarty.foreach.orders.total - $smarty.foreach.orders.iteration)*0.24)|number_format:2:',':''}
|
||||
{else}
|
||||
{(46*0.24)|number_format:2:',':''}
|
||||
{/if} KG<br />
|
||||
TOTAL CRBT DE LA PAGE : 0,00 EUR<br />
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
<br /><br /><br />
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<br /><br />
|
||||
NOMBRE TOTAL DE COLIS : {$count_orders}<br />
|
||||
POIDS TOTAL DE COLIS : {$total_weight|number_format:2:',':''} KG<br />
|
||||
TOTAL CRBT : 0,00 EUR<br />
|
||||
<br />
|
||||
Nombre de pages : {literal} <!--mpdf {nb} mpdf--> {/literal}
|
||||
</td>
|
||||
<td class="right">
|
||||
<table class="border"><tr><td>
|
||||
SIGNATURE DE L'AGENT (*)<br />
|
||||
<br /><br /><br /><br />
|
||||
DATE<br /><br />
|
||||
</td></tr></table>
|
||||
<br /><br /><br />
|
||||
* Cette signature ne vaut pas validation des données indiquées par le client
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
7232
modules/logistics/carriers/mondialrelay/relais.txt
Executable file
7232
modules/logistics/carriers/mondialrelay/relais.txt
Executable file
File diff suppressed because it is too large
Load Diff
BIN
modules/mondialrelay/logo_64.png
Normal file
BIN
modules/mondialrelay/logo_64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
53
modules/mondialrelay/views/templates/admin/admin_order.tpl
Normal file
53
modules/mondialrelay/views/templates/admin/admin_order.tpl
Normal file
@ -0,0 +1,53 @@
|
||||
<br />
|
||||
<fieldset id="sf_panel" class="panel" style="width: 400px;">
|
||||
{*$edit_url*}
|
||||
<div class="float-left" style="width: 50%; float: left; text-align: center;">
|
||||
<img src="{$mondialrelay_logo|escape:'htmlall':'UTF-8'}" alt="Mondial Relay"><br />
|
||||
<br />
|
||||
<span class="sf_delivery_mode">
|
||||
<strong>{$mondialrelay_delivery_address.name|escape:'htmlall':'UTF-8'}
|
||||
{if $mondialrelay_delivery_address.MR_Selected_Num}
|
||||
<br />
|
||||
(#{$mondialrelay_delivery_address.MR_Selected_Num|escape:'htmlall':'UTF-8'})
|
||||
{/if}</strong>
|
||||
</span>
|
||||
</div>
|
||||
<div class="float-left" style="width: 50%; float: left;">
|
||||
<strong>{if $mondialrelay_recipient.company}{$mondialrelay_recipient.company|escape:'htmlall':'UTF-8'}
|
||||
<br />
|
||||
{/if}
|
||||
{$mondialrelay_recipient.firstname} {$mondialrelay_recipient.lastname}</strong><br />
|
||||
{if $mondialrelay_delivery_address}
|
||||
<span id="sf_address1">{$mondialrelay_delivery_address.MR_Selected_LgAdr1|escape:'htmlall':'UTF-8'}</span><br />
|
||||
{if $mondialrelay_delivery_address.MR_Selected_LgAdr2}{$mondialrelay_delivery_address.MR_Selected_LgAdr2|escape:'htmlall':'UTF-8'}
|
||||
<br />
|
||||
{/if}
|
||||
{if $mondialrelay_delivery_address.MR_Selected_LgAdr3}{$mondialrelay_delivery_address.MR_Selected_LgAdr3|escape:'htmlall':'UTF-8'}
|
||||
<br />
|
||||
{/if}
|
||||
{if $mondialrelay_delivery_address.MR_Selected_LgAdr4}{$mondialrelay_delivery_address.MR_Selected_LgAdr4|escape:'htmlall':'UTF-8'}
|
||||
<br />
|
||||
{/if}
|
||||
<span id="sf_postcode">{$mondialrelay_delivery_address.MR_Selected_CP|escape:'htmlall':'UTF-8'}</span> <span id="sf_city">{$mondialrelay_delivery_address.MR_Selected_Ville|escape:'htmlall':'UTF-8'}</span>
|
||||
<br />
|
||||
{assign var=mr_country_id value=Country::getIdByIso($mondialrelay_delivery_address.MR_Selected_Pays)}
|
||||
{if $mr_country_id == 245}
|
||||
{assign var=mr_country_id value=8}
|
||||
{/if}
|
||||
<span id="sf_country">{Country::getNameById(2, $mr_country_id)|strtoupper}</span><br />
|
||||
{else}
|
||||
<span id="sf_address1">{$mondialrelay_recipient.address1|escape:'htmlall':'UTF-8'}</span><br />
|
||||
{if $mondialrelay_recipient.address2}{$mondialrelay_recipient.address2|escape:'htmlall':'UTF-8'}
|
||||
<br />
|
||||
{/if}
|
||||
<span id="sf_postcode">{$mondialrelay_recipient.postcode|escape:'htmlall':'UTF-8'}</span> <span id="sf_city">{$mondialrelay_recipient.city|escape:'htmlall':'UTF-8'}</span>
|
||||
<br />
|
||||
{assign var=mr_country_id value=$mondialrelay_recipient.id_country}
|
||||
{if $mr_country_id == 245}
|
||||
{assign var=mr_country_id value=8}
|
||||
{/if}
|
||||
<span id="sf_country">{Country::getNameById(2, $mr_country_id)|strtoupper}</span><br />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="clearfix"> </div>
|
||||
</fieldset>
|
11
override/classes/Country.php
Normal file
11
override/classes/Country.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
class Country extends CountryCore {
|
||||
|
||||
public static function getIdByIso($iso_code=FALSE) {
|
||||
$isos = array(
|
||||
'AD' => 40, 'AE' => 217, 'AF' => 231, 'AG' => 43, 'AI' => 42, 'AL' => 230, 'AM' => 45, 'AN' => 157, 'AO' => 41, 'AQ' => 232, 'AR' => 44, 'AS' => 39, 'AT' => 2, 'AU' => 24, 'AW' => 46, 'AX' => 244, 'AZ' => 47, 'BA' => 233, 'BB' => 51, 'BD' => 50, 'BE' => 3, 'BF' => 60, 'BG' => 236, 'BH' => 49, 'BI' => 62, 'BJ' => 54, 'BL' => 179, 'BM' => 55, 'BN' => 59, 'BO' => 34, 'BR' => 58, 'BS' => 48, 'BT' => 56, 'BV' => 234, 'BW' => 57, 'BY' => 52, 'BZ' => 53, 'CA' => 4, 'CC' => 239, 'CD' => 71, 'CF' => 66, 'CG' => 72, 'CH' => 19, 'CI' => 32, 'CK' => 240, 'CL' => 68, 'CM' => 64, 'CN' => 5, 'CO' => 69, 'CR' => 73, 'CU' => 75, 'CV' => 65, 'CX' => 238, 'CY' => 76, 'CZ' => 16, 'DE' => 1, 'DJ' => 77, 'DK' => 20, 'DM' => 78, 'DO' => 79, 'DZ' => 38, 'EC' => 81, 'EE' => 86, 'EG' => 82, 'EH' => 226, 'ER' => 85, 'ES' => 6, 'ET' => 87, 'FI' => 7, 'FJ' => 90, 'FK' => 88, 'FM' => 146, 'FO' => 89, 'FR' => 8, 'FR' => 245, 'GA' => 91, 'GB' => 17, 'GD' => 95, 'GE' => 93, 'GF' => 241, 'GG' => 101, 'GH' => 94, 'GI' => 97, 'GL' => 96, 'GM' => 92, 'GN' => 102, 'GP' => 98, 'GQ' => 84, 'GR' => 9, 'GS' => 196, 'GT' => 100, 'GU' => 99, 'GW' => 103, 'GY' => 104, 'HK' => 22, 'HM' => 106, 'HN' => 108, 'HR' => 74, 'HT' => 105, 'HU' => 143, 'ID' => 111, 'IE' => 26, 'IL' => 29, 'IM' => 114, 'IN' => 110, 'IO' => 235, 'IQ' => 113, 'IR' => 112, 'IS' => 109, 'IT' => 10, 'JE' => 116, 'JM' => 115, 'JO' => 117, 'JP' => 11, 'KE' => 119, 'KG' => 123, 'KH' => 63, 'KI' => 120, 'KM' => 70, 'KN' => 180, 'KP' => 121, 'KR' => 28, 'KW' => 122, 'KY' => 237, 'KZ' => 118, 'LA' => 124, 'LB' => 126, 'LC' => 181, 'LI' => 130, 'LK' => 197, 'LR' => 128, 'LS' => 127, 'LT' => 131, 'LU' => 12, 'LV' => 125, 'LY' => 129, 'MA' => 152, 'MC' => 148, 'MD' => 147, 'ME' => 150, 'MF' => 182, 'MG' => 134, 'MH' => 140, 'MK' => 133, 'ML' => 138, 'MM' => 61, 'MN' => 149, 'MO' => 132, 'MP' => 163, 'MQ' => 141, 'MR' => 142, 'MS' => 151, 'MT' => 139, 'MU' => 35, 'MV' => 137, 'MW' => 135, 'MX' => 145, 'MY' => 136, 'MZ' => 153, 'NA' => 154, 'NC' => 158, 'NE' => 160, 'NF' => 162, 'NG' => 31, 'NI' => 159, 'NL' => 13, 'NO' => 23, 'NP' => 156, 'NR' => 155, 'NU' => 161, 'NZ' => 27, 'OM' => 164, 'PA' => 168, 'PE' => 171, 'PF' => 242, 'PG' => 169, 'PH' => 172, 'PK' => 165, 'PL' => 14, 'PM' => 183, 'PN' => 173, 'PR' => 174, 'PS' => 167, 'PT' => 15, 'PW' => 166, 'PY' => 170, 'QA' => 175, 'RE' => 176, 'RO' => 36, 'RS' => 190, 'RU' => 177, 'RW' => 178, 'SA' => 188, 'SB' => 194, 'SC' => 191, 'SD' => 198, 'SE' => 18, 'SG' => 25, 'SI' => 193, 'SJ' => 200, 'SK' => 37, 'SL' => 192, 'SM' => 186, 'SN' => 189, 'SO' => 195, 'SR' => 199, 'ST' => 187, 'SV' => 83, 'SY' => 202, 'SZ' => 201, 'TC' => 213, 'TD' => 67, 'TF' => 243, 'TG' => 33, 'TH' => 206, 'TJ' => 204, 'TK' => 207, 'TL' => 80, 'TM' => 212, 'TN' => 210, 'TO' => 208, 'TR' => 211, 'TT' => 209, 'TV' => 214, 'TW' => 203, 'TZ' => 205, 'UA' => 216, 'UG' => 215, 'US' => 21, 'UY' => 218, 'UZ' => 219, 'VA' => 107, 'VC' => 184, 'VE' => 221, 'VG' => 223, 'VI' => 224, 'VN' => 222, 'VU' => 220, 'WF' => 225, 'WS' => 185, 'YE' => 227, 'YT' => 144, 'ZA' => 30, 'ZM' => 228, 'ZW' => 229,
|
||||
);
|
||||
return isset($isos[strtoupper($iso_code)])? $isos[strtoupper($iso_code)]: 0;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user