Merge branch 'ticket-invoiceOrderBy'

This commit is contained in:
Marion Muszynski 2016-07-13 10:59:09 +02:00
commit 2b9fd29308
3 changed files with 16 additions and 11 deletions

View File

@ -836,7 +836,7 @@ class PDFCore extends PDF_PageGroupCore
if (isset(self::$order->products) AND sizeof(self::$order->products))
$products = self::$order->products;
else
$products = self::$order->getProducts();
$products = self::$order->getProducts(false,false,false,true);
}
else
$products = self::$orderSlip->getOrdersSlipProducts(self::$orderSlip->id, self::$order);

View File

@ -860,6 +860,7 @@ class Sale {
if(count($orders) > 0) {
$_orders = array();
$_nb_product = array();
foreach(Db::getInstance()->ExecuteS('
SELECT d.`id_order`, p.`id_product`, c.`id_sale`, GREATEST(d.`product_quantity` - d.`product_quantity_return`, 0) AS `product_quantity`
FROM `'._DB_PREFIX_.'privatesale_category` c
@ -872,6 +873,9 @@ class Sale {
') as $row) {
if(!isset($_orders[(int)$row['id_order']])) {
$_orders[(int)$row['id_order']] = array();
$_nb_product[(int)$row['id_order']] = 1;
} else {
$_nb_product[(int)$row['id_order']]++;
}
if(!isset($_orders[(int)$row['id_order']][$row['id_sale']]) ) {
$_orders[(int)$row['id_order']][$row['id_sale']] = 1;
@ -931,15 +935,16 @@ class Sale {
if ($multi_only) {
return $order_print;
} else {
// tri par date pour les M2+
sort($order_print);
/*usort($order_print, function ($a, $b) {
if ($order_sales[$a] == $order_sales[$b]) {
return 0;
}
return ($order_sales[$a] < $order_sales[$b]) ? -1 : 1;
});*/
return $order_print;
asort($_nb_product);
$result_to_print = array();
foreach ($_nb_product as $key => $value) {
if (in_array($key,$order_print)) {
$result_to_print[]=$key;
} else {
continue;
}
}
return $result_to_print;
}
return $order_print;