Browse Source

Refactoring services #885

refactoring
Guillaume 1 year ago
parent
commit
148670c093
96 changed files with 555 additions and 394 deletions
  1. +0
    -1
      common/logic/Distribution/PointSaleDistribution/PointSaleDistributionRepository.php
  2. +1
    -1
      common/logic/Distribution/PointSaleDistribution/PointSaleDistributionRepositoryQuery.php
  3. +0
    -1
      common/logic/Distribution/ProductDistribution/ProductDistributionRepository.php
  4. +1
    -1
      common/logic/Distribution/ProductDistribution/ProductDistributionRepositoryQuery.php
  5. +1
    -3
      common/logic/Document/DeliveryNote/DeliveryNoteRepository.php
  6. +1
    -1
      common/logic/Document/DeliveryNote/DeliveryNoteRepositoryQuery.php
  7. +0
    -1
      common/logic/Document/Invoice/InvoiceContainer.php
  8. +0
    -1
      common/logic/Document/Invoice/InvoiceManager.php
  9. +1
    -3
      common/logic/Document/Invoice/InvoiceRepository.php
  10. +1
    -1
      common/logic/Document/Invoice/InvoiceRepositoryQuery.php
  11. +1
    -1
      common/logic/Document/Quotation/QuotationRepository.php
  12. +1
    -1
      common/logic/Document/Quotation/QuotationRepositoryQuery.php
  13. +1
    -2
      common/logic/Order/Order/OrderRepository.php
  14. +1
    -1
      common/logic/Order/Order/OrderRepositoryQuery.php
  15. +1
    -2
      common/logic/Order/OrderStatusHistory/OrderStatusHistoryRepository.php
  16. +1
    -1
      common/logic/Order/OrderStatusHistory/OrderStatusHistoryRepositoryQuery.php
  17. +0
    -1
      common/logic/Order/ProductOrder/ProductOrderRepository.php
  18. +1
    -1
      common/logic/Order/ProductOrder/ProductOrderRepositoryQuery.php
  19. +0
    -4
      common/logic/PointSale/PointSale/PointSaleRepository.php
  20. +1
    -1
      common/logic/PointSale/PointSale/PointSaleRepositoryQuery.php
  21. +3
    -3
      common/logic/Producer/Producer/ProducerBuilder.php
  22. +7
    -8
      common/logic/Producer/Producer/ProducerContainer.php
  23. +2
    -2
      common/logic/Producer/Producer/ProducerManager.php
  24. +5
    -2
      common/logic/Producer/Producer/ProducerRepository.php
  25. +10
    -0
      common/logic/Producer/Producer/ProducerRepositoryQuery.php
  26. +0
    -1
      common/logic/Producer/Producer/ProducerSolver.php
  27. +11
    -6
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeContainer.php
  28. +2
    -2
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeManager.php
  29. +9
    -3
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepository.php
  30. +10
    -0
      common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepositoryQuery.php
  31. +1
    -2
      common/logic/Product/Product/ProductBuilder.php
  32. +5
    -9
      common/logic/Product/Product/ProductContainer.php
  33. +2
    -2
      common/logic/Product/Product/ProductManager.php
  34. +5
    -2
      common/logic/Product/Product/ProductRepository.php
  35. +10
    -0
      common/logic/Product/Product/ProductRepositoryQuery.php
  36. +2
    -2
      common/logic/Product/Product/ProductSearch.php
  37. +1
    -1
      common/logic/Product/Product/ProductSolver.php
  38. +1
    -3
      common/logic/Product/ProductCategory/ProductCategoryBuilder.php
  39. +4
    -5
      common/logic/Product/ProductCategory/ProductCategoryContainer.php
  40. +2
    -2
      common/logic/Product/ProductCategory/ProductCategoryManager.php
  41. +9
    -1
      common/logic/Product/ProductCategory/ProductCategoryRepository.php
  42. +10
    -0
      common/logic/Product/ProductCategory/ProductCategoryRepositoryQuery.php
  43. +3
    -1
      common/logic/Product/ProductCategory/ProductCategorySearch.php
  44. +1
    -2
      common/logic/Product/ProductPointSale/ProductPointSaleBuilder.php
  45. +4
    -6
      common/logic/Product/ProductPointSale/ProductPointSaleContainer.php
  46. +2
    -2
      common/logic/Product/ProductPointSale/ProductPointSaleManager.php
  47. +9
    -3
      common/logic/Product/ProductPointSale/ProductPointSaleRepository.php
  48. +10
    -0
      common/logic/Product/ProductPointSale/ProductPointSaleRepositoryQuery.php
  49. +1
    -2
      common/logic/Product/ProductPrice/ProductPriceBuilder.php
  50. +5
    -6
      common/logic/Product/ProductPrice/ProductPriceContainer.php
  51. +2
    -2
      common/logic/Product/ProductPrice/ProductPriceManager.php
  52. +9
    -3
      common/logic/Product/ProductPrice/ProductPriceRepository.php
  53. +10
    -0
      common/logic/Product/ProductPrice/ProductPriceRepositoryQuery.php
  54. +32
    -35
      common/logic/Product/ProductPrice/ProductPriceSearch.php
  55. +1
    -2
      common/logic/Subscription/ProductSubscription/ProductSubscriptionBuilder.php
  56. +9
    -4
      common/logic/Subscription/ProductSubscription/ProductSubscriptionContainer.php
  57. +2
    -2
      common/logic/Subscription/ProductSubscription/ProductSubscriptionManager.php
  58. +9
    -3
      common/logic/Subscription/ProductSubscription/ProductSubscriptionRepository.php
  59. +10
    -0
      common/logic/Subscription/ProductSubscription/ProductSubscriptionRepositoryQuery.php
  60. +2
    -3
      common/logic/Subscription/Subscription/SubscriptionBuilder.php
  61. +5
    -6
      common/logic/Subscription/Subscription/SubscriptionContainer.php
  62. +1
    -1
      common/logic/Subscription/Subscription/SubscriptionEventSubscriber.php
  63. +2
    -2
      common/logic/Subscription/Subscription/SubscriptionManager.php
  64. +5
    -6
      common/logic/Subscription/Subscription/SubscriptionRepository.php
  65. +10
    -0
      common/logic/Subscription/Subscription/SubscriptionRepositoryQuery.php
  66. +2
    -2
      common/logic/Subscription/Subscription/SubscriptionSearch.php
  67. +1
    -1
      common/logic/Subscription/Subscription/SubscriptionSolver.php
  68. +2
    -2
      common/logic/User/CreditHistory/CreditHistoryBuilder.php
  69. +5
    -6
      common/logic/User/CreditHistory/CreditHistoryContainer.php
  70. +9
    -3
      common/logic/User/CreditHistory/CreditHistoryRepository.php
  71. +10
    -0
      common/logic/User/CreditHistory/CreditHistoryRepositoryQuery.php
  72. +2
    -2
      common/logic/User/CreditHistory/CreditHistorySearch.php
  73. +2
    -1
      common/logic/User/CreditHistory/CreditHistorySolver.php
  74. +2
    -2
      common/logic/User/User/UserBuilder.php
  75. +6
    -7
      common/logic/User/User/UserContainer.php
  76. +2
    -2
      common/logic/User/User/UserManager.php
  77. +5
    -2
      common/logic/User/User/UserRepository.php
  78. +10
    -0
      common/logic/User/User/UserRepositoryQuery.php
  79. +98
    -95
      common/logic/User/User/UserSearch.php
  80. +1
    -2
      common/logic/User/UserGroup/UserGroupBuilder.php
  81. +5
    -6
      common/logic/User/UserGroup/UserGroupContainer.php
  82. +2
    -2
      common/logic/User/UserGroup/UserGroupManager.php
  83. +9
    -3
      common/logic/User/UserGroup/UserGroupRepository.php
  84. +10
    -0
      common/logic/User/UserGroup/UserGroupRepositoryQuery.php
  85. +49
    -50
      common/logic/User/UserGroup/UserGroupSearch.php
  86. +2
    -4
      common/logic/User/UserProducer/UserProducerBuilder.php
  87. +4
    -5
      common/logic/User/UserProducer/UserProducerContainer.php
  88. +1
    -1
      common/logic/User/UserProducer/UserProducerEventSubscriber.php
  89. +2
    -2
      common/logic/User/UserProducer/UserProducerManager.php
  90. +9
    -3
      common/logic/User/UserProducer/UserProducerRepository.php
  91. +10
    -0
      common/logic/User/UserProducer/UserProducerRepositoryQuery.php
  92. +1
    -4
      common/logic/User/UserUserGroup/UserUserGroupBuilder.php
  93. +4
    -5
      common/logic/User/UserUserGroup/UserUserGroupContainer.php
  94. +2
    -3
      common/logic/User/UserUserGroup/UserUserGroupManager.php
  95. +9
    -3
      common/logic/User/UserUserGroup/UserUserGroupRepository.php
  96. +10
    -0
      common/logic/User/UserUserGroup/UserUserGroupRepositoryQuery.php

