From 1a975aea6187cf93718de2b63b300a2517a89253 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 19 Jul 2017 14:34:05 +0200 Subject: [PATCH] fix MR from prod --- .../carriers/mondialrelay/cron_shipping.php | 44 ++++----- .../carriers/mondialrelay/cron_trace.php | 27 +++++- modules/mondialrelay/js/mondialrelay.js | 93 ++++++++++--------- modules/mondialrelay/mondialrelay.php | 2 +- .../templates/front/checkout_process.tpl | 90 +++++++++++++++++- .../views/templates/front/header.tpl | 6 +- .../AdminPrivateSalesLogistique.php | 2 +- 7 files changed, 188 insertions(+), 76 deletions(-) diff --git a/modules/logistics/carriers/mondialrelay/cron_shipping.php b/modules/logistics/carriers/mondialrelay/cron_shipping.php index cf899327..79c383ef 100755 --- a/modules/logistics/carriers/mondialrelay/cron_shipping.php +++ b/modules/logistics/carriers/mondialrelay/cron_shipping.php @@ -54,7 +54,7 @@ function phone_format($phone, $id_country = 8){ // if (($i+1)%2==0) // $_phone .= ' '; // } - $phone = $_phone; + // $phone = $_phone; // set format $phone = $prefix . substr($phone, 1); @@ -112,8 +112,8 @@ $sql = ' 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).'" - d.`id_order_detail` IS NOT NULL + 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` '; @@ -560,28 +560,28 @@ $mr_ftp_conf = Configuration::getMultiple(array( 'MONDIALRELAYWS_FTP_PASSWORD' )); -// $id_ftp = ftp_connect($mr_ftp_conf['MONDIALRELAYWS_FTP_HOST']); +$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)); +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); \ No newline at end of file +$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); \ No newline at end of file diff --git a/modules/logistics/carriers/mondialrelay/cron_trace.php b/modules/logistics/carriers/mondialrelay/cron_trace.php index 617781ea..acf2117b 100755 --- a/modules/logistics/carriers/mondialrelay/cron_trace.php +++ b/modules/logistics/carriers/mondialrelay/cron_trace.php @@ -85,7 +85,7 @@ foreach ($iterator as $fileinfo) { 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) + AND osc.`id_order_state` IN (2, 3, 12, 13, 17) ') as $row) { $expedition_shipping[$row['expedition_number']] = $row['shipping_number']; $expedition_orders[$row['expedition_number']] = (int) $row['id_order']; @@ -173,6 +173,23 @@ foreach ($iterator as $fileinfo) { } } + 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_.'philea_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)) { @@ -243,8 +260,14 @@ foreach ($iterator as $fileinfo) { $content_txt = 'Contenu du colis :'; } + if((int) $order->id_lang == 3) { + $url = 'http://www.puntopack.es/seguir-mi-envio/?numeroExpedition='.$shipping_number; + } else { + $url = 'http://www.mondialrelay.fr/suivi-de-colis/?numeroExpedition='.$shipping_number; + } + $templateVars = array( - '{followup}' => str_replace('@', $shipping_number, $carrier->url), + '{followup}' => $url, '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{id_order}' => (int) $order->id, diff --git a/modules/mondialrelay/js/mondialrelay.js b/modules/mondialrelay/js/mondialrelay.js index 6ca4594e..bcabfd18 100755 --- a/modules/mondialrelay/js/mondialrelay.js +++ b/modules/mondialrelay/js/mondialrelay.js @@ -43,7 +43,7 @@ var PS_MRObject = (function($, undefined) { // List the marker liable to the relay pint var markerList = new Object(); - + var selected = false; /** @@ -168,7 +168,7 @@ var PS_MRObject = (function($, undefined) { $('#PS_MRLineOrderInformation-' + id_order).remove(); $('#successCreatingTicket_' + id_order).fadeIn('slow'); detailedExpeditionList.push({'id_order':id_order, 'expeditionNumber':json.success[id_order].expeditionNumber}); - + if (!$('#detailHistory_' + id_order).length) { $('#PS_MRHistoriqueTableList').append('\ @@ -190,7 +190,7 @@ var PS_MRObject = (function($, undefined) { } $('#successCreatingTicket_' + id_order).fadeOut('slow'); } - + $('.PS_MRSubmitButton').css('display', 'block'); } if(detailedExpeditionList.length) @@ -256,7 +256,7 @@ var PS_MRObject = (function($, undefined) { checkErrorGeneratedTickets(json); detailedExpeditionList = checkSucceedGenerateTickets(json); - + if (detailedExpeditionList.length) getTickets(detailedExpeditionList); else @@ -351,19 +351,19 @@ var PS_MRObject = (function($, undefined) { } }); } - + function PS_MRSubmitButtonPrintSelected(format) { var history_id_list = new Array(); - var history_id_list_str = ''; + var history_id_list_str = ''; $('input[name="history_id_list[]"]:checked').each(function() { var id_order = $.trim($(this).parent().next().html()); var expeditionNumber = $.trim($(this).parent().next().next().html()); history_id_list.push({'id_order':id_order, 'expeditionNumber':expeditionNumber}); - expeditionNumber = strPad(expeditionNumber,8,0); + expeditionNumber = strPad(expeditionNumber,8,0); history_id_list_str += expeditionNumber+';'; }); - + if(history_id_list.length) { history_id_list_str = history_id_list_str.substr(0,(history_id_list_str.length-1)); $.ajax( @@ -377,17 +377,17 @@ var PS_MRObject = (function($, undefined) { 'mrtoken' : mrtoken}, dataType: 'json', success: function(json) - { + { var url = json.success[0]; if(format == 4 && url!=null) { document.location.href= url.URL_PDF_A4; } if(format == 5 && url!=null) { document.location.href= url.URL_PDF_A5; - } + } if(format == '10x15' && url!=null) { document.location.href= url.URL_PDF_10x15; - } + } }, error: function(xhr, ajaxOptions, thrownError) { @@ -396,7 +396,7 @@ var PS_MRObject = (function($, undefined) { }); } } - + function strPad(input, length, string) { string = string || '0'; input = input + ''; return input.length >= length ? input : new Array(length - input.length + 1).join(string) + input; @@ -649,7 +649,7 @@ var PS_MRObject = (function($, undefined) { * @param carrier_id */ function PS_MRDisplayRelayPoint(json, blockContent, carrier_id) - { + { if (typeof json != 'undefined' && typeof blockContent != 'undefined') { numberDisplayed = 0; @@ -694,7 +694,7 @@ var PS_MRObject = (function($, undefined) { PS_MROpenPopupDetail(json.success[relayPoint].permaLinkDetail); });*/ } - } + } PS_MRHandleSelectedRelayPoint(); $(this).fadeIn('fast'); }); @@ -728,7 +728,7 @@ var PS_MRObject = (function($, undefined) { */ function PS_MRFetchRelayPoint(carrierSelected) { - carrier_id = carrierSelected.val().replace(',', ''); + carrier_id = carrierSelected.val().replace(',', ''); // Block is an input, we need the 'tr' element blockTR =$('#MR_PR_list_'+carrier_id+' tr'); // Add a new line to the table after the clicked parent element @@ -811,6 +811,7 @@ var PS_MRObject = (function($, undefined) { // present everytime in the page. Body is the only one sure. // It's an hidden block which will be put in the right block when user select his // own carrier + return; $('body').prepend('\ \ \ @@ -1087,25 +1088,25 @@ var PS_MRObject = (function($, undefined) { if ($('#' + block_form_id).length == 0) $('#MR_error_account').fadeIn('fast'); } - + function checkToDisplayRelayList() - { + { if (typeof PS_MRData != 'undefined') { - PS_MRSelectedRelayPoint['relayPointNum'] = PS_MRData.pre_selected_relay; - + PS_MRSelectedRelayPoint['relayPointNum'] = PS_MRData.pre_selected_relay; + if (PS_MRData.PS_VERSION < '1.5') { $('input[name="id_carrier"]').each(function(i, e){ var parent_element = $(e).closest('tr'); var new_element = 'MR_PR_list_'+$(e).val().replace(',', ''); var MR_idcarrier = $(e).val().replace(',', ''); MR_carrier = isMRCarrier(MR_idcarrier); - + if($('#'+new_element).length > 0) { - $('#'+new_element).remove(); + $('#'+new_element).parent().parent().parent().remove(); if( isMRCarrier(MR_idcarrier)!=false && typeof(MR_carrier) != "undefined" && (MR_carrier.dlv_mode!='LD1' && MR_carrier.dlv_mode!='LDS' && MR_carrier.dlv_mode!='HOM')) { $(parent_element).after( - '
' + '' @@ -1117,7 +1118,7 @@ var PS_MRObject = (function($, undefined) { if(typeof(MR_carrier) != "undefined" && (MR_carrier.dlv_mode!='LD1' && MR_carrier.dlv_mode!='LDS' && MR_carrier.dlv_mode!='HOM')) { $(parent_element).after( - '