Browse Source

[Administration] Emails automatiques : adaptations jour et heure d'envoi + filtre par point de vente

develop
Guillaume Bourgeois 2 months ago
parent
commit
c3b4e97b32
3 changed files with 19 additions and 8 deletions
  1. +11
    -0
      backend/views/automatic-email/index.php
  2. +1
    -2
      console/commands/AutomaticEmailController.php
  3. +7
    -6
      domain/Communication/Email/EmailGenerator.php

+ 11
- 0
backend/views/automatic-email/index.php View File

<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'columns' => [ 'columns' => [
[
'attribute' => 'id_point_sale',
'format' => 'raw',
'value' => function(AutomaticEmail $automaticEmail) {
if(!$automaticEmail->getPointSale()) {
return '<span class="label label-default">Tous</span>';
}

return $automaticEmail->getPointSale()->getName();
}
],
[ [
'attribute' => 'day', 'attribute' => 'day',
'value' => function(AutomaticEmail $automaticEmail) { 'value' => function(AutomaticEmail $automaticEmail) {

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

$distribution, $distribution,
$automaticEmail->getPointSale() $automaticEmail->getPointSale()
); );
//$emailModule->getBulkMailer()->sendEmail($email, $usersArray);
echo $email->getHtmlContent();
$emailModule->getBulkMailer()->sendEmail($email, $usersArray);
echo 'Email automatique "'.$automaticEmail->getSubject().'" envoyé à '.count($usersArray)." utilisateur(s)\n"; echo 'Email automatique "'.$automaticEmail->getSubject().'" envoyé à '.count($usersArray)." utilisateur(s)\n";
} }
} }

+ 7
- 6
domain/Communication/Email/EmailGenerator.php View File

bool $addLinkOrderWhenNoDistribution = false bool $addLinkOrderWhenNoDistribution = false
): Email ): Email
{ {
$linkProducer = '';
if($producer) {
$linkProducer = 'https://'.$producer->slug.'.souke.fr';
}

$messageAutoText = '' ; $messageAutoText = '' ;
$messageAutoHtml = '' ; $messageAutoHtml = '' ;


' ; ' ;
$messageAutoHtml .= '<br /><br />' ; $messageAutoHtml .= '<br /><br />' ;


$linkOrder = $this->distributionSolver->getLinkOrder($distribution);
$linkOrder = $linkProducer.'/order/order?date='.$distribution->date;
$dateOrder = strftime('%A %d %B %Y', strtotime($distribution->date)) ; $dateOrder = strftime('%A %d %B %Y', strtotime($distribution->date)) ;
$messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande du '.$dateOrder.'</a>' ; $messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande du '.$dateOrder.'</a>' ;
$messageAutoText .= 'Suivez ce lien pour passer votre commande du '.$dateOrder.' : $messageAutoText .= 'Suivez ce lien pour passer votre commande du '.$dateOrder.' :
} }
else { else {
if($addLinkOrderWhenNoDistribution) { if($addLinkOrderWhenNoDistribution) {
$linkOrder = \Yii::$app->urlManagerProducer->createAbsoluteUrl([
'order/order',
'slug_producer' => $this->getProducerContext()->slug
]) ;
$linkOrder = $linkProducer.'/order/order';
$messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande</a>' ; $messageAutoHtml .= '<a href="'.$linkOrder.'">Passer ma commande</a>' ;
$messageAutoText .= 'Suivez ce lien pour passer votre commande : $messageAutoText .= 'Suivez ce lien pour passer votre commande :
'.$linkOrder ; '.$linkOrder ;
$fromEmail = $this->producerSolver->getProducerEmailPlatform($producer) ; $fromEmail = $this->producerSolver->getProducerEmailPlatform($producer) ;
$fromName = $producer->name ; $fromName = $producer->name ;


$linkProducer = 'https://'.$producer->slug.'.souke.fr';
$linkUnsubscribe = $linkProducer.'/newsletter/unsubscribe'; $linkUnsubscribe = $linkProducer.'/newsletter/unsubscribe';


// Message inscription newsletter // Message inscription newsletter

Loading…
Cancel
Save