+ 0
- 1
common/logic/Distribution/PointSaleDistribution/PointSaleDistributionRepository.php View File

@@ -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
- 1
common/logic/Distribution/PointSaleDistribution/PointSaleDistributionRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\PointSaleDistribution;

use common\logic\AbstractRepositoryQuery;


+ 0
- 1
common/logic/Distribution/ProductDistribution/ProductDistributionRepository.php View File

@@ -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
- 1
common/logic/Distribution/ProductDistribution/ProductDistributionRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\ProductDistribution;

use common\logic\AbstractRepositoryQuery;


+ 1
- 3
common/logic/Document/DeliveryNote/DeliveryNoteRepository.php View File

@@ -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
- 1
common/logic/Document/DeliveryNote/DeliveryNoteRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Document\DeliveryNote;

use common\logic\AbstractRepositoryQuery;


+ 0
- 1
common/logic/Document/Invoice/InvoiceContainer.php View File

@@ -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
{

+ 0
- 1
common/logic/Document/Invoice/InvoiceManager.php View File

@@ -3,7 +3,6 @@
namespace common\logic\Document\Invoice;

use common\logic\Document\Document\DocumentManager;
use common\logic\PointSale\PointSale\InvoiceRepository;

/**
* @mixin InvoiceRepository

+ 1
- 3
common/logic/Document/Invoice/InvoiceRepository.php View File

@@ -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
- 1
common/logic/Document/Invoice/InvoiceRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Document\Invoice;

use common\logic\AbstractRepositoryQuery;


+ 1
- 1
common/logic/Document/Quotation/QuotationRepository.php View File

@@ -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
- 1
common/logic/Document/Quotation/QuotationRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Document\Quotation;

use common\logic\AbstractRepositoryQuery;


+ 1
- 2
common/logic/Order/Order/OrderRepository.php View File

@@ -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
- 1
common/logic/Order/Order/OrderRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Order\Order;

use common\logic\AbstractRepositoryQuery;


+ 1
- 2
common/logic/Order/OrderStatusHistory/OrderStatusHistoryRepository.php View File

@@ -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
- 1
common/logic/Order/OrderStatusHistory/OrderStatusHistoryRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Order\OrderStatusHistory;

use common\logic\AbstractRepositoryQuery;


+ 0
- 1
common/logic/Order/ProductOrder/ProductOrderRepository.php View File

@@ -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
- 1
common/logic/Order/ProductOrder/ProductOrderRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\Order\ProductOrder;

use common\logic\AbstractRepositoryQuery;


+ 0
- 4
common/logic/PointSale/PointSale/PointSaleRepository.php View File

@@ -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
- 1
common/logic/PointSale/PointSale/PointSaleRepositoryQuery.php View File

@@ -1,6 +1,6 @@
<?php

namespace common\logic\Distribution\Distribution;
namespace common\logic\PointSale\PointSale;

use common\logic\AbstractRepositoryQuery;


+ 3
- 3
common/logic/Producer/Producer/ProducerBuilder.php View File

@@ -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

+ 7
- 8
common/logic/Producer/Producer/ProducerContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/Producer/Producer/ProducerManager.php View File

@@ -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
- 2
common/logic/Producer/Producer/ProducerRepository.php View File

@@ -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);

+ 10
- 0
common/logic/Producer/Producer/ProducerRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Producer\Producer;

use common\logic\AbstractRepositoryQuery;

class ProducerRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 0
- 1
common/logic/Producer/Producer/ProducerSolver.php View File

@@ -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.
*/

+ 11
- 6
common/logic/Producer/ProducerPriceRange/ProducerPriceRangeContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/Producer/ProducerPriceRange/ProducerPriceRangeManager.php View File

@@ -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;
}
}

