Bläddra i källkod

Commandes : système de statut de commande

feature/rotating_product
Guillaume Bourgeois 5 månader sedan
förälder
incheckning
7cf69a8dc2
23 ändrade filer med 157 tillägg och 166 borttagningar
  1. +6
    -3
      backend/controllers/CronController.php
  2. +2
    -1
      backend/controllers/DistributionController.php
  3. +5
    -2
      backend/controllers/PointSaleController.php
  4. +3
    -1
      backend/controllers/ProducerAdminController.php
  5. +1
    -1
      backend/controllers/SubscriptionController.php
  6. +14
    -4
      backend/views/dashboard/index.php
  7. +4
    -4
      backend/views/distribution/index.php
  8. +4
    -2
      backend/views/user/index.php
  9. +3
    -14
      backend/views/user/orders.php
  10. +1
    -1
      backend/web/js/vuejs/distribution-index.js
  11. +0
    -72
      console/migrations/m240528_072445_init_order_status_history.php
  12. +5
    -0
      domain/Order/Order/OrderBuilder.php
  13. +1
    -0
      domain/Order/Order/OrderManager.php
  14. +7
    -3
      domain/Order/Order/OrderRepository.php
  15. +6
    -1
      domain/Order/Order/OrderRepositoryQuery.php
  16. +32
    -23
      domain/Order/Order/OrderSolver.php
  17. +4
    -2
      domain/Order/Order/TillerManager.php
  18. +4
    -4
      domain/Order/OrderStatus/OrderStatusDefinition.php
  19. +6
    -0
      domain/Order/OrderStatus/OrderStatusModule.php
  20. +1
    -1
      domain/Order/OrderStatus/OrderStatusRepository.php
  21. +27
    -0
      domain/Order/OrderStatus/OrderStatusSolver.php
  22. +9
    -15
      domain/Order/OrderStatusHistory/OrderStatusHistorySolver.php
  23. +12
    -12
      producer/controllers/OrderController.php

+ 6
- 3
backend/controllers/CronController.php Visa fil

@@ -41,6 +41,7 @@ namespace backend\controllers;
use common\helpers\MeanPayment;
use domain\Distribution\Distribution\ExportManager;
use domain\Order\Order\Order;
use domain\Order\Order\OrderRepositoryQuery;
use domain\Order\OrderStatus\OrderStatus;
use domain\User\User\User;
use Yii;
@@ -151,7 +152,8 @@ class CronController extends BackendController
$arrayOrders = Order::searchAll([
'distribution.date' => $date,
'distribution.id_producer' => $producer->id,
'order_status_alias' => OrderStatus::ALIAS_ORDERED
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);

$configCredit = $producerModule->getConfig('credit');
@@ -174,8 +176,9 @@ class CronController extends BackendController
if (!strlen($forceDate) && $producerModule->getConfig('option_notify_producer_order_summary')) {
$arrayOrders = Order::searchAll([
'distribution.date' => $date,
'distribution.id_producer' => $producer->id,
'order_status_alias' => OrderStatus::ALIAS_ORDERED
'distribution.id_producer' => $producer->id
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);

$mail = Yii::$app->mailerService->getMailer()->compose(

+ 2
- 1
backend/controllers/DistributionController.php Visa fil

@@ -406,7 +406,8 @@ class DistributionController extends BackendController
'isCreditFunctioningUser' => $orderModule->getRepository()->isOrderCreditFunctioningUser($order),
'debitCredit' => false,
'deliveryNote' => $order->deliveryNote ? $order->deliveryNote->getAttributes() : null,
'labelDeleteAction' => $orderModule->getSolver()->getLabelDeleteAction($order)
'labelDeleteAction' => $orderModule->getSolver()->getLabelDeleteAction($order),
'orderStatusHistorySummaryTitleTag' => $orderModule->getSolver()->getOrderStatusHistorySummaryTitleTag($order, "\n"),
]);
}
}

