Sfoglia il codice sorgente

Gestion problèmes de récption des emails

feature/rotating_product
Guillaume 5 mesi fa
parent
commit
871aa55d31
8 ha cambiato i file con 131 aggiunte e 22 eliminazioni
  1. +14
    -0
      backend/controllers/UserController.php
  2. +11
    -0
      backend/views/user/_form.php
  3. +12
    -1
      backend/views/user/index.php
  4. +26
    -0
      console/migrations/m240611_091617_add_column_user_problem_receiving_emails.php
  5. +16
    -2
      domain/User/User/User.php
  6. +6
    -1
      domain/User/User/UserManager.php
  7. +13
    -0
      producer/controllers/NewsletterController.php
  8. +33
    -18
      producer/views/newsletter/index.php

+ 14
- 0
backend/controllers/UserController.php Vedi File

@@ -258,6 +258,20 @@ class UserController extends BackendController
]));
}

public function actionReportProblemReceivingEmails(int $id)
{
$user = $this->findModel($id);

if($this->getUserModule()->getManager()->reportProblemReceivingEmails($user)) {
$this->setFlash('success', "L'utilisateur <strong>".$this->getUserModule()->getSolver()->getUsername($user)."</strong> a bien été signalé comme ayant des problèmes dans la réception de vos emails. L'administrateur débloquera la situation dès que possible et préviendra l'utilisateur.");
}
else {
$this->setFlash('error', "Une erreur est survenue.");
}

return $this->redirect('index');
}

public function initForm($model)
{
$userPointSaleModule = $this->getUserPointSaleModule();

+ 11
- 0
backend/views/user/_form.php Vedi File

@@ -183,6 +183,17 @@ $distributionModule = DistributionModule::getInstance();
],
]
); ?>
<?= $form->field($model, 'problem_receiving_emails')->widget(Toggle::class,
[
'options' => [
'data-id' => $model->id,
'data-on' => 'Oui',
'data-off' => 'Non',
'data-onstyle' => 'danger',
'data-offstyle' => 'success',
],
]
); ?>
<?php endif; ?>
</div>
</div>

+ 12
- 1
backend/views/user/index.php Vedi File

@@ -199,10 +199,11 @@ $this->render('_menu_filter', [
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}
'template' => '{view} {update}
<div class="wrapper-button-dropdown">
<button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-default dropdown-toggle"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li>{problemReceivingEmails}</li>
<li>{delete}</li>
<li>{switch}</li>
</ul></div>',
@@ -225,6 +226,16 @@ $this->render('_menu_filter', [
'class' => 'btn btn-default'
]);
},
'problemReceivingEmails' => function($url, $model) use ($userModule, $userCurrent) {
if(!$model->getProblemReceivingEmails()) {
return Html::a('<i class="fa fa-life-ring"></i> Réception emails',
Yii::$app->urlManager->createUrl(['user/report-problem-receiving-emails', 'id' => $model->id]),
[
'title' => 'Signaler comme ayant des problèmes de réception des emails',
'class' => ''
]);
}
},
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-minus"></span> Enlever',
Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())),

+ 26
- 0
console/migrations/m240611_091617_add_column_user_problem_receiving_emails.php Vedi File

@@ -0,0 +1,26 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m240611_091617_add_column_user_problem_receiving_emails
*/
class m240611_091617_add_column_user_problem_receiving_emails extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user', 'problem_receiving_emails', Schema::TYPE_BOOLEAN);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('user', 'problem_receiving_emails');
}
}

+ 16
- 2
domain/User/User/User.php Vedi File

@@ -108,7 +108,7 @@ class User extends ActiveRecordCommon implements IdentityInterface
[['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday',
'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday',
'mail_distribution_sunday', 'is_main_contact', 'newsletter', 'exclude_export_shopping_cart_labels',
'send_mail_welcome', 'trust_alert', 'newsletter_souke'], 'boolean'],
'send_mail_welcome', 'trust_alert', 'newsletter_souke', 'problem_receiving_emails'], 'boolean'],
[['lastname', 'name', 'phone', 'address', 'type', 'name_legal_person', 'evoliz_code', 'trust_alert_comment'], 'string'],
['lastname', 'verifyOneName', 'skipOnError' => false, 'skipOnEmpty' => false],
[['email', 'email_sending_invoicing_documents'], 'email', 'message' => 'Cette adresse email n\'est pas valide'],
@@ -157,7 +157,8 @@ class User extends ActiveRecordCommon implements IdentityInterface
'email_sending_invoicing_documents' => 'Email facturation',
'trust_alert' => 'Alerte confiance',
'trust_alert_comment' => 'Commentaire',
'newsletter_souke' => "S'abonner à l'infolettre de Souke"
'newsletter_souke' => "S'abonner à l'infolettre de Souke",
'problem_receiving_emails' => "Rencontre des problèmes pour recevoir les emails"
];
}

