Merge branch 'ticket-14828-ChangeIdContactDynamically' into develop

This commit is contained in:
Marion Muszynski 2017-11-23 15:32:07 +01:00
commit a846de99eb
7 changed files with 75 additions and 8 deletions

View File

@ -96,6 +96,13 @@ if (Tools::isSubmit('submitMessage')) {
$customer->getByEmail($from);
}
if($id_contact == 9){
$id_order_state = Order::getCurrentIdState((int)Tools::getValue('id_order'));
if($id_order_state && in_array($id_order_state, array(4,17,5))) {
$id_contact = 1;
}
}
$contact = new Contact($id_contact, $cookie->id_lang);
if (!((

View File

@ -100,7 +100,7 @@ if($magistorModule->active) {
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)(Configuration::get('PS_LANG_DEFAULT')).'
)
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c ON (c.`id_product` = pp.`id_product_pack`)
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c ON (c.`id_product` = pp.`id_product_item`)
WHERE c.`id_sale` = '.(int) $id_sale.'
ORDER BY p.`id_product` ASC
') as $row){
@ -178,6 +178,24 @@ if($magistorModule->active) {
foreach ($result_quantities as $od) {
$quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']);
}
$id_product_packs = array();
$packs = Pack::getPacks($product['id_product']);
foreach ($packs as $key => $pack) {
$id_product_packs[(int)$pack['id_product_pack']] = (int)$pack['id_product_pack'];
}
if(!empty($id_product_packs)){
$result_quantities2 = Db::getInstance()->executeS('
SELECT od.`product_quantity`,od.`product_quantity_reinjected`
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = od.`id_order`)
WHERE od.`product_id` IN ('.implode(',',$id_product_packs).') AND `product_attribute_id` = 0 AND o.`valid` != 0'
);
foreach ($result_quantities2 as $od) {
$quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']);
}
}
if($quantity>0){
if(isset($product['ean13']) && !empty($product['ean13'])) {
$ean = $product['ean13'];
@ -185,6 +203,15 @@ if($magistorModule->active) {
$ean = $product['supplier_reference'];
}
$link = new Link();
$cover = Db::getInstance()->getValue('
SELECT `id_image`
FROM `'._DB_PREFIX_.'image`
WHERE id_product = ' . (int) $product['id_product'] . '
AND `cover` = 1');
$ids = (int) $product['id_product'] . '-' . (int) $cover;
$img_link = 'http://'.$link->getImageLink($product['link_rewrite'], $ids, 'thickbox');
$data .= str_pad('ART01', 10, ' ', STR_PAD_RIGHT);
$data .= str_pad($code_societe, 20, ' ', STR_PAD_RIGHT);
$data .= str_pad(str_replace(array("\r", "\n"), '', $product['id_product']), 50, ' ', STR_PAD_RIGHT);

View File

@ -145,7 +145,7 @@ if($magistorModule->active) {
$data .= str_pad( $code_societe, 20, ' ', STR_PAD_RIGHT );
$data .= str_pad( 'OP'.(int) $id_sale, 20, ' ', STR_PAD_RIGHT );
$data .= date('Ymd');
$data .= str_pad( substr(utf8_decode(str_replace(array("\r", "\n"), "", $product['product_id'])),0,50), 50, ' ', STR_PAD_RIGHT );
$data .= str_pad( substr(utf8_decode(str_replace(array("\r", "\n"), "", $id_product)),0,50), 50, ' ', STR_PAD_RIGHT );
$data .= str_pad( $row['quantity'], 10, '0', STR_PAD_LEFT );
$data .= str_pad( '', 10, '0', STR_PAD_LEFT );
$data .= str_pad( '', 250, ' ', STR_PAD_LEFT );
@ -153,8 +153,8 @@ if($magistorModule->active) {
$data .= str_pad( str_replace(array("\r", "\n"), "", $product['ean13']), 14, ' ', STR_PAD_LEFT );
$data .= PHP_EOL;
$product_quantities[$product['product_id']] = (int)$row['quantity'];
$product_quantities2[$product['product_id']] = 0;
$product_quantities[$id_product] = (int)$row['quantity'];
$product_quantities2[$id_product] = 0;
}
}
@ -182,7 +182,6 @@ if($magistorModule->active) {
chmod($fileName . '.BAL', 0755);
unset($data);
require_once('connection_ftp.php');
}
echo 'fin'."\n";

View File

@ -2198,7 +2198,7 @@ class Sale {
// Noel sale can be combined only with Noel sale of same shipping
if(
(int)$adding_sale['delivery_delay'] == 5
((int)$adding_sale['delivery_delay'] == 5 || (int)$current_sale['delivery_delay'] == 5)
&& (
(int)$current_sale['delivery_delay'] != (int)$adding_sale['delivery_delay']
|| (

View File

@ -1091,7 +1091,7 @@ class Cart extends CartCore {
SELECT MAX(c.`id_cart`)
FROM '._DB_PREFIX_.'cart c
LEFT JOIN '._DB_PREFIX_.'orders o ON (c.`id_cart` = o.`id_cart`)
WHERE o.`valid` = 1
WHERE o.`id_order` IS NOT NULL
AND c.`id_customer` = '.(int)$id_customer.'
');
}
@ -1103,7 +1103,7 @@ class Cart extends CartCore {
SELECT MIN(c.id_cart)
FROM '._DB_PREFIX_.'cart c
LEFT JOIN '._DB_PREFIX_.'orders o ON (c.`id_cart` = o.`id_cart`)
WHERE (o.`valid` = 0 OR o.`valid` IS NULL)
WHERE o.`id_order` IS NULL
AND c.`id_customer` = '.(int)$id_customer.'
AND c.`id_cart` > '.(int)$max_id_cart.'
');

View File

@ -246,8 +246,37 @@ class Order extends OrderCore {
$data[$info['id_order_detail']] = $info['total_send'];
}
}
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT
d.`id_order_detail`,
IF(
(SELECT COUNT(p.`id_order_detail`)
FROM `'._DB_PREFIX_.'philea_parcel` p
WHERE d.`id_order_detail` = p.`id_order_detail`),
(SELECT SUM(p.`quantity`)
FROM `'._DB_PREFIX_.'philea_parcel` p
WHERE d.`id_order_detail` = p.`id_order_detail`),
0
) as `total_send`
FROM `'._DB_PREFIX_.'order_detail` d
WHERE d.`id_order_detail` IN ('.implode(',', $ids).')
') as $key => $info) {
if($data[$info['id_order_detail']]==0){
$data[$info['id_order_detail']] = $info['total_send'];
}
}
return $data;
}
public static function getCurrentIdState($id_order)
{
$id_order_state = Db::getInstance()->getValue('
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_state_current`
WHERE `id_order`='.(int)$id_order
);
return $id_order_state?$id_order_state:false;
}
}

View File

@ -0,0 +1,5 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{landingpages}site_mobile>authentication_bottom_925cc1fa40ed38377bcb2b77b5315d9c'] = 'Déjà membre';