diff --git a/modules/mondialrelay/classes/MRCreateTickets.php b/modules/mondialrelay/classes/MRCreateTickets.php index 66a4553e4..03cd81076 100755 --- a/modules/mondialrelay/classes/MRCreateTickets.php +++ b/modules/mondialrelay/classes/MRCreateTickets.php @@ -286,8 +286,7 @@ class MRCreateTickets implements IMondialRelayWSMethod $this->_fields['list']['Expe_Pays']['value'] = Country::getIsoById(Configuration::get('PS_SHOP_COUNTRY_ID')); else $this->_fields['list']['Expe_Pays']['value'] = substr(Configuration::get('PS_SHOP_COUNTRY'), 0, 2); - - $this->_fields['list']['Expe_Tel1']['value'] = str_replace(array('.', ' ', '-'), '', Configuration::get('PS_SHOP_PHONE')); + $this->_fields['list']['Expe_Tel1']['value'] = str_replace(array('.', ' ', '-', '_'), '', Configuration::get('PS_SHOP_PHONE')); $this->_fields['list']['Expe_Mail']['value'] = Configuration::get('PS_SHOP_EMAIL'); $this->_fields['list']['NbColis']['value'] = 1; $this->_fields['list']['CRT_Valeur']['value'] = 0; @@ -331,15 +330,15 @@ class MRCreateTickets implements IMondialRelayWSMethod $tmp['NDossier']['value'] = $orderDetail['id_order']; $tmp['NClient']['value'] = $orderDetail['id_customer']; $tmp['Dest_Langage']['value'] = 'FR'; //Language::getIsoById($orderDetail['id_lang']); - $tmp['Dest_Ad1']['value'] = $deliveriesAddress->firstname.' '.$deliveriesAddress->lastname; - $tmp['Dest_Ad2']['value'] = $deliveriesAddress->address2; - $tmp['Dest_Ad3']['value'] = $deliveriesAddress->address1; + $tmp['Dest_Ad1']['value'] = substr($deliveriesAddress->firstname.' '.$deliveriesAddress->lastname, 0, 32);; + $tmp['Dest_Ad2']['value'] = substr($deliveriesAddress->address2, 0, 32); + $tmp['Dest_Ad3']['value'] = substr($deliveriesAddress->address1, 0, 32); $tmp['Dest_Ville']['value'] = $deliveriesAddress->city; $tmp['Dest_CP']['value'] = $deliveriesAddress->postcode; $tmp['Dest_CP']['params']['id_country'] = $deliveriesAddress->id_country; $tmp['Dest_Pays']['value'] = $destIsoCode; - $tmp['Dest_Tel1']['value'] = $deliveriesAddress->phone; - $tmp['Dest_Tel2']['value'] = $deliveriesAddress->phone_mobile; + $tmp['Dest_Tel1']['value'] = str_replace(array('.', ' ', '-', '_'), '', $deliveriesAddress->phone); + $tmp['Dest_Tel2']['value'] = str_replace(array('.', ' ', '-', '_'), '', $deliveriesAddress->phone_mobile); $tmp['Dest_Mail']['value'] = $customer->email; $tmp['Assurance']['value'] = $orderDetail['mr_ModeAss']; if ($orderDetail['MR_Selected_Num'] != 'LD1' && $orderDetail['MR_Selected_Num'] != 'LDS') diff --git a/modules/mondialrelay/classes/MRGetRelayPoint.php b/modules/mondialrelay/classes/MRGetRelayPoint.php index 525f9215a..2ee2d0ba1 100755 --- a/modules/mondialrelay/classes/MRGetRelayPoint.php +++ b/modules/mondialrelay/classes/MRGetRelayPoint.php @@ -151,7 +151,7 @@ class MRGetRelayPoint implements IMondialRelayWSMethod } } $concatenationValue .= $this->_webServiceKey; - $this->_fields['list']['Security']['value' ] = strtoupper(md5($concatenationValue)); + $this->_fields['list']['Security']['value'] = strtoupper(md5($concatenationValue)); } /* @@ -238,7 +238,7 @@ class MRGetRelayPoint implements IMondialRelayWSMethod } if ($totalEmptyFields == count($relayPoint)) unset($result[$num]); - } + } if (!count($result)) $errors[] = $this->_mondialRelay->l('MondialRelay can\'t find any relay point near your address. Maybe your address isn\'t properly filled ?'); else diff --git a/modules/mondialrelay/classes/MRTools.php b/modules/mondialrelay/classes/MRTools.php index 741014f97..823ee028c 100755 --- a/modules/mondialrelay/classes/MRTools.php +++ b/modules/mondialrelay/classes/MRTools.php @@ -37,10 +37,10 @@ class MRTools { if (function_exists('iconv')) { - $currentLocale = setlocale(LC_ALL, NULL); - setlocale(LC_ALL, 'en_US.UTF8'); - $cleanedString = iconv('UTF-8','ASCII//TRANSLIT', $string); - setLocale(LC_ALL, $currentLocale); + $currentLocale = setlocale(LC_ALL, NULL); + setlocale(LC_ALL, 'en_US.UTF8'); + $cleanedString = iconv('UTF-8','ASCII//TRANSLIT', $string); + setLocale(LC_ALL, $currentLocale); } else $cleanedString = strtr($string, diff --git a/modules/mondialrelay/js/gmap.js b/modules/mondialrelay/js/gmap.js index a58b098f6..e1a8d53e2 100644 --- a/modules/mondialrelay/js/gmap.js +++ b/modules/mondialrelay/js/gmap.js @@ -1,7 +1,7 @@ /* * GMAP3 Plugin for JQuery - * Version : 4.0 - * Date : 2011-08-23 + * Version : 4.1 + * Date : 2011-11-18 * Licence : GPL v3 : http://www.gnu.org/licenses/gpl.html * Author : DEMONTE Jean-Baptiste * Contact : jbdemonte@gmail.com @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -(function ($) { + (function ($) { /***************************************************************************/ /* STACK */ @@ -75,10 +75,10 @@ for(var i = 0; i < st.length; i++){ if (st[i]) { return st[i]; - } } - return false; } + return false; + } this.ack = function (){ for(var i = 0; i < st.length; i++){ if (st[i]) { @@ -185,25 +185,25 @@ var idx, i, tmp; name = name.toLowerCase(); if (!store[name]) { - return false; - } + return false; + } if (tag !== undefined){ if (pop){ for(idx = store[name].length - 1; idx >= 0; idx--){ if ( (store[name][idx] !== undefined) && (store[name][idx].tag !== undefined) && ($.inArray(store[name][idx].tag, tag) >= 0) ){ - break; + break; + } } - } } else { for(idx = 0; idx < store[name].length; idx++){ if ( (store[name][idx] !== undefined) && (store[name][idx].tag !== undefined) && ($.inArray(store[name][idx].tag, tag) >= 0) ){ break; + } + } } - } - } } else { idx = pop ? store[name].length - 1 : 0; - } + } if ( !(idx in store[name]) ) { return false; } @@ -386,7 +386,7 @@ return markers[i]; } - this.clusters = function(map, radius, force){ + this.clusters = function(map, radius, maxZoom, force){ var proj = map.getProjection(), nwP = proj.fromLatLngToPoint( new google.maps.LatLng( @@ -403,12 +403,14 @@ cluster, chk, lat, lng, keys, cnt, - bounds = map.getBounds(); + bounds = map.getBounds(), + noClusters = maxZoom && (maxZoom <= map.getZoom()), + chkContain = map.getZoom() > 2; cnt = 0; keys = {}; for(i = 0; i < markers.length; i++){ - if (!bounds.contains(markers[i].latLng)){ + if (chkContain && !bounds.contains(markers[i].latLng)){ continue; } p = proj.fromLatLngToPoint(markers[i].latLng); @@ -420,7 +422,7 @@ cnt++; } // check if visible markers have changed - if (!force){ + if (!force && !noClusters){ for(k = 0; k < latest.length; k++){ if( k in keys ){ cnt--; @@ -466,44 +468,49 @@ lng = pos[i][1]; saved = null; - do{ - cluster = {lat:0, lng:0, idx:[]}; - for(k2 = k; k2 1; - saved = cluster; - } else { - chk = cluster.idx.length > saved.idx.length; - if (chk){ + cluster.lat /= cluster.idx.length; + cluster.lng /= cluster.idx.length; + if (!saved){ + chk = cluster.idx.length > 1; saved = cluster; + } else { + chk = cluster.idx.length > saved.idx.length; + if (chk){ + saved = cluster; + } } - } - if (chk){ - p = proj.fromLatLngToPoint( new google.maps.LatLng(saved.lat, saved.lng) ); - lat = Math.floor((p.x - nwP.x) * Math.pow(2, z)); - lng = Math.floor((p.y - nwP.y) * Math.pow(2, z)); - } - } while(chk); + if (chk){ + p = proj.fromLatLngToPoint( new google.maps.LatLng(saved.lat, saved.lng) ); + lat = Math.floor((p.x - nwP.x) * Math.pow(2, z)); + lng = Math.floor((p.y - nwP.y) * Math.pow(2, z)); + } + } while(chk); + } - for(k2 = 0; k2 < saved.idx.length; k2++){ + for(k2 = 0; k2 < saved.idx.length; k2++){ if (saved.idx[k2] in unik){ delete(unik[saved.idx[k2]]); } - } + } clusters.push(saved); } return clusters; @@ -511,7 +518,7 @@ this.getBounds = function(){ var i, bounds = new google.maps.LatLngBounds(); - for(i = 0; i < markers.length; i++){ + for(i=0; i bounds not available // wait for map google.maps.event.addListenerOnce( @@ -1427,23 +1482,23 @@ if (typeof(radius) === 'number'){ clusterer = new Clusterer(); - for (i = 0 ; i < markers.length; i++){ + for(i=0 ; i'), listeners = []; - - $div - .css('border', 'none') - .css('borderWidth', '0px') - .css('position', 'absolute'); + + $div + .css('border', 'none') + .css('borderWidth', '0px') + .css('position', 'absolute'); $div.append(opts.content); function f() { @@ -1803,7 +1858,6 @@ **/ this.adddirectionsrenderer = function(todo, internal){ var dr, o = getObject('directionrenderer', todo, 'panelId'); - store.rm('directionrenderer'); o.options.map = map; dr = new google.maps.DirectionsRenderer(o.options); if (o.panelId) { @@ -1927,22 +1981,22 @@ if(navigator.geolocation) { navigator.geolocation.getCurrentPosition( function(position) { - var out = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); + var out = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); callback.apply($this, [out]); }, function() { - var out = false; + var out = false; callback.apply($this, [out]); } ); } else if (google.gears) { google.gears.factory.create('beta.geolocation').getCurrentPosition( function(position) { - var out = new google.maps.LatLng(position.latitude,position.longitude); + var out = new google.maps.LatLng(position.latitude,position.longitude); callback.apply($this, [out]); }, function() { - out = false; + out = false; callback.apply($this, [out]); } ); @@ -1962,7 +2016,7 @@ styles[o.id] = new _default.classes.StyledMapType(o.style, o.options); if (map) { map.mapTypes.set(o.id, styles[o.id]); - } + } } this._manageEnd(styles[o.id], o, internal); } @@ -2018,29 +2072,32 @@ return store.all(name, tag); } else { return store.get(name, true, tag); - } - } + } + } /** * return the max zoom of a location **/ this.getmaxzoom = function(todo){ this._resolveLatLng(todo, '_getMaxZoom'); - } + } this._getMaxZoom = function(todo, latLng){ - var callback = ival(todo, 'callback'); + var callback = ival(todo, 'callback'), + that = this; if (callback && typeof(callback) === 'function') { getMaxZoomService().getMaxZoomAtLatLng( latLng, function(result) { var zoom = result.status === google.maps.MaxZoomStatus.OK ? result.zoom : false; callback.apply($this, [zoom, result.status]); + that._end(); } ); - } - this._end(); + } else { + this._end(); } + } /** * modify default values @@ -2048,7 +2105,7 @@ this.setdefault = function(todo){ setDefault(todo); this._end(); - } + } /** * autofit a map using its overlays (markers, rectangles ...) @@ -2056,41 +2113,55 @@ this.autofit = function(todo, internal){ var names, list, obj, i, j, empty = true, - bounds = new google.maps.LatLngBounds(); - + bounds = new google.maps.LatLngBounds(), + maxZoom = ival(todo, 'maxZoom', null); + names = store.names(); for(i=0; i detect zoom level and check maxZoom + google.maps.event.addListenerOnce( + map, + 'bounds_changed', + function() { + if (this.getZoom() > maxZoom){ + this.setZoom(maxZoom); + } + } + ); } + map.fitBounds(bounds); + } if (!internal){ this._manageEnd(empty ? false : bounds, todo, internal); } @@ -2101,7 +2172,7 @@ //-----------------------------------------------------------------------// // jQuery plugin //-----------------------------------------------------------------------// - + $.fn.gmap3 = function(){ var i, args, list = [], empty = true, results = []; // store all arguments in a todo list @@ -2112,7 +2183,7 @@ args = {action:args}; } list.push(args); - } + } // resolve empty call - run init if (!list.length) { list.push({}); @@ -2129,9 +2200,9 @@ // direct call : bypass jQuery method (not stackable, return mixed) if ( (list.length == 1) && (isDirect(list[0])) ){ results.push(gmap3._direct(list[0])); - } else { + } else { gmap3._plan(list); - } + } }); // return for direct call (only) if (results.length){ diff --git a/modules/mondialrelay/mondialrelay.js b/modules/mondialrelay/mondialrelay.js index 259902c83..1d3142a36 100755 --- a/modules/mondialrelay/mondialrelay.js +++ b/modules/mondialrelay/mondialrelay.js @@ -59,7 +59,7 @@ function getTickets(detailedExpeditionList) }, error: function(xhr, ajaxOptions, thrownError) { - displayBackGenerateSubmitButton(); + displayBackGenerateSubmitButton(); } }); } @@ -192,7 +192,7 @@ function generateTicketsAjax() error: function(xhr, ajaxOptions, thrownError) { display_generate_button = true; - displayBackGenerateSubmitButton(); + displayBackGenerateSubmitButton(); } }); delete(order_id_list); @@ -440,7 +440,7 @@ function PS_MRCarrierSelectedProcess(carrierSelected, id_carrier, MRLivraisonTyp // Won't have any relay points PS_MRSelectedRelayPoint['relayPointNum'] = -1; -} + } } /* @@ -512,8 +512,8 @@ function PS_MRDisplayRelayPoint(json, blockContent, carrier_id) numberDisplayed = 0; // Disable Gmap for IE user - if (!$.browser.msie) - PS_MRCreateGmap(carrier_id); + // if (!$.browser.msie) + PS_MRCreateGmap(carrier_id); blockContent.fadeOut('fast', function() { $(this).children('td').html(''); @@ -530,26 +530,26 @@ function PS_MRDisplayRelayPoint(json, blockContent, carrier_id) var classSelection = (PS_MRPreSelectedRelay == json.success[relayPoint].Num) ? 'PS_MRFloatRelayPointSelected' : 'PS_MRFloatRelayPointSelecteIt'; - $('
\ - \ -

