'label' => 'Statut', | 'label' => 'Statut', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($order) use ($orderModule) { | 'value' => function ($order) use ($orderModule) { | ||||
if($orderModule->getSolver()->isOrderStatusOrdered($order)) { | |||||
if($order->date_update) { | |||||
return '<span class="label label-warning">Modifiée</span>'; | |||||
} | |||||
else { | |||||
return '<span class="label label-success">Validée</span>'; | |||||
} | |||||
} | |||||
elseif($orderModule->getSolver()->isOrderStatusCanceled($order)) { | |||||
return '<span class="label label-danger">Annulée</span>'; | |||||
} | |||||
elseif($orderModule->getSolver()->isOrderStatusDeleted($order)) { | |||||
return '<span class="label label-danger">Supprimée</span>'; | |||||
} | |||||
$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>'; | |||||
} | } | ||||
], | ], | ||||
[ | [ |
<?php | <?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\Migration; | ||||
use yii\db\Schema; | use yii\db\Schema; | ||||
public function getOrderStatusHistoryRelation() | public function getOrderStatusHistoryRelation() | ||||
{ | { | ||||
return $this->hasMany(OrderStatusHistory::class, ['id_order' => 'id']) | return $this->hasMany(OrderStatusHistory::class, ['id_order' => 'id']) | ||||
->orderBy(['order_status.id' => SORT_DESC]); | |||||
->orderBy(['order_status_history.id' => SORT_ASC]); | |||||
} | } | ||||
} | } |
use domain\Document\Document\DocumentSolver; | use domain\Document\Document\DocumentSolver; | ||||
use domain\Order\OrderStatus\OrderStatus; | use domain\Order\OrderStatus\OrderStatus; | ||||
use domain\Order\OrderStatusHistory\OrderStatusHistory; | use domain\Order\OrderStatusHistory\OrderStatusHistory; | ||||
use domain\Order\OrderStatusHistory\OrderStatusHistorySolver; | |||||
use domain\Order\ProductOrder\ProductOrderSolver; | use domain\Order\ProductOrder\ProductOrderSolver; | ||||
use domain\Payment\Payment; | use domain\Payment\Payment; | ||||
use domain\Payment\PaymentSolver; | use domain\Payment\PaymentSolver; | ||||
protected PaymentSolver $paymentSolver; | protected PaymentSolver $paymentSolver; | ||||
protected ProducerSolver $producerSolver; | protected ProducerSolver $producerSolver; | ||||
protected ProductOrderSolver $productOrderSolver; | protected ProductOrderSolver $productOrderSolver; | ||||
protected OrderStatusHistorySolver $orderStatusHistorySolver; | |||||
public function loadDependencies(): void | public function loadDependencies(): void | ||||
{ | { | ||||
$this->paymentSolver = $this->loadService(PaymentSolver::class); | $this->paymentSolver = $this->loadService(PaymentSolver::class); | ||||
$this->producerSolver = $this->loadService(ProducerSolver::class); | $this->producerSolver = $this->loadService(ProducerSolver::class); | ||||
$this->productOrderSolver = $this->loadService(ProductOrderSolver::class); | $this->productOrderSolver = $this->loadService(ProductOrderSolver::class); | ||||
$this->orderStatusHistorySolver = $this->loadService(OrderStatusHistorySolver::class); | |||||
} | } | ||||
public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string | public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string | ||||
return 'Supprimer'; | return 'Supprimer'; | ||||
} | } | ||||
public function getOrderStatusCssClass(Order $order): string | |||||
{ | |||||
if($this->isOrderStatusOrdered($order)) { | |||||
if($order->date_update) { | |||||
return 'warning'; | |||||
} | |||||
else { | |||||
return 'success'; | |||||
} | |||||
} | |||||
elseif($this->isOrderStatusCanceled($order)) { | |||||
return 'danger'; | |||||
} | |||||
elseif($this->isOrderStatusDeleted($order)) { | |||||
return 'danger'; | |||||
} | |||||
return ''; | |||||
} | |||||
public function getOrderStatusLabel(Order $order): string | |||||
{ | |||||
if($this->isOrderStatusOrdered($order)) { | |||||
if($order->date_update) { | |||||
return 'Modifiée'; | |||||
} | |||||
else { | |||||
return 'Validée'; | |||||
} | |||||
} | |||||
elseif($this->isOrderStatusCanceled($order)) { | |||||
return 'Annulée'; | |||||
} | |||||
elseif($this->isOrderStatusDeleted($order)) { | |||||
return 'Supprimée'; | |||||
} | |||||
return ''; | |||||
} | |||||
public function getOrderStatusHistorySummaryTitleTag(Order $order): string | |||||
{ | |||||
$titleTagString = ''; | |||||
foreach($order->getOrderStatusHistory() as $orderStatusHistory) { | |||||
$titleTagString .= $this->orderStatusHistorySolver->getOrderStatusHistoryLabel($orderStatusHistory).' ' | |||||
.date('\l\e d/m/Y à H:i:s', $orderStatusHistory->getDate()->getTimestamp()).'
'; | |||||
} | |||||
return $titleTagString; | |||||
} | |||||
} | } |
class OrderStatusModule extends AbstractModule | class OrderStatusModule extends AbstractModule | ||||
{ | { | ||||
public function getDefinition(): OrderStatusDefinition | |||||
{ | |||||
return OrderStatusDefinition::getInstance(); | |||||
} | |||||
public function getServices(): array | public function getServices(): array | ||||
{ | { | ||||
return [ | return [ | ||||
OrderStatusBuilder::class, | OrderStatusBuilder::class, | ||||
]; | ]; | ||||
} | } | ||||
public function getDefinition(): OrderStatusDefinition | |||||
{ | |||||
return OrderStatusDefinition::getInstance(); | |||||
} | |||||
public function getRepository(): OrderStatusRepository | |||||
{ | |||||
return OrderStatusRepository::getInstance(); | |||||
} | |||||
public function getBuilder(): OrderStatusBuilder | |||||
{ | |||||
return OrderStatusBuilder::getInstance(); | |||||
} | |||||
} | } |
public function getDate(): \DateTime | public function getDate(): \DateTime | ||||
{ | { | ||||
return new \DateTime(strtotime($this->date)); | |||||
return new \DateTime($this->date); | |||||
} | } | ||||
public function setDate(\DateTime $date): self | public function setDate(\DateTime $date): self |
class OrderStatusHistoryModule extends AbstractModule | class OrderStatusHistoryModule extends AbstractModule | ||||
{ | { | ||||
public function getDefinition(): OrderStatusHistoryDefinition | |||||
{ | |||||
return OrderStatusHistoryDefinition::getInstance(); | |||||
} | |||||
public function getServices(): array | public function getServices(): array | ||||
{ | { | ||||
return [ | return [ | ||||
OrderStatusHistoryDefinition::class, | OrderStatusHistoryDefinition::class, | ||||
OrderStatusHistorySolver::class, | |||||
OrderStatusHistoryBuilder::class, | OrderStatusHistoryBuilder::class, | ||||
OrderStatusHistoryManager::class, | OrderStatusHistoryManager::class, | ||||
]; | ]; | ||||
} | } | ||||
public function getDefinition(): OrderStatusHistoryDefinition | |||||
{ | |||||
return OrderStatusHistoryDefinition::getInstance(); | |||||
} | |||||
public function getSolver(): OrderStatusHistorySolver | |||||
{ | |||||
return OrderStatusHistorySolver::getInstance(); | |||||
} | |||||
public function getBuilder(): OrderStatusHistoryBuilder | |||||
{ | |||||
return OrderStatusHistoryBuilder::getInstance(); | |||||
} | |||||
public function getManager(): OrderStatusHistoryManager | |||||
{ | |||||
return OrderStatusHistoryManager::getInstance(); | |||||
} | |||||
} | } |
<?php | |||||
namespace domain\Order\OrderStatusHistory; | |||||
use domain\_\AbstractSolver; | |||||
use domain\Order\OrderStatus\OrderStatus; | |||||
class OrderStatusHistorySolver extends AbstractSolver | |||||
{ | |||||
public function getOrderStatusHistoryLabel(OrderStatusHistory $orderStatusHistory): string | |||||
{ | |||||
if($orderStatusHistory->getOrderStatusAlias() == OrderStatus::ALIAS_ORDERED) { | |||||
return 'Validée'; | |||||
} | |||||
elseif($orderStatusHistory->getOrderStatusAlias() == OrderStatus::ALIAS_CANCELED) { | |||||
return 'Annulée'; | |||||
} | |||||
elseif($orderStatusHistory->getOrderStatusAlias() == OrderStatus::ALIAS_DELETED) { | |||||
return 'Supprimée'; | |||||
} | |||||
return ''; | |||||
} | |||||
} |