Browse Source

[Administration] Emails automatiques : ajustements

develop
Guillaume Bourgeois 4 months ago
parent
commit
98b0091446
3 changed files with 30 additions and 24 deletions
  1. +1
    -1
      backend/views/automatic-email/_form.php
  2. +1
    -1
      console/commands/AutomaticEmailController.php
  3. +28
    -22
      domain/Communication/AutomaticEmail/AutomaticEmail.php

+ 1
- 1
backend/views/automatic-email/_form.php View File

?> ?>


<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">

+ 1
- 1
console/commands/AutomaticEmailController.php View File

$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);

+ 28
- 22
domain/Communication/AutomaticEmail/AutomaticEmail.php View File



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>';
}
}
} }

Loading…
Cancel
Save