' + json.success[relayPoint].LgAdr1 + '
' + json.success[relayPoint].LgAdr3 + $('

' + + '' + + '

' + json.success[relayPoint].LgAdr1 + '
' + json.success[relayPoint].LgAdr3 + ' - ' + json.success[relayPoint].CP + ' - ' + json.success[relayPoint].Ville - + ' ' + json.success[relayPoint].Pays + '

\ - \ + + ' ' + json.success[relayPoint].Pays + '

' + + '
' + + '' + BtTranslation + '' + + '
\
').appendTo($(this).children('td')); // Store all the object content to prevent an ajax request relayPointDataContainers[json.success[relayPoint].Num] = json.success[relayPoint]; ++numberDisplayed; // Display popup for IE user - if (!$.browser.msie) - PS_MRAddGMapMarker(carrier_id, json.success[relayPoint].Num, contentBlockid); - else + //if (!$.browser.msie) + PS_MRAddGMapMarker(carrier_id, json.success[relayPoint].Num, contentBlockid); + /* else $('#' + contentBlockid).children('p').click(function() { PS_MROpenPopupDetail(json.success[relayPoint].permaLinkDetail); - }); + });*/ } } PS_MRHandleSelectedRelayPoint(); @@ -693,15 +693,15 @@ function PS_MRGmapPlaceViewOnMarker($map, marker, relayNum) { PS_MRDisplayClickedGmapWindow(marker, relayNum, $map); - // Make dancing markers in Firefox will use the CPU to 100 % - if (!$.browser.mozilla) - (function(m) - { - setTimeout(function() - { - m.setAnimation(google.maps.Animation.BOUNCE); - }, 200); - })(marker); + // Make dancing markers in Firefox / IE will use the CPU to 50 to 100 % about + if (!$.browser.msie && !$.browser.mozilla) + (function(m) + { + setTimeout(function() + { + m.setAnimation(google.maps.Animation.BOUNCE); + }, 200); + })(marker); // marker.setAnimation(google.maps.Animation.BOUNCE); } }); @@ -722,11 +722,11 @@ function PS_MRStopDancingMarkers(currentMarkerList) ** Display the Gmap of the selected relay point */ function PS_MRDisplayGmap(contentBlockid, $map) -{ - tab = contentBlockid.split('_'); - relayPointNumber = tab[1]; - id_carrier = tab[2]; - +{ + var tab = contentBlockid.split('_'); + var relayPointNumber = tab[1]; + var id_carrier = tab[2]; + // Stop the dancing marker of the current carrier PS_MRStopDancingMarkers(markerList[id_carrier]); if ($('#PS_MRGmap_' + id_carrier).css('display') == 'none') @@ -903,7 +903,7 @@ $(document).ready(function() $('#PS_MRDisplayPersonalizedOptions').click(function() { $('#PS_MRAdvancedSettings').toggle('fast'); -}); + }); }); diff --git a/modules/mondialrelay/mondialrelay.php b/modules/mondialrelay/mondialrelay.php index 0ef7082b0..b2a03b2e2 100755 --- a/modules/mondialrelay/mondialrelay.php +++ b/modules/mondialrelay/mondialrelay.php @@ -194,7 +194,7 @@ class MondialRelay extends Module !$this->registerHook('updateCarrier') || !$this->registerHook('newOrder') || !$this->registerHook('BackOfficeHeader') || - !$this->registerHook('paymentTop'))) + !$this->registerHook('header'))) return false; if (_PS_VERSION_ >= '1.4' && @@ -438,7 +438,6 @@ class MondialRelay extends Module var mrtoken = "'.self::$MRBackToken.'"; '; return $ret; - return $ret; } private function _postValidation() @@ -486,7 +485,7 @@ class MondialRelay extends Module if (!preg_match('#^[0-9A-Z_\-\'., /]{2,32}$#', strtoupper($addr1), $match)) $this->_postErrors[] = $this->l('The Main address submited hasn\'t a good format'); }*/ - } + } private function _postProcess() { @@ -543,13 +542,6 @@ class MondialRelay extends Module return $this->display(__FILE__, 'orderDetail.tpl'); } - /* - ** No need anymore - */ - public function hookProcessCarrier($params) - { - } - /* ** Update the carrier id to use the new one if changed */ @@ -599,7 +591,24 @@ class MondialRelay extends Module $carriers = array(); return $carriers; } - + + /* + ** Added to be used properly with OPC + */ + public function hookHeader($params) + { + if (in_array(basename($_SERVER['SCRIPT_NAME']), array('order-opc.php', 'order.php'))) + { + $$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, + 'jQueryOverload' => self::getJqueryCompatibility(false))); + return $this->display(__FILE__, 'header.tpl'); + } + return ''; + } + public function hookextraCarrier($params) { global $nbcarriers; @@ -634,15 +643,10 @@ class MondialRelay extends Module } $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, + $smarty->assign(array( 'carriersextra' => $carriersList, - 'preSelectedRelay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : '', - 'jQueryOverload' => self::getJqueryCompatibility(false) - )); - + 'preSelectedRelay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : '')); + return $this->display(__FILE__, 'mondialrelay.tpl'); } @@ -1131,9 +1135,10 @@ class MondialRelay extends Module $query = 'SELECT url_suivi FROM '._DB_PREFIX_ .'mr_selected WHERE id_mr_selected=\''.(int)($shipping_number).'\';'; - + $settings = Db::getInstance()->executeS($query); - + if(!isset($settings[0]['url_suivi'])) + return null; return $settings[0]['url_suivi']; } @@ -1180,10 +1185,11 @@ class MondialRelay extends Module LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`) WHERE ( - SELECT moh.`id_order_state` - FROM `'._DB_PREFIX_.'order_history` moh - WHERE moh.`id_order` = o.`id_order` - ORDER BY moh.`date_add` DESC LIMIT 1) = '.(int)($id_order_state); + SELECT moh.`id_order_state` + FROM `'._DB_PREFIX_.'order_history` moh + WHERE moh.`id_order` = o.`id_order` + ORDER BY moh.`date_add` DESC LIMIT 1) = '.(int)($id_order_state).' + AND ca.`external_module_name` = "mondialrelay"'; } public static function ordersSQLQuery1_3($id_order_state) @@ -1211,10 +1217,11 @@ class MondialRelay extends Module LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`) WHERE ( - SELECT moh.`id_order_state` - FROM `'._DB_PREFIX_.'order_history` moh - WHERE moh.`id_order` = o.`id_order` - ORDER BY moh.`date_add` DESC LIMIT 1) = '.(int)($id_order_state); + SELECT moh.`id_order_state` + FROM `'._DB_PREFIX_.'order_history` moh + WHERE moh.`id_order` = o.`id_order` + ORDER BY moh.`date_add` DESC LIMIT 1) = '.(int)($id_order_state).' + AND ca.`name` = "mondialrelay"'; } public static function getBaseOrdersSQLQuery($id_order_state) diff --git a/modules/mondialrelay/mondialrelay.tpl b/modules/mondialrelay/mondialrelay.tpl index 64a374e11..bb8a3aa2f 100755 --- a/modules/mondialrelay/mondialrelay.tpl +++ b/modules/mondialrelay/mondialrelay.tpl @@ -26,28 +26,11 @@ {$jQueryOverload} - - - - -