Merge branch 'fix/500-module-invite' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
Christophe LATOUR 2017-12-05 16:21:53 +01:00
commit 6a994070bd
8 changed files with 246 additions and 108 deletions

View File

@ -1532,7 +1532,7 @@ class AdminOrders extends AdminTab
<p class="col-md-12" style="font-size:11px; margin:0 0 10px 0;"><i>* Le chiffre de gauche correspond à la quantité remboursée pré-envoi et celui de droite post-envoi</i></p>'; <p class="col-md-12" style="font-size:11px; margin:0 0 10px 0;"><i>* Le chiffre de gauche correspond à la quantité remboursée pré-envoi et celui de droite post-envoi</i></p>';
$html .= ' $html .= '
<div class="col-md-offset-9 col-md-3">'; <div class="col-md-offset-9 col-md-3" style="padding-left:5px;">';
if ($order->hasBeenDelivered() AND Configuration::get('PS_ORDER_RETURN')){ if ($order->hasBeenDelivered() AND Configuration::get('PS_ORDER_RETURN')){
$html .= '<input type="checkbox" id="reinjectQuantities" name="reinjectQuantities" class="button" />&nbsp;<label for="reinjectQuantities" style="float:none; font-weight:normal;">'.$this->l('Re-stock products').'</label><br />'; $html .= '<input type="checkbox" id="reinjectQuantities" name="reinjectQuantities" class="button" />&nbsp;<label for="reinjectQuantities" style="float:none; font-weight:normal;">'.$this->l('Re-stock products').'</label><br />';
} }
@ -1983,6 +1983,11 @@ class AdminOrders extends AdminTab
public function viewDetails() public function viewDetails()
{ {
$authorized_ip = array(
'88.163.22.99',
'90.63.178.63',
);
if((int)Configuration::get('ANT_BOOTSTRAP_TPL') == 1){ if((int)Configuration::get('ANT_BOOTSTRAP_TPL') == 1){
return $this->_viewDetails(); return $this->_viewDetails();
} }

View File

@ -1548,59 +1548,187 @@ class LaposteCarrier {
$history = new OrderHistory(); $history = new OrderHistory();
$history->id_order = (int) $order->id; $history->id_order = (int) $order->id;
$fully_sent = TRUE; $fully_sent = FALSE;
$products_sent = array(); $products_sent = array();
$to_send = array();
$shipping_numbers = array(); $order_details = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_order_detail`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $order->id.'
') as $row) {
$order_details[] = (int) $row['id_order_detail'];
}
foreach(Db::getInstance()->ExecuteS(' foreach(Db::getInstance()->ExecuteS('
SELECT d.`id_order_detail`, IF( SELECT d.`id_order_detail`, IF(
(d.`product_quantity` - IF( (d.`product_quantity` - IF(
d.`product_quantity_return` > 0, d.`product_quantity_return`, d.`product_quantity_refunded` d.`product_quantity_return` > 0, d.`product_quantity_return`, d.`product_quantity_refunded`
) - IFNULL(SUM(s.`quantity`), 0)) > 0, 1, 0 ) - IFNULL(SUM(s.`quantity`), 0)) > 0, 1, 0
) AS `remain`, s.`shipping_number` ) AS `remain`
FROM `'._DB_PREFIX_.'order_detail` d FROM `'._DB_PREFIX_.'order_detail` d
LEFT OUTER JOIN `'._DB_PREFIX_.'lapostews` s LEFT OUTER JOIN `'._DB_PREFIX_.'lapostews` s
ON s.`id_order_detail` = d.`id_order_detail` ON s.`id_order_detail` = d.`id_order_detail`
WHERE d.`id_order` = '.(int) $order->id.' WHERE d.`id_order` = '.(int) $order->id.'
GROUP BY d.`id_order_detail` GROUP BY d.`id_order_detail`
') as $quantity_remain) { ') as $quantity_remain) {
if($quantity_remain['shipping_number']) { if((int) $quantity_remain['remain'] == 0) {
$shipping_numbers[] = pSQL($quantity_remain['shipping_number']); $products_sent[] = (int) $quantity_remain['id_order_detail'];
}
if((int) $quantity_remain['remain'] > 0) {
$fully_sent = FALSE;
$to_send[] = (int) $quantity_remain['id_order_detail'];
} }
} }
$_to_send = array(); foreach(Db::getInstance()->ExecuteS('
foreach($to_send as $p) { SELECT d.`id_order_detail`, IF(
$id_sale = (int) Db::getInstance()->getValue(' (d.`product_quantity` - IF(
SELECT `id_sale` d.`product_quantity_return` > 0, d.`product_quantity_return`, d.`product_quantity_refunded`
FROM `'._DB_PREFIX_.'product_ps_cache` ) - IFNULL(SUM(s.`quantity`), 0)) > 0, 1, 0
WHERE `id_product` = ( ) AS `remain`
SELECT `product_id` FROM `'._DB_PREFIX_.'order_detail` d
FROM `'._DB_PREFIX_.'order_detail` LEFT OUTER JOIN `'._DB_PREFIX_.'exapaqws` s
WHERE `id_order` = '.(int) $order->id.' ON s.`id_order_detail` = d.`id_order_detail`
AND `id_order_detail` = '.(int) $p.' 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'];
}
}
if(!Db::getInstance()->getValue(' foreach(Db::getInstance()->ExecuteS('
SELECT `id_order` 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_.'mondialrelay_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'];
}
}
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)) {
$remaining[] = (int) $d;
}
}
if(count($remaining) == 0) {
$fully_sent = TRUE;
} else {
$id_sales = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT c.`id_sale`
FROM `'._DB_PREFIX_.'product_ps_cache` c
LEFT JOIN `'._DB_PREFIX_.'order_detail` d
ON c.`id_product` = d.`product_id`
WHERE d.`id_order_detail` IN ('.implode(', ', $remaining).')
') as $row) {
$id_sales[] = (int) $row['id_sale'];
}
$sent_sales = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_sale`
FROM `'._DB_PREFIX_.'shipping_history` FROM `'._DB_PREFIX_.'shipping_history`
WHERE `id_order` = '.(int) $order->id.' WHERE `id_order` = '.(int) $order->id.'
AND `id_sale` = '.(int) $id_sale.' AND `id_sale` IN ('.implode(', ', $id_sales).')
AND `shipping_number` NOT IN ("'.implode('", "', $shipping_numbers).'") ') as $row) {
')) { $sent_sales[] = (int) $row['id_sale'];
$_to_send[] = $p;
} }
$remaining = array();
foreach($id_sales as $s) {
if(!in_array($s, $sent_sales)) {
$remaining[] = (int) $s;
break;
}
}
$fully_sent = (count($remaining) == 0);
} }
if(count($_to_send) === 0) { // $fully_sent = TRUE;
$fully_sent = TRUE; // $products_sent = array();
} // $to_send = array();
// $shipping_numbers = array();
// 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`, s.`shipping_number`
// FROM `'._DB_PREFIX_.'order_detail` d
// LEFT OUTER JOIN `'._DB_PREFIX_.'lapostews` 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($quantity_remain['shipping_number']) {
// $shipping_numbers[] = pSQL($quantity_remain['shipping_number']);
// }
// if((int) $quantity_remain['remain'] > 0) {
// $fully_sent = FALSE;
// $to_send[] = (int) $quantity_remain['id_order_detail'];
// }
// }
// $_to_send = array();
// foreach($to_send as $p) {
// $id_sale = (int) Db::getInstance()->getValue('
// SELECT `id_sale`
// FROM `'._DB_PREFIX_.'product_ps_cache`
// WHERE `id_product` = (
// SELECT `product_id`
// FROM `'._DB_PREFIX_.'order_detail`
// WHERE `id_order` = '.(int) $order->id.'
// AND `id_order_detail` = '.(int) $p.'
// )
// ');
// $shipping_order = Db::getInstance()->getValue('
// SELECT `id_order`
// FROM `'._DB_PREFIX_.'shipping_history`
// WHERE `id_order` = '.(int) $order->id.'
// AND `id_sale` = '.(int) $id_sale.'
// AND `shipping_number` NOT IN ("'.implode('", "', $shipping_numbers).'")
// ');
// $dropshipping_parcel = Db::getInstance()->getValue('
// SELECT COUNT(*)
// FROM `'._DB_PREFIX_.'ant_dropshipping_parcel`
// WHERE `id_order_detail` = '.(int) $p.'
// ');
// if((int)$shipping_order==0 && (int)$dropshipping_parcel==0){
// $_to_send[] = $p;
// }
// }
// if(count($_to_send) === 0) {
// $fully_sent = TRUE;
// }
//mail('perron@antadis.com', 'test logistics', (int) $order->id); //mail('perron@antadis.com', 'test logistics', (int) $order->id);