+ 9
- 3
common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepository.php View File

@@ -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.
*

+ 10
- 0
common/logic/Producer/ProducerPriceRange/ProducerPriceRangeRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Producer\ProducerPriceRange;

use common\logic\AbstractRepositoryQuery;

class ProducerPriceRangeRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 1
- 2
common/logic/Product/Product/ProductBuilder.php View File

@@ -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
{

+ 5
- 9
common/logic/Product/Product/ProductContainer.php View File

@@ -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();
}



}

+ 2
- 2
common/logic/Product/Product/ProductManager.php View File

@@ -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;
}
}

+ 5
- 2
common/logic/Product/Product/ProductRepository.php View File

@@ -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);

+ 10
- 0
common/logic/Product/Product/ProductRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Product\Product;

use common\logic\AbstractRepositoryQuery;

class ProductRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 2
- 2
common/logic/Product/Product/ProductSearch.php View File

@@ -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'])

+ 1
- 1
common/logic/Product/Product/ProductSolver.php View File

@@ -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);
}

+ 1
- 3
common/logic/Product/ProductCategory/ProductCategoryBuilder.php View File

@@ -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
{

+ 4
- 5
common/logic/Product/ProductCategory/ProductCategoryContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/Product/ProductCategory/ProductCategoryManager.php View File

@@ -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;
}
}

