Browse Source

[Administration] Supprimer development, development_priority, order_status #1153

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
b0e554cfa4
14 changed files with 31 additions and 688 deletions
  1. +2
    -137
      backend/controllers/DevelopmentController.php
  2. +0
    -1
      common/components/BusinessLogic.php
  3. +0
    -12
      common/components/BusinessLogicTrait.php
  4. +0
    -148
      common/logic/Development/Development/Development.php
  5. +0
    -149
      common/logic/Development/DevelopmentPriority/DevelopmentPriority.php
  6. +0
    -17
      common/logic/Order/Order/Service/OrderBuilder.php
  7. +0
    -72
      common/logic/Order/OrderStatusHistory/Model/OrderStatusHistory.php
  8. +0
    -25
      common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepository.php
  9. +0
    -18
      common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepositoryQuery.php
  10. +0
    -39
      common/logic/Order/OrderStatusHistory/Service/OrderStatusHistoryBuilder.php
  11. +0
    -14
      common/logic/Order/OrderStatusHistory/Service/OrderStatusHistoryDefinition.php
  12. +0
    -35
      common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryContainer.php
  13. +0
    -21
      common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryManager.php
  14. +29
    -0
      console/migrations/m230823_072853_delete_development_order_status.php

+ 2
- 137
backend/controllers/DevelopmentController.php View File



namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam;
use common\helpers\Opendistrib; use common\helpers\Opendistrib;
use common\logic\Development\Development\Development;
use common\logic\Development\DevelopmentPriority\DevelopmentPriority;
use Yii;
use yii\data\ActiveDataProvider;
use yii\web\NotFoundHttpException;
use yii\filters\AccessControl; use yii\filters\AccessControl;


/** /**
} }


/** /**
* Liste les développements.
*
* @return mixed
* Liste les versions d'Opendistrib
*/ */
public function actionIndex() public function actionIndex()
{ {
]; ];
} }


$producer = $this->getProducerCurrent();
$producerManager->updateOpendistribVersion($producer);
$producerManager->updateOpendistribVersion($this->getProducerCurrent());


return $this->render('index', [ return $this->render('index', [
'versionsArray' => $versionsRenderArray 'versionsArray' => $versionsRenderArray
]); ]);
} }


public function actionDevelopment($status = Development::STATUS_OPEN)
{
$dataProvider = new ActiveDataProvider([
'query' => Development::find()
->with(['developmentPriority', 'developmentPriorityCurrentProducer'])
->where(['status' => $status])
->orderBy('date DESC'),
]);

return $this->render('development', [
'dataProvider' => $dataProvider,
'status' => $status
]);
}

/**
* Creates a new Developpement model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Development();

if ($model->load(\Yii::$app->request->post())) {
$model->date = date('Y-m-d H:i:s');
$model->setDateDelivery();
if ($model->save()) {
$this->setFlash('success', 'Développement ajouté');
return $this->redirect(['index']);
}
} else {
return $this->render('create', [
'model' => $model,
]);
}
}

/**
* Updates an existing Developpement model.
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);

if ($model->load(\Yii::$app->request->post())) {
$model->setDateDelivery();
if ($model->save()) {
$this->setFlash('success', 'Développement modifié');
return $this->redirect(['index']);
}
} else {
return $this->render('update', [
'model' => $model,
]);
}
}

/**
* Deletes an existing Developpement model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
$this->setFlash('success', 'Développement supprimé');

return $this->redirect(['index']);
}

/**
* Définit une priorité pour un développement.
*
* @param integer $idDevelopment
* @param string $priorite
*/
public function actionPriority($idDevelopment, $priority = null)
{
$develpmentPriority = DevelopmentPriority::searchOne([
'id_development' => $idDevelopment,
]);

if (in_array($priority, [DevelopmentPriority::PRIORITY_HIGH,
DevelopmentPriority::PRIORITY_NORMAL,
DevelopmentPriority::PRIORITY_LOW])) {

if ($develpmentPriority) {
$develpmentPriority->priority = $priority;
$develpmentPriority->id_producer = GlobalParam::getCurrentProducerId();
} else {
$develpmentPriority = new DevelopmentPriority;
$develpmentPriority->id_development = $idDevelopment;
$develpmentPriority->priority = $priority;
$develpmentPriority->id_producer = GlobalParam::getCurrentProducerId();
}

$develpmentPriority->save();
} else {
if ($develpmentPriority) {
$develpmentPriority->delete();
}
}

$this->redirect(['index']);
}

