@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic; | |||
use yii\db\ActiveRecord; | |||
abstract class AbstractDefinition extends AbstractService implements DefinitionInterface | |||
{ | |||
} |
@@ -4,6 +4,11 @@ namespace common\logic; | |||
abstract class AbstractRepository extends AbstractService implements RepositoryInterface | |||
{ | |||
const WITH = 'with'; | |||
const JOIN_WITH = 'join_with'; | |||
const ORDER_BY = 'orderby'; | |||
const ATTRIBUTE_ID_PRODUCER = 'attribute_id_producer'; | |||
public function createQuery() | |||
{ | |||
$this->repositoryQuery->createQuery(); | |||
@@ -17,11 +22,26 @@ abstract class AbstractRepository extends AbstractService implements RepositoryI | |||
$defaultOptions = $this->getDefaultOptionsSearch(); | |||
// id producer | |||
// with | |||
if (is_array($defaultOptions['with']) && count($defaultOptions['with'])) { | |||
$this->repositoryQuery->with($defaultOptions['with']); | |||
} | |||
// join with | |||
if (is_array($defaultOptions['join_with']) && count($defaultOptions['join_with'])) { | |||
$this->repositoryQuery->joinWith($defaultOptions['join_with']); | |||
} | |||
// id producer contexte | |||
if(isset($defaultOptions['attribute_id_producer']) && $defaultOptions['attribute_id_producer']) { | |||
$this->repositoryQuery->andWhere([$defaultOptions['attribute_id_producer'] => $this->getProducerContextId()]); | |||
} | |||
// order by | |||
if(isset($defaultOptions['orderby']) && $defaultOptions['orderby']) { | |||
$this->repositoryQuery->orderBy($defaultOptions['orderby']); | |||
} | |||
return $this->repositoryQuery; | |||
} | |||
} |
@@ -2,11 +2,20 @@ | |||
namespace common\logic; | |||
use common\components\ActiveRecordCommon; | |||
use yii\db\ActiveQuery; | |||
class AbstractRepositoryQuery extends AbstractService implements RepositoryQueryInterface | |||
abstract class AbstractRepositoryQuery extends AbstractService implements RepositoryQueryInterface | |||
{ | |||
protected ActiveQuery $query; | |||
protected DefinitionInterface $definition; | |||
public function createQuery(): self | |||
{ | |||
$this->query = $this->baseQuery(); | |||
return $this; | |||
} | |||
public function __call(string $name, $params): self | |||
{ | |||
@@ -15,6 +24,14 @@ class AbstractRepositoryQuery extends AbstractService implements RepositoryQuery | |||
return $this; | |||
} | |||
public function count() | |||
{ | |||
$class = $this->definition->getEntityFqcn(); | |||
$class::groupByPrimaryKey($class, $this->query); | |||
return $this->query->count(); | |||
} | |||
public function find() | |||
{ | |||
return $this->query->all(); | |||
@@ -25,8 +42,10 @@ class AbstractRepositoryQuery extends AbstractService implements RepositoryQuery | |||
return $this->query->one(); | |||
} | |||
public function filterById(int $id) | |||
public function filterById(int $id): self | |||
{ | |||
$this->query->andWhere(['id' => $id]); | |||
return $this; | |||
} | |||
} |
@@ -11,6 +11,7 @@ abstract class AbstractService extends AbstractSingleton implements ServiceInter | |||
protected function getHierarchy(): array | |||
{ | |||
return [ | |||
DefinitionInterface::class, | |||
SolverInterface::class, | |||
RepositoryQueryInterface::class, | |||
RepositoryInterface::class, |
@@ -8,20 +8,20 @@ use yii\db\ActiveQuery; | |||
class TaxRateRepository extends AbstractRepository | |||
{ | |||
protected TaxRateRepositoryQuery $query; | |||
protected TaxRateRepositoryQuery $repositoryQuery; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(TaxRateRepositoryQuery::class); | |||
$this->repositoryQuery = $this->loadService(TaxRateRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => 'pourcent ASC', | |||
'attribute_id_producer' => '' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => 'pourcent ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
] ; | |||
} | |||
@@ -4,11 +4,12 @@ namespace common\logic\Config\TaxRate\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Config\TaxRate\Model\TaxRate; | |||
use yii\db\ActiveQuery; | |||
class TaxRateRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function createQuery() | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
$this->query = TaxRate::find(); | |||
return TaxRate::find(); | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
<?php | |||
namespace common\logic; | |||
interface DefinitionInterface | |||
{ | |||
} |
@@ -2,7 +2,6 @@ | |||
namespace common\logic\Distribution\Distribution\Repository; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
@@ -25,10 +24,10 @@ class DistributionRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => 'distribution.id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => 'date ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'distribution.id_producer' | |||
]; | |||
} | |||
@@ -51,25 +50,24 @@ class DistributionRepository extends AbstractRepository | |||
public function findOneFirstDistribution(): ?Distribution | |||
{ | |||
return Distribution::searchOne([], [ | |||
'orderby' => 'date ASC' | |||
]); | |||
return $this->createDefaultQuery() | |||
->orderBy('date ASC') | |||
->findOne(); | |||
} | |||
public function findOneLastDistribution(): ?Distribution | |||
{ | |||
return Distribution::searchOne([], [ | |||
'orderby' => 'date DESC' | |||
]); | |||
return $this->createDefaultQuery() | |||
->orderBy('date DESC') | |||
->findOne(); | |||
} | |||
public function findDistributionsActive(): array | |||
{ | |||
return Distribution::searchAll([ | |||
'active' => 1 | |||
], [ | |||
'orderby' => 'date ASC', | |||
]); | |||
return $this->createDefaultQuery() | |||
->filterByActive(true) | |||
->orderBy('date ASC') | |||
->find(); | |||
} | |||
/** | |||
@@ -77,51 +75,34 @@ class DistributionRepository extends AbstractRepository | |||
*/ | |||
public function findDistributionsIncoming($ignoreActive = false): array | |||
{ | |||
$paramsWhere = [ | |||
'id_producer' => $this->getProducerContext()->id, | |||
]; | |||
$query = $this->createDefaultQuery(); | |||
if(!$ignoreActive) { | |||
$paramsWhere['active'] = 1; | |||
$query->filterByActive(true); | |||
} | |||
$distributionsArray = Distribution::find() | |||
->where('date > \'' . date('Y-m-d') . '\'') | |||
->andWhere($paramsWhere) | |||
->orderBy('date ASC') | |||
->all(); | |||
$query | |||
->filterByDateBetterThanToday() | |||
->orderBy('date ASC'); | |||
return $distributionsArray; | |||
return $query->find(); | |||
} | |||
/** | |||
* Recherche les distributions futures où l'abonnement peut s'appliquer. | |||
*/ | |||
// searchMatchedIncomingDistributions | |||
public function findDistributionsIncomingMatchWithSubscrtiption(Subscription $subscription, bool $filterByOrderDeadline = false): array | |||
{ | |||
$params = [ | |||
':date_earliest_order' => date('Y-m-d'), | |||
':date_begin' => date('Y-m-d', strtotime($subscription->date_begin)), | |||
':id_producer' => GlobalParam::getCurrentProducerId() | |||
]; | |||
$incomingDistributionsArray = $this->createDefaultQuery() | |||
->filterByDateBetterThanToday() | |||
->filterBySubscriptionDates($subscription) | |||
->find(); | |||
$incomingDistributions = Distribution::find() | |||
->where('id_producer = :id_producer') | |||
->andWhere('date >= :date_begin') | |||
->andWhere('date > :date_earliest_order'); | |||
if ($subscription->date_end) { | |||
$incomingDistributions->andWhere('date <= :date_end'); | |||
$params[':date_end'] = date('Y-m-d', strtotime($subscription->date_end)); | |||
if($filterByOrderDeadline) { | |||
$incomingDistributionsArray = $this->distributionSolver | |||
->filterDistributionsByDateDelay($incomingDistributionsArray); | |||
} | |||
$incomingDistributions->orderBy('date ASC'); | |||
$incomingDistributions->params($params); | |||
$incomingDistributionsArray = $incomingDistributions->all(); | |||
$this->distributionSolver->filterDistributionsByDateDelay($incomingDistributionsArray); | |||
$matchedIncomingDistributionsArray = []; | |||
foreach ($incomingDistributionsArray as $incomingDistribution) { | |||
if ($this->subscriptionSolver->isSubscriptionMatchWith($subscription, $incomingDistribution->date)) { | |||
@@ -129,14 +110,9 @@ class DistributionRepository extends AbstractRepository | |||
} | |||
} | |||
if($filterByOrderDeadline) { | |||
$matchedIncomingDistributionsArray = $this->distributionSolver->filterDistributionsByDateDelay($matchedIncomingDistributionsArray); | |||
} | |||
return $matchedIncomingDistributionsArray; | |||
} | |||
// isDateAvailable | |||
public function isDistributionDateAvailable(string $date = null): bool | |||
{ | |||
if($date && strlen($date)) { |
@@ -4,21 +4,62 @@ namespace common\logic\Distribution\Distribution\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\Distribution\Service\DistributionDefinition; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use yii\db\ActiveQuery; | |||
class DistributionRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function createQuery() | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = Distribution::find(); | |||
$this->definition = $this->loadService(DistributionDefinition::class); | |||
} | |||
return $this; | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
$class = $this->definition->getEntityFqcn(); | |||
return $class::find(); | |||
} | |||
public function filterByDate(string $date) | |||
public function filterByDate(string $date): self | |||
{ | |||
$this->query->andWhere(['date' => $date]); | |||
return $this; | |||
} | |||
public function filterByActive(bool $active): self | |||
{ | |||
$this->query->andWhere(['active' => $active]); | |||
return $this; | |||
} | |||
public function filterByDateBetterThanToday(): self | |||
{ | |||
$this->query | |||
->andWhere('date > :date') | |||
->addParams(['date' => date('Y-m-d') ]); | |||
return $this; | |||
} | |||
public function filterBySubscriptionDates(Subscription $subscription): self | |||
{ | |||
$this->query | |||
->andWhere('date >= :date_begin') | |||
->addParams([ | |||
'date_begin' => date('Y-m-d', strtotime($subscription->date_begin)), | |||
]); | |||
if($subscription->date_end) { | |||
$this->query | |||
->andWhere('date <= :date_end') | |||
->addParams([ | |||
'date_end' => date('Y-m-d', strtotime($subscription->date_end)) | |||
]); | |||
} | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution\Service; | |||
use common\logic\AbstractDefinition; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
class DistributionDefinition extends AbstractDefinition | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return Distribution::class; | |||
} | |||
} |
@@ -6,24 +6,31 @@ use common\logic\AbstractContainer; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\Distribution\Repository\DistributionRepository; | |||
use common\logic\Distribution\Distribution\Service\DistributionBuilder; | |||
use common\logic\Distribution\Distribution\Service\DistributionDefinition; | |||
use common\logic\Distribution\Distribution\Service\DistributionSolver; | |||
class DistributionContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return Distribution::class; | |||
return $this->getDefinition()->getEntityFqcn(); | |||
} | |||
public function getServices(): array | |||
{ | |||
return [ | |||
DistributionDefinition::class, | |||
DistributionSolver::class, | |||
DistributionRepository::class, | |||
DistributionBuilder::class | |||
]; | |||
} | |||
public function getDefinition(): DistributionDefinition | |||
{ | |||
return DistributionDefinition::getInstance(); | |||
} | |||
public function getSolver(): DistributionSolver | |||
{ | |||
return DistributionSolver::getInstance(); |
@@ -9,42 +9,42 @@ use common\logic\PointSale\PointSale\Model\PointSale; | |||
class PointSaleDistributionRepository extends AbstractRepository | |||
{ | |||
protected PointSaleDistributionRepositoryQuery $query; | |||
protected PointSaleDistributionRepositoryQuery $repositoryQuery; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(PointSaleDistributionRepositoryQuery::class); | |||
$this->repositoryQuery = $this->loadService(PointSaleDistributionRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['distribution', 'pointSale'], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
] ; | |||
self::WITH => ['distribution', 'pointSale'], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
public function findOnePointSaleDistribution(Distribution $distribution, PointSale $pointSale): ?PointSaleDistribution | |||
{ | |||
return PointSaleDistribution::searchOne([ | |||
'id_distribution' => $distribution->id, | |||
'id_point_sale' => $pointSale->id | |||
]); | |||
return $this->createDefaultQuery() | |||
->filterByDistribution($distribution) | |||
->filterByPointSale($pointSale) | |||
->findOne(); | |||
} | |||
public function findPointSaleDistributionsByDistribution(Distribution $distribution): array | |||
{ | |||
return PointSaleDistribution::searchAll([ | |||
'id_distribution' => $distribution->id | |||
]) ; | |||
return $this->createDefaultQuery() | |||
->filterByDistribution($distribution) | |||
->find(); | |||
} | |||
public function countPointSaleDistributionsByDistribution(Distribution $distribution): int | |||
{ | |||
return PointSaleDistribution::searchCount([ | |||
'id_distribution' => $distribution->id | |||
]); | |||
return $this->createDefaultQuery() | |||
->filterByDistribution($distribution) | |||
->count(); | |||
} | |||
} |
@@ -3,8 +3,35 @@ | |||
namespace common\logic\Distribution\PointSaleDistribution\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionDefinition; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use yii\db\ActiveQuery; | |||
class PointSaleDistributionRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function loadDependencies(): void | |||
{ | |||
$this->definition = $this->loadService(PointSaleDistributionDefinition::class); | |||
} | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
$class = $this->definition->getEntityFqcn(); | |||
return $class::find(); | |||
} | |||
public function filterByDistribution(Distribution $distribution): self | |||
{ | |||
$this->andWhere(['id_distribution' => $distribution->id]); | |||
return $this; | |||
} | |||
public function filterByPointSale(PointSale $pointSale): self | |||
{ | |||
$this->andWhere(['id_point_sale' => $pointSale->id]); | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
<?php | |||
namespace common\logic\Distribution\PointSaleDistribution\Service; | |||
use common\logic\AbstractDefinition; | |||
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution; | |||
class PointSaleDistributionDefinition extends AbstractDefinition | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return PointSaleDistribution::class; | |||
} | |||
} |
@@ -3,25 +3,31 @@ | |||
namespace common\logic\Distribution\PointSaleDistribution\Wrapper; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution; | |||
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository; | |||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder; | |||
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionDefinition; | |||
class PointSaleDistributionContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return PointSaleDistribution::class; | |||
return $this->getDefinition()->getEntityFqcn(); | |||
} | |||
public function getServices(): array | |||
{ | |||
return [ | |||
PointSaleDistributionDefinition::class, | |||
PointSaleDistributionRepository::class, | |||
PointSaleDistributionBuilder::class, | |||
]; | |||
} | |||
public function getDefinition(): PointSaleDistributionDefinition | |||
{ | |||
return PointSaleDistributionDefinition::getInstance(); | |||
} | |||
public function getRepository(): PointSaleDistributionRepository | |||
{ | |||
return PointSaleDistributionRepository::getInstance(); |
@@ -19,10 +19,10 @@ class ProductDistributionRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['product','distribution'], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => ['product','distribution'], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
] ; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Distribution\ProductDistribution\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution; | |||
use yii\db\ActiveQuery; | |||
class ProductDistributionRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return ProductDistribution::find(); | |||
} | |||
} |
@@ -17,10 +17,10 @@ class DeliveryNoteRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['user AS user_delivery_note', 'producer'], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => 'delivery_note.id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => ['user AS user_delivery_note', 'producer'], | |||
self::ORDER_BY => 'date ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'delivery_note.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Document\DeliveryNote\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||
use yii\db\ActiveQuery; | |||
class DeliveryNoteRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return DeliveryNote::find(); | |||
} | |||
} |
@@ -17,10 +17,10 @@ class InvoiceRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['user AS user_invoice', 'producer'], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => 'invoice.id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => ['user AS user_invoice', 'producer'], | |||
self::ORDER_BY => 'date ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'invoice.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Document\Invoice\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Document\Invoice\Model\Invoice; | |||
use yii\db\ActiveQuery; | |||
class InvoiceRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return Invoice::find(); | |||
} | |||
} |
@@ -17,10 +17,10 @@ class QuotationRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['user AS user_quotation', 'producer'], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => 'quotation.id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => ['user AS user_quotation', 'producer'], | |||
self::ORDER_BY => 'date ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'quotation.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Document\Quotation\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Document\Quotation\Model\Quotation; | |||
use yii\db\ActiveQuery; | |||
class QuotationRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return Quotation::find(); | |||
} | |||
} |
@@ -41,20 +41,20 @@ class OrderRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [ | |||
self::WITH => [ | |||
'productOrder', | |||
'productOrder.product', | |||
'creditHistory', | |||
'creditHistory.userAction', | |||
'pointSale' | |||
], | |||
'join_with' => [ | |||
self::JOIN_WITH => [ | |||
'distribution', | |||
'user', | |||
'user.userProducer' | |||
], | |||
'orderby' => 'order.date ASC', | |||
'attribute_id_producer' => 'distribution.id_producer' | |||
self::ORDER_BY => 'order.date ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'distribution.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Order\Order\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Order\Order\Model\Order; | |||
use yii\db\ActiveQuery; | |||
class OrderRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return Order::find(); | |||
} | |||
} |
@@ -16,10 +16,10 @@ class OrderStatusHistoryRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['order', 'orderStatus'], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => '' | |||
self::WITH => [], | |||
self::JOIN_WITH => ['order', 'orderStatus'], | |||
self::ORDER_BY => 'date ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
} |
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Order\OrderStatusHistory\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory; | |||
use yii\db\ActiveQuery; | |||
class OrderStatusHistoryRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return OrderStatusHistory::find(); | |||
} | |||
} |
@@ -18,10 +18,10 @@ class ProductOrderRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['taxRate'], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => ['taxRate'], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Order\ProductOrder\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Order\ProductOrder\Model\ProductOrder; | |||
use yii\db\ActiveQuery; | |||
class ProductOrderRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return ProductOrder::find(); | |||
} | |||
} |
@@ -21,10 +21,10 @@ class PointSaleRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => 'is_bread_box ASC, name ASC', | |||
'attribute_id_producer' => 'point_sale.id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => 'is_bread_box ASC, name ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'point_sale.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\PointSale\PointSale\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use yii\db\ActiveQuery; | |||
class PointSaleRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return PointSale::find(); | |||
} | |||
} |
@@ -19,10 +19,10 @@ class UserPointSaleRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
] ; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\PointSale\UserPointSale\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\PointSale\UserPointSale\Model\UserPointSale; | |||
use yii\db\ActiveQuery; | |||
class UserPointSaleRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return UserPointSale::find(); | |||
} | |||
} |
@@ -37,10 +37,10 @@ class ProducerRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['taxRate'], | |||
'join_with' => [], | |||
'orderby' => 'name ASC', | |||
'attribute_id_producer' => 'id' | |||
self::WITH => ['taxRate'], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => 'name ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'id' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Producer\Producer\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use yii\db\ActiveQuery; | |||
class ProducerRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return Producer::find(); | |||
} | |||
} |
@@ -22,10 +22,10 @@ class ProducerPriceRangeRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Producer\ProducerPriceRange\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Producer\ProducerPriceRange\Model\ProducerPriceRange; | |||
use yii\db\ActiveQuery; | |||
class ProducerPriceRangeRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return ProducerPriceRange::find(); | |||
} | |||
} |
@@ -32,10 +32,10 @@ class ProductRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['taxRate', 'productPointSale'], | |||
'join_with' => [], | |||
'orderby' => 'order ASC', | |||
'attribute_id_producer' => 'product.id_producer' | |||
self::WITH => ['taxRate', 'productPointSale'], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => 'order ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'product.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Product\Product\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Product\Product\Model\Product; | |||
use yii\db\ActiveQuery; | |||
class ProductRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return Product::find(); | |||
} | |||
} |
@@ -17,10 +17,10 @@ class ProductCategoryRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => 'id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => 'id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Product\ProductCategory\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Product\ProductCategory\Model\ProductCategory; | |||
use yii\db\ActiveQuery; | |||
class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return ProductCategory::find(); | |||
} | |||
} |
@@ -16,10 +16,10 @@ class ProductPointSaleRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['product', 'pointSale'], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => ['product', 'pointSale'], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
] ; | |||
} | |||
} |
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Product\ProductPointSale\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Product\ProductPointSale\Model\ProductPointSale; | |||
use yii\db\ActiveQuery; | |||
class ProductPointSaleRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return ProductPointSale::find(); | |||
} | |||
} |
@@ -24,10 +24,10 @@ class ProductPriceRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['user', 'pointSale', 'userGroup'], | |||
'join_with' => ['product'], | |||
'orderby' => '', | |||
'attribute_id_producer' => 'product.id_producer' | |||
self::WITH => ['user', 'pointSale', 'userGroup'], | |||
self::JOIN_WITH => ['product'], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => 'product.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Product\ProductPrice\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Product\ProductPrice\Model\ProductPrice; | |||
use yii\db\ActiveQuery; | |||
class ProductPriceRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return ProductPrice::find(); | |||
} | |||
} |
@@ -2,7 +2,9 @@ | |||
namespace common\logic; | |||
use yii\db\ActiveQuery; | |||
interface RepositoryQueryInterface | |||
{ | |||
public function baseQuery(): ActiveQuery; | |||
} |
@@ -21,10 +21,10 @@ class ProductSubscriptionRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['product'], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => ['product'], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Subscription\ProductSubscription\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | |||
use yii\db\ActiveQuery; | |||
class ProductSubscriptionRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return ProductSubscription::find(); | |||
} | |||
} |
@@ -22,10 +22,10 @@ class SubscriptionRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['producer'], | |||
'join_with' => ['user', 'productSubscription', 'productSubscription.product', 'pointSale'], | |||
'orderby' => 'user.name ASC', | |||
'attribute_id_producer' => 'subscription.id_producer' | |||
self::WITH => ['producer'], | |||
self::JOIN_WITH => ['user', 'productSubscription', 'productSubscription.product', 'pointSale'], | |||
self::ORDER_BY => 'user.name ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => 'subscription.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\Subscription\Subscription\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use yii\db\ActiveQuery; | |||
class SubscriptionRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return Subscription::find(); | |||
} | |||
} |
@@ -18,10 +18,10 @@ class CreditHistoryRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => CreditHistory::tableName() . '.date ASc', | |||
'attribute_id_producer' => CreditHistory::tableName() . '.id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => CreditHistory::tableName() . '.date ASc', | |||
self::ATTRIBUTE_ID_PRODUCER => CreditHistory::tableName() . '.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\User\CreditHistory\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\User\CreditHistory\Model\CreditHistory; | |||
use yii\db\ActiveQuery; | |||
class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return CreditHistory::find(); | |||
} | |||
} |
@@ -36,10 +36,10 @@ class UserRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['userProducer', 'userUserGroup'], | |||
'orderby' => 'user.name ASC, user.lastname ASC', | |||
'attribute_id_producer' => '' | |||
self::WITH => [], | |||
self::JOIN_WITH => ['userProducer', 'userUserGroup'], | |||
self::ORDER_BY => 'user.name ASC, user.lastname ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\User\User\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\User\User\Model\User; | |||
use yii\db\ActiveQuery; | |||
class UserRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return User::find(); | |||
} | |||
} |
@@ -18,10 +18,10 @@ class UserGroupRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\User\UserGroup\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\User\UserGroup\Model\UserGroup; | |||
use yii\db\ActiveQuery; | |||
class UserGroupRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return UserGroup::find(); | |||
} | |||
} |
@@ -19,10 +19,10 @@ class UserProducerRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => 'user_producer.id_producer' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => 'user_producer.id_producer' | |||
]; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\User\UserProducer\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\User\UserProducer\Model\UserProducer; | |||
use yii\db\ActiveQuery; | |||
class UserProducerRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return UserProducer::find(); | |||
} | |||
} |
@@ -18,10 +18,10 @@ class UserUserGroupRepository extends AbstractRepository | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => '' | |||
self::WITH => [], | |||
self::JOIN_WITH => [], | |||
self::ORDER_BY => '', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
] ; | |||
} | |||
@@ -3,8 +3,13 @@ | |||
namespace common\logic\User\UserUserGroup\Repository; | |||
use common\logic\AbstractRepositoryQuery; | |||
use common\logic\User\UserUserGroup\Model\UserUserGroup; | |||
use yii\db\ActiveQuery; | |||
class UserUserGroupRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
public function baseQuery(): ActiveQuery | |||
{ | |||
return UserUserGroup::find(); | |||
} | |||
} |