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

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

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

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

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

@@ -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()
{

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

@@ -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()
{

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

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

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

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

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

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


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

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


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

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

Loading…
Cancel
Save