Merge branch 'ticket-10133' into develop

This commit is contained in:
Marion Muszynski 2016-09-15 11:42:52 +02:00
commit 445227062e

View File

@ -441,18 +441,18 @@ class AdminOrders extends AdminTab
if(count($to_send) == 0) {
$partial = false;
} else {
// include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
// $quantities_sent = array();
include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
$quantities_sent = array();
$product_ids = array();
foreach(Db::getInstance()->ExecuteQ('
SELECT `product_id`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $order->id.'
') as $row) {
$product_ids[] = (int) $row['product_id'];
}
// $product_ids = array();
// foreach(Db::getInstance()->ExecuteQ('
// SELECT `product_id`
// FROM `'._DB_PREFIX_.'order_detail`
// WHERE `id_order` = '.(int) $order->id.'
// ') as $row) {
// $product_ids[] = (int) $row['product_id'];
// }
//
// /**
// * @Override Philea
// */
@ -469,51 +469,54 @@ class AdminOrders extends AdminTab
// $quantities_sent[(int) $row['id_product']] = -1;
// }
// }
// $parcel_quantities = array();
// foreach($to_send as $ts) {
// if(!isset($quantities_sent[(int) $ts['product_id']])) {
// $parcel_quantities[(int) $ts['id_order_detail']] = $ts;
// }
// }
// if(count($parcel_quantities) > 0) {
// $partial = false;
// $sent_logistics = array();
// foreach(Db::getInstance()->ExecuteS('
// SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
// FROM `'._DB_PREFIX_.'lapostews`
// WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
// GROUP BY `id_order_detail`
// ') as $row) {
// $sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
// }
// foreach(Db::getInstance()->ExecuteS('
// SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
// FROM `'._DB_PREFIX_.'exapaqws`
// WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
// GROUP BY `id_order_detail`
// ') as $row) {
// $sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
// }
$parcel_quantities = array();
foreach($to_send as $ts) {
if(!isset($quantities_sent[(int) $ts['product_id']])) {
$parcel_quantities[(int) $ts['id_order_detail']] = $ts;
}
}
// if(count($sent_logistics) == 0) {
// $partial = true;
// } else {
// foreach($parcel_quantities as $k => $v) {
// if(!isset($sent_logistics[(int) $k])) {
// $partial = true;
// break;
// } else {
// if($sent_logistics[(int) $k] < $v['quantity']) {
// $partial = true;
// break;
// }
// }
// }
// }
// } else {
// $partial = false;
// }
if(count($parcel_quantities) > 0) {
$partial = false;
$sent_logistics = array();
foreach(Db::getInstance()->ExecuteS('
SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
FROM `'._DB_PREFIX_.'lapostews`
WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
GROUP BY `id_order_detail`
') as $row) {
$sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
}
foreach(Db::getInstance()->ExecuteS('
SELECT SUM(`quantity`) AS `quantity`, `id_order_detail`
FROM `'._DB_PREFIX_.'exapaqws`
WHERE `id_order_detail` IN ('.implode(', ', array_keys($parcel_quantities)).')
GROUP BY `id_order_detail`
') as $row) {
$sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
}
if(count($sent_logistics) == 0) {
$partial = true;
} else {
foreach($parcel_quantities as $k => $v) {
if(!isset($sent_logistics[(int) $k])) {
$partial = true;
break;
} else {
if($sent_logistics[(int) $k] < $v['quantity']) {
$partial = true;
break;
}
}
}
}
} else {
$partial = false;
}
}
if(!$partial) {