@@ -4,7 +4,6 @@ namespace common\logic\Distribution\PointSaleDistribution; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Distribution\Distribution\PointSaleDistributionRepositoryQuery; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
class PointSaleDistributionRepository extends AbstractRepository |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Distribution\PointSaleDistribution; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -4,7 +4,6 @@ namespace common\logic\Distribution\ProductDistribution; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Distribution\Distribution\ProductDistributionRepositoryQuery; | |||
use common\logic\Product\Product\Product; | |||
class ProductDistributionRepository extends AbstractRepository |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Distribution\ProductDistribution; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -1,10 +1,8 @@ | |||
<?php | |||
namespace common\logic\PointSale\PointSale; | |||
namespace common\logic\Document\DeliveryNote; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\DeliveryNoteRepositoryQuery; | |||
use common\logic\Document\DeliveryNote\DeliveryNote; | |||
class DeliveryNoteRepository extends AbstractRepository | |||
{ |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Document\DeliveryNote; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -4,7 +4,6 @@ namespace common\logic\Document\Invoice; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Document\Document\DocumentSolver; | |||
use common\logic\PointSale\PointSale\InvoiceRepository; | |||
class InvoiceContainer extends AbstractContainer | |||
{ |
@@ -3,7 +3,6 @@ | |||
namespace common\logic\Document\Invoice; | |||
use common\logic\Document\Document\DocumentManager; | |||
use common\logic\PointSale\PointSale\InvoiceRepository; | |||
/** | |||
* @mixin InvoiceRepository |
@@ -1,10 +1,8 @@ | |||
<?php | |||
namespace common\logic\PointSale\PointSale; | |||
namespace common\logic\Document\Invoice; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\InvoiceRepositoryQuery; | |||
use common\logic\Document\Invoice\Invoice; | |||
class InvoiceRepository extends AbstractRepository | |||
{ |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Document\Invoice; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -3,7 +3,7 @@ | |||
namespace common\logic\PointSale\PointSale; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\QuotationRepositoryQuery; | |||
use common\logic\Document\Quotation\QuotationRepositoryQuery; | |||
class QuotationRepository extends AbstractRepository | |||
{ |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Document\Quotation; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -4,7 +4,6 @@ namespace common\logic\Order\Order; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Distribution\Distribution\OrderRepositoryQuery; | |||
use common\logic\Distribution\ProductDistribution\ProductDistributionRepository; | |||
use common\logic\Order\ProductOrder\ProductOrderRepository; | |||
use common\logic\Producer\Producer\Producer; | |||
@@ -63,7 +62,7 @@ class OrderRepository extends AbstractRepository | |||
*/ | |||
// searchBy | |||
// findBy | |||
public function findOrdersBy(array $params = [], array $options = []): mixed | |||
public function findOrdersBy(array $params = [], array $options = []) | |||
{ | |||
$orders = Order::searchBy($params, $options); | |||
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Order\Order; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -1,9 +1,8 @@ | |||
<?php | |||
namespace common\logic\PointSale\PointSale; | |||
namespace common\logic\Order\OrderStatusHistory; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\OrderStatusHistoryRepositoryQuery; | |||
class OrderStatusHistoryRepository extends AbstractRepository | |||
{ |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Order\OrderStatusHistory; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -3,7 +3,6 @@ | |||
namespace common\logic\Order\ProductOrder; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Distribution\Distribution\ProductOrderRepositoryQuery; | |||
use common\logic\Order\Order\Order; | |||
class ProductOrderRepository extends AbstractRepository |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\Order\ProductOrder; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -4,12 +4,8 @@ namespace common\logic\PointSale\PointSale; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractRepository; | |||
use common\logic\AbstractService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\Distribution\Distribution\PointSaleRepositoryQuery; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\RepositoryInterface; | |||
class PointSaleRepository extends AbstractRepository | |||
{ |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Distribution\Distribution; | |||
namespace common\logic\PointSale\PointSale; | |||
use common\logic\AbstractRepositoryQuery; | |||
@@ -13,14 +13,14 @@ use common\logic\User\UserProducer\UserProducerBuilder; | |||
use common\logic\User\UserProducer\UserProducerRepository; | |||
use common\helpers\Url; | |||
class ProducerBuilder extends AbstractBuilder implements BuilderInterface | |||
class ProducerBuilder extends AbstractBuilder | |||
{ | |||
protected ProducerRepository $producerRepository; | |||
protected UserProducerRepository $userProducerRepository; | |||
protected UserProducerBuilder $userProducerBuilder; | |||
protected ProducerSolver $producerSolver; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->producerRepository = $this->loadService(ProducerRepository::class); | |||
$this->userProducerRepository = $this->loadService(UserProducerRepository::class); | |||
@@ -53,7 +53,7 @@ class ProducerBuilder extends AbstractBuilder implements BuilderInterface | |||
} | |||
$producer->slug = $slug ; | |||
$cptSlug ++ ; | |||
} while($this->producerRepository->getOneBySlug($producer->slug)) ; | |||
} while($this->producerRepository->findOneProducerBySlug($producer->slug)) ; | |||
} | |||
public function initProducerCode(Producer $producer): void |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\Producer\Producer; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class ProducerContainer extends AbstractSingleton implements ContainerInterface | |||
class ProducerContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -24,21 +23,21 @@ class ProducerContainer extends AbstractSingleton implements ContainerInterface | |||
public function getSolver(): ProducerSolver | |||
{ | |||
return new ProducerSolver(); | |||
return ProducerSolver::getInstance(); | |||
} | |||
public function getRepository() | |||
public function getRepository(): ProducerRepository | |||
{ | |||
return new ProducerRepository(); | |||
return ProducerRepository::getInstance(); | |||
} | |||
public function getBuilder(): ProducerBuilder | |||
{ | |||
return new ProducerBuilder(); | |||
return ProducerBuilder::getInstance(); | |||
} | |||
public function getUtils(): ProducerUtils | |||
{ | |||
return new ProducerUtils(); | |||
return ProducerUtils::getInstance(); | |||
} | |||
} |
@@ -12,8 +12,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class ProducerManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new ProducerContainer()); | |||
return ProducerContainer::class; | |||
} | |||
} |
@@ -5,6 +5,7 @@ namespace common\logic\Producer\Producer; | |||
use common\helpers\Departments; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Price; | |||
use common\logic\AbstractRepository; | |||
use common\logic\AbstractService; | |||
use common\logic\Document\Document\DocumentInterface; | |||
use common\logic\Document\Document\DocumentSolver; | |||
@@ -15,14 +16,16 @@ use common\logic\RepositoryInterface; | |||
use common\logic\User\User\User; | |||
use yii\helpers\Html; | |||
class ProducerRepository extends AbstractService implements RepositoryInterface | |||
class ProducerRepository extends AbstractRepository | |||
{ | |||
protected ProducerRepositoryQuery $query; | |||
protected ProducerPriceRangeRepository $producerPriceRangeRepository; | |||
protected ProducerSolver $producerSolver; | |||
protected DocumentSolver $documentSolver; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(ProducerRepositoryQuery::class); | |||
$this->producerPriceRangeRepository = $this->loadService(ProducerPriceRangeRepository::class); | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
$this->documentSolver = $this->loadService(DocumentSolver::class); |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Producer\Producer; | |||
use common\logic\AbstractRepositoryQuery; | |||
class ProducerRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -9,7 +9,6 @@ use common\logic\User\User\User; | |||
class ProducerSolver extends AbstractService implements SolverInterface | |||
{ | |||
/** | |||
* Retourne true si le compte est un compte de démo. | |||
*/ |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\Producer\ProducerPriceRange; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class ProducerPriceRangeContainer extends AbstractSingleton implements ContainerInterface | |||
class ProducerPriceRangeContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -15,12 +14,18 @@ class ProducerPriceRangeContainer extends AbstractSingleton implements Container | |||
public function getServices(): array | |||
{ | |||
return [ | |||
ProducerPriceRangeRepository::class | |||
ProducerPriceRangeRepository::class, | |||
ProducerPriceRangeBuilder::class, | |||
]; | |||
} | |||
public function getRepository() | |||
public function getRepository(): ProducerPriceRangeRepository | |||
{ | |||
return new ProducerPriceRangeRepository(); | |||
return ProducerPriceRangeRepository::getInstance(); | |||
} | |||
public function getBuilder(): ProducerPriceRangeBuilder | |||
{ | |||
return ProducerPriceRangeBuilder::getInstance(); | |||
} | |||
} |
@@ -10,8 +10,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class ProducerPriceRangeManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new ProducerPriceRangeContainer()); | |||
return ProducerPriceRangeContainer::class; | |||
} | |||
} |
@@ -3,11 +3,17 @@ | |||
namespace common\logic\Producer\ProducerPriceRange; | |||
use common\helpers\Price; | |||
use common\logic\AbstractService; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\AbstractRepository; | |||
class ProducerPriceRangeRepository extends AbstractService implements RepositoryInterface | |||
class ProducerPriceRangeRepository extends AbstractRepository | |||
{ | |||
protected ProducerPriceRangeRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(ProducerPriceRangeRepositoryQuery::class); | |||
} | |||
/** | |||
* Retourne les options de base nécessaires à la fonction de recherche. | |||
* |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Producer\ProducerPriceRange; | |||
use common\logic\AbstractRepositoryQuery; | |||
class ProducerPriceRangeRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -3,9 +3,8 @@ | |||
namespace common\logic\Product\Product; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\BuilderInterface; | |||
class ProductBuilder extends AbstractBuilder implements BuilderInterface | |||
class ProductBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateProduct(): Product | |||
{ |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\Product\Product; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class ProductContainer extends AbstractSingleton implements ContainerInterface | |||
class ProductContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -23,19 +22,16 @@ class ProductContainer extends AbstractSingleton implements ContainerInterface | |||
public function getSolver(): ProductSolver | |||
{ | |||
return new ProductSolver(); | |||
return ProductSolver::getInstance(); | |||
} | |||
public function getRepository(): ProductRepository | |||
{ | |||
return new ProductRepository(); | |||
return ProductRepository::getInstance(); | |||
} | |||
public function getBuilder(): ProductBuilder | |||
{ | |||
return new ProductBuilder(); | |||
return ProductBuilder::getInstance(); | |||
} | |||
} |
@@ -11,8 +11,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class ProductManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new ProductContainer()); | |||
return ProductContainer::class; | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace common\logic\Product\Product; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractRepository; | |||
use common\logic\AbstractService; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
@@ -13,14 +14,16 @@ use common\logic\RepositoryInterface; | |||
use common\logic\User\User\User; | |||
use common\logic\User\UserProducer\UserProducerRepository; | |||
class ProductRepository extends AbstractService implements RepositoryInterface | |||
class ProductRepository extends AbstractRepository | |||
{ | |||
protected ProductRepositoryQuery $query; | |||
protected ProductSolver $productSolver; | |||
protected ProductPriceSolver $productPriceSolver; | |||
protected UserProducerRepository $userProducerRepository; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(ProductRepositoryQuery::class); | |||
$this->productSolver = $this->loadService(ProductSolver::class); | |||
$this->productPriceSolver = $this->loadService(ProductPriceSolver::class); | |||
$this->userProducerRepository = $this->loadService(UserProducerRepository::class); |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Product\Product; | |||
use common\logic\AbstractRepositoryQuery; | |||
class ProductRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -57,8 +57,8 @@ class ProductSearch extends Product | |||
public function search($params) | |||
{ | |||
$productManager = ProductManager::getInstance(); | |||
$optionsSearch = $productManager->getDefaultOptionsSearch() ; | |||
$productRepository = ProductRepository::getInstance(); | |||
$optionsSearch = $productRepository->getDefaultOptionsSearch() ; | |||
$query = Product::find() | |||
->with($optionsSearch['with']) |
@@ -13,7 +13,7 @@ class ProductSolver extends AbstractService implements SolverInterface | |||
{ | |||
protected ProductPriceSolver $productPriceSolver; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->productPriceSolver = $this->loadService(ProductPriceSolver::class); | |||
} |
@@ -3,10 +3,8 @@ | |||
namespace common\logic\Product\ProductCategory; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\AbstractService; | |||
use common\logic\BuilderInterface; | |||
class ProductCategoryBuilder extends AbstractBuilder implements BuilderInterface | |||
class ProductCategoryBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateProductCategory(): ProductCategory | |||
{ |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\Product\ProductCategory; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class ProductCategoryContainer extends AbstractSingleton implements ContainerInterface | |||
class ProductCategoryContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -22,11 +21,11 @@ class ProductCategoryContainer extends AbstractSingleton implements ContainerInt | |||
public function getBuilder(): ProductCategoryBuilder | |||
{ | |||
return new ProductCategoryBuilder(); | |||
return ProductCategoryBuilder::getInstance(); | |||
} | |||
public function getRepository(): ProductCategoryRepository | |||
{ | |||
return new ProductCategoryRepository(); | |||
return ProductCategoryRepository::getInstance(); | |||
} | |||
} |
@@ -10,8 +10,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class ProductCategoryManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new ProductCategoryContainer()); | |||
return ProductCategoryContainer::class; | |||
} | |||
} |
@@ -3,11 +3,19 @@ | |||
namespace common\logic\Product\ProductCategory; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractRepository; | |||
use common\logic\AbstractService; | |||
use common\logic\RepositoryInterface; | |||
class ProductCategoryRepository extends AbstractService implements RepositoryInterface | |||
class ProductCategoryRepository extends AbstractRepository | |||
{ | |||
protected ProductCategoryRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(ProductCategoryRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Product\ProductCategory; | |||
use common\logic\AbstractRepositoryQuery; | |||
class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -39,6 +39,7 @@ termes. | |||
namespace common\logic\Product\ProductCategory ; | |||
use common\helpers\GlobalParam; | |||
use yii\data\ActiveDataProvider; | |||
class ProductCategorySearch extends ProductCategory | |||
{ | |||
@@ -54,7 +55,8 @@ class ProductCategorySearch extends ProductCategory | |||
public function search($params) | |||
{ | |||
$optionsSearch = self::getDefaultOptionsSearch() ; | |||
$productCategoryRepository = ProductCategoryRepository::getInstance(); | |||
$optionsSearch = $productCategoryRepository->getDefaultOptionsSearch() ; | |||
$query = ProductCategory::find() | |||
->with($optionsSearch['with']) |
@@ -3,11 +3,10 @@ | |||
namespace common\logic\Product\ProductPointSale; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\BuilderInterface; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
use common\logic\Product\Product\Product; | |||
class ProductPointSaleBuilder extends AbstractBuilder implements BuilderInterface | |||
class ProductPointSaleBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateProductPointSale(): ProductPointSale | |||
{ |
@@ -2,11 +2,9 @@ | |||
namespace common\logic\Product\ProductPointSale; | |||
use common\logic\ContainerInterface; | |||
use common\logic\Product\ProductPrice\ProductPointSaleRepository; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class ProductPointSaleContainer extends AbstractSingleton implements ContainerInterface | |||
class ProductPointSaleContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -23,11 +21,11 @@ class ProductPointSaleContainer extends AbstractSingleton implements ContainerIn | |||
public function getRepository(): ProductPointSaleRepository | |||
{ | |||
return new ProductPointSaleRepository(); | |||
return ProductPointSaleRepository::getInstance(); | |||
} | |||
public function getBuilder(): ProductPointSaleBuilder | |||
{ | |||
return new ProductPointSaleBuilder(); | |||
return ProductPointSaleBuilder::getInstance(); | |||
} | |||
} |
@@ -10,8 +10,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class ProductPointSaleManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new ProductPointSaleContainer()); | |||
return ProductPointSaleContainer::class; | |||
} | |||
} |
@@ -2,11 +2,17 @@ | |||
namespace common\logic\Product\ProductPointSale; | |||
use common\logic\AbstractService; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\AbstractRepository; | |||
class ProductPointSaleRepository extends AbstractService implements RepositoryInterface | |||
class ProductPointSaleRepository extends AbstractRepository | |||
{ | |||
protected ProductPointSaleRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(ProductPointSaleRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Product\ProductPointSale; | |||
use common\logic\AbstractRepositoryQuery; | |||
class ProductPointSaleRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -3,9 +3,8 @@ | |||
namespace common\logic\Product\ProductPrice; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\BuilderInterface; | |||
class ProductPriceBuilder extends AbstractBuilder implements BuilderInterface | |||
class ProductPriceBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateProductPrice(): ProductPrice | |||
{ |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\Product\ProductPrice; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class ProductPriceContainer extends AbstractSingleton implements ContainerInterface | |||
class ProductPriceContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -22,16 +21,16 @@ class ProductPriceContainer extends AbstractSingleton implements ContainerInterf | |||
public function getBuilder(): ProductPriceBuilder | |||
{ | |||
return new ProductPriceBuilder(); | |||
return ProductPriceBuilder::getInstance(); | |||
} | |||
public function getSolver(): ProductPriceSolver | |||
{ | |||
return new ProductPriceSolver(); | |||
return ProductPriceSolver::getInstance(); | |||
} | |||
public function getRepository(): ProductPriceRepository | |||
{ | |||
return new ProductPriceRepository(); | |||
return ProductPriceRepository::getInstance(); | |||
} | |||
} |
@@ -10,8 +10,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class ProductPriceManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new ProductPriceContainer()); | |||
return ProductPriceContainer::class; | |||
} | |||
} |
@@ -2,11 +2,17 @@ | |||
namespace common\logic\Product\ProductPrice; | |||
use common\logic\AbstractService; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\AbstractRepository; | |||
class ProductPriceRepository extends AbstractService implements RepositoryInterface | |||
class ProductPriceRepository extends AbstractRepository | |||
{ | |||
protected ProductPriceRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(ProductPriceRepositoryQuery::class); | |||
} | |||
/** | |||
* Retourne les options de base nécessaires à la fonction de recherche. | |||
*/ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Product\ProductPrice; | |||
use common\logic\AbstractRepositoryQuery; | |||
class ProductPriceRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -42,49 +42,46 @@ use common\helpers\GlobalParam; | |||
/** | |||
* This is the model class for table "product_price". | |||
* | |||
* @property integer $id | |||
*/ | |||
class ProductPriceSearch extends ProductPrice | |||
{ | |||
public function rules() | |||
{ | |||
return [ | |||
[['id_user', 'id_point_sale'], 'string'], | |||
[['price'], 'double'], | |||
]; | |||
} | |||
public function rules() | |||
{ | |||
return [ | |||
[['id_user', 'id_point_sale'], 'string'], | |||
[['price'], 'double'], | |||
]; | |||
} | |||
public function search($params) | |||
{ | |||
$optionsSearch = self::getDefaultOptionsSearch() ; | |||
public function search($params) | |||
{ | |||
$productPriceRepository = ProductPriceRepository::getInstance(); | |||
$optionsSearch = $productPriceRepository->getDefaultOptionsSearch(); | |||
$query = ProductPrice::find() | |||
->with($optionsSearch['with']) | |||
->innerJoinWith($optionsSearch['join_with'], true) | |||
->where(['product.id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->orderBy('product_price.price ASC') | |||
; | |||
$query = ProductPrice::find() | |||
->with($optionsSearch['with']) | |||
->innerJoinWith($optionsSearch['join_with'], true) | |||
->where(['product.id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->orderBy('product_price.price ASC'); | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query, | |||
'sort' => false, | |||
'pagination' => [ | |||
'pageSize' => 1000, | |||
], | |||
]); | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query, | |||
'sort' => false, | |||
'pagination' => [ | |||
'pageSize' => 1000, | |||
], | |||
]); | |||
$this->load($params); | |||
if (!$this->validate()) { | |||
return $dataProvider; | |||
} | |||
if(isset($params['id_product'])) { | |||
$query->andWhere(['product.id' => (int) $params['id_product']]) ; | |||
} | |||
$this->load($params); | |||
if (!$this->validate()) { | |||
return $dataProvider; | |||
} | |||
return $dataProvider; | |||
if (isset($params['id_product'])) { | |||
$query->andWhere(['product.id' => (int)$params['id_product']]); | |||
} | |||
return $dataProvider; | |||
} | |||
} |
@@ -3,9 +3,8 @@ | |||
namespace common\logic\Subscription\ProductSubscription; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\BuilderInterface; | |||
class ProductSubscriptionBuilder extends AbstractBuilder implements BuilderInterface | |||
class ProductSubscriptionBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateProductSubscription(): ProductSubscription | |||
{ |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\Subscription\ProductSubscription; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class ProductSubscriptionContainer extends AbstractSingleton implements ContainerInterface | |||
class ProductSubscriptionContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -15,12 +14,18 @@ class ProductSubscriptionContainer extends AbstractSingleton implements Containe | |||
public function getServices(): array | |||
{ | |||
return [ | |||
ProductSubscriptionRepository::class, | |||
ProductSubscriptionBuilder::class | |||
]; | |||
} | |||
public function getRepository(): ProductSubscriptionRepository | |||
{ | |||
return ProductSubscriptionRepository::getInstance(); | |||
} | |||
public function getFactory(): ProductSubscriptionBuilder | |||
{ | |||
return new ProductSubscriptionBuilder(); | |||
return ProductSubscriptionBuilder::getInstance(); | |||
} | |||
} |
@@ -10,8 +10,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class ProductSubscriptionManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new ProductSubscriptionContainer()); | |||
return ProductSubscriptionContainer::class; | |||
} | |||
} |
@@ -2,12 +2,18 @@ | |||
namespace common\logic\Subscription\ProductSubscription; | |||
use common\logic\AbstractService; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Subscription\Subscription\Subscription; | |||
class ProductSubscriptionRepository extends AbstractService implements RepositoryInterface | |||
class ProductSubscriptionRepository extends AbstractRepository | |||
{ | |||
protected ProductSubscriptionRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(ProductSubscriptionRepositoryQuery::class); | |||
} | |||
/** | |||
* Retourne les options de base nécessaires à la fonction de recherche. | |||
*/ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Subscription\ProductSubscription; | |||
use common\logic\AbstractRepositoryQuery; | |||
class ProductSubscriptionRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -3,15 +3,14 @@ | |||
namespace common\logic\Subscription\Subscription; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\BuilderInterface; | |||
use common\logic\Distribution\Distribution\DistributionRepository; | |||
use common\logic\Subscription\ProductSubscription\ProductSubscription; | |||
class SubscriptionBuilder extends AbstractBuilder implements BuilderInterface | |||
class SubscriptionBuilder extends AbstractBuilder | |||
{ | |||
protected DistributionRepository $distributionRepository; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->distributionRepository = $this->loadService(DistributionRepository::class); | |||
} |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\Subscription\Subscription; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class SubscriptionContainer extends AbstractSingleton implements ContainerInterface | |||
class SubscriptionContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -23,16 +22,16 @@ class SubscriptionContainer extends AbstractSingleton implements ContainerInterf | |||
public function getSolver(): SubscriptionSolver | |||
{ | |||
return new SubscriptionSolver(); | |||
return SubscriptionSolver::getInstance(); | |||
} | |||
public function getRepository(): SubscriptionRepository | |||
{ | |||
return new SubscriptionRepository(); | |||
return SubscriptionRepository::getInstance(); | |||
} | |||
public function getBuilder(): SubscriptionBuilder | |||
{ | |||
return new SubscriptionBuilder(); | |||
return SubscriptionBuilder::getInstance(); | |||
} | |||
} |
@@ -13,7 +13,7 @@ class SubscriptionEventSubscriber | |||
*/ | |||
public static function onActiveDistribution(Distribution $distribution): void | |||
{ | |||
$orderManager = new OrderManager(); | |||
$orderManager = OrderManager::getInstance(); | |||
$orderManager->createAllOrdersFromSubscriptions($distribution->date); | |||
} | |||
} |
@@ -11,8 +11,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class SubscriptionManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new SubscriptionContainer()); | |||
return SubscriptionContainer::class; | |||
} | |||
} |
@@ -2,19 +2,18 @@ | |||
namespace common\logic\Subscription\Subscription; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractService; | |||
use common\logic\Distribution\Distribution\Distribution; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\User\User\User; | |||
class SubscriptionRepository extends AbstractService implements RepositoryInterface | |||
class SubscriptionRepository extends AbstractRepository | |||
{ | |||
protected SubscriptionRepositoryQuery $query; | |||
protected SubscriptionSolver $subscriptionSolver; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(SubscriptionRepositoryQuery::class); | |||
$this->subscriptionSolver = $this->loadService(SubscriptionSolver::class); | |||
} | |||
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\Subscription\Subscription; | |||
use common\logic\AbstractRepositoryQuery; | |||
class SubscriptionRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -57,8 +57,8 @@ class SubscriptionSearch extends Subscription | |||
public function search($params) { | |||
$subscriptionManager = new SubscriptionManager(); | |||
$optionsSearch = $subscriptionManager->getDefaultOptionsSearch() ; | |||
$subscriptionRepository = SubscriptionRepository::getInstance(); | |||
$optionsSearch = $subscriptionRepository->getDefaultOptionsSearch() ; | |||
$query = Subscription::find() | |||
->with($optionsSearch['with']) |
@@ -10,7 +10,7 @@ class SubscriptionSolver extends AbstractService implements SolverInterface | |||
{ | |||
protected UserSolver $userSolver; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->userSolver = $this->loadService(UserSolver::class); | |||
} |
@@ -10,11 +10,11 @@ use common\logic\User\User\User; | |||
use yii\base\Event; | |||
use yii\db\ActiveRecord; | |||
class CreditHistoryBuilder extends AbstractBuilder implements BuilderInterface | |||
class CreditHistoryBuilder extends AbstractBuilder | |||
{ | |||
protected CreditHistorySolver $creditHistorySolver; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->creditHistorySolver = $this->loadService(CreditHistorySolver::class); | |||
} |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\User\CreditHistory; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class CreditHistoryContainer extends AbstractSingleton implements ContainerInterface | |||
class CreditHistoryContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -23,16 +22,16 @@ class CreditHistoryContainer extends AbstractSingleton implements ContainerInter | |||
public function getSolver(): CreditHistorySolver | |||
{ | |||
return new CreditHistorySolver(); | |||
return CreditHistorySolver::getInstance(); | |||
} | |||
public function getBuilder(): CreditHistoryBuilder | |||
{ | |||
return new CreditHistoryBuilder(); | |||
return CreditHistoryBuilder::getInstance(); | |||
} | |||
public function getRepository(): CreditHistoryRepository | |||
{ | |||
return new CreditHistoryRepository(); | |||
return CreditHistoryRepository::getInstance(); | |||
} | |||
} |
@@ -2,12 +2,18 @@ | |||
namespace common\logic\User\CreditHistory; | |||
use common\logic\AbstractService; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\RepositoryInterface; | |||
class CreditHistoryRepository extends AbstractService implements RepositoryInterface | |||
class CreditHistoryRepository extends AbstractRepository | |||
{ | |||
protected CreditHistoryRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(CreditHistoryRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\User\CreditHistory; | |||
use common\logic\AbstractRepositoryQuery; | |||
class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -56,8 +56,8 @@ class CreditHistorySearch extends CreditHistory | |||
public function search($params) | |||
{ | |||
$creditHistoryManager = new CreditHistoryManager(); | |||
$optionsSearch = $creditHistoryManager->getDefaultOptionsSearch() ; | |||
$creditHistoryRepository = CreditHistoryRepository::getInstance(); | |||
$optionsSearch = $creditHistoryRepository->getDefaultOptionsSearch() ; | |||
$query = CreditHistory::find() | |||
->with($optionsSearch['with']) |
@@ -3,10 +3,11 @@ | |||
namespace common\logic\User\CreditHistory; | |||
use common\helpers\MeanPayment; | |||
use common\logic\AbstractService; | |||
use common\logic\SolverInterface; | |||
use yii\helpers\Html; | |||
class CreditHistorySolver implements SolverInterface | |||
class CreditHistorySolver extends AbstractService implements SolverInterface | |||
{ | |||
public function isTypeDebit(CreditHistory $creditHistory): bool | |||
{ |
@@ -7,11 +7,11 @@ use common\logic\AbstractService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\Producer\Producer\Producer; | |||
class UserBuilder extends AbstractBuilder implements BuilderInterface | |||
class UserBuilder extends AbstractBuilder | |||
{ | |||
protected UserRepository $userRepository; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->userRepository = $this->loadService(UserRepository::class); | |||
} |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\User\User; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class UserContainer extends AbstractSingleton implements ContainerInterface | |||
class UserContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -24,21 +23,21 @@ class UserContainer extends AbstractSingleton implements ContainerInterface | |||
public function getSolver(): UserSolver | |||
{ | |||
return new UserSolver(); | |||
return UserSolver::getInstance(); | |||
} | |||
public function getRepository(): UserRepository | |||
{ | |||
return new UserRepository(); | |||
return UserRepository::getInstance(); | |||
} | |||
public function getBuilder(): UserBuilder | |||
{ | |||
return new UserBuilder(); | |||
return UserBuilder::getInstance(); | |||
} | |||
public function getUtils(): UserUtils | |||
{ | |||
return new UserUtils(); | |||
return UserUtils::getInstance(); | |||
} | |||
} |
@@ -12,8 +12,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class UserManager extends AbstractManager | |||
{ | |||
protected function construct(): void | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(UserContainer::getInstance()); | |||
return UserContainer::class; | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace common\logic\User\User; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractRepository; | |||
use common\logic\AbstractService; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
@@ -14,13 +15,15 @@ use common\logic\User\UserProducer\UserProducerRepository; | |||
use common\logic\User\UserUserGroup\UserUserGroup; | |||
use yii\db\Query; | |||
class UserRepository extends AbstractService implements RepositoryInterface | |||
class UserRepository extends AbstractRepository | |||
{ | |||
protected UserRepositoryQuery $query; | |||
protected UserProducerRepository $userProducerRepository; | |||
protected UserSolver $userSolver; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(UserRepositoryQuery::class); | |||
$this->userProducerRepository = $this->loadService(UserProducerRepository::class); | |||
$this->userSolver = $this->loadService(UserSolver::class); | |||
} |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\User\User; | |||
use common\logic\AbstractRepositoryQuery; | |||
class UserRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -39,106 +39,109 @@ | |||
namespace common\logic\User\User; | |||
use common\helpers\GlobalParam; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
use yii\data\ActiveDataProvider; | |||
class UserSearch extends User | |||
{ | |||
var $id_point_sale; | |||
var $subscribers; | |||
var $inactive; | |||
var $username; | |||
public function rules() | |||
{ | |||
return [ | |||
[['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday', 'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday', 'mail_distribution_sunday'], 'boolean'], | |||
[['lastname', 'name', 'phone', 'address'], 'string'], | |||
[['id_point_sale', 'inactive', 'subscribers'], 'integer'], | |||
[['date_last_connection', 'id_point_sale', 'username'], 'safe'], | |||
]; | |||
var $id_point_sale; | |||
var $subscribers; | |||
var $inactive; | |||
var $username; | |||
public function rules() | |||
{ | |||
return [ | |||
[['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday', 'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday', 'mail_distribution_sunday'], 'boolean'], | |||
[['lastname', 'name', 'phone', 'address'], 'string'], | |||
[['id_point_sale', 'inactive', 'subscribers'], 'integer'], | |||
[['date_last_connection', 'id_point_sale', 'username'], 'safe'], | |||
]; | |||
} | |||
public function search($params = []) | |||
{ | |||
$userRepository = UserRepository::getInstance(); | |||
$optionsSearch = $userRepository->getDefaultOptionsSearch(); | |||
$query = User::find() | |||
->select( | |||
'`user`.id, ' | |||
. '`user`.username,' | |||
. '`user`.email, ' | |||
. '`user`.status, ' | |||
. '`user`.created_at, ' | |||
. '`user`.updated_at, ' | |||
. '`user`.lastname, ' | |||
. '`user`.name, ' | |||
. '`user`.phone, ' | |||
. '`user`.address, ' | |||
. '`user`.no_mail, ' | |||
. '`user`.mail_distribution_monday, ' | |||
. '`user`.mail_distribution_tuesday, ' | |||
. '`user`.mail_distribution_wednesday, ' | |||
. '`user`.mail_distribution_thursday, ' | |||
. '`user`.mail_distribution_friday, ' | |||
. '`user`.mail_distribution_saturday, ' | |||
. '`user`.mail_distribution_sunday, ' | |||
. '`user`.id_producer, ' | |||
. '`user`.date_last_connection, ' | |||
. '`user`.name_legal_person, ' | |||
. '`user`.type, ' | |||
. '(SELECT COUNT(*) FROM `order` WHERE `user`.id = `order`.id_user) AS count_orders'); | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query, | |||
'sort' => ['attributes' => ['username', 'credit', 'orders']], | |||
'pagination' => [ | |||
'pageSize' => 20, | |||
], | |||
]); | |||
$dataProvider->sort->attributes['username'] = [ | |||
'asc' => ['user.lastname' => SORT_ASC, 'user.name' => SORT_ASC], | |||
'desc' => ['user.lastname' => SORT_DESC, 'user.name' => SORT_DESC], | |||
]; | |||
$dataProvider->sort->attributes['credit'] = [ | |||
'asc' => ['user_producer.credit' => SORT_ASC], | |||
'desc' => ['user_producer.credit' => SORT_DESC], | |||
]; | |||
$this->load($params); | |||
if (!$this->validate()) { | |||
return $dataProvider; | |||
} | |||
public function search($params = []) | |||
{ | |||
$optionsSearch = self::getDefaultOptionsSearch(); | |||
$query = User::find() | |||
->select( | |||
'`user`.id, ' | |||
. '`user`.username,' | |||
. '`user`.email, ' | |||
. '`user`.status, ' | |||
. '`user`.created_at, ' | |||
. '`user`.updated_at, ' | |||
. '`user`.lastname, ' | |||
. '`user`.name, ' | |||
. '`user`.phone, ' | |||
. '`user`.address, ' | |||
. '`user`.no_mail, ' | |||
. '`user`.mail_distribution_monday, ' | |||
. '`user`.mail_distribution_tuesday, ' | |||
. '`user`.mail_distribution_wednesday, ' | |||
. '`user`.mail_distribution_thursday, ' | |||
. '`user`.mail_distribution_friday, ' | |||
. '`user`.mail_distribution_saturday, ' | |||
. '`user`.mail_distribution_sunday, ' | |||
. '`user`.id_producer, ' | |||
. '`user`.date_last_connection, ' | |||
. '`user`.name_legal_person, ' | |||
. '`user`.type, ' | |||
. '(SELECT COUNT(*) FROM `order` WHERE `user`.id = `order`.id_user) AS count_orders'); | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query, | |||
'sort' => ['attributes' => ['username', 'credit', 'orders']], | |||
'pagination' => [ | |||
'pageSize' => 20, | |||
], | |||
]); | |||
$dataProvider->sort->attributes['username'] = [ | |||
'asc' => ['user.lastname' => SORT_ASC, 'user.name' => SORT_ASC], | |||
'desc' => ['user.lastname' => SORT_DESC, 'user.name' => SORT_DESC], | |||
]; | |||
$dataProvider->sort->attributes['credit'] = [ | |||
'asc' => ['user_producer.credit' => SORT_ASC], | |||
'desc' => ['user_producer.credit' => SORT_DESC], | |||
]; | |||
$this->load($params); | |||
if (!$this->validate()) { | |||
return $dataProvider; | |||
} | |||
$query->innerJoin('user_producer', 'user.id = user_producer.id_user AND user_producer.id_producer = :id_producer AND user_producer.active = 1', [':id_producer' => GlobalParam::getCurrentProducerId()]); | |||
if (isset($this->id_point_sale) && $this->id_point_sale) { | |||
$pointSale = PointSale::findOne(['id' => $this->id_point_sale]); | |||
$query->innerJoin('user_point_sale', 'user.id = user_point_sale.id_user AND user_point_sale.id_point_sale = :id_point_sale', [':id_point_sale' => $this->id_point_sale]); | |||
} | |||
if (isset($this->subscribers) && $this->subscribers) { | |||
$query->innerJoin( | |||
'subscription', | |||
'user.id = subscription.id_user AND subscription.id_producer = :id_producer', | |||
[':id_producer' => GlobalParam::getCurrentProducerId()] | |||
)->groupBy('user.id'); | |||
} | |||
if (isset($this->inactive) && $this->inactive) { | |||
$query->having([ | |||
'count_orders' => 0 | |||
]); | |||
} | |||
$query->andFilterWhere([ | |||
'or', | |||
['like', 'user.lastname', $this->username], | |||
['like', 'user.name', $this->username], | |||
['like', 'user.name_legal_person', $this->username], | |||
]); | |||
return $dataProvider; | |||
$query->innerJoin('user_producer', 'user.id = user_producer.id_user AND user_producer.id_producer = :id_producer AND user_producer.active = 1', [':id_producer' => GlobalParam::getCurrentProducerId()]); | |||
if (isset($this->id_point_sale) && $this->id_point_sale) { | |||
$pointSale = PointSale::findOne(['id' => $this->id_point_sale]); | |||
$query->innerJoin('user_point_sale', 'user.id = user_point_sale.id_user AND user_point_sale.id_point_sale = :id_point_sale', [':id_point_sale' => $this->id_point_sale]); | |||
} | |||
if (isset($this->subscribers) && $this->subscribers) { | |||
$query->innerJoin( | |||
'subscription', | |||
'user.id = subscription.id_user AND subscription.id_producer = :id_producer', | |||
[':id_producer' => GlobalParam::getCurrentProducerId()] | |||
)->groupBy('user.id'); | |||
} | |||
if (isset($this->inactive) && $this->inactive) { | |||
$query->having([ | |||
'count_orders' => 0 | |||
]); | |||
} | |||
$query->andFilterWhere([ | |||
'or', | |||
['like', 'user.lastname', $this->username], | |||
['like', 'user.name', $this->username], | |||
['like', 'user.name_legal_person', $this->username], | |||
]); | |||
return $dataProvider; | |||
} | |||
} |
@@ -3,9 +3,8 @@ | |||
namespace common\logic\User\UserGroup; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\BuilderInterface; | |||
class UserGroupBuilder extends AbstractBuilder implements BuilderInterface | |||
class UserGroupBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateUserGroup(): UserGroup | |||
{ |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\User\UserGroup; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class UserGroupContainer extends AbstractSingleton implements ContainerInterface | |||
class UserGroupContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -20,13 +19,13 @@ class UserGroupContainer extends AbstractSingleton implements ContainerInterface | |||
]; | |||
} | |||
public function getFactory(): UserGroupBuilder | |||
public function getBuilder(): UserGroupBuilder | |||
{ | |||
return new UserGroupBuilder(); | |||
return UserGroupBuilder::getInstance(); | |||
} | |||
public function getRepository(): UserGroupRepository | |||
{ | |||
return new UserGroupRepository(); | |||
return UserGroupRepository::getInstance(); | |||
} | |||
} |
@@ -10,8 +10,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class UserGroupManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new UserGroupContainer()); | |||
return UserGroupContainer::class; | |||
} | |||
} |
@@ -3,11 +3,17 @@ | |||
namespace common\logic\User\UserGroup; | |||
use common\helpers\GlobalParam; | |||
use common\logic\AbstractService; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\AbstractRepository; | |||
class UserGroupRepository extends AbstractService implements RepositoryInterface | |||
class UserGroupRepository extends AbstractRepository | |||
{ | |||
protected UserGroupRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(UserGroupRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch() | |||
{ | |||
return [ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\User\UserGroup; | |||
use common\logic\AbstractRepositoryQuery; | |||
class UserGroupRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -1,50 +1,49 @@ | |||
<?php | |||
/** | |||
Copyright distrib (2018) | |||
/** | |||
* 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. | |||
*/ | |||
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\User\UserGroup ; | |||
namespace common\logic\User\UserGroup; | |||
use common\helpers\GlobalParam; | |||
use common\logic\User\UserGroup\UserGroup; | |||
use yii\data\ActiveDataProvider; | |||
class UserGroupSearch extends UserGroup | |||
{ | |||
public function rules() | |||
public function rules() | |||
{ | |||
return [ | |||
[['name'], 'string'], | |||
@@ -52,17 +51,17 @@ class UserGroupSearch extends UserGroup | |||
['id_producer', 'integer'], | |||
]; | |||
} | |||
public function search($params) | |||
public function search($params) | |||
{ | |||
$optionsSearch = self::getDefaultOptionsSearch() ; | |||
$userGroupRepository = UserGroupRepository::getInstance(); | |||
$optionsSearch = $userGroupRepository->getDefaultOptionsSearch(); | |||
$query = UserGroup::find() | |||
->with($optionsSearch['with']) | |||
->innerJoinWith($optionsSearch['join_with'], true) | |||
->where(['user_group.id_producer' => GlobalParam::getCurrentProducerId()]) | |||
; | |||
->where(['user_group.id_producer' => GlobalParam::getCurrentProducerId()]); | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query, | |||
'sort' => ['attributes' => ['name']], | |||
@@ -70,15 +69,15 @@ class UserGroupSearch extends UserGroup | |||
'pageSize' => 20, | |||
], | |||
]); | |||
$this->load($params); | |||
if (!$this->validate()) { | |||
return $dataProvider; | |||
} | |||
$query->andFilterWhere(['like', 'user_group.name', $this->name]) ; | |||
$query->andFilterWhere(['like', 'user_group.name', $this->name]); | |||
return $dataProvider; | |||
} | |||
} |
@@ -4,8 +4,6 @@ namespace common\logic\User\UserProducer; | |||
use common\helpers\MeanPayment; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\AbstractService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\Order\Order\OrderRepository; | |||
use common\logic\Producer\Producer\Producer; | |||
@@ -14,14 +12,14 @@ use common\logic\User\CreditHistory\CreditHistory; | |||
use common\logic\User\CreditHistory\CreditHistorySolver; | |||
use common\logic\User\User\User; | |||
class UserProducerBuilder extends AbstractBuilder implements BuilderInterface | |||
class UserProducerBuilder extends AbstractBuilder | |||
{ | |||
protected CreditHistorySolver $creditHistorySolver; | |||
protected UserProducerRepository $userProducerRepository; | |||
protected OrderRepository $orderRepository; | |||
protected ProducerRepository $producerRepository; | |||
public function __construct() | |||
public function loadDependencies(): void | |||
{ | |||
$this->creditHistorySolver = $this->loadService(CreditHistorySolver::class); | |||
$this->userProducerRepository = $this->loadService(UserProducerRepository::class); |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\User\UserProducer; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class UserProducerContainer extends AbstractSingleton implements ContainerInterface | |||
class UserProducerContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -22,11 +21,11 @@ class UserProducerContainer extends AbstractSingleton implements ContainerInterf | |||
public function getRepository(): UserProducerRepository | |||
{ | |||
return new UserProducerRepository(); | |||
return UserProducerRepository::getInstance(); | |||
} | |||
public function getBuilder(): UserProducerBuilder | |||
{ | |||
return new UserProducerBuilder(); | |||
return UserProducerBuilder::getInstance(); | |||
} | |||
} |
@@ -6,7 +6,7 @@ class UserProducerEventSubscriber | |||
{ | |||
public static function onCreateCreditHistory($event) | |||
{ | |||
$userProducerManager = new UserProducerManager(); | |||
$userProducerManager = UserProducerManager::getInstance(); | |||
$userProducerManager->updateCredit($event->creditHistory); | |||
} | |||
} |
@@ -10,8 +10,8 @@ use common\logic\AbstractManager; | |||
*/ | |||
class UserProducerManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new UserProducerContainer()); | |||
return UserProducerContainer::class; | |||
} | |||
} |
@@ -2,13 +2,19 @@ | |||
namespace common\logic\User\UserProducer; | |||
use common\logic\AbstractService; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\User\User\User; | |||
class UserProducerRepository extends AbstractService implements RepositoryInterface | |||
class UserProducerRepository extends AbstractRepository | |||
{ | |||
protected UserProducerRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(UserProducerRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\User\UserProducer; | |||
use common\logic\AbstractRepositoryQuery; | |||
class UserProducerRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |
@@ -3,11 +3,8 @@ | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\AbstractBuilder; | |||
use common\logic\AbstractService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\User\UserUserGroup\UserUserGroup; | |||
class UserUserGroupBuilder extends AbstractBuilder implements BuilderInterface | |||
class UserUserGroupBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateUserUserGroup(): UserUserGroup | |||
{ |
@@ -2,10 +2,9 @@ | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\ContainerInterface; | |||
use common\logic\AbstractSingleton; | |||
use common\logic\AbstractContainer; | |||
class UserUserGroupContainer extends AbstractSingleton implements ContainerInterface | |||
class UserUserGroupContainer extends AbstractContainer | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
@@ -22,11 +21,11 @@ class UserUserGroupContainer extends AbstractSingleton implements ContainerInter | |||
public function getRepository(): UserUserGroupRepository | |||
{ | |||
return new UserUserGroupRepository(); | |||
return UserUserGroupRepository::getInstance(); | |||
} | |||
public function getBuilder(): UserUserGroupBuilder | |||
{ | |||
return new UserUserGroupBuilder(); | |||
return UserUserGroupBuilder::getInstance(); | |||
} | |||
} |
@@ -3,7 +3,6 @@ | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\AbstractManager; | |||
use common\logic\User\UserGroup\UserUserGroupBuilder; | |||
/** | |||
* @mixin UserUserGroupRepository | |||
@@ -11,8 +10,8 @@ use common\logic\User\UserGroup\UserUserGroupBuilder; | |||
*/ | |||
class UserUserGroupManager extends AbstractManager | |||
{ | |||
public function __construct() | |||
public function getContainerFqcn(): string | |||
{ | |||
$this->setContainer(new UserUserGroupContainer()); | |||
return UserUserGroupContainer::class; | |||
} | |||
} |
@@ -2,12 +2,18 @@ | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\AbstractService; | |||
use common\logic\RepositoryInterface; | |||
use common\logic\AbstractRepository; | |||
use common\logic\User\User\User; | |||
class UserUserGroupRepository extends AbstractService implements RepositoryInterface | |||
class UserUserGroupRepository extends AbstractRepository | |||
{ | |||
protected UserUserGroupRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->query = $this->loadService(UserUserGroupRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\AbstractRepositoryQuery; | |||
class UserUserGroupRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
} |