Guillaume Bourgeois hace 5 años
padre
commit
9081ed7248
Se han modificado 3 ficheros con 19 adiciones y 3 borrados
  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 Ver fichero

@@ -39,6 +39,8 @@ termes.
namespace backend\controllers;

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

/**
* UserController implements the CRUD actions for User model.
@@ -234,11 +236,25 @@ class UserController extends BackendController
if($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', [
'usersArray' => $usersArray,
'pointsSaleArray' => $pointsSaleArray,
'pointSale' => $pointSale
'pointSale' => $pointSale,
'mailForm' => $mailForm,
]);
}


+ 1
- 1
backend/models/MailForm.php Ver fichero

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

+ 1
- 1
backend/views/user/index.php Ver fichero

@@ -62,7 +62,7 @@ $this->addButton(['label' => '+', 'url' => 'user/create', 'class' => 'btn btn-pr
</li>
</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([
'dataProvider' => $dataProvider,

Cargando…
Cancelar
Guardar