/**
* Finds the Developpement model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*/
protected function findModel($id)
{
if (($model = Development::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

} }

+ 0
- 1
common/components/BusinessLogic.php View File

$this->getUserProducerContainer(), $this->getUserProducerContainer(),
$this->getUserPointSaleContainer(), $this->getUserPointSaleContainer(),
$this->getUserContainer(), $this->getUserContainer(),
$this->getOrderSatusHistoryContainer(),
$this->getPointSaleDistributionContainer(), $this->getPointSaleDistributionContainer(),
$this->getProductDistributionContainer(), $this->getProductDistributionContainer(),
$this->getProductCategoryContainer(), $this->getProductCategoryContainer(),

+ 0
- 12
common/components/BusinessLogicTrait.php View File

use common\logic\Document\Quotation\Wrapper\QuotationManager; use common\logic\Document\Quotation\Wrapper\QuotationManager;
use common\logic\Order\Order\Wrapper\OrderContainer; use common\logic\Order\Order\Wrapper\OrderContainer;
use common\logic\Order\Order\Wrapper\OrderManager; use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\Order\OrderStatusHistory\Wrapper\OrderStatusHistoryContainer;
use common\logic\Order\OrderStatusHistory\Wrapper\OrderStatusHistoryManager;
use common\logic\Order\ProductOrder\Wrapper\ProductOrderContainer; use common\logic\Order\ProductOrder\Wrapper\ProductOrderContainer;
use common\logic\Order\ProductOrder\Wrapper\ProductOrderManager; use common\logic\Order\ProductOrder\Wrapper\ProductOrderManager;
use common\logic\PointSale\PointSale\Wrapper\PointSaleContainer; use common\logic\PointSale\PointSale\Wrapper\PointSaleContainer;
return QuotationManager::getInstance(); return QuotationManager::getInstance();
} }


public function getOrderStatusHistoryManager(): OrderStatusHistoryManager
{
return OrderStatusHistoryManager::getInstance();
}

public function getProductOrderManager(): ProductOrderManager public function getProductOrderManager(): ProductOrderManager
{ {
return ProductOrderManager::getInstance(); return ProductOrderManager::getInstance();
return OrderContainer::getInstance(); return OrderContainer::getInstance();
} }


public function getOrderSatusHistoryContainer(): OrderStatusHistoryContainer
{
return OrderStatusHistoryContainer::getInstance();
}