+ 5
- 2
backend/controllers/PointSaleController.php Visa fil

@@ -41,6 +41,7 @@ namespace backend\controllers;
use common\helpers\GlobalParam;
use domain\Distribution\PointSaleDistribution\PointSaleDistribution;
use domain\Order\Order\Order;
use domain\Order\Order\OrderRepositoryQuery;
use domain\Order\OrderStatus\OrderStatus;
use domain\PointSale\PointSale\PointSale;
use domain\PointSale\PointSale\PointSaleSearch;
@@ -193,10 +194,12 @@ class PointSaleController extends BackendController
$ordersArray = Order::searchAll(
[
'id_point_sale' => $id,
'order_status_alias' => OrderStatus::ALIAS_ORDERED
],
[
'conditions' => 'distribution.date > :today',
'conditions' => [
'distribution.date > :today',
OrderRepositoryQuery::getSqlFilterIsValid()
],
'params' => [':today' => date('Y-m-d')]
]
);

+ 3
- 1
backend/controllers/ProducerAdminController.php Visa fil

@@ -41,6 +41,7 @@ namespace backend\controllers;
use common\helpers\Ajax;
use common\helpers\Alwaysdata;
use domain\Order\Order\Order;
use domain\Order\Order\OrderRepositoryQuery;
use domain\Order\OrderStatus\OrderStatus;
use domain\Producer\Producer\Producer;
use domain\Product\Product\Product;
@@ -192,7 +193,8 @@ class ProducerAdminController extends BackendController
$countOrders = Order::searchCount([
'id_user' => $idUser,
'distribution.id_producer' => $fromProducerId,
'order_status_alias' => OrderStatus::ALIAS_ORDERED
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);
}


+ 1
- 1
backend/controllers/SubscriptionController.php Visa fil

@@ -270,7 +270,7 @@ class SubscriptionController extends BackendController
->deleteOrdersIncomingDistributionsFromSubscription($subscription, $this->getUserCurrent());
}
foreach ($matchedDistributionsArray as $distribution) {
$subscriptionModule->createOrderFromSubscription($subscription, $distribution->date, $this->getUserCurrent());
$orderModule->getManager()->createOrderFromSubscription($subscription, $distribution->date, $this->getUserCurrent());
}
$this->setFlash('success', 'Commandes ' . ($update ? 're-' : '') . 'générées dans les distributions futures.');
return $this->redirect(['subscription/index']);

+ 14
- 4
backend/views/dashboard/index.php Visa fil

@@ -238,13 +238,13 @@ $this->setTitle('Tableau de bord');
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th></th>
<th>Statut</th>
<th>Origine</th>
<th>Date</th>
<th>Client</th>
<th>Produits</th>
<th>Point de vente</th>
<th>Montant</th>
<th>Historique</th>
</tr>
</thead>
<tbody>
@@ -252,7 +252,18 @@ $this->setTitle('Tableau de bord');
<?php $orderModule->initOrder($order); ?>

<tr class="<?= $orderModule->getHistoryClass($order) ; ?>">
<td class="infos"><?= $orderModule->getLabelOrigin($order, true); ?></td>
<td class="history">
<?= $orderModule->getSolver()->getLabelOrderStatus($order); ?>
<?php
$lastOrderStatusHistory = $orderModule->getSolver()->getLastOrderStatusHistory($order);
if($lastOrderStatusHistory) {
echo '<br /><span class="small gray">'.$lastOrderStatusHistory->getDate()->format('d/m/Y à H:i').'</span>';
}
?>
</td>
<td class="infos">
<?= $orderModule->getSolver()->getLabelOrigin($order, true); ?>
</td>
<td class="date">
<div class="block-date">
<div class="day"><?= strftime('%A', strtotime($order->distribution->date)) ?></div>
@@ -276,7 +287,6 @@ $this->setTitle('Tableau de bord');
<td><?= $orderModule->getCartSummary($order); ?></td>
<td><?= $orderModule->getPointSaleSummary($order) ; ?></td>
<td><?= $orderModule->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true) ; ?></td>
<td class="history"><?= $orderModule->getHistorySummary($order) ; ?></td>
</tr>
<?php endforeach; ?>
</tbody>

