Browse Source

[Administration] Tableau de bord : correctif nombre de commandes qui prend en compte les commandes supprimées

develop
Guillaume Bourgeois 4 months ago
parent
commit
f73c51ebfb
9 changed files with 69 additions and 53 deletions
  1. +1
    -1
      backend/controllers/DistributionController.php
  2. +1
    -1
      backend/views/dashboard/index.php
  3. +19
    -3
      domain/Distribution/Distribution/Distribution.php
  4. +35
    -3
      domain/Order/Order/Order.php
  5. +1
    -1
      domain/Order/Order/OrderBuilder.php
  6. +2
    -2
      domain/Order/Order/OrderManager.php
  7. +8
    -40
      domain/Order/Order/OrderSolver.php
  8. +1
    -1
      producer/controllers/OrderController.php
  9. +1
    -1
      producer/views/order/history.php

+ 1
- 1
backend/controllers/DistributionController.php View File

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;

+ 1
- 1
backend/views/dashboard/index.php View File

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

+ 19
- 3
domain/Distribution/Distribution/Distribution.php View File

]; ];
} }


/*
* 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()
{ {

+ 35
- 3
domain/Order/Order/Order.php View File

]; ];
} }


/*
* 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()
{ {

+ 1
- 1
domain/Order/Order/OrderBuilder.php View File

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

+ 2
- 2
domain/Order/Order/OrderManager.php View File

$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);

+ 8
- 40
domain/Order/Order/OrderSolver.php View File



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';
} }



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

$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());
} }



+ 1
- 1
producer/views/order/history.php View File

'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 {

Loading…
Cancel
Save