if ($ordersArray) { | if ($ordersArray) { | ||||
foreach ($ordersArray as $order) { | foreach ($ordersArray as $order) { | ||||
$orderModule->initOrder($order); | $orderModule->initOrder($order); | ||||
if($orderModule->getSolver()->isOrderStatusValid($order)) { | |||||
if($order->isOrderStatusValid()) { | |||||
$revenues += $orderModule->getOrderAmount($order); | $revenues += $orderModule->getOrderAmount($order); | ||||
$revenuesWithTax += $orderModule->getOrderAmountWithTax($order); | $revenuesWithTax += $orderModule->getOrderAmountWithTax($order); | ||||
$weight += $order->weight; | $weight += $order->weight; |
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text"> | <span class="info-box-text"> | ||||
<?php if(count($distribution->order)): ?> | <?php if(count($distribution->order)): ?> | ||||
<strong><?= count($distribution->order); ?></strong> COMMANDES | |||||
<strong><?= $distribution->countOrders(); ?></strong> COMMANDES | |||||
<?php else: ?> | <?php else: ?> | ||||
AUCUNE COMMANDE | AUCUNE COMMANDE | ||||
<?php endif; ?> | <?php endif; ?> |
]; | ]; | ||||
} | } | ||||
/* | |||||
* 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() | public function getProducer() | ||||
{ | { |
]; | ]; | ||||
} | } | ||||
/* | |||||
* 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() | public function getUser() | ||||
{ | { |
if ($pointSale->id == $order->id_point_sale) { | if ($pointSale->id == $order->id_point_sale) { | ||||
$pointSale->orders[] = $order; | $pointSale->orders[] = $order; | ||||
if($this->orderSolver->isOrderStatusValid($order)) { | |||||
if($order->isOrderStatusValid()) { | |||||
$pointSale->revenues += (float)$order->amount; | $pointSale->revenues += (float)$order->amount; | ||||
$pointSale->revenues_with_tax += (float)$order->amount_with_tax; | $pointSale->revenues_with_tax += (float)$order->amount_with_tax; | ||||
} | } |
$orderStatus = $this->orderStatusRepository->getOrderStatusByAlias($orderStatusAlias); | $orderStatus = $this->orderStatusRepository->getOrderStatusByAlias($orderStatusAlias); | ||||
$order->setOrderStatus($orderStatus); | $order->setOrderStatus($orderStatus); | ||||
if(!$this->orderSolver->isOrderStatusOrdered($order)) { | |||||
if(!$order->isOrderStatusOrdered()) { | |||||
$this->orderBuilder->initDateUpdate($order); | $this->orderBuilder->initDateUpdate($order); | ||||
} | } | ||||
$this->orderBuilder->update($order); | $this->orderBuilder->update($order); | ||||
// delete | // delete | ||||
if ($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_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->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS | ||||
&& $this->orderSolver->isOrderStatusCanceled($order)) | |||||
&& $order->isOrderStatusCanceled()) | |||||
|| $force) { | || $force) { | ||||
$this->changeOrderStatus($order, OrderStatus::ALIAS_DELETED, $user); | $this->changeOrderStatus($order, OrderStatus::ALIAS_DELETED, $user); |
if (count($ordersArray)) { | if (count($ordersArray)) { | ||||
foreach ($ordersArray as $order) { | foreach ($ordersArray as $order) { | ||||
if($this->isOrderStatusValid($order)) { | |||||
if($order->isOrderStatusValid()) { | |||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
if ($productOrder->id_product == $product->id) { | if ($productOrder->id_product == $product->id) { | ||||
$quantity += $this->productOrderSolver->getQuantityPieces($productOrder); | $quantity += $this->productOrderSolver->getQuantityPieces($productOrder); | ||||
if (count($ordersArray)) { | if (count($ordersArray)) { | ||||
foreach ($ordersArray as $order) { | foreach ($ordersArray as $order) { | ||||
if ($this->isOrderStatusValid($order) || $ignoreCancel) { | |||||
if ($order->isOrderStatusValid() || $ignoreCancel) { | |||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
if ($productOrder->id_product == $product->id && | if ($productOrder->id_product == $product->id && | ||||
((is_null($unit) && $productOrder->product->unit == $productOrder->unit) | ((is_null($unit) && $productOrder->product->unit == $productOrder->unit) | ||||
// getClassHistory | // getClassHistory | ||||
public function getHistoryClass(Order $order): string | public function getHistoryClass(Order $order): string | ||||
{ | { | ||||
if($this->isOrderStatusCanceled($order)) { | |||||
if($order->isOrderStatusCanceled()) { | |||||
return 'commande-delete'; | return 'commande-delete'; | ||||
} | } | ||||
return $orderStatusHistoryReturn; | 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 | public function getLabelDeleteAction(Order $order): string | ||||
{ | { | ||||
$optionBehaviorCancelOrder = $this->producerSolver->getConfig('option_behavior_cancel_order'); | $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'; | return 'Annuler'; | ||||
} | } | ||||
public function getOrderStatusCssClass(Order $order): string | public function getOrderStatusCssClass(Order $order): string | ||||
{ | { | ||||
if($this->isOrderStatusOrdered($order)) { | |||||
if($order->isOrderStatusOrdered()) { | |||||
return 'success'; | return 'success'; | ||||
} | } | ||||
elseif($this->isOrderStatusUpdated($order)) { | |||||
elseif($order->isOrderStatusUpdated()) { | |||||
return 'warning'; | return 'warning'; | ||||
} | } | ||||
elseif($this->isOrderStatusCanceled($order)) { | |||||
elseif($order->isOrderStatusCanceled()) { | |||||
return 'danger'; | return 'danger'; | ||||
} | } | ||||
elseif($this->isOrderStatusDeleted($order)) { | |||||
elseif($order->isOrderStatusDeleted()) { | |||||
return 'danger'; | return 'danger'; | ||||
} | } | ||||
$pointSaleModule->getComment($pointSale) : ''; | $pointSaleModule->getComment($pointSale) : ''; | ||||
// une commande annulée est automatiquement réactivée lors d'une modification | // 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()); | $orderModule->getManager()->changeOrderStatus($order, OrderStatus::ALIAS_UPDATED, $this->getUserCurrent()); | ||||
} | } | ||||
'value' => function($order) use ($orderModule) { | 'value' => function($order) use ($orderModule) { | ||||
$html = '' ; | $html = '' ; | ||||
if($orderModule->getSolver()->isOrderStatusCanceled($order)) { | |||||
if($order->isOrderStatusCanceled()) { | |||||
$html .= '<span class="badge text-bg-danger">Annulée</span>' ; | $html .= '<span class="badge text-bg-danger">Annulée</span>' ; | ||||
} | } | ||||
else { | else { |