Merge branch 'ticket-11985-MondialRelay_part2' into develop

This commit is contained in:
Marion Muszynski 2017-01-19 17:36:47 +01:00
commit d63be8f6ae
4 changed files with 44 additions and 31 deletions

View File

@ -368,7 +368,7 @@ class AdminLogistics extends AdminTab {
} elseif($render === 'route_error') { } elseif($render === 'route_error') {
$this->_html .= '<p class="error">'.$this->l('Route not found').'</p><br />'; $this->_html .= '<p class="error">'.$this->l('Route not found').'</p><br />';
} elseif($render !== FALSE) { } elseif($render !== FALSE) {
$this->printLabel($render); //$this->printLabel($render); // comment in dev
$this->_html .= '<p class="conf">'.$this->l('Registration complete, label sent to printer').'</p><br />'; $this->_html .= '<p class="conf">'.$this->l('Registration complete, label sent to printer').'</p><br />';

View File

@ -112,12 +112,12 @@ $sql = '
ON d.`id_order` = o.`id_order` ON d.`id_order` = o.`id_order`
LEFT JOIN `'._DB_PREFIX_.'customer` c LEFT JOIN `'._DB_PREFIX_.'customer` c
ON c.`id_customer` = o.`id_customer` ON c.`id_customer` = o.`id_customer`
WHERE p.`date_add` > "'.pSQL($last_sync).'" WHERE -- p.`date_add` > "'.pSQL($last_sync).'"
AND d.`id_order_detail` IS NOT NULL d.`id_order_detail` IS NOT NULL
AND o.`id_order` IS NOT NULL AND o.`id_order` IS NOT NULL
GROUP BY p.`shipping_number` GROUP BY p.`shipping_number`
'; ';
$lines = Db::getInstance()->ExecuteQ($sql); $lines = Db::getInstance()->ExecuteS($sql);
if(count($lines)) { if(count($lines)) {
$mr_account_details = unserialize(Configuration::get('MR_ACCOUNT_DETAIL')); $mr_account_details = unserialize(Configuration::get('MR_ACCOUNT_DETAIL'));
@ -402,7 +402,7 @@ if(count($lines)) {
// ."\n"; // ."\n";
$i = 0; $i = 0;
foreach(Db::getInstance()->ExecuteQ(' foreach(Db::getInstance()->ExecuteS('
SELECT d.*, p.`quantity` SELECT d.*, p.`quantity`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` p FROM `'._DB_PREFIX_.'mondialrelay_parcel` p
LEFT JOIN `'._DB_PREFIX_.'order_detail` d LEFT JOIN `'._DB_PREFIX_.'order_detail` d
@ -553,28 +553,28 @@ $mr_ftp_conf = Configuration::getMultiple(array(
'MONDIALRELAYWS_FTP_PASSWORD' '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'])) // 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)); // die('erreur lors de l\'identification FTP'.chr(10).chr(10));
//activation du mode passif // //activation du mode passif
// if (!ftp_pasv($id_ftp, true)) // // if (!ftp_pasv($id_ftp, true))
// die('erreur lors de l\'activation du mode passif'.chr(10).chr(10)); // // die('erreur lors de l\'activation du mode passif'.chr(10).chr(10));
$repo_dpc = dirname(__FILE__) . '/dpc/'; // $repo_dpc = dirname(__FILE__) . '/dpc/';
$mr_repo_in = 'versmrelay/'; // $mr_repo_in = 'versmrelay/';
//envoie du fichier // //envoie du fichier
$list = scandir($repo_dpc); // $list = scandir($repo_dpc);
foreach($list as $file) // foreach($list as $file)
{ // {
if (!preg_match('/^dpc\..+\.txt$/', $file)) // if (!preg_match('/^dpc\..+\.txt$/', $file))
continue; // continue;
if ($file == '.' || $file == '..') // if ($file == '.' || $file == '..')
continue; // continue;
if (!ftp_put ($id_ftp, $mr_repo_in . $file, $repo_dpc . $file, FTP_BINARY)) // 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)); // print('erreur lors de l\'ouverture du fichier : ' . $file . chr(10));
else // else
unlink($repo_dpc . $file); // unlink($repo_dpc . $file);
} // }
ftp_close($id_ftp); // ftp_close($id_ftp);

View File

@ -699,10 +699,10 @@ class MondialrelayCarrier {
} }
} }
public function addOrderHistory($shipping_data, $order, $products_sent) { public function __addOrderHistory($shipping_data, $order, $products_sent) {
} }
public function __addOrderHistory($shipping_data, $order, $products_sent) { public function addOrderHistory($shipping_data, $order, $products_sent) {
global $cookie; global $cookie;
// $MONDIALRELAY_carrier_id = unserialize(Configuration::get('MONDIALRELAY_CARRIERS')); // $MONDIALRELAY_carrier_id = unserialize(Configuration::get('MONDIALRELAY_CARRIERS'));

View File

@ -628,11 +628,11 @@ class MondialRelay extends Module
// CHECK MR_SELECTED // CHECK MR_SELECTED
if ((int) Tools::getValue('step') == 3){ if ((int) Tools::getValue('step') == 3){
global $cookie, $cart; global $cookie, $cart;
if (isset($cart->id_carrier) && $this->isMondialRelayCarrier($cart->id_carrier)){ if (isset($cart->id_carrier) && $this->isMondialRelayNoDomCarrier($cart->id_carrier)){
$mr_selected = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'mr_selected` WHERE `id_cart` = ' . (int) $cart->id); $mr_selected = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'mr_selected` WHERE `id_cart` = ' . (int) $cart->id);
if (!$mr_selected || !$mr_selected['MR_Selected_Num']) if (!$mr_selected || !$mr_selected['MR_Selected_Num'])
{ {
Tools::redirect('order.php?step=1&no_mr_selected=1'); Tools::redirect('order.php?step=2&no_mr_selected=1');
} }
} }
return ''; return '';
@ -1360,6 +1360,19 @@ class MondialRelay extends Module
WHERE `id_carrier` = '.(int)$id_carrier); WHERE `id_carrier` = '.(int)$id_carrier);
} }
/**
* @param $id_carrier
* @return mixed
*/
public function isMondialRelayNoDomCarrier($id_carrier)
{
return Db::getInstance()->getRow('
SELECT m.`id_mr_method`
FROM `'._DB_PREFIX_.'mr_method` m
WHERE `dlv_mode` NOT IN ("LD1","LDS","HOM")
AND `id_carrier` = '.(int)$id_carrier);
}
public function getMethodValueByIdCarier($id_carrier, $key) public function getMethodValueByIdCarier($id_carrier, $key)
{ {
$content = Db::getInstance()->executeS( $content = Db::getInstance()->executeS(