+ 4
- 4
backend/views/distribution/index.php Visa fil

@@ -374,9 +374,9 @@ $this->setPageTitle('Distributions') ;
<input type="checkbox" v-model="order.selected" />
</td>
<td class="column-state">
<span class="label label-danger" v-if="order.order_status_alias == 'canceled'"><span class="glyphicon glyphicon-trash"></span></span>
<span class="label label-warning" v-if="order.order_status_alias == 'updated'"><span class="glyphicon glyphicon-pencil"></span></span>
<span class="label label-success" v-if="order.order_status_alias == 'ordered'"><span class="glyphicon glyphicon-check"></span></span>
<span v-if="order.order_status_alias == 'canceled'" class="label label-danger" :title="order.orderStatusHistorySummaryTitleTag"><span class="glyphicon glyphicon-trash"></span></span>
<span v-if="order.order_status_alias == 'updated'" class="label label-warning" :title="order.orderStatusHistorySummaryTitleTag"><span class="glyphicon glyphicon-pencil"></span></span>
<span v-if="order.order_status_alias == 'ordered'" class="label label-success" :title="order.orderStatusHistorySummaryTitleTag"><span class="glyphicon glyphicon-check"></span></span>
</td>
<td class="column-origin">
<label class="label label-success outline" v-if="order.origin == 'user'">Utilisateur</label>
@@ -413,7 +413,7 @@ $this->setPageTitle('Distributions') ;
</div>
</td>
<td class="column-state-payment">
<template v-if="order.order_status_alias == 'ordered'">
<template v-if="order.order_status_alias == 'ordered' || order.order_status_alias == 'updated'">
<a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</a>

+ 4
- 2
backend/views/user/index.php Visa fil

