getRepository()->findProducers(); foreach($producersArray as $producer) { \Yii::$app->logic->setProducerContext($producer); $automaticEmailsArray = $automaticEmailModule->getRepository()->findAutomaticEmails(); foreach($automaticEmailsArray as $automaticEmail) { if($automaticEmail->isEnabled()) { $distribution = $automaticEmailModule->getResolver()->getMatchedDistribution($automaticEmail); if(($distribution || $automaticEmail->getSendingDay() == $dayToday) && $automaticEmail->getSendingHour() == $currentHour) { $email = $automaticEmailModule->getManager()->createEmailFromAutomaticEmail($automaticEmail, $distribution); $usersArray = $emailModule->getContactListResolver()->search( $producer, Email::TYPE_ORDER_TAKING, $distribution, $automaticEmail->getPointSale() ); $emailModule->getBulkMailer()->sendEmail($email, $usersArray); echo 'Email automatique "'.$automaticEmail->getSubject().'" envoyé à '.count($usersArray)." utilisateur(s)\n"; } } } } } } ?>