fix conflcit

This commit is contained in:
Marion Muszynski 2016-10-12 12:42:41 +02:00
commit 385561fc7c
8 changed files with 478 additions and 9 deletions

View File

@ -0,0 +1,38 @@
<?php
require_once(dirname(__FILE__).'../../../config/config.inc.php');
require_once(dirname(__FILE__).'../../../init.php');
require_once(dirname(__FILE__).'../../../modules/ant_changeaddress/ant_changeaddress.php');
$ant_changeaddress = new Ant_Changeaddress();
if($cookie->isLogged() && Tools::getValue('id_order')) {
if(Tools::getValue('getPR')
&& ($mode = (float) Tools::getValue('mode'))
&& ($h_xcoords = (float) Tools::getValue('h_xcoords'))
&& ($h_ycoords = (float) Tools::getValue('h_ycoords'))) {
$pr_list = array();
header('Content-Type: text/json');
die(json_encode(Db::getInstance()->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'lapostews_pr`
WHERE `ycoords` >= '.(float) $h_ycoords.' - 0.02
AND `ycoords` <= '.(float) $h_ycoords.' + 0.02
AND `xcoords` >= '.(float) $h_xcoords.' - 0.01
AND `xcoords` <= '.(float) $h_xcoords.' + 0.01
AND `type` = "'.$mode.'"
')));
}
if(Tools::getValue('getAD')
&& ($id_address = Tools::getValue('id_address'))) {
$change_address = $ant_changeaddress->getAddress($id_address);
$html = '';
foreach ($change_address as $key => $value) {
$html .= '<li>'.$value.'</li>';
}
header('Content-Type: text/json');
die(json_encode($html));
}
die(json_encode('error1'));
} else {
die(json_encode('error'));
}

View File

@ -0,0 +1,57 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
class Ant_Changeaddress extends Module
{
public function __construct()
{
$this->name = 'ant_changeaddress';
$this->tab = 'administration';
$this->author = 'Antadis';
$this->version = '1.0';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Change délivery address');
$this->description = $this->l('Allow to change the delivery address before order is sent');
}
public function install()
{
if(!(parent::install())) {
return false;
}
return true;
}
public function uninstall()
{
if(parent::uninstall() == false) {
return false;
}
return true;
}
public function getAddress($id_address)
{
$current_address = array();
$delivery_address = new Address((int)$id_address);
$delivery_address = AddressFormat::getFormattedLayoutData($delivery_address);
foreach ($delivery_address['ordered'] as $key => $value) {
$addressKey = explode(" ", $value);
foreach ($addressKey as $k => $v) {
if (!empty($delivery_address['formated'][$v]) && $delivery_address['formated'][$v]) {
if (!isset($current_address[$key])) {
$current_address[$key] = $delivery_address['formated'][$v];
} else {
$current_address[$key] .= " ".$delivery_address['formated'][$v];
}
}
}
}
return $current_address;
}
}

View File

@ -0,0 +1,56 @@
#module-ant_changeaddress-change_address #center_column h1{
background: #fff;
margin-top: 10px;
}
#module-ant_changeaddress-change_address #center_column form{
background: #fff;
padding: 20px;
-moz-box-shadow: 2px 2px 5px #cccccc;
-webkit-box-shadow: 2px 2px 5px #CCC;
-ms-box-shadow: 2px 2px 5px #cccccc;
-o-box-shadow: 2px 2px 5px #cccccc;
box-shadow: 2px 2px 5px #CCC;
text-align: center;
}
#module-ant_changeaddress-change_address #center_column form p.info{
font-size: 14px;
color: #514c8c;
}
#module-ant_changeaddress-change_address #center_column .button_large{
text-align: center;
text-transform: none;
border: 0px;
color: #FFF;
font-size: 12px;
padding: 8px 20px 8px 20px;
text-decoration: none;
font-weight: normal;
/* background: #504d8b url(../img/arrow.png) right 9px no-repeat; */
background: #504d8b;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
font-family: georgia, times new roman, serif;
font-style: italic;
font-size: 13px;
}
#module-ant_changeaddress-change_address #center_column .address_box{
width: auto;
max-width: 250px;
margin: 0 auto;
list-style: none;
padding: 10px;
-moz-box-shadow:
-moz-box-shadow: 0px 3px 5px 2px #cccccc;
-webkit-box-shadow: 0px 3px 5px 2px #CCC;
-ms-box-shadow: 0px 3px 5px 2px #cccccc;
-o-box-shadow: 0px 3px 5px 2px #cccccc;
box-shadow: 0px 3px 5px 2px #CCC;
}
#module-ant_changeaddress-change_address #center_column .address_box li:first-child{
font-weight: bold;
}
#module-ant_changeaddress-change_address #center_column form .submit_buttons{
margin: 20px auto;
text-align: center;
}