View File

@ -689,7 +689,6 @@ class PayPal extends PaymentModule
public function hookAdminOrderNew($params) public function hookAdminOrderNew($params)
{ {
if (Tools::isSubmit('submitPayPalRefund')){ if (Tools::isSubmit('submitPayPalRefund')){
echo '<pre>';var_dump('test');echo '</pre>';die();
$this->_doTotalRefund($params['id_order']); $this->_doTotalRefund($params['id_order']);
} }
} }

View File

@ -2203,6 +2203,7 @@ class Sale {
(int)$current_sale['delivery_delay'] != (int)$adding_sale['delivery_delay'] (int)$current_sale['delivery_delay'] != (int)$adding_sale['delivery_delay']
|| ( || (
(int)$current_sale['delivery_delay'] == (int)$adding_sale['delivery_delay'] (int)$current_sale['delivery_delay'] == (int)$adding_sale['delivery_delay']
&& ((int)$current_sale['shipping'] == 1 || (int)$adding_sale['shipping'] == 1)
&& (int)$current_sale['shipping'] != (int)$adding_sale['shipping'] && (int)$current_sale['shipping'] != (int)$adding_sale['shipping']
) )
) )

View File

@ -6,8 +6,8 @@ require_once(dirname(__FILE__).'/../../init.php');
require_once(_PS_MODULE_DIR_.'privatesales/Sale.php'); require_once(_PS_MODULE_DIR_.'privatesales/Sale.php');
require_once('AdminPrivateSalesLogistique.php'); require_once('AdminPrivateSalesLogistique.php');
require_once dirname(__FILE__).'/classes/SaleStats.php'; require_once dirname(__FILE__).'/classes/SaleStats.php';
ini_set('memory_limit', '4096M'); ini_set('memory_limit', '5G');
ini_set('max_execution_time', 0); ini_set('max_execution_time', -1);
set_include_path(get_include_path() . PATH_SEPARATOR . _PS_MODULE_DIR_.'privatesales_logistique/classes/'); set_include_path(get_include_path() . PATH_SEPARATOR . _PS_MODULE_DIR_.'privatesales_logistique/classes/');
include_once('PHPExcel.php'); include_once('PHPExcel.php');
@ -246,7 +246,8 @@ if(Tools::getValue('action') == 'getOrderForm' && ( ( $id_category = Tools::getV
// $authorized_ip = array( // $authorized_ip = array(
// '80.13.158.176', // '80.13.158.176',
// '88.120.248.124' // '88.120.248.124',
// '88.163.22.99'
// ); // );
// if(in_array($_SERVER['REMOTE_ADDR'], $authorized_ip)) // if(in_array($_SERVER['REMOTE_ADDR'], $authorized_ip))
// { // {
@ -1352,4 +1353,4 @@ if(Tools::getValue('action') == 'getOrderForm' && ( ( $id_category = Tools::getV
} }
exit; exit;
} }

View File

@ -191,78 +191,81 @@ class Order extends OrderCore {
public static function getIfSended($ids) { public static function getIfSended($ids) {
$data = array(); $data = array();
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT if (is_array($ids) && !empty($ids)) {
d.`id_order_detail`, foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
IF( SELECT
(SELECT COUNT(p.`id_order_detail`) d.`id_order_detail`,
FROM `'._DB_PREFIX_.'lapostews` p IF(
WHERE d.`id_order_detail` = p.`id_order_detail`), (SELECT COUNT(p.`id_order_detail`)
(SELECT SUM(p.`quantity`) FROM `'._DB_PREFIX_.'lapostews` p
FROM `'._DB_PREFIX_.'lapostews` p WHERE d.`id_order_detail` = p.`id_order_detail`),
WHERE d.`id_order_detail` = p.`id_order_detail`), (SELECT SUM(p.`quantity`)
0 FROM `'._DB_PREFIX_.'lapostews` p
) as `total_send` WHERE d.`id_order_detail` = p.`id_order_detail`),
FROM `'._DB_PREFIX_.'order_detail` d 0
WHERE d.`id_order_detail` IN ('.implode(',', $ids).') ) as `total_send`
') as $key => $info) { FROM `'._DB_PREFIX_.'order_detail` d
$data[$info['id_order_detail']] = $info['total_send']; WHERE d.`id_order_detail` IN ('.implode(',', $ids).')
} ') as $key => $info) {
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT
d.`id_order_detail`,
IF(
(SELECT COUNT(p.`id_order_detail`)
FROM `'._DB_PREFIX_.'mondialrelay_parcel` p
WHERE d.`id_order_detail` = p.`id_order_detail`),
(SELECT SUM(p.`quantity`)
FROM `'._DB_PREFIX_.'mondialrelay_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']; $data[$info['id_order_detail']] = $info['total_send'];
} }
} foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT
SELECT d.`id_order_detail`,
d.`id_order_detail`, IF(
IF( (SELECT COUNT(p.`id_order_detail`)
(SELECT COUNT(p.`id_order_detail`) FROM `'._DB_PREFIX_.'mondialrelay_parcel` p
FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` p WHERE d.`id_order_detail` = p.`id_order_detail`),
WHERE d.`id_order_detail` = p.`id_order_detail`), (SELECT SUM(p.`quantity`)
(SELECT SUM(p.`quantity`) FROM `'._DB_PREFIX_.'mondialrelay_parcel` p
FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` p WHERE d.`id_order_detail` = p.`id_order_detail`),
WHERE d.`id_order_detail` = p.`id_order_detail`), 0
0 ) as `total_send`
) as `total_send` FROM `'._DB_PREFIX_.'order_detail` d
FROM `'._DB_PREFIX_.'order_detail` d WHERE d.`id_order_detail` IN ('.implode(',', $ids).')
WHERE d.`id_order_detail` IN ('.implode(',', $ids).') ') as $key => $info) {
') as $key => $info) { if($data[$info['id_order_detail']]==0){
if($data[$info['id_order_detail']]==0){ $data[$info['id_order_detail']] = $info['total_send'];
$data[$info['id_order_detail']] = $info['total_send']; }
} }
} foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT
SELECT d.`id_order_detail`,
d.`id_order_detail`, IF(
IF( (SELECT COUNT(p.`id_order_detail`)
(SELECT COUNT(p.`id_order_detail`) FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` p
FROM `'._DB_PREFIX_.'philea_parcel` p WHERE d.`id_order_detail` = p.`id_order_detail`),
WHERE d.`id_order_detail` = p.`id_order_detail`), (SELECT SUM(p.`quantity`)
(SELECT SUM(p.`quantity`) FROM `'._DB_PREFIX_.'ant_dropshipping_parcel` p
FROM `'._DB_PREFIX_.'philea_parcel` p WHERE d.`id_order_detail` = p.`id_order_detail`),
WHERE d.`id_order_detail` = p.`id_order_detail`), 0
0 ) as `total_send`
) as `total_send` FROM `'._DB_PREFIX_.'order_detail` d
FROM `'._DB_PREFIX_.'order_detail` d WHERE d.`id_order_detail` IN ('.implode(',', $ids).')
WHERE d.`id_order_detail` IN ('.implode(',', $ids).') ') as $key => $info) {
') as $key => $info) { if($data[$info['id_order_detail']]==0){
if($data[$info['id_order_detail']]==0){ $data[$info['id_order_detail']] = $info['total_send'];
$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; return $data;

View File

@ -100,6 +100,8 @@
$storeAllTaxes = array(); $storeAllTaxes = array();
$id_country = (int)Country::getDefaultCountryId();
foreach ($products AS $key => $product) foreach ($products AS $key => $product)
{ {
$productQuantity = (int)(Product::getQuantity((int)($product['id_product']), ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL))); $productQuantity = (int)(Product::getQuantity((int)($product['id_product']), ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL)));
@ -117,7 +119,6 @@
$price_wt = Product::getPriceStatic((int)($product['id_product']), true, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), 2, NULL, false, true, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); $price_wt = Product::getPriceStatic((int)($product['id_product']), true, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), 2, NULL, false, true, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
/* Store tax info */ /* Store tax info */
$id_country = (int)Country::getDefaultCountryId();
$id_state = 0; $id_state = 0;
$id_county = 0; $id_county = 0;
$rate = 0; $rate = 0;

View File

@ -24,7 +24,7 @@
</div> </div>
{elseif $delivery_delay == 8} {elseif $delivery_delay == 8}
<div class="delivery_delay"> <div class="delivery_delay">
<img src="{$img_ps_dir}delay/48h_noel_{$cookie->id_lang}.png" alt="72h"> <img src="{$img_ps_dir}delay/48h_noel_{$cookie->id_lang}.png" alt="48h">
</div> </div>
{elseif $delivery_delay == 10} {elseif $delivery_delay == 10}
<div class="delivery_delay"> <div class="delivery_delay">