Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

ActiveDistributionsInAdvanceController.php 1.3KB

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