diff --git a/modules/labelgenerate/AdminLabelGenerate.php b/modules/labelgenerate/AdminLabelGenerate.php index b90bdc52..d43e4f55 100644 --- a/modules/labelgenerate/AdminLabelGenerate.php +++ b/modules/labelgenerate/AdminLabelGenerate.php @@ -57,8 +57,10 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = 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` = ' . (int)$combination['id_product'] .' - AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'] + AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'].' + AND o.valid != 0' ); $quantity = 0; foreach ($result_quantities as $od) { @@ -72,7 +74,8 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = Db::getInstance()->executeS(' SELECT od.`product_quantity`,od.`product_quantity_reinjected` FROM '._DB_PREFIX_.'order_detail od - WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0' + LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = od.`id_order`) + WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0 AND o.valid != 0' ); $quantity = 0; foreach ($result_quantities as $od) { @@ -171,8 +174,10 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = 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` = ' . (int)$combination['id_product'] .' - AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'] + AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'].' + AND o.`valid` != 0' ); foreach ($result_quantities as $od) { $quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']); @@ -206,7 +211,8 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = Db::getInstance()->executeS(' SELECT od.`product_quantity`,od.`product_quantity_reinjected` FROM '._DB_PREFIX_.'order_detail od - WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0' + LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = od.`id_order`) + WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0 AND o.`valid` != 0' ); foreach ($result_quantities as $od) { $quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']); @@ -279,8 +285,10 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = 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` = ' . (int)$combination['id_product'] .' - AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'] + AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'].' + AND o.`valid` != 0' ); foreach ($result_quantities as $od) { $quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']); @@ -311,7 +319,8 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = Db::getInstance()->executeS(' SELECT od.`product_quantity`,od.`product_quantity_reinjected` FROM '._DB_PREFIX_.'order_detail od - WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0' + LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = od.`id_order`) + WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0 AND o.`valid` != 0' ); foreach ($result_quantities as $od) { $quantity += ($od['product_quantity'] - $od['product_quantity_reinjected']); @@ -381,8 +390,10 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = 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` = ' . (int)$combination['id_product'] .' - AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'] + AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'].' + AND o.`valid` != 0' ); $quantity = 0; foreach ($result_quantities as $od) { @@ -413,7 +424,8 @@ class AdminLabelGenerate extends AdminTab { $result_quantities = Db::getInstance()->executeS(' SELECT od.`product_quantity`,od.`product_quantity_reinjected` FROM '._DB_PREFIX_.'order_detail od - WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0' + LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = od.`id_order`) + WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0 AND o.`valid` != 0' ); $quantity = 0; foreach ($result_quantities as $od) {