Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ActiveDistributionsInAdvanceController.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace console\commands;
  3. use domain\Distribution\Distribution\DistributionModule;
  4. use domain\Producer\Producer\ProducerModule;
  5. use yii\console\Controller;
  6. class ActiveDistributionsInAdvanceController extends Controller
  7. {
  8. // ./yii active-distributions-in-advance/index
  9. public function actionIndex()
  10. {
  11. $producerModule = ProducerModule::getInstance();
  12. $distributionModule = DistributionModule::getInstance();
  13. $producersArray = $producerModule->findProducersActive();
  14. foreach($producersArray as $producer) {
  15. \Yii::$app->logic->setProducerContext($producer);
  16. $weeksDistributionsActivatedInAdvance = $producerModule->getSolver()->getConfig('option_weeks_distributions_activated_in_advance');
  17. if($weeksDistributionsActivatedInAdvance) {
  18. $date = new \DateTime('+'.$weeksDistributionsActivatedInAdvance.' weeks');
  19. if(!$producerModule->getSolver()->isOnLeavePeriod($producer, $date)) {
  20. $distributionModule->getBuilder()->activeDistributionByDateIfDelivery($date);
  21. $distribution = $distributionModule->getRepository()
  22. ->findOneDistribution($date->format('Y-m-d'), true);
  23. if($distribution) {
  24. echo $producer->name. ' : distribution du ' . $date->format('d/m/Y') .' activée' ."\n";
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }
  31. ?>