Przeglądaj źródła

[Administration] Emails automatiques : ajustements

develop
Guillaume Bourgeois 4 miesięcy temu
rodzic
commit
98b0091446
3 zmienionych plików z 30 dodań i 24 usunięć
  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 Wyświetl plik

@@ -44,7 +44,7 @@ use yii\widgets\ActiveForm;
?>

<div class="automatic-email-form">
<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">

+ 1
- 1
console/commands/AutomaticEmailController.php Wyświetl plik

@@ -23,7 +23,7 @@ class AutomaticEmailController extends Controller
$automaticEmailsArray = $automaticEmailModule->getRepository()->findAutomaticEmails();
foreach($automaticEmailsArray as $automaticEmail) {
$distribution = $automaticEmailModule->getResolver()->getMatchedDistribution($automaticEmail);
if($distribution) {
if($automaticEmail->isEnabled() && $distribution) {
$email = $automaticEmailModule->getManager()->createEmailFromAutomaticEmail($automaticEmail, $distribution);
$usersArray = $emailModule->getContactListResolver()->search($producer, Email::TYPE_ORDER_TAKING, $distribution);
$emailModule->getBulkMailer()->sendEmail($email, $usersArray);

+ 28
- 22
domain/Communication/AutomaticEmail/AutomaticEmail.php Wyświetl plik

@@ -4,6 +4,7 @@ namespace domain\Communication\AutomaticEmail;

use common\components\ActiveRecordCommon;
use common\components\Date;
use domain\_\StatusInterface;
use domain\Producer\Producer\Producer;
use yii\db\ActiveQuery;

@@ -37,6 +38,33 @@ class AutomaticEmail extends ActiveRecordCommon
];
}

/* 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 */

public function getId(): ?int
@@ -127,26 +155,4 @@ class AutomaticEmail extends ActiveRecordCommon
{
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>';
}
}
}

Ładowanie…
Anuluj
Zapisz