public function getUserPointSaleContainer(): UserPointSaleContainer public function getUserPointSaleContainer(): UserPointSaleContainer
{ {
return UserPointSaleContainer::getInstance(); return UserPointSaleContainer::getInstance();

+ 0
- 148
common/logic/Development/Development/Development.php View File

<?php

/**
Copyright distrib (2018)

contact@opendistrib.net

Ce logiciel est un programme informatique servant à aider les producteurs
à distribuer leur production en circuits courts.

Ce logiciel est régi par la licence CeCILL soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".

En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.

A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.

Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

namespace common\logic\Development\Development;

use common\helpers\GlobalParam;
use Yii;
use common\components\ActiveRecordCommon ;

/**
* This is the model class for table "development".
*/
class Development extends ActiveRecordCommon
{
const STATUS_OPEN = 'open';
const STATUS_CLOSED = 'closed';
const TYPE_EVOLUTION = 'evolution';
const TYPE_BUG = 'bug';

/**
* @inheritdoc
*/
public static function tableName()
{
return 'development';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['subject', 'date'], 'required'],
[['id', 'progress'], 'integer'],
[['description'], 'string'],
[['date', 'date_delivery'], 'safe'],
[['time_estimate'], 'number'],
[['subject', 'status', 'type'], 'string', 'max' => 255],
];
}

/*
* Relations
*/
public function getDevelopmentPriority()
{
return $this->hasMany(
DevelopmentPriorityModel::className(),
['id_development' => 'id'])
->with('producer');
}

public function getDevelopmentPriorityCurrentProducer()
{
return $this->hasOne(
DevelopmentPriorityModel::className(),
['id_development' => 'id'])
->where(['id_producer' => GlobalParam::getCurrentProducerId()])
->with('producer');
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'subject' => 'Sujet',
'description' => 'Description',
'date' => 'Date',
'progress' => 'Avancement',
'status' => 'Statut',
'time_estimate' => 'Estimation temps',
'type' => 'Type',
'date_delivery' => 'Date de livraison'
];
}
/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
* @return array
*/
public static function getDefaultOptionsSearch() {
return [
'with' => ['developmentPriority', 'developmentPriorityCurrentProducer'],
'join_with' => [],
'orderby' => 'date DESC',
'attribute_id_producer' => ''
] ;
}
/**
* Définit une date de livraison.
*
* @param string $date
*/
public function setDateDelivery($date = '')
{
if (strlen($date)) {
$this->date_delivery = $date;
}
if (strlen($this->date_delivery)) {
$this->date_delivery = date('Y-m-d', strtotime($this->date_delivery));
}
}

}

+ 0
- 149
common/logic/Development/DevelopmentPriority/DevelopmentPriority.php View File

<?php

/**
Copyright distrib (2018)

contact@opendistrib.net

Ce logiciel est un programme informatique servant à aider les producteurs
à distribuer leur production en circuits courts.

Ce logiciel est régi par la licence CeCILL soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".

En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.

A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, à l'utilisation, à la modification et/ou au
développement et à la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe à
manipuler et qui le réserve donc à des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités à charger et tester l'adéquation du
logiciel à leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.

Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL, et que vous en avez accepté les
termes.
*/

namespace common\logic\Development\DevelopmentPriority;

use common\logic\Producer\Producer\Producer;
use common\components\ActiveRecordCommon ;

/**
* This is the model class for table "development_priority".
*/
class DevelopmentPriority extends ActiveRecordCommon
{

const PRIORITY_HIGH = 'high';
const PRIORITY_NORMAL = 'normal';
const PRIORITY_LOW = 'low';

/**
* @inheritdoc
*/
public static function tableName()
{
return 'development_priority';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_producer', 'id_development'], 'required'],
[['id_producer', 'id_development'], 'integer'],
[['priority'], 'string'],
];
}
/*
* Relations
*/

public function getProducer()
{
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_producer' => 'Producteur',
'id_development' => 'Développement',
'priority' => 'Priorité'
];
}
/**
* Retourne les options de base nécessaires à la fonction de recherche.
*
* @return array
*/
public static function getDefaultOptionsSearch() {
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => 'development_priority.id_producer'
] ;
}

/**
* Retourne la priorité.
*
* @return string
*/
public function getStrPriority()
{
switch ($this->priority) {
case self::PRIORITY_LOW : return 'Basse';
break;
case self::PRIORITY_NORMAL : return 'Normale';
break;
case self::PRIORITY_HIGH : return 'Haute';
break;
default: return 'Non définie';
break;
}
}

/**
* Retourne la classe CSS du bouton servant à définir la priorité.
*
* @return string
*/
public function getClassCssStyleButton()
{
$styleButton = 'default';
if ($this->priority == DevelopmentPriorityModel::PRIORITY_LOW) {
$styleButton = 'info';
}
elseif ($this->priority == DevelopmentPriorityModel::PRIORITY_NORMAL) {
$styleButton = 'warning';
}
elseif ($this->priority == DevelopmentPriorityModel::PRIORITY_HIGH) {
$styleButton = 'danger';
}
return $styleButton;
}

}

+ 0
- 17
common/logic/Order/Order/Service/OrderBuilder.php View File