@@ -39,6 +39,7 @@
use common\helpers\GlobalParam;
use common\helpers\Price;
use domain\Order\Order\Order;
use domain\Order\Order\OrderRepositoryQuery;
use domain\Order\OrderStatus\OrderStatus;
use domain\Producer\Producer\ProducerModule;
use domain\User\User\UserModule;
@@ -144,8 +145,9 @@ $this->render('_menu_filter', [
'orders' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]);
$countOrders = Order::searchCount([
'id_user' => $model['id'],
'order_status_alias' => OrderStatus::ALIAS_ORDERED
'id_user' => $model['id']
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);

$html = '';

+ 3
- 14
backend/views/user/orders.php Visa fil

@@ -66,25 +66,14 @@ $this->addBreadcrumb('Commandes') ;
'label' => 'Statut',
'format' => 'raw',
'value' => function ($order) use ($orderModule) {
$orderStatusCssClass = $orderModule->getSolver()->getOrderStatusCssClass($order);
$orderStatusLabel = $orderModule->getSolver()->getOrderStatusLabel($order);
$orderStatusHistorySummaryTitleTag = $orderModule->getSolver()->getOrderStatusHistorySummaryTitleTag($order);
return '<span class="label label-'.$orderStatusCssClass.'" title="'.$orderStatusHistorySummaryTitleTag.'">'.$orderStatusLabel.'</span>';
return $orderModule->getSolver()->getLabelOrderStatus($order);
}
],
[
'label' => 'Origine',
'format' => 'raw',
'value' => function ($order) {
if($order->origin == 'user') {
return '<span class="label label-success outline">Utilisateur</span>';
}
elseif($order->origin == 'auto') {
return '<span class="label label-default outline">Abonnement</span>';
}
else {
return '<span class="label label-warning outline">Producteur</span>';
}
'value' => function ($order) use ($orderModule) {
return $orderModule->getSolver()->getLabelOrigin($order);;
}
],
[

+ 1
- 1
backend/web/js/vuejs/distribution-index.js Visa fil

@@ -178,7 +178,7 @@ if($(selector).length) {
app.ordersUpdate = JSON.parse(JSON.stringify(response.data.orders));

for (i = 0; i < app.orders.length; i++) {
if (!app.orders[i].order_status_alias == 'ordered') {
if (app.orders[i].order_status_alias == 'ordered' || app.orders[i].order_status_alias == 'updated') {
app.countOrders++;
}
}

+ 0
- 72
console/migrations/m240528_072445_init_order_status_history.php Visa fil

@@ -1,72 +0,0 @@
<?php

use domain\Order\Order\OrderModule;
use domain\Order\OrderStatus\OrderStatus;
use domain\Producer\Producer\ProducerModule;
use domain\User\User\UserModule;
use yii\db\Migration;
use yii\db\Schema;

/**
* Class m240528_072445_init_order_status_history
*/
class m240528_072445_init_order_status_history extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
//$this->execute("UPDATE `order` SET order_status_alias = IF(`order`.date_delete IS NULL, 'ordered', 'deleted')");

$producerModule = ProducerModule::getInstance();
$orderModule = OrderModule::getInstance();

$userSystem = UserModule::getInstance()->getRepository()->findOneUserSystem();

foreach($producerModule->getRepository()->findProducers() as $producer) {
Yii::$app->logic->setProducerContext($producer);

$ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
echo ($ordersArray ? count($ordersArray) : '0').' : '.$producer->name."\n";

while ($ordersArray && count($ordersArray)) {
foreach ($ordersArray as $order) {
$orderModule->getManager()->changeOrderStatus(
$order,
OrderStatus::ALIAS_ORDERED,
$userSystem,
new DateTime($order->date)
);
if($order->date_update) {
$orderModule->getManager()->changeOrderStatus(
$order,
OrderStatus::ALIAS_UPDATED,
$userSystem,
new DateTime($order->date_update)
);
}
if($order->date_delete) {
$orderModule->getManager()->changeOrderStatus(
$order,
OrderStatus::ALIAS_DELETED,
$userSystem,
new DateTime($order->date_delete)
);
}

echo 'Order #'.$order->id."\n";
}
$ordersArray = $orderModule->getRepository()->findOrdersWithOrderStatusAliasNull();
}
}
}

/**
* {@inheritdoc}
*/
public function safeDown()
{

}
}

+ 5
- 0
domain/Order/Order/OrderBuilder.php Visa fil

@@ -118,6 +118,11 @@ class OrderBuilder extends AbstractBuilder
return $order;
}

public function initDateUpdate(Order $order)
{
$this->date_update = date('Y-m-d H:i:s');;
}

public function addProductOrdersFromSubscription(Order $order, Subscription $subscription): bool
{
$productsAdd = false;

+ 1
- 0
domain/Order/Order/OrderManager.php Visa fil

@@ -51,6 +51,7 @@ class OrderManager extends AbstractService implements ManagerInterface
$orderStatus = $this->orderStatusRepository->getOrderStatusByAlias($orderStatusAlias);

$order->setOrderStatus($orderStatus);
$this->orderBuilder->initDateUpdate($order);
$this->orderBuilder->update($order);

$this->orderStatusHistoryManager->create(

+ 7
- 3
domain/Order/Order/OrderRepository.php Visa fil

@@ -542,7 +542,8 @@ class OrderRepository extends AbstractRepository
->where('distribution.id_producer = :id_producer')
->andWhere('distribution.date >= :date_today')
->andWhere('distribution.date ' . $comparatorDateStart . ' :date_start')
->andWhere('order.id_subscription = :id_subscription');
->andWhere('order.id_subscription = :id_subscription')
->andWhere(OrderRepositoryQuery::getSqlFilterIsValid());

$orders->params($params);

@@ -740,9 +741,11 @@ class OrderRepository extends AbstractRepository
$paramsOrders[':date_start'] = date('Y-m-d 00:00:00');
}

$conditionsOrders .= ' AND '.OrderRepositoryQuery::getSqlFilterIsOrderStatusNotDeleted();

$ordersArray = Order::searchAll([], [
'orderby' => 'IF(ISNULL(date_update), `order`.`date`, `order`.`date_update`) DESC',
'conditions' => $conditionsOrders . ' AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND (date_update IS NOT NULL OR order_status_alias LIKE \''.OrderStatus::ALIAS_CANCELED.'\')))',
'conditions' => $conditionsOrders . ' AND (origin = \'' . Order::ORIGIN_USER . '\' OR origin = \'' . Order::ORIGIN_ADMIN . '\' OR (origin = \'' . Order::ORIGIN_AUTO . '\' AND date_update IS NOT NULL))',
'params' => $paramsOrders,
]);

@@ -753,7 +756,8 @@ class OrderRepository extends AbstractRepository
{
return Order::searchCount([
'id_user' => $user->id,
'order_status_alias' => OrderStatus::ALIAS_ORDERED
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);
}


+ 6
- 1
domain/Order/Order/OrderRepositoryQuery.php Visa fil

@@ -58,7 +58,12 @@ class OrderRepositoryQuery extends AbstractRepositoryQuery

public static function getSqlFilterIsValid(): string
{
return "(`order`.order_status_alias = '".OrderStatus::ALIAS_ORDERED."' OR `order`.order_status_alias = '".OrderStatus::ALIAS_UPDATED."')";
return " (`order`.order_status_alias = '".OrderStatus::ALIAS_ORDERED."' OR `order`.order_status_alias = '".OrderStatus::ALIAS_UPDATED."') ";
}

public static function getSqlFilterIsOrderStatusNotDeleted(): string
{
return " (`order`.order_status_alias != '".OrderStatus::ALIAS_DELETED."') ";
}

public function filterIsValid(): self

+ 32
- 23
domain/Order/Order/OrderSolver.php Visa fil

@@ -6,6 +6,7 @@ use common\helpers\Price;
use domain\Document\Document\Document;
use domain\Document\Document\DocumentSolver;
use domain\Order\OrderStatus\OrderStatus;
use domain\Order\OrderStatus\OrderStatusSolver;
use domain\Order\OrderStatusHistory\OrderStatusHistory;
use domain\Order\OrderStatusHistory\OrderStatusHistorySolver;
use domain\Order\ProductOrder\ProductOrderSolver;
@@ -28,6 +29,7 @@ class OrderSolver extends AbstractService implements SolverInterface
protected ProducerSolver $producerSolver;
protected ProductOrderSolver $productOrderSolver;
protected OrderStatusHistorySolver $orderStatusHistorySolver;
protected OrderStatusSolver $orderStatusSolver;

public function loadDependencies(): void
{
@@ -37,6 +39,7 @@ class OrderSolver extends AbstractService implements SolverInterface
$this->producerSolver = $this->loadService(ProducerSolver::class);
$this->productOrderSolver = $this->loadService(ProductOrderSolver::class);
$this->orderStatusHistorySolver = $this->loadService(OrderStatusHistorySolver::class);
$this->orderStatusSolver = $this->loadService(OrderStatusSolver::class);
}

public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string
@@ -328,10 +331,17 @@ class OrderSolver extends AbstractService implements SolverInterface
return '<br><span class="payment-detail-remaining-surplus">'.$text.'</span>';
}

public function getLabelOrderStatus(Order $order): string
{
$orderStatusCssClass = $this->getOrderStatusCssClass($order);
$orderStatusLabel = $this->getOrderStatusLabel($order);
$orderStatusHistorySummaryTitleTag = $this->getOrderStatusHistorySummaryTitleTag($order);
return '<span class="label label-'.$orderStatusCssClass.'" title="'.$orderStatusHistorySummaryTitleTag.'">'.$orderStatusLabel.'</span>';
}

/**
* Retourne l'origine de la commande (client, automatique ou admin) sous forme texte ou HTML.
*/
// getStrOrigin
public function getLabelOrigin(Order $order, bool $withLabel = false): string
{
$classLabel = '';
@@ -339,18 +349,17 @@ class OrderSolver extends AbstractService implements SolverInterface

if ($order->origin == Order::ORIGIN_USER) {
$classLabel = 'success';
$str = 'Client';
$str = 'Utilisateur';
} elseif ($order->origin == Order::ORIGIN_AUTO) {
$classLabel = 'default';
$str = 'Auto';
$str = 'Abonnement';
} elseif ($order->origin == Order::ORIGIN_ADMIN) {
$classLabel = 'warning';
$str = 'Vous';
$str = 'Producteur';
}

if ($withLabel) {
return '<span class="label label-' . $classLabel . '">'
. $str . '</span>';
return '<span class="label label-' . $classLabel . ' outline">' . $str . '</span>';
} else {
return $str;
}
@@ -629,33 +638,33 @@ class OrderSolver extends AbstractService implements SolverInterface

public function getOrderStatusLabel(Order $order): string
{
if($this->isOrderStatusOrdered($order)) {
return 'Validée';
}
elseif($this->isOrderStatusUpdated($order)) {
return 'Modifiée';
}
elseif($this->isOrderStatusCanceled($order)) {
return 'Annulée';
}
elseif($this->isOrderStatusDeleted($order)) {
return 'Supprimée';
}

return '';
return $this->orderStatusSolver->getLabel($order->getOrderStatusAlias());
}

public function getOrderStatusHistorySummaryTitleTag(Order $order): string
public function getOrderStatusHistorySummaryTitleTag(Order $order, string $lineBreak = '&#013;'): string
{
$titleTagString = '';

foreach($order->getOrderStatusHistory() as $orderStatusHistory) {
$titleTagString .= $this->orderStatusHistorySolver->getOrderStatusHistoryLabel($orderStatusHistory).' '
.date('\l\e d/m/Y à H:i:s', $orderStatusHistory->getDate()->getTimestamp()).' '
.date('\l\e d/m/Y à H:i', $orderStatusHistory->getDate()->getTimestamp()).' '
.' par '.$this->userSolver->getUsername($orderStatusHistory->getUser()).' (#'.$orderStatusHistory->getUser()->getId().')'
.'&#013;';
.$lineBreak;
}

return $titleTagString;
}

public function getLastOrderStatusHistory(Order $order): ?OrderStatusHistory
{
$lastOrderStatusHistory = null;

foreach($order->getOrderStatusHistory() as $orderStatusHistory) {
if(!$lastOrderStatusHistory || $orderStatusHistory->date > $lastOrderStatusHistory->date) {
$lastOrderStatusHistory = $orderStatusHistory;
}
}

return $lastOrderStatusHistory;
}
}

+ 4
- 2
domain/Order/Order/TillerManager.php Visa fil

@@ -76,7 +76,8 @@ class TillerManager extends AbstractManager
$orders = Order::searchAll([
'distribution.date' => $date,
'order.tiller_synchronization' => 1,
'order_status_alias' => OrderStatus::ALIAS_ORDERED
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);

$strDate = date('Y-m-d\T12:i:s+0000', strtotime($date) + 1);
@@ -213,7 +214,8 @@ class TillerManager extends AbstractManager
$ordersOpendistrib = Order::searchAll([
'distribution.date' => $date,
'order.tiller_synchronization' => 1,
'order_status_alias' => OrderStatus::ALIAS_ORDERED
], [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);

$ordersOpendistribSynchro = [];

+ 4
- 4
domain/Order/OrderStatus/OrderStatusDefinition.php Visa fil

@@ -15,16 +15,16 @@ class OrderStatusDefinition extends AbstractDefinition
{
return [
OrderStatus::ALIAS_ORDERED => [
'name' => 'Validée'
'label' => 'Créée'
],
OrderStatus::ALIAS_UPDATED => [
'name' => 'Modifiée'
'label' => 'Modifiée'
],
OrderStatus::ALIAS_CANCELED => [
'name' => 'Annulée'
'label' => 'Annulée'
],
OrderStatus::ALIAS_DELETED => [
'name' => 'Supprimée'
'label' => 'Supprimée'
]
];
}

+ 6
- 0
domain/Order/OrderStatus/OrderStatusModule.php Visa fil

@@ -10,6 +10,7 @@ class OrderStatusModule extends AbstractModule
{
return [
OrderStatusDefinition::class,
OrderStatusSolver::class,
OrderStatusRepository::class,
OrderStatusBuilder::class,
];
@@ -20,6 +21,11 @@ class OrderStatusModule extends AbstractModule
return OrderStatusDefinition::getInstance();
}

public function getSolver(): OrderStatusSolver
{
return OrderStatusSolver::getInstance();
}

public function getRepository(): OrderStatusRepository
{
return OrderStatusRepository::getInstance();

+ 1
- 1
domain/Order/OrderStatus/OrderStatusRepository.php Visa fil

@@ -26,7 +26,7 @@ class OrderStatusRepository extends AbstractRepository
if(isset($orderStatusArray[$alias])) {
return OrderStatusBuilder::getInstance()->instanciateOrderStatus(
$alias,
$orderStatusArray[$alias]['name']
$orderStatusArray[$alias]['label']
);
}
else {

+ 27
- 0
domain/Order/OrderStatus/OrderStatusSolver.php Visa fil

@@ -0,0 +1,27 @@
<?php

namespace domain\Order\OrderStatus;

use domain\_\AbstractSolver;

class OrderStatusSolver extends AbstractSolver
{
protected OrderStatusDefinition $orderStatusDefinition;

public function loadDependencies(): void
{
$this->orderStatusDefinition = $this->loadService(OrderStatusDefinition::class);
}

public function getLabel(string $orderStatusAlias): string
{
$orderStatusArray = $this->orderStatusDefinition->getOrderStatusList();

if(isset($orderStatusArray[$orderStatusAlias])) {
return $orderStatusArray[$orderStatusAlias]['label'];
}
else {
return '?';
}
}
}

+ 9
- 15
domain/Order/OrderStatusHistory/OrderStatusHistorySolver.php Visa fil

@@ -3,25 +3,19 @@
namespace domain\Order\OrderStatusHistory;

use domain\_\AbstractSolver;
use domain\Order\OrderStatus\OrderStatus;
use domain\Order\OrderStatus\OrderStatusSolver;

class OrderStatusHistorySolver extends AbstractSolver
{
public function getOrderStatusHistoryLabel(OrderStatusHistory $orderStatusHistory): string
protected OrderStatusSolver $orderStatusSolver;

public function loadDependencies(): void
{
if($orderStatusHistory->getOrderStatusAlias() == OrderStatus::ALIAS_ORDERED) {
return 'Validée';
}
elseif($orderStatusHistory->getOrderStatusAlias() == OrderStatus::ALIAS_UPDATED) {
return 'Modifiée';
}
elseif($orderStatusHistory->getOrderStatusAlias() == OrderStatus::ALIAS_CANCELED) {
return 'Annulée';
}
elseif($orderStatusHistory->getOrderStatusAlias() == OrderStatus::ALIAS_DELETED) {
return 'Supprimée';
}
$this->orderStatusSolver = $this->loadService(OrderStatusSolver::class);
}

return '';
public function getOrderStatusHistoryLabel(OrderStatusHistory $orderStatusHistory): string
{
return $this->orderStatusSolver->getLabel($orderStatusHistory->getOrderStatusAlias());
}
}

+ 12
- 12
producer/controllers/OrderController.php Visa fil

@@ -44,6 +44,7 @@ use common\helpers\Password;
use domain\Config\Unit\UnitDefinition;
use domain\Distribution\Distribution\Distribution;
use domain\Order\Order\Order;
use domain\Order\Order\OrderRepositoryQuery;
use domain\Order\OrderStatus\OrderStatus;
use domain\Order\ProductOrder\ProductOrder;
use domain\PointSale\PointSale\PointSale;
@@ -175,6 +176,7 @@ class OrderController extends ProducerBaseController
->where('id_distribution = :id_distribution')
->andWhere('id_user = :id_user')
->andWhere('id_point_sale = :id_point_sale')
->andWhere(OrderRepositoryQuery::getSqlFilterIsValid())
->params([
':id_distribution' => $posts['Order']['id_distribution'],
':id_point_sale' => $posts['Order']['id_point_sale'],
@@ -185,8 +187,6 @@ class OrderController extends ProducerBaseController
if ($order && !$order->online_payment_url) {
if ($order->id_point_sale != $posts['Order']['id_point_sale']) {
$order->id_point_sale = $posts['Order']['id_point_sale'];

$orderModule->getManager()->changeOrderStatus($order, OrderStatus::ALIAS_UPDATED, $user);
}
} else {
// gestion user : option_allow_order_guest
@@ -406,15 +406,15 @@ class OrderController extends ProducerBaseController
}

$order->comment = isset($posts['Order']['comment']) ? $posts['Order']['comment'] : null;
if(!$isNewOrder) {
$orderModule->getManager()->changeOrderStatus($order, OrderStatus::ALIAS_UPDATED, $user);
}
$order->save();

$orderModule->generateOrderReference($order);
if($isNewOrder) {
$orderModule->getManager()->changeOrderStatus($order, OrderStatus::ALIAS_ORDERED, $user);
}
else {
$orderModule->getManager()->changeOrderStatus($order, OrderStatus::ALIAS_UPDATED, $user);
}
$producerModule->addUser($user, $producer);

// suppression de tous les enregistrements ProductOrder
@@ -738,9 +738,7 @@ class OrderController extends ProducerBaseController

public function ajaxInfosOrders(Producer $producer, PointSale $pointSaleCurrent = null): array
{
$producerModule = $this->getProducerModule();
$orderModule = $this->getOrderModule();

$dateMini = date('Y-m-d');
$ordersUserArray = [];
if (GlobalParam::getCurrentUserId()) {
@@ -757,6 +755,8 @@ class OrderController extends ProducerBaseController
$paramsOrdersUser[':id_point_sale'] = $pointSaleCurrent->id;
}

$conditionsOrdersUser[] = OrderRepositoryQuery::getSqlFilterIsValid();

$ordersUserArray = Order::searchAll([
'id_user' => GlobalParam::getCurrentUserId()
], [
@@ -1014,14 +1014,14 @@ class OrderController extends ProducerBaseController
if (GlobalParam::getCurrentUserId()) {
$conditionOrderUser = [
'distribution.date' => $date,
'id_user' => GlobalParam::getCurrentUserId(),
'id_user' => GlobalParam::getCurrentUserId()
];

if ($pointSale) {
$conditionOrderUser['id_point_sale'] = $pointSale;
$conditionOrderUser['id_point_sale'] = $pointSale->id;
}

$orderUser = Order::searchOne($conditionOrderUser);
$orderUser = Order::searchOne($conditionOrderUser, [
'conditions' => OrderRepositoryQuery::getSqlFilterIsValid()
]);

if ($orderUser && $orderUser->online_payment_url) {
$orderUser = null;

Laddar…
Avbryt
Spara