@@ -1,53 +1,56 @@ | |||
<?php | |||
/** | |||
Copyright distrib (2018) | |||
contact@opendistrib.net | |||
Ce logiciel est un programme informatique servant à aider les producteurs | |||
à distribuer leur production en circuits courts. | |||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
sur le site "http://www.cecill.info". | |||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||
de modification et de redistribution accordés par cette licence, il n'est | |||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
titulaire des droits patrimoniaux et les concédants successifs. | |||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
associés au chargement, à l'utilisation, à la modification et/ou au | |||
développement et à la reproduction du logiciel par l'utilisateur étant | |||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||
avertis possédant des connaissances informatiques approfondies. Les | |||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
/** | |||
* Copyright distrib (2018) | |||
* | |||
* contact@opendistrib.net | |||
* | |||
* Ce logiciel est un programme informatique servant à aider les producteurs | |||
* à distribuer leur production en circuits courts. | |||
* | |||
* Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
* respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
* utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
* sur le site "http://www.cecill.info". | |||
* | |||
* En contrepartie de l'accessibilité au code source et des droits de copie, | |||
* de modification et de redistribution accordés par cette licence, il n'est | |||
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
* seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
* titulaire des droits patrimoniaux et les concédants successifs. | |||
* | |||
* A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
* associés au chargement, à l'utilisation, à la modification et/ou au | |||
* développement et à la reproduction du logiciel par l'utilisateur étant | |||
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
* manipuler et qui le réserve donc à des développeurs et des professionnels | |||
* avertis possédant des connaissances informatiques approfondies. Les | |||
* utilisateurs sont donc invités à charger et tester l'adéquation du | |||
* logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
* sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
* | |||
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
* pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
* termes. | |||
*/ | |||
namespace backend\controllers; | |||
use common\helpers\GlobalParam; | |||
use backend\models\AccessUserProducerForm ; | |||
use backend\models\AccessUserProducerForm; | |||
use common\logic\Document\DeliveryNote\DeliveryNoteManager; | |||
use common\logic\Producer\Producer\ProducerManager; | |||
/** | |||
* UserController implements the CRUD actions for User model. | |||
*/ | |||
class AccessController extends BackendController | |||
class AccessController extends BackendController | |||
{ | |||
public function behaviors() { | |||
public function behaviors() | |||
{ | |||
return [ | |||
'verbs' => [ | |||
'class' => VerbFilter::className(), | |||
@@ -72,27 +75,27 @@ class AccessController extends BackendController | |||
/** | |||
* Affiche les utilisateurs ayant accès à l'administration de ce producteur. | |||
* Gestion du formulaire permettant d'en ajouter de nouveaux. | |||
* | |||
* | |||
* @return string | |||
*/ | |||
public function actionIndex() | |||
public function actionIndex() | |||
{ | |||
$userSearch = new UserSearch ; | |||
$usersArray = $userSearch->search()->query->all() ; | |||
$modelAccessUserProducerForm = new AccessUserProducerForm ; | |||
if($modelAccessUserProducerForm->load(Yii::$app->request->post()) && $modelAccessUserProducerForm->save()) { | |||
$userSearch = new UserSearch; | |||
$usersArray = $userSearch->search()->query->all(); | |||
$modelAccessUserProducerForm = new AccessUserProducerForm; | |||
if ($modelAccessUserProducerForm->load(Yii::$app->request->post()) && $modelAccessUserProducerForm->save()) { | |||
Yii::$app->getSession()->setFlash('success', 'Droits ajoutés à l\'utilisateur'); | |||
} | |||
$usersAccessArray = User::find() | |||
$usersAccessArray = User::find() | |||
->where([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
'status' => User::STATUS_PRODUCER | |||
'status' => User::STATUS_PRODUCER | |||
]) | |||
->all() ; | |||
$producer = Producer::searchOne() ; | |||
->all(); | |||
$producer = Producer::searchOne(); | |||
return $this->render('index', [ | |||
'usersArray' => $usersArray, | |||
@@ -102,20 +105,20 @@ class AccessController extends BackendController | |||
]); | |||
} | |||
public function actionDelete($idUser) | |||
public function actionDelete($idUser) | |||
{ | |||
$user = User::searchOne([ | |||
$user = User::searchOne([ | |||
'id' => $idUser | |||
]) ; | |||
if($user) { | |||
$user->id_producer = 0 ; | |||
$user->status = User::STATUS_ACTIVE ; | |||
$user->save() ; | |||
]); | |||
if ($user) { | |||
$user->id_producer = 0; | |||
$user->status = User::STATUS_ACTIVE; | |||
$user->save(); | |||
Yii::$app->getSession()->setFlash('success', 'Droits de l\'utilisateur supprimé.'); | |||
} | |||
return $this->redirect(['index']) ; | |||
return $this->redirect(['index']); | |||
} | |||
} |
@@ -7,27 +7,49 @@ use common\logic\Config\TaxRate\TaxRateManager; | |||
use common\logic\Distribution\Distribution\DistributionContainer; | |||
use common\logic\Distribution\Distribution\DistributionManager; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionContainer; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionManager; | |||
use common\logic\Distribution\ProductDistribution\ProductDistributionContainer; | |||
use common\logic\Distribution\ProductDistribution\ProductDistributionManager; | |||
use common\logic\Document\DeliveryNote\DeliveryNoteManager; | |||
use common\logic\Document\Document\DocumentContainer; | |||
use common\logic\Document\Document\DocumentManager; | |||
use common\logic\Document\Invoice\InvoiceManager; | |||
use common\logic\Document\Invoice\QuotationManager; | |||
use common\logic\Order\Order\OrderContainer; | |||
use common\logic\Order\Order\OrderManager; | |||
use common\logic\Order\OrderStatusHistory\OrderStatusHistoryContainer; | |||
use common\logic\Order\OrderStatusHistory\OrderStatusHistoryManager; | |||
use common\logic\Order\ProductOrder\ProductOrderContainer; | |||
use common\logic\Order\ProductOrder\ProductOrderManager; | |||
use common\logic\PointSale\PointSale\PointSaleContainer; | |||
use common\logic\PointSale\PointSale\PointSaleManager; | |||
use common\logic\PointSale\UserPointSale\UserPointSaleContainer; | |||
use common\logic\PointSale\UserPointSale\UserPointSaleManager; | |||
use common\logic\Producer\Producer\ProducerContainer; | |||
use common\logic\Producer\Producer\ProducerManager; | |||
use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeContainer; | |||
use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeManager; | |||
use common\logic\Product\Product\ProductContainer; | |||
use common\logic\Product\Product\ProductManager; | |||
use common\logic\Product\ProductCategory\ProductCategoryContainer; | |||
use common\logic\Product\ProductCategory\ProductCategoryManager; | |||
use common\logic\Product\ProductPointSale\ProductPointSaleContainer; | |||
use common\logic\Product\ProductPointSale\ProductPointSaleManager; | |||
use common\logic\Product\ProductPrice\ProductPriceContainer; | |||
use common\logic\Product\ProductPrice\ProductPriceManager; | |||
use common\logic\Subscription\ProductSubscription\ProductSubscriptionContainer; | |||
use common\logic\Subscription\ProductSubscription\ProductSubscriptionManager; | |||
use common\logic\Subscription\Subscription\SubscriptionContainer; | |||
use common\logic\Subscription\Subscription\SubscriptionManager; | |||
use common\logic\User\CreditHistory\CreditHistoryContainer; | |||
use common\logic\User\CreditHistory\CreditHistoryManager; | |||
use common\logic\User\User\UserContainer; | |||
use common\logic\User\User\UserManager; | |||
use common\logic\User\UserGroup\UserGroupContainer; | |||
use common\logic\User\UserGroup\UserGroupManager; | |||
use common\logic\User\UserProducer\UserProducerContainer; | |||
use common\logic\User\UserUserGroup\UserUserGroupContainer; | |||
use common\logic\User\UserUserGroup\UserUserGroupManager; | |||
trait BusinessLogicContainerTrait | |||
{ | |||
@@ -46,6 +68,116 @@ trait BusinessLogicContainerTrait | |||
return new DistributionManager(); | |||
} | |||
public function getPointSaleDistributionManager(): PointSaleDistributionManager | |||
{ | |||
return new PointSaleDistributionManager(); | |||
} | |||
public function getProductDistributionManager(): ProductDistributionManager | |||
{ | |||
return new ProductDistributionManager(); | |||
} | |||
public function getDeliveryNoteManager(): DeliveryNoteManager | |||
{ | |||
return new DeliveryNoteManager(); | |||
} | |||
public function getDocumentManager(): DocumentManager | |||
{ | |||
return new DocumentManager(); | |||
} | |||
public function getInvoiceManager(): InvoiceManager | |||
{ | |||
return new InvoiceManager(); | |||
} | |||
public function getQuotationManager(): QuotationManager | |||
{ | |||
return new QuotationManager(); | |||
} | |||
public function getOrderStatusHistoryManager(): OrderStatusHistoryManager | |||
{ | |||
return new OrderStatusHistoryManager(); | |||
} | |||
public function getProductOrderManager(): ProductOrderManager | |||
{ | |||
return new ProductOrderManager(); | |||
} | |||
public function getPointSaleManager(): PointSaleManager | |||
{ | |||
return new PointSaleManager(); | |||
} | |||
public function getUserPointSaleManager(): UserPointSaleManager | |||
{ | |||
return new UserPointSaleManager(); | |||
} | |||
public function getProducerManager(): ProducerManager | |||
{ | |||
return new ProducerManager(); | |||
} | |||
public function getProducerPriceRangeManager(): ProducerPriceRangeManager | |||
{ | |||
return new ProducerPriceRangeManager(); | |||
} | |||
public function getProductManager(): ProductManager | |||
{ | |||
return new ProductManager(); | |||
} | |||
public function getProductCategoryManager(): ProductCategoryManager | |||
{ | |||
return new ProductCategoryManager(); | |||
} | |||
public function getProductPointSaleManager(): ProductPointSaleManager | |||
{ | |||
return new ProductPointSaleManager(); | |||
} | |||
public function getProductPriceManager(): ProductPriceManager | |||
{ | |||
return new ProductPriceManager(); | |||
} | |||
public function getProductSubscriptionManager(): ProductSubscriptionManager | |||
{ | |||
return new ProductSubscriptionManager(); | |||
} | |||
public function getSubscriptionManager(): SubscriptionManager | |||
{ | |||
return new SubscriptionManager(); | |||
} | |||
public function getCreditHistoryManager(): CreditHistoryManager | |||
{ | |||
return new CreditHistoryManager(); | |||
} | |||
public function getUserManager(): UserManager | |||
{ | |||
return new UserManager(); | |||
} | |||
public function getUserGroupManager(): UserGroupManager | |||
{ | |||
return new UserGroupManager(); | |||
} | |||
public function getUserUserGroupManager(): UserUserGroupManager | |||
{ | |||
return new UserUserGroupManager(); | |||
} | |||
public function getUserContainer(): UserContainer | |||
{ | |||
return new UserContainer(); |
@@ -6,7 +6,7 @@ use yii\base\ErrorException; | |||
class BaseService | |||
{ | |||
public function getHierarchy(): array | |||
protected function getHierarchy(): array | |||
{ | |||
return [ | |||
SolverInterface::class, | |||
@@ -17,7 +17,7 @@ class BaseService | |||
]; | |||
} | |||
public function loadService(string $serviceClass) | |||
protected function loadService(string $serviceClass) | |||
{ | |||
if(!$this->respectHierarchy($serviceClass)) { | |||
throw new ErrorException('Le service '.$serviceClass.' ne peut pas être chargé ici.'); | |||
@@ -26,7 +26,7 @@ class BaseService | |||
return new $serviceClass; | |||
} | |||
public function respectHierarchy(string $serviceClassAsked): bool | |||
protected function respectHierarchy(string $serviceClassAsked): bool | |||
{ | |||
$domain = \Yii::$app->logic; | |||
$serviceCurrentClass = get_class($this); | |||
@@ -46,7 +46,7 @@ class BaseService | |||
return false; | |||
} | |||
public function getServiceLevelHierarchy(string $serviceClass): int | |||
protected function getServiceLevelHierarchy(string $serviceClass): int | |||
{ | |||
$hierarchyArray = $this->getHierarchy(); | |||
@@ -60,22 +60,22 @@ class BaseService | |||
FactoryInterface, SolverInterface ou BuilderInterface au service.'); | |||
} | |||
public function isSolver(): bool | |||
protected function isSolver(): bool | |||
{ | |||
return $this->classImplementsInterface(SolverInterface::class); | |||
} | |||
public function isBuilder(): bool | |||
protected function isBuilder(): bool | |||
{ | |||
return $this->classImplementsInterface(BuilderInterface::class); | |||
} | |||
public function isResolver(): bool | |||
protected function isResolver(): bool | |||
{ | |||
return $this->classImplementsInterface(ResolverInterface::class); | |||
} | |||
public function isUtils(): bool | |||
protected function isUtils(): bool | |||
{ | |||
return $this->classImplementsInterface(UtilsInterface::class); | |||
} |
@@ -5,12 +5,8 @@ namespace common\logic\Config\TaxRate; | |||
use common\logic\BaseManager; | |||
/** | |||
* @see TaxRateRepository | |||
* @method array getAsArray() | |||
* | |||
* @see TaxRateBuilder | |||
* @method TaxRate instanciateTaxRate() | |||
* @method TaxRate createTaxRate() | |||
* @mixin TaxRateRepository | |||
* @mixin TaxRateBuilder | |||
*/ | |||
class TaxRateManager extends BaseManager | |||
{ |
@@ -44,16 +44,8 @@ use common\components\ActiveRecordCommon ; | |||
/** | |||
* This is the model class for table "development". | |||
* | |||
* @property integer $id | |||
* @property string $subject | |||
* @property string $description | |||
* @property string $date | |||
* @property integer $progress | |||
* @property string $status | |||
* @property double $time_estimate | |||
*/ | |||
class DevelopmentModel extends ActiveRecordCommon | |||
class Development extends ActiveRecordCommon | |||
{ | |||
const STATUS_OPEN = 'open'; | |||
const STATUS_CLOSED = 'closed'; |
@@ -43,9 +43,8 @@ use common\components\ActiveRecordCommon ; | |||
/** | |||
* This is the model class for table "development_priority". | |||
* | |||
*/ | |||
class DevelopmentPriorityModel extends ActiveRecordCommon | |||
class DevelopmentPriority extends ActiveRecordCommon | |||
{ | |||
const PRIORITY_HIGH = 'high'; | |||
@@ -88,7 +87,7 @@ class DevelopmentPriorityModel extends ActiveRecordCommon | |||
{ | |||
return [ | |||
'id_producer' => 'Producteur', | |||
'id_producer' => 'Développement', | |||
'id_development' => 'Développement', | |||
'priority' => 'Priorité' | |||
]; | |||
} |
@@ -3,40 +3,11 @@ | |||
namespace common\logic\Distribution\Distribution; | |||
use common\logic\BaseManager; | |||
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution; | |||
use common\logic\Distribution\ProductDistribution\ProductDistribution; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\Product\Product\Product; | |||
/** | |||
* @see DistributionSolver | |||
* @method string getDayAsString(Distribution $distribution) | |||
* @method bool isActiveProduct(Distribution $distribution, Product $product) | |||
* @method bool isAvailable(Distribution $distribution) | |||
* @method array filterDistributionsByDateDelay(array $distributionsArray) | |||
* @method bool isPointSaleActive(Distribution $distribution, PointSale $pointSale) | |||
* | |||
* @see DistributionRepository | |||
* @method array defaultOptionsSearch() | |||
* @method Distribution|null getOneById(int $id) | |||
* @method Distribution|null getOne(Producer $producer, string $date) | |||
* @method Distribution|null getOneByDate(string $date) | |||
* @method array getIncoming() | |||
* @method bool isDateAvailable(Producer $producer, string $date = null) | |||
* | |||
* @see DistributionBuilder | |||
* @method Distribution instanciateDistribution(Producer $producer, string $date, bool $delivery = true) | |||
* @method Distribution createDistribution(Producer $producer, string $date, bool $delivery = true) | |||
* @method Distribution createDistributionIfNotExist(Producer $producer, string $date, int $delivery = 1) | |||
* @method void initPointSaleDistribution(Distribution $distribution) | |||
* @method void initProductDistribution(Distribution $distribution) | |||
* @method ProductDistribution linkProduct(Distribution $distribution, Product $product) | |||
* @method void linkProductIncomingDistributions(Product $product) | |||
* @method PointSaleDistribution linkPointSale(Distribution $distribution, PointSale $pointSale) | |||
* @method void linkPointSaleIncomingDistributions(PointSale $pointSale) | |||
* @method void updateOrderProductPrices(Distribution $distribution, Product $product) | |||
* @method void active(Distribution $distribution, bool $active = true) | |||
* @mixin DistributionSolver | |||
* @mixin DistributionRepository | |||
* @mixin DistributionBuilder | |||
*/ | |||
class DistributionManager extends BaseManager | |||
{ |
@@ -26,7 +26,7 @@ class PointSaleDistributionBuilder extends BaseService implements BuilderInterfa | |||
/** | |||
* Instancie un PointSaleDistribution. | |||
*/ | |||
public function instanciate(Distribution $distribution, PointSale $pointSale): PointSaleDistribution | |||
public function instanciatePointSaleDistribution(Distribution $distribution, PointSale $pointSale): PointSaleDistribution | |||
{ | |||
$pointSaleDistribution = new PointSaleDistribution(); | |||
@@ -39,20 +39,20 @@ class PointSaleDistributionBuilder extends BaseService implements BuilderInterfa | |||
/** | |||
* Crée un PointSaleDistribution. | |||
*/ | |||
public function create(Distribution $distribution, PointSale $pointSale): PointSaleDistribution | |||
public function createPointSaleDistribution(Distribution $distribution, PointSale $pointSale): PointSaleDistribution | |||
{ | |||
$pointSaleDistribution = $this->instanciate($distribution, $pointSale); | |||
$pointSaleDistribution = $this->instanciatePointSaleDistribution($distribution, $pointSale); | |||
$pointSaleDistribution->save(); | |||
return $pointSaleDistribution; | |||
} | |||
public function createIfNotExist(Distribution $distribution, PointSale $pointSale): PointSaleDistribution | |||
public function createPointSaleDistributionIfNotExist(Distribution $distribution, PointSale $pointSale): PointSaleDistribution | |||
{ | |||
$pointSaleDistribution = $this->pointSaleDistributionRepository->getOne($distribution, $pointSale); | |||
if (!$pointSaleDistribution) { | |||
$pointSaleDistribution = $this->create($distribution, $pointSale); | |||
$pointSaleDistribution = $this->createPointSaleDistribution($distribution, $pointSale); | |||
} | |||
return $pointSaleDistribution; | |||
@@ -62,7 +62,7 @@ class PointSaleDistributionBuilder extends BaseService implements BuilderInterfa | |||
* Crée les PointSaleDistribution pour une distribution donnée. | |||
*/ | |||
// setAll | |||
public function createAll(Distribution $distribution, bool $delivery): void | |||
public function createAllPointSaleDistribution(Distribution $distribution, bool $delivery): void | |||
{ | |||
$pointSaleArray = $this->pointSaleRepository->getByDistribution($distribution); | |||
foreach ($pointSaleArray as $pointSale) { | |||
@@ -77,7 +77,7 @@ class PointSaleDistributionBuilder extends BaseService implements BuilderInterfa | |||
} | |||
} | |||
public function initDelivery(PointSaleDistribution $pointSaleDistribution, bool $delivery) | |||
public function initDelivery(PointSaleDistribution $pointSaleDistribution, bool $delivery): void | |||
{ | |||
$day = date('N', strtotime($pointSaleDistribution->distribution->date)); | |||
$pointSale = $pointSaleDistribution->pointSale; |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\Distribution\PointSaleDistribution; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin PointSaleDistributionRepository | |||
* @mixin PointSaleDistributionBuilder | |||
*/ | |||
class PointSaleDistributionManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new PointSaleDistributionContainer()); | |||
} | |||
} |
@@ -9,7 +9,8 @@ use common\logic\RepositoryInterface; | |||
class PointSaleDistributionRepository extends BaseService implements RepositoryInterface | |||
{ | |||
public function defaultOptionsSearch() { | |||
public function defaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['distribution', 'pointSale'], | |||
'join_with' => [], |
@@ -19,7 +19,7 @@ class ProductDistributionBuilder extends BaseService implements BuilderInterface | |||
$this->distributionSolver = $this->loadService(DistributionSolver::class); | |||
} | |||
public function instanciate(Distribution $distribution, Product $product): ProductDistribution | |||
public function instanciateProductDistribution(Distribution $distribution, Product $product): ProductDistribution | |||
{ | |||
$productDistribution = new ProductDistribution(); | |||
@@ -32,9 +32,9 @@ class ProductDistributionBuilder extends BaseService implements BuilderInterface | |||
return $productDistribution; | |||
} | |||
public function create(Distribution $distribution, Product $product): ProductDistribution | |||
public function createProductDistribution(Distribution $distribution, Product $product): ProductDistribution | |||
{ | |||
$productDistribution = $this->instanciate($distribution, $product); | |||
$productDistribution = $this->instanciateProductDistribution($distribution, $product); | |||
$this | |||
->initActive($productDistribution) | |||
@@ -45,12 +45,12 @@ class ProductDistributionBuilder extends BaseService implements BuilderInterface | |||
return $productDistribution; | |||
} | |||
public function createIfNotExist(Distribution $distribution, Product $product): ProductDistribution | |||
public function createProductDistributionIfNotExist(Distribution $distribution, Product $product): ProductDistribution | |||
{ | |||
$productDistribution = $this->productDistributionRepository->getOne($distribution, $product); | |||
if(!$productDistribution) { | |||
$productDistribution = $this->create($distribution, $product); | |||
$productDistribution = $this->createProductDistribution($distribution, $product); | |||
} | |||
return $productDistribution; |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\Distribution\ProductDistribution; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProductDistributionRepository | |||
* @mixin ProductDistributionBuilder | |||
*/ | |||
class ProductDistributionManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProductDistributionContainer()); | |||
} | |||
} |
@@ -10,7 +10,8 @@ use common\logic\RepositoryInterface; | |||
class ProductDistributionRepository extends BaseService implements RepositoryInterface | |||
{ | |||
public function defaultOptionsSearch() { | |||
public function defaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => ['product','distribution'], | |||
'join_with' => [], |
@@ -4,10 +4,11 @@ namespace common\logic\Document\DeliveryNote; | |||
use common\logic\BaseService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\Document\Document\DocumentBuilder; | |||
class DeliveryNoteBuilder extends BaseService implements BuilderInterface | |||
class DeliveryNoteBuilder extends DocumentBuilder implements BuilderInterface | |||
{ | |||
public function instanciate(): DeliveryNote | |||
public function instanciateDeliveryNote(): DeliveryNote | |||
{ | |||
$deliveryNote = new DeliveryNote(); | |||
@@ -0,0 +1,19 @@ | |||
<?php | |||
namespace common\logic\Document\DeliveryNote; | |||
use common\logic\Document\Document\DocumentManager; | |||
use common\logic\PointSale\PointSale\DeliveryNoteRepository; | |||
/** | |||
* @mixin DeliveryNoteSolver | |||
* @mixin DeliveryNoteRepository | |||
* @mixin DeliveryNoteBuilder | |||
*/ | |||
class DeliveryNoteManager extends DocumentManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new DeliveryNoteContainer()); | |||
} | |||
} |
@@ -3,10 +3,11 @@ | |||
namespace common\logic\Document\DeliveryNote; | |||
use common\logic\BaseService; | |||
use common\logic\Document\Document\DocumentSolver; | |||
use common\logic\Document\Invoice\Invoice; | |||
use common\logic\SolverInterface; | |||
class DeliveryNoteSolver extends BaseService implements SolverInterface | |||
class DeliveryNoteSolver extends DocumentSolver implements SolverInterface | |||
{ | |||
public function getInvoiceId(DeliveryNote $deliveryNote): ?int | |||
{ |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\Document\Document; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin DocumentSolver | |||
* @mixin DocumentBuilder | |||
* @mixin DocumentUtils | |||
*/ | |||
class DocumentManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new DocumentContainer()); | |||
} | |||
} |
@@ -4,27 +4,28 @@ namespace common\logic\Document\Document; | |||
use common\logic\BaseService; | |||
use common\logic\Order\Order\Order; | |||
use common\logic\PointSale\PointSale\PointSale; | |||
use common\logic\Producer\Producer\Producer; | |||
use common\logic\SolverInterface; | |||
class DocumentSolver extends BaseService implements SolverInterface | |||
{ | |||
public function getAmount(DocumentInterface $document, $type = Order::AMOUNT_TOTAL, $format = false) | |||
public function getAmount(DocumentInterface $document, string $type = Order::AMOUNT_TOTAL, bool $format = false) | |||
{ | |||
return $this->_getAmountGeneric($document, $type, false, $format); | |||
} | |||
public function getAmountWithTax(DocumentInterface $document, $type = Order::AMOUNT_TOTAL, $format = false) | |||
public function getAmountWithTax(DocumentInterface $document, string $type = Order::AMOUNT_TOTAL, bool $format = false) | |||
{ | |||
return $this->_getAmountGeneric($document, $type, true, $format); | |||
} | |||
protected function _getAmountGeneric(DocumentInterface $document, $type = Order::AMOUNT_TOTAL, $withTax = true, $format = false) | |||
protected function _getAmountGeneric(DocumentInterface $document, string $type = Order::AMOUNT_TOTAL, bool $withTax = true, bool $format = false) | |||
{ | |||
$amount = 0; | |||
$totalVat = 0; | |||
foreach($document->getProductsOrders() as $productOrderArray) { | |||
foreach($this->getProductsOrders($document) as $productOrderArray) { | |||
foreach($productOrderArray as $productOrder) { | |||
$priceLine = $productOrder->getPriceByTypeTotal($type) * $productOrder->quantity; | |||
$amount += $priceLine; | |||
@@ -32,7 +33,7 @@ class DocumentSolver extends BaseService implements SolverInterface | |||
} | |||
} | |||
if ($this->isTaxCalculationMethodRoundingOfTheSum()) { | |||
if ($this->isTaxCalculationMethodRoundingOfTheSum($document)) { | |||
$totalVat = Price::round($totalVat); | |||
} | |||
@@ -47,12 +48,12 @@ class DocumentSolver extends BaseService implements SolverInterface | |||
} | |||
} | |||
public function getTotalVatArray($typeTotal) | |||
public function getTotalVatArray(DocumentInterface $document, string $typeTotal): array | |||
{ | |||
$totalVatArray = []; | |||
// Méthode de calcul via getProductOrders() | |||
foreach($this->getProductsOrders() as $productOrderArray) { | |||
foreach($this->getProductsOrders($document) as $productOrderArray) { | |||
foreach ($productOrderArray as $productOrder) { | |||
$idTaxRate = $productOrder->taxRate->id; | |||
@@ -63,7 +64,7 @@ class DocumentSolver extends BaseService implements SolverInterface | |||
$totalVatArray[$idTaxRate] += Price::getVat( | |||
$productOrder->getPriceByTypeTotal($typeTotal) * $productOrder->quantity, | |||
$productOrder->taxRate->value, | |||
$this->tax_calculation_method | |||
$document->tax_calculation_method | |||
); | |||
} | |||
} | |||
@@ -71,32 +72,32 @@ class DocumentSolver extends BaseService implements SolverInterface | |||
return $totalVatArray; | |||
} | |||
public function getPointSale() | |||
public function getPointSale(DocumentInterface $document): ?PointSale | |||
{ | |||
if (isset($this->orders) && isset($this->orders[0])) { | |||
return $this->orders[0]->pointSale; | |||
} else { | |||
return ''; | |||
if (isset($document->orders) && isset($document->orders[0])) { | |||
return $document->orders[0]->pointSale; | |||
} | |||
return null; | |||
} | |||
public function getDistribution() | |||
public function getDistribution(DocumentInterface $document) | |||
{ | |||
if (isset($this->orders) && isset($this->orders[0])) { | |||
return $this->orders[0]->distribution; | |||
} else { | |||
return ''; | |||
if (isset($document->orders) && isset($document->orders[0])) { | |||
return $document->orders[0]->distribution; | |||
} | |||
return null; | |||
} | |||
public function getClass() | |||
public function getClass(DocumentInterface $document): string | |||
{ | |||
return str_replace('common\models\\', '', get_class($this)); | |||
return str_replace('common\models\\', '', get_class($document)); | |||
} | |||
public function getType() | |||
public function getType(DocumentInterface $document): string | |||
{ | |||
$class = $this->getClass(); | |||
$class = $this->getClass($document); | |||
if ($class == 'Invoice') { | |||
$documentType = 'Facture'; | |||
@@ -113,7 +114,7 @@ class DocumentSolver extends BaseService implements SolverInterface | |||
return ''; | |||
} | |||
public function isValidClass($typeDocument) | |||
public function isValidClass(string $typeDocument): bool | |||
{ | |||
return in_array($typeDocument, ['Invoice', 'DeliveryNote', 'Quotation']); | |||
} | |||
@@ -128,7 +129,7 @@ class DocumentSolver extends BaseService implements SolverInterface | |||
return ($document->status == Document::STATUS_DRAFT) ? 'default' : 'success'; | |||
} | |||
public function getHtmlLabel(DocumentInterface $document) | |||
public function getHtmlLabel(DocumentInterface $document): string | |||
{ | |||
$label = $this->getStatusWording($document); | |||
$classLabel = $this->getStatusCssClass($document); | |||
@@ -218,16 +219,16 @@ class DocumentSolver extends BaseService implements SolverInterface | |||
public function isInvoicePrice(DocumentInterface $document): bool | |||
{ | |||
return $this->getClass() == 'Invoice' || $this->getClass() == 'DeliveryNote'; | |||
return $this->getClass($document) == 'Invoice' || $this->getClass($document) == 'DeliveryNote'; | |||
} | |||
public function isTaxCalculationMethodSumOfRoundings(DocumentInterface $document): bool | |||
{ | |||
return $document->tax_calculation_method == self::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS; | |||
return $document->tax_calculation_method == Document::TAX_CALCULATION_METHOD_SUM_OF_ROUNDINGS; | |||
} | |||
public function isTaxCalculationMethodRoundingOfTheSum(DocumentInterface $document): bool | |||
{ | |||
return $document->tax_calculation_method == self::TAX_CALCULATION_METHOD_ROUNDING_OF_THE_SUM; | |||
return $document->tax_calculation_method == Document::TAX_CALCULATION_METHOD_ROUNDING_OF_THE_SUM; | |||
} | |||
} |
@@ -84,7 +84,7 @@ class DocumentUtils extends BaseService implements UtilsInterface | |||
} | |||
} | |||
public function downloadPdf(DocumentInterface $document, $regenerate = false) | |||
public function downloadPdf(DocumentInterface $document, bool $regenerate = false) | |||
{ | |||
$filenameComplete = $this->documentSolver->getFilenameComplete($document); | |||
@@ -99,7 +99,7 @@ class DocumentUtils extends BaseService implements UtilsInterface | |||
} | |||
} | |||
public function send(DocumentInterface $document) | |||
public function send(DocumentInterface $document): bool | |||
{ | |||
if (isset($document->user) && strlen($document->user->email) > 0) { | |||
$producer = GlobalParam::getCurrentProducer(); |
@@ -8,7 +8,7 @@ use common\logic\Document\Document\DocumentBuilder; | |||
class InvoiceBuilder extends DocumentBuilder implements BuilderInterface | |||
{ | |||
public function instanciate(): Invoice | |||
public function instanciateInvoice(): Invoice | |||
{ | |||
$invoice = new Invoice(); | |||
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\Document\Invoice; | |||
use common\logic\Document\Document\DocumentManager; | |||
use common\logic\PointSale\PointSale\InvoiceRepository; | |||
/** | |||
* @mixin InvoiceRepository | |||
* @mixin InvoiceBuilder | |||
*/ | |||
class InvoiceManager extends DocumentManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new InvoiceContainer()); | |||
} | |||
} |
@@ -7,7 +7,7 @@ use common\logic\BuilderInterface; | |||
class QuotationBuilder extends BaseService implements BuilderInterface | |||
{ | |||
public function instanciate(): Quotation | |||
public function instanciateQuotation(): Quotation | |||
{ | |||
$quotation = new Quotation(); | |||
@@ -0,0 +1,19 @@ | |||
<?php | |||
namespace common\logic\Document\Invoice; | |||
use common\logic\Document\Document\DocumentManager; | |||
use common\logic\Document\Quotation\QuotationBuilder; | |||
use common\logic\PointSale\PointSale\QuotationRepository; | |||
/** | |||
* @mixin QuotationRepository | |||
* @mixin QuotationBuilder | |||
*/ | |||
class QuotationManager extends DocumentManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new QuotationContainer()); | |||
} | |||
} |
@@ -14,65 +14,9 @@ use common\logic\User\User\User; | |||
use yii\db\Query; | |||
/** | |||
* @see OrderSolver | |||
* @method string getFieldNameAmount($typeTotal = Order::AMOUNT_TOTAL, string $typeField = '') | |||
* @method float getOrderTotalVat(Order $order, string $typeTotal = Order::AMOUNT_TOTAL) | |||
* @method string|null getPaymentStatus(Order $order) | |||
* @method string getPointSaleSummary(Order $order) | |||
* @method string getOrderUsername(Order $order) | |||
* @method bool isLinkedToValidDocument(Order $order) | |||
* @method string getCommentReport(Order $order) | |||
* @method string getDateAsHtml(Order $order) | |||
* @method int countProducts(Order $order) | |||
* @method int getProductQuantityPieces(Product $product, array $orders) | |||
* @method int getProductQuantity(Product $product, array $orders, bool $ignoreCancel = false, string $unit = null) | |||
* @method string getHistoryClass(Order $order) | |||
* @method string getHistorySummary(Order $order) | |||
* @method string getLabelOrigin(Order $order, bool $withLabel = false) | |||
* @method float getOrderAmount(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | |||
* @method float getOrderAmountWithTax(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | |||
* @method bool isOrderStateOpen(Order $order) | |||
* @method bool isOrderStatePreparation(Order $order) | |||
* @method bool isOrderStateDelivered(Order $order) | |||
* @method bool isOrderBelongsToUser(Order $order, User $user = null) | |||
* @method string getDataJson(Order $order) | |||
* | |||
* @see OrderRepository | |||
* @method array defaultOptionsSearch() | |||
* @method Order|null findOneById(int $id) | |||
* @method array findBy(array $params = [], array $options = []) | |||
* @method array findByDistribution(Distribution $distribution, string $conditionAppend = '') | |||
* @method Order|null findOneLastOfYear(Producer $producer) | |||
* @method Query queryHistory(Producer $producer, User $user, string $type = 'incoming') | |||
* @method string getCartSummary(Order $order, $htmlFormat = true) | |||
* @method string getAmountSummary(Order $order) | |||
* @method string getState(Order $order) | |||
* | |||
* @see OrderBuilder | |||
* @method Order instanciateOrder(Distribution $distribution) | |||
* @method Order createOrder(Distribution $distribution) | |||
* @method Order|null createOrderFromSubscription(Subscription $subscription, string $date, bool $force = false) | |||
* @method array createAllOrdersFromSubscriptions(string $date, bool $force = false) | |||
* @method array updateOrdersIncomingDistributionsFromSubscription(Subscription $subscription, bool $update = false) | |||
* @method int deleteOrdersIncomingDistributionsFromSubscription(Subscription $subscription, bool $deleteAfterDateEnd = false) | |||
* @method bool addProductOrdersFromSubscription(Order $order, Subscription $subscription) | |||
* @method void updateOrderFromSubscription(Order $order, Subscription $subscription) | |||
* @method void initOrderBaseFromSubscription(Order $order, Subscription $subscription) | |||
* @method void initOrderAutoPaymentFromSubscription(Order $order, Subscription $subscription) | |||
* @method void createUserPointSale(Order $order) | |||
* @method void initOrderCommentPointSale(Order $order) | |||
* @method void initOrder(Order $order, string $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
* @method void initOrderAmount(Order $order, string $taxCalculationMethod = Document::TAX_CALCULATION_METHOD_DEFAULT) | |||
* @method void addProductOrderWeight(Order $order, ProductOrder $productOrder) | |||
* @method void addProductOrderAmount(Order $order, string $typeTotal, ProductOrder $productOrder, string $taxCalculationMethod) | |||
* @method void addProductOrderVat(Order $order, string $typeTotal, float $priceTotalWithoutTax, TaxRate $taxRate, string $taxCalculationMethod) | |||
* @method void initOrderPaidAmount(Order $order) | |||
* @method void deleteOrder(Order $order, bool $force = false): bool | |||
* @method void processCredit(Order $order) | |||
* @method void updateOrderTillerSynchronization(Order $order) | |||
* @method void updateOrderStatus(Order $order, string $newStatus, string $origin) | |||
* @method void generateOrderReference(Order $order) | |||
* @method void updateOrderInvoicePrices(Order $order, array $params = []) | |||
* @mixin OrderSolver | |||
* @mixin OrderRepository | |||
* @mixin OrderBuilder | |||
*/ | |||
class OrderManager extends BaseManager | |||
{ |
@@ -17,7 +17,7 @@ class OrderStatusHistoryBuilder extends BaseService implements BuilderInterface | |||
$this->userSolver = $this->loadService(UserSolver::class); | |||
} | |||
public function instanciate(Order $order, User $user, string $status, string $origin): OrderStatusHistory | |||
public function instanciateOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory | |||
{ | |||
$orderStatusHistory = new OrderStatusHistory(); | |||
@@ -32,9 +32,11 @@ class OrderStatusHistoryBuilder extends BaseService implements BuilderInterface | |||
return $orderStatusHistory; | |||
} | |||
public function create(Order $order, User $user, string $status, string $origin): OrderStatusHistory | |||
public function createOrderStatusHistory(Order $order, User $user, string $status, string $origin): OrderStatusHistory | |||
{ | |||
$orderStatusHistory = $this->instanciate($order, $user, $status, $origin); | |||
$orderStatusHistory = $this->instanciateOrderStatusHistory($order, $user, $status, $origin); | |||
$orderStatusHistory->save(); | |||
return $orderStatusHistory | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\Order\OrderStatusHistory; | |||
use common\logic\BaseManager; | |||
use common\logic\PointSale\PointSale\OrderStatusHistoryRepository; | |||
/** | |||
* @mixin OrderStatusHistoryRepository | |||
* @mixin OrderStatusHistoryBuilder | |||
*/ | |||
class OrderStatusHistoryManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new OrderStatusHistoryContainer()); | |||
} | |||
} |
@@ -21,7 +21,7 @@ class ProductOrderBuilder extends BaseService implements BuilderInterface | |||
$this->productSolver = $this->loadService(ProductSolver::class); | |||
} | |||
public function instanciate(Order $order, Product $product, float $quantity, float $price): ProductOrder | |||
public function instanciateProductOrder(Order $order, Product $product, float $quantity, float $price): ProductOrder | |||
{ | |||
$productOrder = new ProductOrder(); | |||
@@ -36,9 +36,9 @@ class ProductOrderBuilder extends BaseService implements BuilderInterface | |||
return $productOrder; | |||
} | |||
public function create(Order $order, Product $product, float $quantity, float $price): ProductOrder | |||
public function createProductOrder(Order $order, Product $product, float $quantity, float $price): ProductOrder | |||
{ | |||
$productOrder = $this->instanciate($order, $product, $quantity, $price); | |||
$productOrder = $this->instanciateProductOrder($order, $product, $quantity, $price); | |||
$productOrder->save(); | |||
return $productOrder; | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\Order\ProductOrder; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProductOrderSolver | |||
* @mixin ProductOrderRepository | |||
* @mixin ProductOrderBuilder | |||
*/ | |||
class ProductOrderManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProductOrderContainer()); | |||
} | |||
} |
@@ -4,6 +4,7 @@ namespace common\logic\PointSale\PointSale; | |||
use common\logic\BaseService; | |||
use common\logic\BuilderInterface; | |||
use common\logic\PointSale\UserPointSale\UserPointSale; | |||
use common\logic\PointSale\UserPointSale\UserPointSaleBuilder; | |||
use common\logic\PointSale\UserPointSale\UserPointSaleRepository; | |||
use common\logic\Producer\Producer\Producer; | |||
@@ -23,7 +24,7 @@ class PointSaleBuilder extends BaseService implements BuilderInterface | |||
$this->userPointSaleRepository = $this->loadService(UserPointSaleRepository::class); | |||
} | |||
public function instanciate(): PointSale | |||
public function instanciatePointSale(): PointSale | |||
{ | |||
$pointSale = new PointSale(); | |||
@@ -95,15 +96,14 @@ class PointSaleBuilder extends BaseService implements BuilderInterface | |||
* Lie un utilisateur au point de vente. | |||
*/ | |||
// linkUser | |||
public function addUser(User $user, PointSale $pointSale) | |||
public function addUser(User $user, PointSale $pointSale): UserPointSale | |||
{ | |||
$userPointSale = $this->userPointSaleRepository->getOne($user, $pointSale); | |||
if (!$userPointSale) { | |||
$this->userPointSaleBuilder->create($user, $pointSale); | |||
$userPointSale = $this->userPointSaleBuilder->create($user, $pointSale); | |||
} | |||
} | |||
return $userPointSale; | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\PointSale\PointSale; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin PointSaleSolver | |||
* @mixin PointSaleRepository | |||
* @mixin PointSaleBuilder | |||
*/ | |||
class PointSaleManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new PointSaleContainer()); | |||
} | |||
} |
@@ -65,7 +65,7 @@ class PointSaleRepository extends BaseService implements RepositoryInterface | |||
); | |||
} | |||
public function populateDropdownList() | |||
public function populateDropdownList(): array | |||
{ | |||
$pointSalesArrayDropdown = ['' => '--']; | |||
$pointSalesArray = $this->get(); |
@@ -9,7 +9,7 @@ use common\logic\User\User\User; | |||
class UserPointSaleBuilder extends BaseService implements BuilderInterface | |||
{ | |||
public function instanciate(User $user, PointSale $pointSale, string $comment = null): UserPointSale | |||
public function instanciateUserPointSale(User $user, PointSale $pointSale, string $comment = null): UserPointSale | |||
{ | |||
$userPointSale = new UserPointSale(); | |||
@@ -25,9 +25,9 @@ class UserPointSaleBuilder extends BaseService implements BuilderInterface | |||
return $userPointSale; | |||
} | |||
public function create(User $user, PointSale $pointSale, string $comment = null): UserPointSale | |||
public function createUserPointSale(User $user, PointSale $pointSale, string $comment = null): UserPointSale | |||
{ | |||
$userPointSale = $this->instanciate($user, $pointSale, $comment); | |||
$userPointSale = $this->instanciateUserPointSale($user, $pointSale, $comment); | |||
$userPointSale->save(); | |||
return $userPointSale; |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\PointSale\UserPointSale; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin UserPointSaleRepository | |||
* @mixin UserPointSaleBuilder | |||
*/ | |||
class UserPointSaleManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new UserPointSaleContainer()); | |||
} | |||
} |
@@ -27,7 +27,7 @@ class ProducerBuilder extends BaseService implements BuilderInterface | |||
$this->producerSolver = $this->loadService(ProducerSolver::class); | |||
} | |||
public function instanciate(): Producer | |||
public function instanciateProducer(): Producer | |||
{ | |||
$producer = new Producer(); | |||
@@ -76,7 +76,7 @@ class ProducerBuilder extends BaseService implements BuilderInterface | |||
return $userProducer; | |||
} | |||
public function updateOpendistribVersion(Producer $producer) | |||
public function updateOpendistribVersion(Producer $producer): void | |||
{ | |||
$versionsArray = Opendistrib::getVersions(); | |||
$producer->latest_version_opendistrib = array_values($versionsArray)[0]; |
@@ -0,0 +1,19 @@ | |||
<?php | |||
namespace common\logic\Producer\Producer; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProducerSolver | |||
* @mixin ProducerRepository | |||
* @mixin ProducerBuilder | |||
* @mixin ProducerUtils | |||
*/ | |||
class ProducerManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProducerContainer()); | |||
} | |||
} |
@@ -39,12 +39,12 @@ class ProducerRepository extends BaseService implements RepositoryInterface | |||
]; | |||
} | |||
public function getOneById($id) | |||
public function getOneById(int $id) | |||
{ | |||
return Producer::searchOne(['id' => $id]); | |||
} | |||
public function getOneBySlug($slug) | |||
public function getOneBySlug(string $slug) | |||
{ | |||
return Producer::searchOne(['slug' => $slug]); | |||
} | |||
@@ -73,7 +73,7 @@ class ProducerRepository extends BaseService implements RepositoryInterface | |||
* | |||
* @return array | |||
*/ | |||
public static function getPopulateDropdown() | |||
public static function getPopulateDropdown(): array | |||
{ | |||
$producers = Producer::find() | |||
->where([ | |||
@@ -147,13 +147,13 @@ class ProducerRepository extends BaseService implements RepositoryInterface | |||
} | |||
} | |||
public function getAmountToBeBilledByMonth(Producer $producer, $month, $format = false) | |||
public function getAmountToBeBilledByMonth(Producer $producer, $month, bool $format = false) | |||
{ | |||
$turnover = $this->getTurnover($producer, $month); | |||
return $this->producerPriceRangeRepository->getAmountToBeBilledByTurnover($turnover, $format); | |||
} | |||
public function getSummaryAmountsToBeBilled(Producer $producer, $label, $numberOfMonths = 1) | |||
public function getSummaryAmountsToBeBilled(Producer $producer, string $label, int $numberOfMonths = 1): string | |||
{ | |||
$text = ''; | |||
$numMonthCurrent = date('m'); | |||
@@ -185,7 +185,7 @@ class ProducerRepository extends BaseService implements RepositoryInterface | |||
return $text; | |||
} | |||
public function getAmountBilledLastMonth(Producer $producer) | |||
public function getAmountBilledLastMonth(Producer $producer): float | |||
{ | |||
if ($this->producerSolver->isBillingTypeClassic($producer)) { | |||
$month = date('Y-m', strtotime('-1 month')); | |||
@@ -197,7 +197,7 @@ class ProducerRepository extends BaseService implements RepositoryInterface | |||
return 0; | |||
} | |||
public function getOnlinePaymentMinimumAmount(Producer $producer) | |||
public function getOnlinePaymentMinimumAmount(Producer $producer): float | |||
{ | |||
$onlinePaymentMinimumAmount = $this->getConfig('option_online_payment_minimum_amount'); | |||
if (!$onlinePaymentMinimumAmount) { | |||
@@ -211,7 +211,7 @@ class ProducerRepository extends BaseService implements RepositoryInterface | |||
* Retourne une configuration d'un producteur donné | |||
* | |||
*/ | |||
public function getConfig($config = '', $idProducer = 0) | |||
public function getConfig(string $config = '', int $idProducer = 0) | |||
{ | |||
if (strlen($config)) { | |||
if (!$idProducer) { | |||
@@ -224,15 +224,13 @@ class ProducerRepository extends BaseService implements RepositoryInterface | |||
} | |||
} | |||
return false; | |||
return null; | |||
} | |||
/** | |||
* Retourne les établissements liés à l'utilisateur. | |||
* | |||
* @return array | |||
*/ | |||
public function getBookmarked(User $user) | |||
public function getBookmarked(User $user): array | |||
{ | |||
$producers = (new \yii\db\Query()) | |||
->select('*') |
@@ -9,10 +9,6 @@ use common\logic\User\User\User; | |||
class ProducerSolver extends BaseService implements SolverInterface | |||
{ | |||
public function getCurrent() | |||
{ | |||
} | |||
/** | |||
* Retourne true si le compte est un compte de démo. | |||
@@ -26,7 +22,7 @@ class ProducerSolver extends BaseService implements SolverInterface | |||
return false; | |||
} | |||
public function getFullAddress(Producer $producer, $nl2br = false) | |||
public function getFullAddress(Producer $producer, bool $nl2br = false): string | |||
{ | |||
$address = ''; | |||
$address .= $producer->name . "\n"; | |||
@@ -101,7 +97,7 @@ class ProducerSolver extends BaseService implements SolverInterface | |||
return $producer->option_billing_type == Producer::BILLING_TYPE_CLASSIC; | |||
} | |||
public function isBillingTypeFreePrice(Producer $producer) | |||
public function isBillingTypeFreePrice(Producer $producer): bool | |||
{ | |||
return $producer->option_billing_type == Producer::BILLING_TYPE_FREE_PRICE; | |||
} | |||
@@ -109,9 +105,8 @@ class ProducerSolver extends BaseService implements SolverInterface | |||
/** | |||
* Retourne le montant de l'abonnement à prix libre définit par | |||
* le producteur. | |||
* | |||
*/ | |||
public function getFreePrice(Producer $producer, $format = true) | |||
public function getFreePrice(Producer $producer, bool $format = true) | |||
{ | |||
if (!is_null($producer->free_price)) { | |||
if ($format) { | |||
@@ -181,22 +176,20 @@ class ProducerSolver extends BaseService implements SolverInterface | |||
return false; | |||
} | |||
public function getFilenamePrivateKeyApiStripe(Producer $producer) | |||
public function getFilenamePrivateKeyApiStripe(Producer $producer): string | |||
{ | |||
return '../../common/config/stripe/api-' . $producer->id . '.key'; | |||
} | |||
public function getFilenamePrivateKeyEndpointStripe(Producer $producer) | |||
public function getFilenamePrivateKeyEndpointStripe(Producer $producer): string | |||
{ | |||
return '../../common/config/stripe/endpoint-' . $producer->id . '.key'; | |||
} | |||
/** | |||
* Retourne la clé secrète d'API de Stripe. | |||
* | |||
* @return string | |||
*/ | |||
public function getPrivateKeyStripe($filename) | |||
public function getPrivateKeyStripe(string $filename): string | |||
{ | |||
if (file_exists($filename)) { | |||
$handle = fopen($filename, "r"); | |||
@@ -211,17 +204,17 @@ class ProducerSolver extends BaseService implements SolverInterface | |||
return ''; | |||
} | |||
public function getPrivateKeyApiStripe(Producer $producer) | |||
public function getPrivateKeyApiStripe(Producer $producer): string | |||
{ | |||
return $this->getPrivateKeyStripe($this->getFilenamePrivateKeyApiStripe($producer)); | |||
} | |||
public function getPrivateKeyEndpointStripe(Producer $producer) | |||
public function getPrivateKeyEndpointStripe(Producer $producer): string | |||
{ | |||
return $this->getPrivateKeyStripe($this->getFilenamePrivateKeyEndpointStripe($producer)); | |||
} | |||
public function isOnlinePaymentActive(Producer $producer) | |||
public function isOnlinePaymentActive(Producer $producer): bool | |||
{ | |||
return $producer->online_payment | |||
|| ($producer->option_stripe_mode_test | |||
@@ -249,5 +242,4 @@ class ProducerSolver extends BaseService implements SolverInterface | |||
{ | |||
return $producer->option_billing_frequency == Producer::BILLING_FREQUENCY_BIANNUAL; | |||
} | |||
} |
@@ -7,7 +7,7 @@ use common\logic\UtilsInterface; | |||
class ProducerUtils extends BaseService implements UtilsInterface | |||
{ | |||
public function sendEmailNewProducer(Producer $producer) | |||
public function sendEmailNewProducer(Producer $producer): void | |||
{ | |||
\Yii::$app->mailer->compose( | |||
[ |
@@ -0,0 +1,16 @@ | |||
<?php | |||
namespace common\logic\Producer\ProducerPriceRange; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProducerPriceRangeRepository | |||
*/ | |||
class ProducerPriceRangeManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProducerPriceRangeContainer()); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\Product\Product; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProductSolver | |||
* @mixin ProductRepository | |||
* @mixin ProductBuilder | |||
*/ | |||
class ProductManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProductContainer()); | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\Product\ProductCategory; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProductCategoryRepository | |||
* @mixin ProductCategoryBuilder | |||
*/ | |||
class ProductCategoryManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProductCategoryContainer()); | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\Product\ProductPointSale; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProductPointSaleRepository | |||
* @mixin ProductPointSaleBuilder | |||
*/ | |||
class ProductPointSaleManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProductPointSaleContainer()); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Product\ProductPrice; | |||
namespace common\logic\Product\ProductPointSale; | |||
use common\logic\BaseService; | |||
use common\logic\RepositoryInterface; |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\Product\ProductPrice; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProductPriceRepository | |||
* @mixin ProductPriceBuilder | |||
*/ | |||
class ProductPriceManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProductPriceContainer()); | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\Subscription\ProductSubscription; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin ProductSubscriptionRepository | |||
* @mixin ProductSubscriptionBuilder | |||
*/ | |||
class ProductSubscriptionManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new ProductSubscriptionContainer()); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\Subscription\Subscription; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin SubscriptionSolver | |||
* @mixin SubscriptionRepository | |||
* @mixin SubscriptionBuilder | |||
*/ | |||
class SubscriptionManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new SubscriptionContainer()); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\User\CreditHistory; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin CreditHistorySolver | |||
* @mixin CreditHistoryRepository | |||
* @mixin CreditHistoryBuilder | |||
*/ | |||
class CreditHistoryManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new CreditHistoryContainer()); | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
<?php | |||
namespace common\logic\User\User; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin UserSolver | |||
* @mixin UserRepository | |||
* @mixin UserBuilder | |||
* @mixin UserUtils | |||
*/ | |||
class UserManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new UserContainer()); | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\User\UserGroup; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin UserGroupRepository | |||
* @mixin UserGroupBuilder | |||
*/ | |||
class UserGroupManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new UserGroupContainer()); | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace common\logic\User\UserProducer; | |||
use common\logic\BaseManager; | |||
/** | |||
* @mixin UserProducerRepository | |||
* @mixin UserProducerBuilder | |||
*/ | |||
class UserProducerManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new UserProducerContainer()); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?php | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\BaseManager; | |||
use common\logic\User\UserGroup\UserUserGroupBuilder; | |||
/** | |||
* @mixin UserUserGroupRepository | |||
* @mixin UserUserGroupBuilder | |||
*/ | |||
class UserUserGroupManager extends BaseManager | |||
{ | |||
public function __construct() | |||
{ | |||
$this->setContainer(new UserUserGroupContainer()); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\User\UserProducer; | |||
namespace common\logic\User\UserUserGroup; | |||
use common\logic\BaseService; | |||
use common\logic\RepositoryInterface; |