use common\logic\Document\Document\Model\Document; use common\logic\Document\Document\Model\Document;
use common\logic\Order\Order\Model\Order; use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Repository\OrderRepository; use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryBuilder;
use common\logic\Order\ProductOrder\Model\ProductOrder; use common\logic\Order\ProductOrder\Model\ProductOrder;
use common\logic\Order\ProductOrder\Service\ProductOrderBuilder; use common\logic\Order\ProductOrder\Service\ProductOrderBuilder;
use common\logic\Order\ProductOrder\Service\ProductOrderSolver; use common\logic\Order\ProductOrder\Service\ProductOrderSolver;
protected ProducerRepository $producerRepository; protected ProducerRepository $producerRepository;
protected CreditHistoryBuilder $creditHistoryBuilder; protected CreditHistoryBuilder $creditHistoryBuilder;
protected ProductOrderBuilder $productOrderBuilder; protected ProductOrderBuilder $productOrderBuilder;
protected OrderStatusHistoryBuilder $orderStatusHistoryBuilder;
protected OrderRepository $orderRepository; protected OrderRepository $orderRepository;
protected DistributionRepository $distributionRepository; protected DistributionRepository $distributionRepository;
protected SubscriptionBuilder $subscriptionBuilder; protected SubscriptionBuilder $subscriptionBuilder;
$this->producerRepository = $this->loadService(ProducerRepository::class); $this->producerRepository = $this->loadService(ProducerRepository::class);
$this->creditHistoryBuilder = $this->loadService(CreditHistoryBuilder::class); $this->creditHistoryBuilder = $this->loadService(CreditHistoryBuilder::class);
$this->productOrderBuilder = $this->loadService(ProductOrderBuilder::class); $this->productOrderBuilder = $this->loadService(ProductOrderBuilder::class);
$this->orderStatusHistoryBuilder = $this->loadService(OrderStatusHistoryBuilder::class);
$this->orderRepository = $this->loadService(OrderRepository::class); $this->orderRepository = $this->loadService(OrderRepository::class);
$this->distributionRepository = $this->loadService(DistributionRepository::class); $this->distributionRepository = $this->loadService(DistributionRepository::class);
$this->subscriptionBuilder = $this->loadService(SubscriptionBuilder::class); $this->subscriptionBuilder = $this->loadService(SubscriptionBuilder::class);
/** /**
* Ajoute l'abonnement' pour une date donnée. * Ajoute l'abonnement' pour une date donnée.
*/ */
// add
public function createOrderFromSubscription(Subscription $subscription, string $date, bool $force = false): ?Order public function createOrderFromSubscription(Subscription $subscription, string $date, bool $force = false): ?Order
{ {
$now = date('Y-m-d'); $now = date('Y-m-d');
/** /**
* Ajoute les commandes pour une date donnée à partir des abonnements. * Ajoute les commandes pour une date donnée à partir des abonnements.
*/ */
// addAll
// createAllFromSubscriptions
public function createAllOrdersFromSubscriptions(string $date, bool $force = false): array public function createAllOrdersFromSubscriptions(string $date, bool $force = false): array
{ {
$orderArray = []; $orderArray = [];
return $orderArray; return $orderArray;
} }


// updateIncomingDistributions
public function updateOrdersIncomingDistributionsFromSubscription(Subscription $subscription, $update = false): array public function updateOrdersIncomingDistributionsFromSubscription(Subscription $subscription, $update = false): array
{ {
$orderArray = []; $orderArray = [];
return $productsAdd; return $productsAdd;
} }


// updateFromSubscription
public function updateOrderFromSubscription(Order $order, Subscription $subscription): void public function updateOrderFromSubscription(Order $order, Subscription $subscription): void
{ {
$this->initOrderBaseFromSubscription($order, $subscription); $this->initOrderBaseFromSubscription($order, $subscription);
$order->tiller_synchronization = $order->auto_payment; $order->tiller_synchronization = $order->auto_payment;
} }


// addUserPointSale
public function createUserPointSale(Order $order): void public function createUserPointSale(Order $order): void
{ {
if ($order->user) { if ($order->user) {
} }
} }


// initCommentPointSale
public function initOrderCommentPointSale(Order $order): void public function initOrderCommentPointSale(Order $order): void
{ {
if ($order->user && $order->pointSale) { if ($order->user && $order->pointSale) {
$this->addProductOrderVat($order, $typeTotal, $price * $productOrder->quantity, $productOrder->taxRate, $taxCalculationMethod); $this->addProductOrderVat($order, $typeTotal, $price * $productOrder->quantity, $productOrder->taxRate, $taxCalculationMethod);
} }


// addVat
public function addProductOrderVat( public function addProductOrderVat(
Order $order, Order $order,
string $typeTotal, string $typeTotal,
} }
} }


// delete
public function deleteOrder(Order $order, bool $force = false): bool public function deleteOrder(Order $order, bool $force = false): bool
{ {
$this->initOrder($order); $this->initOrder($order);
} }
} }


