Merge branch 'ticket-14285-Dropshipping' into develop

This commit is contained in:
Marion Muszynski 2017-09-28 16:50:18 +02:00
commit 0462fda92b
3 changed files with 85 additions and 5 deletions

View File

@ -23,7 +23,7 @@ class AdminAntDropshippingtracking extends AdminTab
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `is_sale` = '.(int) $id_sale.'
WHERE `id_sale` = '.(int) $id_sale.'
') as $key => $row) {
$sale_products[(int)$row['id_product']] = (int)$row['id_product'];
}
@ -53,7 +53,7 @@ class AdminAntDropshippingtracking extends AdminTab
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $id_order.'
') as $key => $row) {
$order_details[(int)$row['id_order_detail']] = (int)$row;
$order_details[(int)$row['id_order_detail']] = $row;
}
$fully_sent = false;
@ -127,13 +127,40 @@ class AdminAntDropshippingtracking extends AdminTab
}
}
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_.'ant_dropshipping_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();
$html_products_sent = '';
foreach($order_details as $id_order_detail => $d) {
if(!in_array($id_order_detail, $products_sent) && in_array($d['product_id'],$sale_products)) {
if(!in_array($id_order_detail, $products_sent) && !in_array($d['product_id'],$sale_products)) {
$remaining[] = (int)$id_order_detail;
} elseif(in_array((int)$d['product_id'],$sale_products)) {
} elseif(!in_array($id_order_detail, $products_sent) && in_array((int)$d['product_id'],$sale_products)) {
$html_products_sent .= '<br />'."\r\n".$d['quantity'] . 'x' . ' ' . $p['product_name'];
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'ant_dropshipping_parcel`
VALUES (
'.(int) $id_order_detail.',
'.(int) $d['quantity'].',
"'.pSQL($o['tracking_number']).'",
"'.pSQL($o['carrier']).'",
"'.pSQL($o['link']).'",
NOW()
)
');
}
}
@ -162,6 +189,17 @@ class AdminAntDropshippingtracking extends AdminTab
$history->id_employee = 0;
$history->add();
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'shipping_history`
VALUES (
'.(int) $order->id.',
"'.pSQL($o['shipping_number']).'",
NOW(),
0,
'.(int)$id_sale.'
)
');
$order->shipping_number = $o['tracking_number'];
$order->save();
@ -226,7 +264,10 @@ class AdminAntDropshippingtracking extends AdminTab
<div class="row">
<div class="col-md-12">
<div class="panel">
<h2 class="heading-title"><span class="anticon anticon-cog"></span> '.$this->l('Import information dropshipping').'</h2>
<div class="panel-title">
<h2 class=""><span class="text-rose anticon anticon-truck"></span> '.$this->l('Import information dropshipping').'</h2>
<div class="clearfix"></div>
</div>
<div class="panel-content">
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
<div class="col-md-5 col-md-offset-4">';

View File

@ -1573,6 +1573,28 @@ class LaposteCarrier {
$to_send[] = (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`, s.`shipping_number`
FROM `'._DB_PREFIX_.'order_detail` d
LEFT OUTER JOIN `'._DB_PREFIX_.'ant_dropshipping_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($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('

View File

@ -190,6 +190,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_.'ant_dropshipping_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)) {