Guillaume Bourgeois 5 years ago
parent
commit
9081ed7248
3 changed files with 19 additions and 3 deletions
  1. +17
    -1
      backend/controllers/UserController.php
  2. +1
    -1
      backend/models/MailForm.php
  3. +1
    -1
      backend/views/user/index.php

+ 17
- 1
backend/controllers/UserController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\models\User ; use common\models\User ;
use common\models\Producer ;
use backend\models\MailForm ;


/** /**
* UserController implements the CRUD actions for User model. * UserController implements the CRUD actions for User model.
if($idPointSale) { if($idPointSale) {
$pointSale = PointSale::findOne(['id' => $idPointSale]) ; $pointSale = PointSale::findOne(['id' => $idPointSale]) ;
} }
$mailForm = new MailForm() ;
if ($mailForm->load(Yii::$app->request->post()) && $mailForm->validate()) {
$resultSendEmail = $mailForm->sendEmail($users) ;
if($resultSendEmail) {
Yii::$app->getSession()->setFlash('success', 'Votre email a bien été envoyé.');
}
else {
Yii::$app->getSession()->setFlash('error', 'Un problème est survenu lors de l\'envoi de votre email.');
}
return $this->redirect(['mail','idPointSale' => $idPointSale]);
}


return $this->render('emails', [ return $this->render('emails', [
'usersArray' => $usersArray, 'usersArray' => $usersArray,
'pointsSaleArray' => $pointsSaleArray, 'pointsSaleArray' => $pointsSaleArray,
'pointSale' => $pointSale
'pointSale' => $pointSale,
'mailForm' => $mailForm,
]); ]);
} }



+ 1
- 1
backend/models/MailForm.php View File

foreach($usersArray as $user) { foreach($usersArray as $user) {
$body['Messages'][] = [ $body['Messages'][] = [
'From' => [ 'From' => [
'Email' => "contact@laboiteapain.net",
'Email' => $producer->slug.'@laboiteapain.net',
'Name' => $producer->name 'Name' => $producer->name
], ],
'To' => [ 'To' => [

+ 1
- 1
backend/views/user/index.php View File

</li> </li>
</ul> </ul>


<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail', 'idPointSale' => $idPointSaleActive], ['class' => 'btn btn-default btn-liste-emails']) ?>
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Envoyer un email', ['mail', 'idPointSale' => $idPointSaleActive], ['class' => 'btn btn-default btn-liste-emails']) ?>
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,

Loading…
Cancel
Save