fix quantity sold request in adminPrivatesSaleLogistic
This commit is contained in:
parent
d0dc500502
commit
b4370e2440
@ -634,6 +634,7 @@ class AdminPrivateSalesLogistique extends AdminTab {
|
|||||||
|
|
||||||
public function getSaleExportsByDate($date_start,$date_end,$id_lang)
|
public function getSaleExportsByDate($date_start,$date_end,$id_lang)
|
||||||
{
|
{
|
||||||
|
$order_states = explode(',', Configuration::get('PS_IT_OF_ORDER_STATES'));
|
||||||
$ids = Db::getInstance()->ExecuteS('
|
$ids = Db::getInstance()->ExecuteS('
|
||||||
SELECT c.id_category
|
SELECT c.id_category
|
||||||
FROM `'._DB_PREFIX_.'privatesale` p
|
FROM `'._DB_PREFIX_.'privatesale` p
|
||||||
@ -799,16 +800,30 @@ class AdminPrivateSalesLogistique extends AdminTab {
|
|||||||
sort($names, SORT_STRING);
|
sort($names, SORT_STRING);
|
||||||
|
|
||||||
$quantity_sold = (int) Db::getInstance()->getValue('
|
$quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
SELECT SUM(d.`product_quantity`)
|
SELECT SUM(d.`product_quantity` - d.`product_quantity_reinjected`)
|
||||||
FROM `'._DB_PREFIX_.'order_detail` d
|
FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
|
||||||
ON o.`id_order` = d.`id_order`
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
|
||||||
ON h.`id_order` = d.`id_order`
|
|
||||||
WHERE d.`product_id` = '.(int) $p->id.'
|
WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
AND d.`product_attribute_id` = '.(int) $k.'
|
AND d.`product_attribute_id` = '.(int) $k.'
|
||||||
AND h.`id_order_state` = 2
|
AND (
|
||||||
|
SELECT `id_order_state`
|
||||||
|
FROM `'._DB_PREFIX_.'order_history` oh
|
||||||
|
WHERE o.`id_order` = oh.`id_order`
|
||||||
|
ORDER BY `id_order_history` DESC
|
||||||
|
LIMIT 1
|
||||||
|
) IN ("'.implode('","', $order_states).'")
|
||||||
');
|
');
|
||||||
|
// $quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
|
// SELECT SUM(d.`product_quantity`)
|
||||||
|
// FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||||
|
// ON o.`id_order` = d.`id_order`
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
||||||
|
// ON h.`id_order` = d.`id_order`
|
||||||
|
// WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
|
// AND d.`product_attribute_id` = '.(int) $k.'
|
||||||
|
// AND h.`id_order_state` = 2
|
||||||
|
// ');
|
||||||
|
|
||||||
$customs = Db::getInstance()->getRow('
|
$customs = Db::getInstance()->getRow('
|
||||||
SELECT `nc8`, `id_country`
|
SELECT `nc8`, `id_country`
|
||||||
@ -850,17 +865,30 @@ class AdminPrivateSalesLogistique extends AdminTab {
|
|||||||
), ';', '"');
|
), ';', '"');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$quantity_sold = (int) Db::getInstance()->getValue('
|
$quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
SELECT SUM(d.`product_quantity`)
|
SELECT SUM(d.`product_quantity` - d.`product_quantity_reinjected`)
|
||||||
FROM `'._DB_PREFIX_.'order_detail` d
|
FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
|
||||||
ON o.`id_order` = d.`id_order`
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
|
||||||
ON h.`id_order` = d.`id_order`
|
|
||||||
WHERE d.`product_id` = '.(int) $p->id.'
|
WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
AND h.`id_order_state` = 2
|
AND d.`product_attribute_id` = 0
|
||||||
|
AND (
|
||||||
|
SELECT `id_order_state`
|
||||||
|
FROM `'._DB_PREFIX_.'order_history` oh
|
||||||
|
WHERE o.`id_order` = oh.`id_order`
|
||||||
|
ORDER BY `id_order_history` DESC
|
||||||
|
LIMIT 1
|
||||||
|
) IN ("'.implode('","', $order_states).'")
|
||||||
');
|
');
|
||||||
|
// $quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
|
// SELECT SUM(d.`product_quantity`)
|
||||||
|
// FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||||
|
// ON o.`id_order` = d.`id_order`
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
||||||
|
// ON h.`id_order` = d.`id_order`
|
||||||
|
// WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
|
// AND h.`id_order_state` = 2
|
||||||
|
// ');
|
||||||
|
|
||||||
$customs = Db::getInstance()->getRow('
|
$customs = Db::getInstance()->getRow('
|
||||||
SELECT `nc8`, `id_country`
|
SELECT `nc8`, `id_country`
|
||||||
@ -920,6 +948,7 @@ class AdminPrivateSalesLogistique extends AdminTab {
|
|||||||
if($id_lang == 0) {
|
if($id_lang == 0) {
|
||||||
$id_lang = $cookie->id_lang;
|
$id_lang = $cookie->id_lang;
|
||||||
}
|
}
|
||||||
|
$order_states = explode(',', Configuration::get('PS_IT_OF_ORDER_STATES'));
|
||||||
$sale = Sale::getSaleFromCategory($id_category);
|
$sale = Sale::getSaleFromCategory($id_category);
|
||||||
$category = new Category($id_category, $cookie->id_lang);
|
$category = new Category($id_category, $cookie->id_lang);
|
||||||
if ($category) {
|
if ($category) {
|
||||||
@ -1078,16 +1107,30 @@ class AdminPrivateSalesLogistique extends AdminTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$quantity_sold = (int) Db::getInstance()->getValue('
|
$quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
SELECT SUM(d.`product_quantity`)
|
SELECT SUM(d.`product_quantity` - d.`product_quantity_reinjected`)
|
||||||
FROM `'._DB_PREFIX_.'order_detail` d
|
FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
|
||||||
ON o.`id_order` = d.`id_order`
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
|
||||||
ON h.`id_order` = d.`id_order`
|
|
||||||
WHERE d.`product_id` = '.(int) $p->id.'
|
WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
AND d.`product_attribute_id` = '.(int) $k.'
|
AND d.`product_attribute_id` = '.(int) $k.'
|
||||||
AND h.`id_order_state` = 2
|
AND (
|
||||||
|
SELECT `id_order_state`
|
||||||
|
FROM `'._DB_PREFIX_.'order_history` oh
|
||||||
|
WHERE o.`id_order` = oh.`id_order`
|
||||||
|
ORDER BY `id_order_history` DESC
|
||||||
|
LIMIT 1
|
||||||
|
) IN ("'.implode('","', $order_states).'")
|
||||||
');
|
');
|
||||||
|
// $quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
|
// SELECT SUM(d.`product_quantity`)
|
||||||
|
// FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||||
|
// ON o.`id_order` = d.`id_order`
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
||||||
|
// ON h.`id_order` = d.`id_order`
|
||||||
|
// WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
|
// AND d.`product_attribute_id` = '.(int) $k.'
|
||||||
|
// AND h.`id_order_state` = 2
|
||||||
|
// ');
|
||||||
|
|
||||||
$names = array_unique($v['name']);
|
$names = array_unique($v['name']);
|
||||||
sort($names, SORT_STRING);
|
sort($names, SORT_STRING);
|
||||||
@ -1125,15 +1168,29 @@ class AdminPrivateSalesLogistique extends AdminTab {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$quantity_sold = (int) Db::getInstance()->getValue('
|
$quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
SELECT SUM(d.`product_quantity`)
|
SELECT SUM(d.`product_quantity` - d.`product_quantity_reinjected`)
|
||||||
FROM `'._DB_PREFIX_.'order_detail` d
|
FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
|
||||||
ON o.`id_order` = d.`id_order`
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
|
||||||
ON h.`id_order` = d.`id_order`
|
|
||||||
WHERE d.`product_id` = '.(int) $p->id.'
|
WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
AND h.`id_order_state` = 2
|
AND d.`product_attribute_id` = 0
|
||||||
|
AND (
|
||||||
|
SELECT `id_order_state`
|
||||||
|
FROM `'._DB_PREFIX_.'order_history` oh
|
||||||
|
WHERE o.`id_order` = oh.`id_order`
|
||||||
|
ORDER BY `id_order_history` DESC
|
||||||
|
LIMIT 1
|
||||||
|
) IN ("'.implode('","', $order_states).'")
|
||||||
');
|
');
|
||||||
|
// $quantity_sold = (int) Db::getInstance()->getValue('
|
||||||
|
// SELECT SUM(d.`product_quantity`)
|
||||||
|
// FROM `'._DB_PREFIX_.'order_detail` d
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||||
|
// ON o.`id_order` = d.`id_order`
|
||||||
|
// LEFT JOIN `'._DB_PREFIX_.'order_history` h
|
||||||
|
// ON h.`id_order` = d.`id_order`
|
||||||
|
// WHERE d.`product_id` = '.(int) $p->id.'
|
||||||
|
// AND h.`id_order_state` = 2
|
||||||
|
// ');
|
||||||
|
|
||||||
fputcsv($f, array(
|
fputcsv($f, array(
|
||||||
$p->supplier_reference,
|
$p->supplier_reference,
|
||||||
|
Loading…
Reference in New Issue
Block a user