252 lines
14 KiB
PHP
252 lines
14 KiB
PHP
<?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']).'"
|
|
');
|
|
if($rel) {
|
|
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'].'
|
|
');
|
|
?>
|
|
|
|
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title></title>
|
|
|
|
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
|
<!-- <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> -->
|
|
<!--[if lt IE 9]>
|
|
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
|
<![endif]-->
|
|
<script type="text/javascript" src="<?php echo __PS_BASE_URI__.'adm/helpers/includes/js/bootstrap.min.js';?>"></script>
|
|
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>
|
|
<script type="text/javascript">
|
|
var ssl = true;
|
|
</script>
|
|
<script type="text/javascript" src="<?php echo __PS_BASE_URI__.'js/mondialrelay_widget.js';?>"></script>
|
|
<!-- <script type="text/javascript" src="https://widget.mondialrelay.com/parcelshop-picker/v3_2_1/scripts/jquery.plugin.mondialrelay.parcelshoppicker.min.js"></script> -->
|
|
<!-- <script type="text/javascript" src="http://widget.mondialrelay.com/parcelshop-picker/v3_2_1/scripts/jquery.plugin.mondialrelay.parcelshoppicker.min.js"></script> -->
|
|
<style>
|
|
@import url("<?php echo __PS_BASE_URI__.'adm/helpers/includes/css/bootstrap.min.css';?>");
|
|
@import url("<?php echo __PS_BASE_URI__.'adm/helpers/includes/jquery-ui-1.8.20.custom.css';?>");
|
|
@import url("<?php echo __PS_BASE_URI__.'adm/helpers/includes/css/custom.css';?>");
|
|
</style>
|
|
</head>
|
|
<body onload="<?php if(isset($_POST['submitMR'])) { ?>window.close();<?php } ?>">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-xs-4">
|
|
<div class="panel">
|
|
<div class="panel-title">
|
|
<h2>Info Destinataire</h2>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<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>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-xs-8">
|
|
<div class="panel">
|
|
<div class="panel-title">
|
|
<h2>Information Point relais</h2>
|
|
<div class="clearfix"></div>
|
|
</div>
|
|
<div class="panel-content">
|
|
<div class="row">
|
|
<div class="col-xs-7 col-xs-offset-3" style="margin-bottom: 20px;">
|
|
<span id="TargetDisplayInfoPR_Widget" />
|
|
</div>
|
|
</div>
|
|
<form class="form-horizontal" action="" method="post">
|
|
<div class="form-group">
|
|
<label class="col-xs-4 control-label">Adresse 1</label>
|
|
<div class="col-xs-8">
|
|
<input class="form-control" autocomplete="off" type="text" name="MR_Selected_LgAdr1" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr1'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-xs-4 control-label">Adresse 2</label>
|
|
<div class="col-xs-8">
|
|
<input class="form-control" autocomplete="off" type="text" name="MR_Selected_LgAdr2" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr2'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-xs-4 control-label">Adresse 3</label>
|
|
<div class="col-xs-8">
|
|
<input class="form-control" autocomplete="off" type="text" name="MR_Selected_LgAdr3" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr3'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-xs-4 control-label">Adresse 4</label>
|
|
<div class="col-xs-8">
|
|
<input class="form-control" autocomplete="off" type="text" name="MR_Selected_LgAdr4" readonly="true" value="<?php echo htmlentities($address['MR_Selected_LgAdr4'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-xs-4 control-label">Code postal</label>
|
|
<div class="col-xs-8">
|
|
<input class="form-control" autocomplete="off" type="text" name="MR_Selected_CP" readonly="true" value="<?php echo htmlentities($address['MR_Selected_CP'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-xs-4 control-label">Ville</label>
|
|
<div class="col-xs-8">
|
|
<input class="form-control" autocomplete="off" type="text" name="MR_Selected_Ville" readonly="true" value="<?php echo htmlentities($address['MR_Selected_Ville'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-xs-4 control-label">ID point retrait</label>
|
|
<div class="col-xs-8">
|
|
<input class="form-control" autocomplete="off" type="text" name="MR_Selected_Num" readonly="true" value="<?php echo htmlentities($address['MR_Selected_Num'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?>" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<input class="btn btn-primary pull-right" type="submit" value="Envoyer" name="submitMR" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<div id="Zone_Widget"></div>
|
|
|
|
|
|
</body>
|
|
|
|
<?php
|
|
echo '
|
|
<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);
|
|
}
|
|
|
|
var enseigne = "F1BEBEBO";
|
|
var isocode = "'.$address['MR_Selected_Pays'].'";
|
|
var postcode = "'.$address['MR_Selected_CP'].'";
|
|
var mode = "24R";
|
|
var weight = '.(int)($weight * 1000).';
|
|
if( weight == 0 ) weight = 100;
|
|
var t;
|
|
$(document).ready(function () {
|
|
$("#Zone_Widget").MR_ParcelShopPicker({
|
|
UseSSL : true,
|
|
Weight: weight,
|
|
Target: "#Target_Widget",
|
|
TargetDisplay: "#TargetDisplay_Widget",
|
|
TargetDisplayInfoPR: "#TargetDisplayInfoPR_Widget",
|
|
Brand: enseigne,
|
|
Country: isocode,
|
|
PostCode: postcode,
|
|
ColLivMod: mode,
|
|
NbResults: "15",
|
|
DisplayMapInfo: true,
|
|
OnParcelShopSelected: function (data) {
|
|
updateForm("24R",data.Nom,"",data.Adresse1,data.Adresse2,data.CP,data.Ville,data.ID);
|
|
$("#cb_ID").html(data.ID);
|
|
$("#cb_Nom").html(data.Nom);
|
|
$("#cb_Adresse").html(data.Adresse1 + " " + data.Adresse2);
|
|
$("#cb_CP").html(data.CP);
|
|
$("#cb_Ville").html(data.Ville);
|
|
$("#cb_Pays").html(data.Pays);
|
|
}
|
|
});
|
|
});
|
|
</script>';
|
|
?>
|
|
</html>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|