Merge branch 'ticket-10657-PhileaPacks' into develop

This commit is contained in:
Marion Muszynski 2016-11-28 17:08:04 +01:00
commit 7571bc08f6

View File

@ -75,8 +75,13 @@
$product = explode('_', $product);
$id_product = (int) $product[0];
$id_product_attribute = (isset($product[1]) ? (int) $product[1] : 0);
if($detail = Db::getInstance()->getRow('
$is_pack = false;
if (isset($order_details[$id_sale][$id_order][$id_product.'|'.$id_product_attribute])) {
if (Pack::isPacked((int) $id_product)){
$is_pack = true;
}
}
if(!$is_pack && $detail = Db::getInstance()->getRow('
SELECT `id_order_detail`, `product_quantity` - GREATEST(`product_quantity_return`, `product_quantity_refunded`) AS `quantity`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $id_order.'
@ -93,6 +98,32 @@
// GET QTY
$qty = (int) trim($data[8]);
$order_details[$id_sale][$id_order][$id_product.'|'.$id_product_attribute] = (int) $detail['quantity'] - $qty;
} else {
if (Pack::isPacked((int) $id_product)) {
$packs = Pack::getPacks((int) $id_product);
foreach($packs as $pack) {
if (is_array($pack)) {
if($detail = Db::getInstance()->getRow('
SELECT `id_order_detail`, `product_quantity` - GREATEST(`product_quantity_return`, `product_quantity_refunded`) AS `quantity`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $id_order.'
AND `product_id` = '.(int) $pack['id_product_pack'].'
AND `product_attribute_id` = 0
')) {
if ($id_sale && !isset($order_details[$id_sale])) {
$order_details[$id_sale] = array();
}
if ($id_sale && !isset($order_details[$id_sale][$id_order])) {
$order_details[$id_sale][$id_order] = array();
}
// GET QTY
$qty = (int) trim($data[8]);
$order_details[$id_sale][$id_order][$pack['id_product_pack'].'|'.$id_product.'|1'] = ((int) $detail['quantity'] * (int) $pack['quantity']) - $qty;
}
}
}
}
}
}
foreach ($order_details as $sale => $orders) {
@ -103,10 +134,17 @@
foreach ($products as $key => $qty) {
$count += $qty;
$product = explode('|', $key);
$id_product = (int) $product[0];
$id_product_attribute = (isset($product[1]) ? (int) $product[1] : 0);
$is_pack = (isset($product[2]) ? (int) $product[2] : 0);
if ($qty>0) {
$errors .= "<li>".$qty." Produit #".$id_product.($id_product_attribute?" - attribute #".$id_product_attribute:"")." manquant</li>";
if($is_pack) {
$id_pack = (int) $product[0];
$id_product = (isset($product[1]) ? (int) $product[1] : 0);
$errors .= "<li>".$qty." Produit #".$id_product." du Pack ".$id_pack." manquant</li>";
} else {
$id_product = (int) $product[0];
$id_product_attribute = (isset($product[1]) ? (int) $product[1] : 0);
$errors .= "<li>".$qty." Produit #".$id_product.($id_product_attribute?" - attribute #".$id_product_attribute:"")." manquant</li>";
}
}
}
$comments .= "<strong>Commande [".$order."] : ".($count>0? "<span style='color:red;'>Produits manquants</span>": "<span style='color:green;'>Commande préparée</span>")."</strong><br />";