@@ -314,7 +314,7 @@ class DistributionController extends BackendController | |||
if ($ordersArray) { | |||
foreach ($ordersArray as $order) { | |||
$orderModule->initOrder($order); | |||
if($orderModule->getSolver()->isOrderStatusValid($order)) { | |||
if($order->isOrderStatusValid()) { | |||
$revenues += $orderModule->getOrderAmount($order); | |||
$revenuesWithTax += $orderModule->getOrderAmountWithTax($order); | |||
$weight += $order->weight; |
@@ -118,7 +118,7 @@ $this->setTitle('Tableau de bord'); | |||
<div class="info-box-content"> | |||
<span class="info-box-text"> | |||
<?php if(count($distribution->order)): ?> | |||
<strong><?= count($distribution->order); ?></strong> COMMANDES | |||
<strong><?= $distribution->countOrders(); ?></strong> COMMANDES | |||
<?php else: ?> | |||
AUCUNE COMMANDE | |||
<?php endif; ?> |
@@ -80,9 +80,25 @@ class Distribution extends ActiveRecordCommon | |||
]; | |||
} | |||
/* | |||
* Relations | |||
*/ | |||
/* Getters / Setters */ | |||
/* Méthodes */ | |||
public function countOrders(): int | |||
{ | |||
$count = 0; | |||
$ordersArray = $this->order; | |||
foreach($ordersArray as $order) { | |||
if($order->isOrderStatusValid()) { | |||
$count ++; | |||
} | |||
} | |||
return $count; | |||
} | |||
/* Relations */ | |||
public function getProducer() | |||
{ |
@@ -172,9 +172,41 @@ class Order extends ActiveRecordCommon | |||
]; | |||
} | |||
/* | |||
* Relations | |||
*/ | |||
/* Getters / Setters */ | |||
/* Méthodes */ | |||
public function isOrderStatusValid(): bool | |||
{ | |||
return $this->isOrderStatusOrdered() || $this->isOrderStatusUpdated(); | |||
} | |||
public function isOrderStatusCanceledOrDeleted(): bool | |||
{ | |||
return $this->isOrderStatusCanceled() || $this->isOrderStatusDeleted(); | |||
} | |||
public function isOrderStatusOrdered(): bool | |||
{ | |||
return $this->getOrderStatusAlias() == OrderStatus::ALIAS_ORDERED; | |||
} | |||
public function isOrderStatusUpdated(): bool | |||
{ | |||
return $this->getOrderStatusAlias() == OrderStatus::ALIAS_UPDATED; | |||
} | |||
public function isOrderStatusCanceled(): bool | |||
{ | |||
return $this->getOrderStatusAlias() == OrderStatus::ALIAS_CANCELED; | |||
} | |||
public function isOrderStatusDeleted(): bool | |||
{ | |||
return $this->getOrderStatusAlias() == OrderStatus::ALIAS_DELETED; | |||
} | |||
/* Relations */ | |||
public function getUser() | |||
{ |
@@ -484,7 +484,7 @@ class OrderBuilder extends AbstractBuilder | |||
if ($pointSale->id == $order->id_point_sale) { | |||
$pointSale->orders[] = $order; | |||
if($this->orderSolver->isOrderStatusValid($order)) { | |||
if($order->isOrderStatusValid()) { | |||
$pointSale->revenues += (float)$order->amount; | |||
$pointSale->revenues_with_tax += (float)$order->amount_with_tax; | |||
} |
@@ -51,7 +51,7 @@ class OrderManager extends AbstractService implements ManagerInterface | |||
$orderStatus = $this->orderStatusRepository->getOrderStatusByAlias($orderStatusAlias); | |||
$order->setOrderStatus($orderStatus); | |||
if(!$this->orderSolver->isOrderStatusOrdered($order)) { | |||
if(!$order->isOrderStatusOrdered()) { | |||
$this->orderBuilder->initDateUpdate($order); | |||
} | |||
$this->orderBuilder->update($order); | |||
@@ -72,7 +72,7 @@ class OrderManager extends AbstractService implements ManagerInterface | |||
// delete | |||
if ($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE || | |||
($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS | |||
&& $this->orderSolver->isOrderStatusCanceled($order)) | |||
&& $order->isOrderStatusCanceled()) | |||
|| $force) { | |||
$this->changeOrderStatus($order, OrderStatus::ALIAS_DELETED, $user); |
@@ -209,7 +209,7 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
if (count($ordersArray)) { | |||
foreach ($ordersArray as $order) { | |||
if($this->isOrderStatusValid($order)) { | |||
if($order->isOrderStatusValid()) { | |||
foreach ($order->productOrder as $productOrder) { | |||
if ($productOrder->id_product == $product->id) { | |||
$quantity += $this->productOrderSolver->getQuantityPieces($productOrder); | |||
@@ -231,7 +231,7 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
if (count($ordersArray)) { | |||
foreach ($ordersArray as $order) { | |||
if ($this->isOrderStatusValid($order) || $ignoreCancel) { | |||
if ($order->isOrderStatusValid() || $ignoreCancel) { | |||
foreach ($order->productOrder as $productOrder) { | |||
if ($productOrder->id_product == $product->id && | |||
((is_null($unit) && $productOrder->product->unit == $productOrder->unit) | |||
@@ -253,7 +253,7 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
// getClassHistory | |||
public function getHistoryClass(Order $order): string | |||
{ | |||
if($this->isOrderStatusCanceled($order)) { | |||
if($order->isOrderStatusCanceled()) { | |||
return 'commande-delete'; | |||
} | |||
@@ -539,43 +539,11 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
return $orderStatusHistoryReturn; | |||
} | |||
public function isOrderStatusValid(Order $order): bool | |||
{ | |||
return $this->isOrderStatusOrdered($order) | |||
|| $this->isOrderStatusUpdated($order); | |||
} | |||
public function isOrderStatusCanceledOrDeleted(Order $order): bool | |||
{ | |||
return $this->isOrderStatusCanceled($order) | |||
|| $this->isOrderStatusDeleted($order); | |||
} | |||
public function isOrderStatusOrdered(Order $order): bool | |||
{ | |||
return $order->getOrderStatusAlias() == OrderStatus::ALIAS_ORDERED; | |||
} | |||
public function isOrderStatusUpdated(Order $order): bool | |||
{ | |||
return $order->getOrderStatusAlias() == OrderStatus::ALIAS_UPDATED; | |||
} | |||
public function isOrderStatusCanceled(Order $order): bool | |||
{ | |||
return $order->getOrderStatusAlias() == OrderStatus::ALIAS_CANCELED; | |||
} | |||
public function isOrderStatusDeleted(Order $order): bool | |||
{ | |||
return $order->getOrderStatusAlias() == OrderStatus::ALIAS_DELETED; | |||
} | |||
public function getLabelDeleteAction(Order $order): string | |||
{ | |||
$optionBehaviorCancelOrder = $this->producerSolver->getConfig('option_behavior_cancel_order'); | |||
if($optionBehaviorCancelOrder == Producer::BEHAVIOR_DELETE_ORDER_STATUS && $this->isOrderStatusValid($order)) { | |||
if($optionBehaviorCancelOrder == Producer::BEHAVIOR_DELETE_ORDER_STATUS && $order->isOrderStatusValid()) { | |||
return 'Annuler'; | |||
} | |||
@@ -584,16 +552,16 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
public function getOrderStatusCssClass(Order $order): string | |||
{ | |||
if($this->isOrderStatusOrdered($order)) { | |||
if($order->isOrderStatusOrdered()) { | |||
return 'success'; | |||
} | |||
elseif($this->isOrderStatusUpdated($order)) { | |||
elseif($order->isOrderStatusUpdated()) { | |||
return 'warning'; | |||
} | |||
elseif($this->isOrderStatusCanceled($order)) { | |||
elseif($order->isOrderStatusCanceled()) { | |||
return 'danger'; | |||
} | |||
elseif($this->isOrderStatusDeleted($order)) { | |||
elseif($order->isOrderStatusDeleted()) { | |||
return 'danger'; | |||
} | |||
@@ -393,7 +393,7 @@ class OrderController extends ProducerBaseController | |||
$pointSaleModule->getComment($pointSale) : ''; | |||
// une commande annulée est automatiquement réactivée lors d'une modification | |||
if($orderModule->getSolver()->isOrderStatusCanceled($order)) { | |||
if($order->isOrderStatusCanceled()) { | |||
$orderModule->getManager()->changeOrderStatus($order, OrderStatus::ALIAS_UPDATED, $this->getUserCurrent()); | |||
} | |||
@@ -121,7 +121,7 @@ $this->setTitle('Mes commandes') ; | |||
'value' => function($order) use ($orderModule) { | |||
$html = '' ; | |||
if($orderModule->getSolver()->isOrderStatusCanceled($order)) { | |||
if($order->isOrderStatusCanceled()) { | |||
$html .= '<span class="badge text-bg-danger">Annulée</span>' ; | |||
} | |||
else { |