@@ -247,6 +248,19 @@ class User extends ActiveRecordCommon implements IdentityInterface
}
}

/* Getters / Setters */

public function getProblemReceivingEmails(): ?bool
{
return $this->problem_receiving_emails;
}

public function setProblemReceivingEmails(bool $problemReceivingEmails = null): self
{
$this->problem_receiving_emails = $problemReceivingEmails;
return $this;
}

/*
* Relations
*/

+ 6
- 1
domain/User/User/UserManager.php Vedi File

@@ -19,7 +19,6 @@ class UserManager extends AbstractManager
{
$password = $this->userBuilder->generatePassword($user);
$this->userNotifier->sendMailWelcome($user, $password);

}

public function newPassword(User $user)
@@ -27,4 +26,10 @@ class UserManager extends AbstractManager
$password = $this->userBuilder->generatePassword($user);
$this->userNotifier->sendMailNewPassword($user, $password);
}

public function reportProblemReceivingEmails(User $user): bool
{
$user->setProblemReceivingEmails(true);
return $this->userBuilder->update($user);
}
}

+ 13
- 0
producer/controllers/NewsletterController.php Vedi File

@@ -85,6 +85,19 @@ class NewsletterController extends ProducerBaseController
return $this->redirect('index');
}

public function actionReportProblemReceivingEmails()
{
if(!$this->getUserCurrent()) {
return $this->redirectProducerLoginFrontend('index');
}

if(!$this->getUserModule()->getManager()->reportProblemReceivingEmails($this->getUserCurrent())) {
$this->setFlash('error', "Une erreur est survenue.");
}

return $this->redirect('index');
}

public function redirectProducerLoginFrontend(string $actionNewsletter)
{
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $this->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['newsletter/'.$actionNewsletter, 'slug_producer' => $this->getProducerCurrent()->slug])]));

+ 33
- 18
producer/views/newsletter/index.php Vedi File

@@ -66,24 +66,39 @@ else {
?>
<div class="newsletter-index">

<div class="alert alert-info">
<i class="bi bi-info-circle"></i>
<?php if($producer->option_newsletter_description): ?>
<?= nl2br(Html::encode($producer->option_newsletter_description)); ?>
<?php else: ?>
L'infolettre vous permet de recevoir les emails de prise de commande et les actualités de ce producteur.
<?php endif; ?>
</div>

<?php if($userModule->isUserSubscribedNewsletter($user)): ?>
<div class="alert alert-success">
<i class="bi bi-megaphone"></i>
Vous êtes inscrit à l'infolettre <strong><?= Html::encode($producer->name) ?></strong>.
<div class="row">
<div class="col-md-8">
<div class="alert alert-info">
<i class="bi bi-info-circle"></i>
<?php if($producer->option_newsletter_description): ?>
<?= nl2br(Html::encode($producer->option_newsletter_description)); ?>
<?php else: ?>
L'infolettre vous permet de recevoir les emails de prise de commande et les actualités de ce producteur.
<?php endif; ?>
</div>
<?php if($userModule->isUserSubscribedNewsletter($user)): ?>
<div class="alert alert-success">
<i class="bi bi-megaphone"></i>
Vous êtes inscrit à l'infolettre <strong><?= Html::encode($producer->name) ?></strong>.
</div>
<?php else: ?>
<div class="alert alert-danger">
<i class="bi bi-x-circle"></i>
Vous n'êtes pas inscrit à l'infolettre <strong><?= Html::encode($producer->name) ?></strong>.
</div>
<?php endif; ?>
</div>
<?php else: ?>
<div class="alert alert-danger">
<i class="bi bi-x-circle"></i>
Vous n'êtes pas inscrit à l'infolettre <strong><?= Html::encode($producer->name) ?></strong>.
<div class="col-md-4">
<div class="alert alert-dark">
<i class="bi bi-life-preserver"></i>
<?php if(!$user->getProblemReceivingEmails()): ?>
Vous rencontrez des problèmes pour recevoir les emails de ce producteur ?
<a href="<?= Yii::$app->urlManager->createUrl('newsletter/report-problem-receiving-emails') ?>">Cliquez ici</a> pour nous prévenir.
<?php else: ?>
Nous avons bien été prévenu de vos difficultés à recevoir les emails de ce producteur,
nous reviendrons vers vous dès que possible.
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>

Loading…
Annulla
Salva