View File

@ -0,0 +1,148 @@
<?php
require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/../../modules/ant_changeaddress/ant_changeaddress.php');
$controller->preProcess();
$ant_changeaddress = new Ant_Changeaddress();
$lang = (int) $cookie->id_lang;
$isolang = Language::getIsoById($lang);
$errors = array();
if ($cookie->isLogged()) {
$smarty->assign('isLogged', 1);
$customer = new Customer((int)($cookie->id_customer));
if (!Validate::isLoadedObject($customer)) {
die(Tools::displayError('Customer not found'));
}
if(Tools::getValue('id_order')) {
$id_order = Tools::getValue('id_order');
$order = new Order((int) $id_order);
$order_cart = new Cart((int) $order->id_cart);
if((int)$order->id_customer != (int)$customer->id) {
$errors[] = Tools::displayError('Invalid customer for this order');
} else {
$address = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
WHERE id_cart = '.pSQL(intval($order->id_cart)).'
');
if ($address) {
if ($address['delivery_mode'] == "DOM"){
$delivery_mode = "DOM";
$mode = array(
'2' => 'Livraison à domicile (DOM)',
'3' => 'Livraison à domicile (DOM)',
);
} elseif($address['delivery_mode'] == "BPR") {
$delivery_mode = "BPR";
$mode = array(
'2' => 'Livraison en Bureau de Poste (BPR)',
'3' => 'Livraison en Bureau de Poste (BPR)',
);
} elseif($address['delivery_mode'] == "A2P"){
$delivery_mode = "A2P";
$mode = array(
'2' => 'Livraison Commerce de proximité (A2P)',
'3' => 'Livraison Commerce de proximité (A2P)',
);
}
if ($delivery_mode == "BPR" || $delivery_mode == "A2P") {
$pr_coords = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'lapostews_pr`
WHERE `id_pr` = '.pSQL($address['prid']).'
');
$c_address = htmlentities(preg_replace('/(, ){2,}/', ', ', preg_replace('/(, ){2,}/', ', ', implode(', ', array($address['pradress3'], $address['pradress4'], $address['pradress1'], $address['pradress2']))).', '.$address['przipcode'].' '.$address['prtown'].', FRANCE'));
//echo '<pre>';var_dump($c_address);echo '</pre>';die();
$smarty->assign(array(
'c_address' => $c_address,
//'pr_coords' => $pr_coords
));
}
} else {
$delivery_mode = "DOM";
}
$current_address = $ant_changeaddress->getAddress($order->id_address_delivery);
$smarty->assign(array(
'current_address' => $current_address,
'addresses' => $customer->getAddresses((int)$cookie->id_lang)
));
$smarty->assign(array(
'address' => $address,
'mode' => $mode,
'delivery_mode' => $delivery_mode,
'order' => $order,
'order_cart' => $order_cart,
));
}
} else {
$errors[] = Tools::displayError('Invalid order');
}
if(isset($_POST['submitChangeAddress'])) {
$mode = Tools::getValue('delivery_mode','');
if (empty($mode)) {
$mode = "DOM";
}
Db::getInstance()->Execute('UPDATE ps_socolissimo_delivery_info SET
delivery_mode = "'.pSQL($mode).'",
prname = "'.pSQL(Tools::getValue('prname', '')).'",
prfirstname = "'.pSQL(Tools::getValue('prfirstname', '')).'",
cecompanyname = "'.pSQL(Tools::getValue('cecompanyname', '')).'",
cename = "'.pSQL(Tools::getValue('cename', '')).'",
cefirstname = "'.pSQL(Tools::getValue('cefirstname', '')).'",
prcompladress = "'.pSQL(Tools::getValue('prcompladress', '')).'",
pradress1 = "'.pSQL(Tools::getValue('pradress1', '')).'",
pradress2 = "'.pSQL(Tools::getValue('pradress2', '')).'",
pradress3 = "'.pSQL(Tools::getValue('pradress3', '')).'",
pradress4 = "'.pSQL(Tools::getValue('pradress4', '')).'",
przipcode = "'.pSQL(Tools::getValue('przipcode', '')).'",
prtown = "'.pSQL(Tools::getValue('prtown', '')).'",
cephonenumber = "'.pSQL(Tools::getValue('cephonenumber', '')).'",
ceemail = "'.pSQL(Tools::getValue('ceemail', '')).'",
cedeliveryinformation = "'.pSQL(Tools::getValue('cedeliveryinformation', '')).'",
cedoorcode1 = "'.pSQL(Tools::getValue('cedoorcode1', '')).'",
cedoorcode2 = "'.pSQL(Tools::getValue('cedoorcode2', '')).'",
prid = "'.pSQL(Tools::getValue('prid', '')).'"
WHERE id_cart = '.pSQL(intval(Tools::getValue('id_cart'))));
$order = Db::getInstance()->getRow('
SELECT date_add,id_order
FROM `'._DB_PREFIX_.'orders`
WHERE id_cart = '.pSQL(intval(Tools::getValue('id_cart'))).'
');
mail('marion@antadis.com', '[BBB] Modif transporteur FRONT',
'ID Customer : ' . $address['id_customer'].
' , ID Order : ' . $order['id_order'].
' , Date Order : ' . $order['date_add'].
' , Date now : ' . date("Y-m-d H:i:s").
' , ID cart : ' . Tools::getValue('id_cart').
' , Mode en date : '.$address['delivery_mode'].' -- remplacé par : ' .Tools::getValue('delivery_mode', '').
' , Address1 en date : '.$address['pradress1'].' -- remplacé par : ' .Tools::getValue('pradress1', '').
' , Address2 en date : '.$address['pradress2'].' -- remplacé par : ' .Tools::getValue('pradress2', '').
' , Address3 en date : '.$address['pradress3'].' -- remplacé par : ' .Tools::getValue('pradress3', '').
' , Address4 en date : '.$address['pradress4'].' -- remplacé par : ' .Tools::getValue('pradress4', '')
);
}
}
$smarty->assign(array(
'errors' => $errors,
));
$_POST = array_merge($_POST, $_GET);
require_once(dirname(__FILE__).'/../../header.php');
echo Module::display(dirname(__FILE__), 'change_address.tpl');
require_once(dirname(__FILE__).'/../../footer.php');

View File

@ -0,0 +1,168 @@
<link media="all" type="text/css" rel="stylesheet" href="{$base_dir_ssl}modules/ant_changeaddress/change_address.css">
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
<h1>{l s='Change your delivery address for this order'}</h1>
{if $current_address}
<form action="{$request_uri|escape:'htmlall':'UTF-8'}" class="std" method="post">
<fieldset>
<h3>{$mode[$cookie->id_lang]}</h3>
<p class="info">{l s='For reasons of tarification, you cannot change the delivery mode'}</p>
{if $delivery_mode == "DOM"}
<p class="address_delivery select">
<label for="id_address_delivery">{l s='Choose a delivery address:'}</label>
<select name="id_address_delivery" id="id_address_delivery" class="address_select">
{foreach from=$addresses key=k item=address}
<option value="{$address.id_address|intval}" {if $address.id_address == $order_cart->id_address_delivery}selected="selected"{/if}>{$address.alias|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
</p>
<ul class="address_box" >
{if !empty($current_address)}
{foreach from=$current_address name=address item=line}
<li>{$line}</li>
{/foreach}
{/if}
</ul>
{elseif $delivery_mode == "BPR" || $delivery_mode == "A2P"}
<ul class="address_box" >
{if !empty($current_address)}
{foreach from=$current_address name=address item=line}
<li>{$line}</li>
{/foreach}
{/if}
</ul>
{* <p>
<label>{l s='Name'}</label>
<input autocomplete="off" type="text" name="prname" value="{addslashes($address['prname'])}" />
</p>
<p>
<label>{l s='Firstname'}</label>
<input autocomplete="off" type="text" name="prfirstname" value="{addslashes($address['prfirstname'])}" />
</p>
<p>
<label>{l s='Phone'}</label>
<input autocomplete="off" type="text" name="cephonenumber" value="{addslashes($address['cephonenumber'])}" />
</p>
<p>
<label>{l s='Email'}</label>
<input autocomplete="off" type="text" name="ceemail" value="{addslashes($address['ceemail'])}" />
</p>
<p>
<label>{l s='Company'}</label>
<input autocomplete="off" type="text" name="cecompanyname" value="{addslashes($address['cecompanyname'])}" />
</p> *}
<div id="map_canvas"></div><div id="pr_list"><ul></ul></div>
{/if}
<p class="submit_buttons">
{if $delivery_mode == "DOM"}
<a href="{$link->getPageLink('address.php', true)}" title="{l s='Add'}" class="button_large">{l s='Add a new address'}</a>
{/if}
<input type="submit" name="submitChandAddress" class="button_large" value="{l s='Update'}">
</p>
</fieldset>
</form>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="{$base_dir_ssl}js/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="{$base_dir_ssl}js/jquery/jquery.ui.map.js"></script>
<script type="text/javascript" src="{$base_dir_ssl}js/jquery/jquery.ui.map.services.js"></script>
<script type="text/javascript">
{literal}
$("#id_address_delivery").change(function(){
var id_address = $("#id_address_delivery").val();
$.ajax({
type: 'POST',
url: '{/literal}{$base_dir_ssl}{literal}modules/ant_changeaddress/ajax.php',
dataType: 'json',
data: {
id_order : {/literal}{$order->id}{literal},
getAD : 1,
id_address : id_address,
token : static_token
},
success: function(jsonData) {
$("ul.address_box").empty();
$("ul.address_box").html(jsonData);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to get update address \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
});
markers = [];
delivery_modes = {};
delivery_modes['{/literal}{$delivery_mode}{literal}'] = "{/literal}{$mode[$cookie->id_lang]}{literal}";
$("#map_canvas").gmap({/literal}{if $pr_coords}{literal}'{ "center": "{/literal}{$pr_coords['xcoords']}{literal},{/literal}{$pr_coords['ycoords']}{literal}"}'{/literal}{/if}{literal}).bind("init", function(ev, map) {
$("#map_canvas").gmap("search", {"address": "{/literal}{$c_address}{literal}"}, 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);
});
$.ajax({
type: 'POST',
url: '{/literal}{$base_dir_ssl}{literal}modules/ant_changeaddress/ajax.php',
dataType: 'json',
data: {
id_order : {/literal}{$order->id}{literal},
id_cart : {/literal}{$order_cart->id}{literal},
getPR : 1,
h_xcoords : lat,
h_ycoords : lng,
mode : "{/literal}{$delivery_mode}{literal}",
token : static_token
},
success: function(data) {
if(data) {
for(var i=0; i < data.length; i++) {
var prtext = [delivery_modes[data[i].type], data[i].name, data[i].address1, data[i].address2, data[i].address3, data[i].address4, data[i].postcode + " " + data[i].city].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_" + data[i].id_pr, "position": data[i].xcoords + "," + data[i].ycoords, "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).attr("data-content", $.param(data[i])).html(prtext).click(function() {
var data = $.deparam($(this).attr("data-content"));
$.each(markers, function(id, el) {
if(el[0].id == "pr_" + data.id_pr) {
google.maps.event.trigger(el[0], "click");
}
});
$("#map_canvas").gmap("option", "center", markers[parseInt($(this).attr("data-index"))][0].getPosition());
updateForm(data.type, data.name, data.address1, data.address2, data.address3, data.address4, data.postcode, data.city, data.id_pr);
});
$("#pr_list ul").append(litem);
}
}
}
});
}
});
});
{/literal}
</script>
{/if}