+ 9
- 1
common/logic/Product/ProductCategory/ProductCategoryRepository.php View File

@@ -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 [

+ 10
- 0
common/logic/Product/ProductCategory/ProductCategoryRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Product\ProductCategory;

use common\logic\AbstractRepositoryQuery;

class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 3
- 1
common/logic/Product/ProductCategory/ProductCategorySearch.php View File

@@ -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'])

+ 1
- 2
common/logic/Product/ProductPointSale/ProductPointSaleBuilder.php View File

@@ -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
{

+ 4
- 6
common/logic/Product/ProductPointSale/ProductPointSaleContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/Product/ProductPointSale/ProductPointSaleManager.php View File

@@ -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;
}
}

+ 9
- 3
common/logic/Product/ProductPointSale/ProductPointSaleRepository.php View File

@@ -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 [

+ 10
- 0
common/logic/Product/ProductPointSale/ProductPointSaleRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Product\ProductPointSale;

use common\logic\AbstractRepositoryQuery;

class ProductPointSaleRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 1
- 2
common/logic/Product/ProductPrice/ProductPriceBuilder.php View File

@@ -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
{

+ 5
- 6
common/logic/Product/ProductPrice/ProductPriceContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/Product/ProductPrice/ProductPriceManager.php View File

@@ -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;
}
}

+ 9
- 3
common/logic/Product/ProductPrice/ProductPriceRepository.php View File

@@ -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.
*/

+ 10
- 0
common/logic/Product/ProductPrice/ProductPriceRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Product\ProductPrice;

use common\logic\AbstractRepositoryQuery;

class ProductPriceRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 32
- 35
common/logic/Product/ProductPrice/ProductPriceSearch.php View File

@@ -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;
}

}

+ 1
- 2
common/logic/Subscription/ProductSubscription/ProductSubscriptionBuilder.php View File

@@ -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
{

+ 9
- 4
common/logic/Subscription/ProductSubscription/ProductSubscriptionContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/Subscription/ProductSubscription/ProductSubscriptionManager.php View File

@@ -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;
}
}

+ 9
- 3
common/logic/Subscription/ProductSubscription/ProductSubscriptionRepository.php View File

@@ -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.
*/

+ 10
- 0
common/logic/Subscription/ProductSubscription/ProductSubscriptionRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Subscription\ProductSubscription;

use common\logic\AbstractRepositoryQuery;

class ProductSubscriptionRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 2
- 3
common/logic/Subscription/Subscription/SubscriptionBuilder.php View File

@@ -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);
}

+ 5
- 6
common/logic/Subscription/Subscription/SubscriptionContainer.php View File

@@ -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();
}
}

+ 1
- 1
common/logic/Subscription/Subscription/SubscriptionEventSubscriber.php View File

@@ -13,7 +13,7 @@ class SubscriptionEventSubscriber
*/
public static function onActiveDistribution(Distribution $distribution): void
{
$orderManager = new OrderManager();
$orderManager = OrderManager::getInstance();
$orderManager->createAllOrdersFromSubscriptions($distribution->date);
}
}

+ 2
- 2
common/logic/Subscription/Subscription/SubscriptionManager.php View File

@@ -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;
}
}

+ 5
- 6
common/logic/Subscription/Subscription/SubscriptionRepository.php View File

