?> | ?> | ||||
<div class="automatic-email-form"> | <div class="automatic-email-form"> | ||||
<?php $form = ActiveForm::begin(); ?> | |||||
<?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?> | |||||
<div class="col-md-8"> | <div class="col-md-8"> | ||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> |
$automaticEmailsArray = $automaticEmailModule->getRepository()->findAutomaticEmails(); | $automaticEmailsArray = $automaticEmailModule->getRepository()->findAutomaticEmails(); | ||||
foreach($automaticEmailsArray as $automaticEmail) { | foreach($automaticEmailsArray as $automaticEmail) { | ||||
$distribution = $automaticEmailModule->getResolver()->getMatchedDistribution($automaticEmail); | $distribution = $automaticEmailModule->getResolver()->getMatchedDistribution($automaticEmail); | ||||
if($distribution) { | |||||
if($automaticEmail->isEnabled() && $distribution) { | |||||
$email = $automaticEmailModule->getManager()->createEmailFromAutomaticEmail($automaticEmail, $distribution); | $email = $automaticEmailModule->getManager()->createEmailFromAutomaticEmail($automaticEmail, $distribution); | ||||
$usersArray = $emailModule->getContactListResolver()->search($producer, Email::TYPE_ORDER_TAKING, $distribution); | $usersArray = $emailModule->getContactListResolver()->search($producer, Email::TYPE_ORDER_TAKING, $distribution); | ||||
$emailModule->getBulkMailer()->sendEmail($email, $usersArray); | $emailModule->getBulkMailer()->sendEmail($email, $usersArray); |
use common\components\ActiveRecordCommon; | use common\components\ActiveRecordCommon; | ||||
use common\components\Date; | use common\components\Date; | ||||
use domain\_\StatusInterface; | |||||
use domain\Producer\Producer\Producer; | use domain\Producer\Producer\Producer; | ||||
use yii\db\ActiveQuery; | use yii\db\ActiveQuery; | ||||
]; | ]; | ||||
} | } | ||||
/* Méthodes */ | |||||
public function isEnabled(): bool | |||||
{ | |||||
return (bool) $this->getStatus() == StatusInterface::STATUS_ONLINE; | |||||
} | |||||
public function getDayAsString(): string | |||||
{ | |||||
return Date::getDayOfWeekStringByNumber($this->getDay()); | |||||
} | |||||
public function getDelayBeforeDistributionAsString(): string | |||||
{ | |||||
return $this->getDelayBeforeDistribution().' jour(s) avant'; | |||||
} | |||||
public function getStatusAsHtml(): string | |||||
{ | |||||
if($this->getStatus()) { | |||||
return '<span class="label label-success">Activé</span>'; | |||||
} | |||||
else { | |||||
return '<span class="label label-danger">Désactivé</span>'; | |||||
} | |||||
} | |||||
/* Getters / Setters */ | /* Getters / Setters */ | ||||
public function getId(): ?int | public function getId(): ?int | ||||
{ | { | ||||
return $this->hasOne(Producer::class, ['id' => 'id_producer']); | return $this->hasOne(Producer::class, ['id' => 'id_producer']); | ||||
} | } | ||||
/* Méthodes */ | |||||
public function getDayAsString(): string | |||||
{ | |||||
return Date::getDayOfWeekStringByNumber($this->getDay()); | |||||
} | |||||
public function getDelayBeforeDistributionAsString(): string | |||||
{ | |||||
return $this->getDelayBeforeDistribution().' jour(s) avant'; | |||||
} | |||||
public function getStatusAsHtml(): string | |||||
{ | |||||
if($this->getStatus()) { | |||||
return '<span class="label label-success">Activé</span>'; | |||||
} | |||||
else { | |||||
return '<span class="label label-danger">Désactivé</span>'; | |||||
} | |||||
} | |||||
} | } |