You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 satır
1.4KB

  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. ?>