@@ -66,20 +66,10 @@ $this->addBreadcrumb('Commandes') ; | |||
'label' => 'Statut', | |||
'format' => 'raw', | |||
'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>'; | |||
} | |||
], | |||
[ |
@@ -1,9 +1,5 @@ | |||
<?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; | |||
@@ -265,6 +265,6 @@ class Order extends ActiveRecordCommon | |||
public function getOrderStatusHistoryRelation() | |||
{ | |||
return $this->hasMany(OrderStatusHistory::class, ['id_order' => 'id']) | |||
->orderBy(['order_status.id' => SORT_DESC]); | |||
->orderBy(['order_status_history.id' => SORT_ASC]); | |||
} | |||
} |
@@ -7,6 +7,7 @@ use domain\Document\Document\Document; | |||
use domain\Document\Document\DocumentSolver; | |||
use domain\Order\OrderStatus\OrderStatus; | |||
use domain\Order\OrderStatusHistory\OrderStatusHistory; | |||
use domain\Order\OrderStatusHistory\OrderStatusHistorySolver; | |||
use domain\Order\ProductOrder\ProductOrderSolver; | |||
use domain\Payment\Payment; | |||
use domain\Payment\PaymentSolver; | |||
@@ -26,6 +27,7 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
protected PaymentSolver $paymentSolver; | |||
protected ProducerSolver $producerSolver; | |||
protected ProductOrderSolver $productOrderSolver; | |||
protected OrderStatusHistorySolver $orderStatusHistorySolver; | |||
public function loadDependencies(): void | |||
{ | |||
@@ -34,6 +36,7 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
$this->paymentSolver = $this->loadService(PaymentSolver::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
$this->productOrderSolver = $this->loadService(ProductOrderSolver::class); | |||
$this->orderStatusHistorySolver = $this->loadService(OrderStatusHistorySolver::class); | |||
} | |||
public function getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = ''): string | |||
@@ -598,4 +601,56 @@ class OrderSolver extends AbstractService implements SolverInterface | |||
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; | |||
} | |||
} |
@@ -6,11 +6,6 @@ use domain\_\AbstractModule; | |||
class OrderStatusModule extends AbstractModule | |||
{ | |||
public function getDefinition(): OrderStatusDefinition | |||
{ | |||
return OrderStatusDefinition::getInstance(); | |||
} | |||
public function getServices(): array | |||
{ | |||
return [ | |||
@@ -19,4 +14,19 @@ class OrderStatusModule extends AbstractModule | |||
OrderStatusBuilder::class, | |||
]; | |||
} | |||
public function getDefinition(): OrderStatusDefinition | |||
{ | |||
return OrderStatusDefinition::getInstance(); | |||
} | |||
public function getRepository(): OrderStatusRepository | |||
{ | |||
return OrderStatusRepository::getInstance(); | |||
} | |||
public function getBuilder(): OrderStatusBuilder | |||
{ | |||
return OrderStatusBuilder::getInstance(); | |||
} | |||
} |
@@ -35,7 +35,7 @@ class OrderStatusHistory extends ActiveRecordCommon | |||
public function getDate(): \DateTime | |||
{ | |||
return new \DateTime(strtotime($this->date)); | |||
return new \DateTime($this->date); | |||
} | |||
public function setDate(\DateTime $date): self |
@@ -6,17 +6,33 @@ use domain\_\AbstractModule; | |||
class OrderStatusHistoryModule extends AbstractModule | |||
{ | |||
public function getDefinition(): OrderStatusHistoryDefinition | |||
{ | |||
return OrderStatusHistoryDefinition::getInstance(); | |||
} | |||
public function getServices(): array | |||
{ | |||
return [ | |||
OrderStatusHistoryDefinition::class, | |||
OrderStatusHistorySolver::class, | |||
OrderStatusHistoryBuilder::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(); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
<?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 ''; | |||
} | |||
} |