// setTillerSynchronization
// updateTillerSynchronization
public function updateOrderTillerSynchronization(Order $order, int $synchroTiller = null): void public function updateOrderTillerSynchronization(Order $order, int $synchroTiller = null): void
{ {
if (!is_null($synchroTiller)) { if (!is_null($synchroTiller)) {
/** /**
* Changement de statut d'une commande. * Changement de statut d'une commande.
*/ */
// changeOrderStatus
public function updateOrderStatus(Order $order, string $newStatus, string $origin): void public function updateOrderStatus(Order $order, string $newStatus, string $origin): void
{ {
$orderStatusArray = GlobalParam::get('orderStatus'); $orderStatusArray = GlobalParam::get('orderStatus');


switch ($newStatus) { switch ($newStatus) {
case 'new-order' : case 'new-order' :
//$this->orderStatusHistoryBuilder->createOrderStatusHistory($order, $userCurrent, $newStatus, $origin);
$order->status = $newStatus; $order->status = $newStatus;
$order->save(); $order->save();
break; break;
case 'refunded': case 'refunded':
case 'cancel': case 'cancel':
if (in_array($newStatus, $orderStatusArray[$order->status]['nextStatusAllow'])) { if (in_array($newStatus, $orderStatusArray[$order->status]['nextStatusAllow'])) {
//$this->orderStatusHistoryBuilder->createOrderStatusHistory($order, $userCurrent, $newStatus, $origin);
$order->status = $newStatus; $order->status = $newStatus;
$order->save(); $order->save();
} }

+ 0
- 72
common/logic/Order/OrderStatusHistory/Model/OrderStatusHistory.php View File

<?php

namespace common\logic\Order\OrderStatusHistory\Model;

use common\components\ActiveRecordCommon;
use common\logic\Order\Order\Model\Order;
use common\logic\User\User\Model\User;

/**
* This is the model class for table "order_status_history".
*/
class OrderStatusHistory extends ActiveRecordCommon
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'order_status_history';
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_order', 'status', 'id_user', 'date', 'origin'], 'required'],
[['id_order', 'id_user',], 'integer'],
[['date'], 'safe'],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'id_order' => 'Commande',
'id_user' => 'Utilisateur',
'status' => 'Statut',
'origin' => 'Origine',
'date' => 'Date',
];
}

/*
* Relations
*/

public function getOrder()
{
return $this->hasOne(Order::class, ['id' => 'id_order']);
}

public function populateOrder(Order $order): void
{
$this->populateFieldObject('id_order', 'order', $order);
}

public function getUser()
{
return $this->hasOne(User::class, ['id' => 'id_user']);
}

public function populateUser(User $user): void
{
$this->populateFieldObject('id_user', 'user', $user);
}
}

+ 0
- 25
common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepository.php View File

<?php

namespace common\logic\Order\OrderStatusHistory\Repository;

use common\logic\AbstractRepository;

class OrderStatusHistoryRepository extends AbstractRepository
{
protected OrderStatusHistoryRepositoryQuery $query;

public function loadDependencies(): void
{
$this->loadQuery(OrderStatusHistoryRepositoryQuery::class);
}

public function getDefaultOptionsSearch(): array
{
return [
self::WITH => [],
self::JOIN_WITH => ['order', 'orderStatus'],
self::ORDER_BY => 'date ASC',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}
}

+ 0
- 18
common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepositoryQuery.php View File

<?php

namespace common\logic\Order\OrderStatusHistory\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryDefinition;
use yii\db\ActiveQuery;

class OrderStatusHistoryRepositoryQuery extends AbstractRepositoryQuery
{
protected OrderStatusHistoryDefinition $definition;

public function loadDependencies(): void
{
$this->loadDefinition(OrderStatusHistoryDefinition::class);
}
}

+ 0
- 39
common/logic/Order/OrderStatusHistory/Service/OrderStatusHistoryBuilder.php View File

<?php

namespace common\logic\Order\OrderStatusHistory\Service;

use common\logic\AbstractBuilder;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;
use common\logic\User\User\Model\User;
use common\logic\User\User\Service\UserSolver;

class OrderStatusHistoryBuilder extends AbstractBuilder
{
protected UserSolver $userSolver;

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

public function instanciateOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory
{
$orderStatusHistory = new OrderStatusHistory();
$orderStatusHistory->populateOrder($order);
$orderStatusHistory->populateUser($user);
$orderStatusHistory->status = $status;
$orderStatusHistory->origin = $origin;
$orderStatusHistory->date = date('Y-m-d H:i:s');

return $orderStatusHistory;
}

public function createOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory
{
$orderStatusHistory = $this->instanciateOrderStatusHistory($order, $user, $status, $origin);
$this->saveCreate($orderStatusHistory);

return $orderStatusHistory;
}
}

+ 0
- 14
common/logic/Order/OrderStatusHistory/Service/OrderStatusHistoryDefinition.php View File

<?php

namespace common\logic\Order\OrderStatusHistory\Service;

use common\logic\AbstractDefinition;
use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;

class OrderStatusHistoryDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return OrderStatusHistory::class;
}
}

+ 0
- 35
common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryContainer.php View File

<?php

namespace common\logic\Order\OrderStatusHistory\Wrapper;

use common\logic\AbstractContainer;
use common\logic\Order\OrderStatusHistory\Repository\OrderStatusHistoryRepository;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryBuilder;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryDefinition;

class OrderStatusHistoryContainer extends AbstractContainer
{
public function getServices(): array
{
return [
OrderStatusHistoryDefinition::class,
OrderStatusHistoryRepository::class,
OrderStatusHistoryBuilder::class
];
}

public function getDefinition(): OrderStatusHistoryDefinition
{
return OrderStatusHistoryDefinition::getInstance();
}

public function getRepository(): OrderStatusHistoryRepository
{
return OrderStatusHistoryRepository::getInstance();
}

public function getBuilder(): OrderStatusHistoryBuilder
{
return OrderStatusHistoryBuilder::getInstance();
}
}

+ 0
- 21
common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryManager.php View File

<?php

namespace common\logic\Order\OrderStatusHistory\Wrapper;

use common\logic\AbstractManager;
use common\logic\Order\OrderStatusHistory\Repository\OrderStatusHistoryRepository;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryBuilder;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryDefinition;

/**
* @mixin OrderStatusHistoryDefinition
* @mixin OrderStatusHistoryRepository
* @mixin OrderStatusHistoryBuilder
*/
class OrderStatusHistoryManager extends AbstractManager
{
public function getContainerFqcn(): string
{
return OrderStatusHistoryContainer::class;
}
}

+ 29
- 0
console/migrations/m230823_072853_delete_development_order_status.php View File

<?php

use yii\db\Migration;

/**
* Class m230823_072853_delete_development_order_status
*/
class m230823_072853_delete_development_order_status extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->dropTable('development');
$this->dropTable('development_priority');
$this->dropTable('order_status');
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
echo "m230823_072853_delete_development_order_status cannot be reverted.\n";

return false;
}
}

Loading…
Cancel
Save