@@ -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);
}


+ 10
- 0
common/logic/Subscription/Subscription/SubscriptionRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\Subscription\Subscription;

use common\logic\AbstractRepositoryQuery;

class SubscriptionRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 2
- 2
common/logic/Subscription/Subscription/SubscriptionSearch.php View File

@@ -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'])

+ 1
- 1
common/logic/Subscription/Subscription/SubscriptionSolver.php View File

@@ -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);
}

+ 2
- 2
common/logic/User/CreditHistory/CreditHistoryBuilder.php View File

@@ -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);
}

+ 5
- 6
common/logic/User/CreditHistory/CreditHistoryContainer.php View File

@@ -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();
}
}

+ 9
- 3
common/logic/User/CreditHistory/CreditHistoryRepository.php View File

@@ -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 [

+ 10
- 0
common/logic/User/CreditHistory/CreditHistoryRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\User\CreditHistory;

use common\logic\AbstractRepositoryQuery;

class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 2
- 2
common/logic/User/CreditHistory/CreditHistorySearch.php View File

@@ -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'])

+ 2
- 1
common/logic/User/CreditHistory/CreditHistorySolver.php View File

@@ -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
{

+ 2
- 2
common/logic/User/User/UserBuilder.php View File

@@ -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);
}

+ 6
- 7
common/logic/User/User/UserContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/User/User/UserManager.php View File

@@ -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;
}
}

+ 5
- 2
common/logic/User/User/UserRepository.php View File

@@ -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);
}

+ 10
- 0
common/logic/User/User/UserRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\User\User;

use common\logic\AbstractRepositoryQuery;

class UserRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 98
- 95
common/logic/User/User/UserSearch.php View File

@@ -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;
}

}

+ 1
- 2
common/logic/User/UserGroup/UserGroupBuilder.php View File

@@ -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
{

+ 5
- 6
common/logic/User/UserGroup/UserGroupContainer.php View File

@@ -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();
}
}

+ 2
- 2
common/logic/User/UserGroup/UserGroupManager.php View File

@@ -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;
}
}

+ 9
- 3
common/logic/User/UserGroup/UserGroupRepository.php View File

@@ -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 [

+ 10
- 0
common/logic/User/UserGroup/UserGroupRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\User\UserGroup;

use common\logic\AbstractRepositoryQuery;

class UserGroupRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 49
- 50
common/logic/User/UserGroup/UserGroupSearch.php View File

@@ -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;
}
}

+ 2
- 4
common/logic/User/UserProducer/UserProducerBuilder.php View File

@@ -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);

+ 4
- 5
common/logic/User/UserProducer/UserProducerContainer.php View File

@@ -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();
}
}

+ 1
- 1
common/logic/User/UserProducer/UserProducerEventSubscriber.php View File

@@ -6,7 +6,7 @@ class UserProducerEventSubscriber
{
public static function onCreateCreditHistory($event)
{
$userProducerManager = new UserProducerManager();
$userProducerManager = UserProducerManager::getInstance();
$userProducerManager->updateCredit($event->creditHistory);
}
}

+ 2
- 2
common/logic/User/UserProducer/UserProducerManager.php View File

@@ -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;
}
}

+ 9
- 3
common/logic/User/UserProducer/UserProducerRepository.php View File

@@ -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 [

+ 10
- 0
common/logic/User/UserProducer/UserProducerRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\User\UserProducer;

use common\logic\AbstractRepositoryQuery;

class UserProducerRepositoryQuery extends AbstractRepositoryQuery
{

}

+ 1
- 4
common/logic/User/UserUserGroup/UserUserGroupBuilder.php View File

@@ -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
{

+ 4
- 5
common/logic/User/UserUserGroup/UserUserGroupContainer.php View File

@@ -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();
}
}

+ 2
- 3
common/logic/User/UserUserGroup/UserUserGroupManager.php View File

@@ -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;
}
}

+ 9
- 3
common/logic/User/UserUserGroup/UserUserGroupRepository.php View File

@@ -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 [

+ 10
- 0
common/logic/User/UserUserGroup/UserUserGroupRepositoryQuery.php View File

@@ -0,0 +1,10 @@
<?php

namespace common\logic\User\UserUserGroup;

use common\logic\AbstractRepositoryQuery;

class UserUserGroupRepositoryQuery extends AbstractRepositoryQuery
{

}

Loading…
Cancel
Save