diff --git a/modules/mondialrelay/mondialrelay.js b/modules/mondialrelay/mondialrelay.js
index 9944b587d..0c34688af 100755
--- a/modules/mondialrelay/mondialrelay.js
+++ b/modules/mondialrelay/mondialrelay.js
@@ -38,8 +38,7 @@ function getTickets(detailedExpeditionList)
{
type : 'POST',
url : _PS_MR_MODULE_DIR_ + 'ajax.php',
- data : {'detailedExpeditionList':detailedExpeditionList,
- 'method' : 'MRGetTickets'},
+ data : {'detailedExpeditionList':detailedExpeditionList, 'method':'MRGetTickets', 'mrtoken':mrtoken},
dataType: 'json',
success: function(json)
{
@@ -175,7 +174,8 @@ function generateTicketsAjax()
data : {'order_id_list' : order_id_list,
'numSelected' : numSelected,
'weight_list' : weight_list,
- 'method' : 'MRCreateTickets'},
+ 'method' : 'MRCreateTickets',
+ 'mrtoken' : mrtoken},
dataType: 'json',
success: function(json)
{
@@ -257,7 +257,8 @@ function deleteSelectedHistories()
url : _PS_MR_MODULE_DIR_ + 'ajax.php',
data : {'history_id_list' : history_id_list,
'numSelected' : numSelected,
- 'method' : 'DeleteHistory'},
+ 'method' : 'DeleteHistory',
+ 'mrtoken' : mrtoken},
dataType: 'json',
success: function(json)
{
@@ -267,7 +268,7 @@ function deleteSelectedHistories()
error: function(xhr, ajaxOptions, thrownError)
{
display_generate_button = true;
- displayBackHistoriesSubmitButton();
+ displayBackHistoriesSubmitButton();
}
});
}
@@ -387,7 +388,8 @@ function PS_MRAddSelectedRelayPointInDB(relayPointNumber, id_carrier)
'mrtoken' : mrtoken},
success: function(json)
{
-
+ if (PS_MROPC)
+ updateCarrierSelectionAndGift();
},
error: function(xhr, ajaxOptions, thrownError)
{
@@ -519,13 +521,20 @@ function PS_MRDisplayRelayPoint(json, blockContent, carrier_id)
contentBlockid = 'relayPoint_' + json.success[relayPoint].Num + '_' + carrier_id;
if (!$('#' + contentBlockid).size())
{
+ // Set translation if a preselection exist
+ var BtTranslation = (PS_MRPreSelectedRelay == json.success[relayPoint].Num) ?
+ PS_MRTranslationList['Selected'] : PS_MRTranslationList['Select'];
+
+ var classSelection = (PS_MRPreSelectedRelay == json.success[relayPoint].Num) ?
+ 'PS_MRFloatRelayPointSelected' : 'PS_MRFloatRelayPointSelecteIt';
+
$('
\

\
' + json.success[relayPoint].LgAdr1 + '
' + json.success[relayPoint].LgAdr3
+ ' - ' + json.success[relayPoint].CP + ' - ' + json.success[relayPoint].Ville
+ ' ' + json.success[relayPoint].Pays + '
\
-
').appendTo($(this).children('td'));
@@ -816,35 +825,41 @@ function PS_MRAddGMapMarker(id_carrier, relayPointNumber, contentBlockid)
PS_MRDisplayClickedGmapWindow(marker, relayInfo.Num, $(this));
}
},
- callback: function(marker)
- {
- if (marker)
+ callback: function(marker)
{
- // Check if the a marker list exist for the carrier,
- if (markerList[id_carrier] == undefined)
- markerList[id_carrier] = new Object();
-
- // Store the marker in the markerList of the carrier
- markerList[id_carrier][relayPointNumber] = marker;
-
- // Link all relay point line info to an action
- $('#' + contentBlockid).children('p').click(function()
+ if (marker)
{
- PS_MRDisplayGmap($(this).parent().attr('id'), GmapList[id_carrier]);
- });
- return true;
+ // Check if the a marker list exist for the carrier,
+ if (markerList[id_carrier] == undefined)
+ markerList[id_carrier] = new Object();
+
+ // Store the marker in the markerList of the carrier
+ markerList[id_carrier][relayPointNumber] = marker;
+
+ // Link all relay point line info to an action
+ $('#' + contentBlockid).children('p').click(function()
+ {
+ PS_MRDisplayGmap($(this).parent().attr('id'), GmapList[id_carrier]);
+ });
+ return true;
+ }
+ else
+ $('#' + contentBlockid).children('p').click(function()
+ {
+ PS_MROpenPopupDetail(relayInfo.permaLinkDetail);
+ });
}
- }
},
infowindow:
{
options: {content:detailContentHtml},
tag:relayInfo.Num,
- callback: function() {
- // To avoid any bug, foreach anytime the elements and try to close them
+ callback: function(infowindow) {
+
var windowList = $(this).gmap3({action:'get', name:'infowindow', all:true});
- for (var x in windowList)
- windowList[x].close();
+ $.each(windowList, function(i, elem) {
+ elem.close();
+ });
}
}
});
diff --git a/modules/mondialrelay/mondialrelay.php b/modules/mondialrelay/mondialrelay.php
index f40f170cd..641955f57 100755
--- a/modules/mondialrelay/mondialrelay.php
+++ b/modules/mondialrelay/mondialrelay.php
@@ -193,7 +193,8 @@ class MondialRelay extends Module
!$this->registerHook('extraCarrier') ||
!$this->registerHook('updateCarrier') ||
!$this->registerHook('newOrder') ||
- !$this->registerHook('BackOfficeHeader')))
+ !$this->registerHook('BackOfficeHeader') ||
+ !$this->registerHook('paymentTop')))
return false;
if (_PS_VERSION_ >= '1.4' &&
@@ -626,17 +627,16 @@ class MondialRelay extends Module
if ((Configuration::get('PS_SHIPPING_METHOD') AND (!Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->context->cart->getTotalWeight(), $id_zone))) OR
(!Configuration::get('PS_SHIPPING_METHOD') AND (!Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, self::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency))))
unset($carriersList[$k]);
- }
}
-
- // $address_map = $address->address1.', '.$address->postcode.', '.
- // MRTools::replaceAccentedCharacters($address->city).', '.$country->iso_code;
-
- $this->context->smarty->assign( array(
- 'one_page_checkout' => (Configuration::get('PS_ORDER_PROCESS_TYPE') ? Configuration::get('PS_ORDER_PROCESS_TYPE') : 0),
- 'new_base_dir' => self::$moduleURL,
+ }
+
+ $preSelectedRelay = $this->getRelayPointSelected($params['cart']->id);
+ $this->context->smarty->assign( array(
+ 'one_page_checkout' => (Configuration::get('PS_ORDER_PROCESS_TYPE') ? Configuration::get('PS_ORDER_PROCESS_TYPE') : 0),
+ 'new_base_dir' => self::$moduleURL,
'MRToken' => self::$MRFrontToken,
'carriersextra' => $carriersList,
+ 'preSelectedRelay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : '',
'jQueryOverload' => self::getJqueryCompatibility()));
return $this->display(__FILE__, 'mondialrelay.tpl');
@@ -1247,4 +1247,27 @@ class MondialRelay extends Module
return $statCode[$code];
return $this->l('This error isn\'t referred : ') . $code;
}
+
+ public function getRelayPointSelected($id_cart)
+ {
+ return Db::getInstance()->getRow('
+ SELECT s.`MR_selected_num`
+ FROM `'._DB_PREFIX_.'mr_selected` s
+ WHERE s.`id_cart` = '.(int)$id_cart);
+ }
+
+ public function isMondialRelayCarrier($id_carrier)
+ {
+ return Db::getInstance()->getRow('
+ SELECT `id_carrier`
+ FROM `'._DB_PREFIX_.'mr_method`
+ WHERE `id_carrier` = '.(int)$id_carrier);
+ }
+
+ public function hookpaymentTop($params)
+ {
+ if ($this->isMondialRelayCarrier($params['cart']->id_carrier) &&
+ !$this->getRelayPointSelected($params['cart']->id))
+ $params['cart']->id_carrier = 0;
+ }
}
diff --git a/modules/mondialrelay/mondialrelay.tpl b/modules/mondialrelay/mondialrelay.tpl
index 46fa38449..1b3a50b3c 100755
--- a/modules/mondialrelay/mondialrelay.tpl
+++ b/modules/mondialrelay/mondialrelay.tpl
@@ -32,10 +32,11 @@
// Global JS Value
var _PS_MR_MODULE_DIR_ = "{$new_base_dir}";
var mrtoken = "{$MRToken}";
- var one_page_checkout = {$one_page_checkout};
+ var PS_MROPC = {($one_page_checkout && (isset($opc) && $opc)) ? 1 : 0};
var PS_MRTranslationList = new Array();
var PS_MRCarrierMethodList = new Array();
var PS_MRSelectedRelayPoint = {literal}{{/literal}'carrier_id': 0, 'relayPointNum': 0{literal}}{/literal};
+ var PS_MRPreSelectedRelay = '{$preSelectedRelay}';
PS_MRTranslationList['Select'] = "{l s='Select' mod='mondialrelay'}";
PS_MRTranslationList['Selected'] = "{l s='Selected' mod='mondialrelay'}";