Browse Source

Corrections diverses liées à l'annulation de commandes

dev
Guillaume Bourgeois 5 years ago
parent
commit
0f67ab5243
2 changed files with 4 additions and 3 deletions
  1. +3
    -2
      common/models/Order.php
  2. +1
    -1
      producer/controllers/OrderController.php

+ 3
- 2
common/models/Order.php View File

@@ -562,16 +562,17 @@ class Order extends ActiveRecordCommon
*
* @param integer $idProduct
* @param array $orders
* @param boolean $ignoreCancel
*
* @return integer
*/
public static function getProductQuantity($idProduct, $orders)
public static function getProductQuantity($idProduct, $orders, $ignoreCancel = false)
{
$quantity = 0;
if (isset($orders) && is_array($orders) && count($orders)) {
foreach ($orders as $c) {
if(is_null($c->date_delete)) {
if(is_null($c->date_delete) || $ignoreCancel) {
foreach ($c->productOrder as $po) {
if ($po->id_product == $idProduct) {
$quantity += $po->quantity ;

+ 1
- 1
producer/controllers/OrderController.php View File

@@ -733,7 +733,7 @@ class OrderController extends ProducerBaseController
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder ;
if($orderUser) {
$quantityOrderUser = Order::getProductQuantity($product['id'], [$orderUser]) ;
$quantityOrderUser = Order::getProductQuantity($product['id'], [$orderUser], true) ;
$product['quantity_ordered'] = $quantityOrder ;
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder + $quantityOrderUser ;
$product['quantity_form'] = $quantityOrderUser ;

Loading…
Cancel
Save