View File

@ -42,7 +42,7 @@
var cgv = acceptCGV();
if(cgv) {
// carrier = $("input[name='id_carrier']:checked","#form").val();
carrier_name = ""+$("input[name='id_carrier']:checked", "#form").data('name')+"";
carrier_name = ""+$("input[name='id_carrier']:checked", "#form").data('carrier-name')+"";
onStepComplete(3, carrier_name, null, null);
} else {
return cgv;
@ -139,7 +139,7 @@
{foreach from=$carriers item=carrier name=myLoop}
<tr class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{/if} {if $smarty.foreach.myLoop.index % 2}alternate_item{else}item{/if}">
<td class="carrier_action radio">
<input type="radio" name="id_carrier" value="{$carrier.id_carrier|intval}" data-name="{$carrier.name|escape:'htmlall':'UTF-8'}" id="id_carrier{$carrier.id_carrier|intval}" {if $opc}onclick="updateCarrierSelectionAndGift();"{/if} {if !($carrier.is_module AND $opc AND !$isLogged)}{if $carrier.id_carrier == $checked}checked="checked"{/if}{else}disabled="disabled"{/if} />
<input type="radio" name="id_carrier" value="{$carrier.id_carrier|intval}" data-carrier-name="{$carrier.name|escape:'htmlall':'UTF-8'}" id="id_carrier{$carrier.id_carrier|intval}" {if $opc}onclick="updateCarrierSelectionAndGift();"{/if} {if !($carrier.is_module AND $opc AND !$isLogged)}{if $carrier.id_carrier == $checked}checked="checked"{/if}{else}disabled="disabled"{/if} />
</td>
<td class="carrier_name">
<label for="id_carrier{$carrier.id_carrier|intval}">
@ -214,7 +214,7 @@
{foreach from=$carriers_ooh item=carrier name=myLoop}
<tr class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{/if} {if $smarty.foreach.myLoop.index % 2}alternate_item{else}item{/if}">
<td class="carrier_action radio">
<input type="radio" name="id_carrier" value="{$carrier.id_carrier|intval}" id="id_carrier{$carrier.id_carrier|intval}" {if $opc}onclick="updateCarrierSelectionAndGift();"{/if} {if !($carrier.is_module AND $opc AND !$isLogged)}{if $carrier.id_carrier == $checked}checked="checked"{/if}{else}disabled="disabled"{/if} />
<input type="radio" name="id_carrier" value="{$carrier.id_carrier|intval}" data-carrier-name="{$carrier.name|escape:'htmlall':'UTF-8'}" id="id_carrier{$carrier.id_carrier|intval}" {if $opc}onclick="updateCarrierSelectionAndGift();"{/if} {if !($carrier.is_module AND $opc AND !$isLogged)}{if $carrier.id_carrier == $checked}checked="checked"{/if}{else}disabled="disabled"{/if} />
</td>
<td class="carrier_name">
<label for="id_carrier{$carrier.id_carrier|intval}">

View File

@ -69,9 +69,9 @@
{if count($numbers) > 0}
<h4>{l s='Numero de suivi'}</h4>
<ul>
{foreach from=$numbers item=number}
{foreach from=$numbers item=number}
<li>
{l s='Numero de suivi'} <b>{$number.shipping_number}</b> <a target="_blank" href="http://www.colissimo.fr/portail_colissimo/suivreResultat.do?parcelnumber={$number.shipping_number}">({l s='Suivre le colis'})</a>
{l s='Numero de suivi'} <b>{$number.shipping_number}</b> <a target="_blank" href="http://www.colissimo.fr/portail_colissimo/suivreResultat.do?parcelnumber={$number.shipping_number}">({l s='Suivre le colis'})</a>
</li>
{/foreach}
</ul>
@ -118,7 +118,7 @@
{/foreach}
</ul>
<ul class="address alternate_item {if $order->isVirtual()}full_width{/if}">
<li class="address_title">{l s='Delivery'}</li>
<li class="address_title">{l s='Delivery'} {if in_array($order->getCurrentState(), array(1,2,3,9,10,11,12,13))}<a href="{$base_dir_ssl}modules/ant_changeaddress/change_address.php?id_order={$order->id}">{l s='(Modify)'}</a>{/if}</li>
{foreach from=$dlv_adr_fields name=dlv_loop item=field_item}
{if $field_item eq "company" && isset($address_delivery->company)}<li class="address_company">{$address_delivery->company|escape:'htmlall':'UTF-8'}</li>
{elseif $field_item eq "address2" && $address_delivery->address2}<li class="address_address2">{$address_delivery->address2|escape:'htmlall':'UTF-8'}</li>
@ -138,7 +138,7 @@
<p>
<b style="color: #e26ea2;">{$date.name}</b> : {l s='Date de réception prévue entre le'} <b>{$date.date_start|date_format:'%d/%m/%Y'}</b> {l s='et le'} <b>{$date.date_end|date_format:'%d/%m/%Y'}</b>
</p>
{/foreach}
{/foreach}
</div>
{/if}

View File

@ -54,15 +54,17 @@
window.location = $input.val();
}
} else {
$form = $input.parent().children('div.hidden').children('form');
$name = $form.attr('data-module-name');
// LOADER POUR PAYPAL
if ($input.attr('data-module-name') == "paypal") {
$('.overlay_bbb').fadeIn();
$('.box_paypal').fadeIn();
$name = 'paypal';
}
$form = $input.parent().children('div.hidden').children('form');
if (window.ga && ga.create){
// submit form by GA send event
onStepComplete(4, $form.attr('data-module-name'),null,$form);
onStepComplete(4, $name,null,$form);
} else {
$form.submit();
}