Ver código fonte

Corrections diverses liées à l'annulation de commandes

refactoring
Guillaume Bourgeois 5 anos atrás
pai
commit
0f67ab5243
2 arquivos alterados com 4 adições e 3 exclusões
  1. +3
    -2
      common/models/Order.php
  2. +1
    -1
      producer/controllers/OrderController.php

+ 3
- 2
common/models/Order.php Ver arquivo

@@ -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 Ver arquivo

@@ -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 ;

Carregando…
Cancelar
Salvar