Selaa lähdekoodia

[Administration] Utilisateurs > Crédit : problème envoi mail lors de l'ajout de crédit si email vide #1257

feature/souke
Guillaume Bourgeois 1 vuosi sitten
vanhempi
commit
6aa9b0575b
2 muutettua tiedostoa jossa 27 lisäystä ja 18 poistoa
  1. +5
    -2
      backend/controllers/UserController.php
  2. +22
    -16
      common/logic/Payment/Service/PaymentNotifier.php

+ 5
- 2
backend/controllers/UserController.php Näytä tiedosto

@@ -402,14 +402,17 @@ class UserController extends BackendController
if ($creditForm->load(\Yii::$app->request->post()) && $creditForm->validate()) {

$paymentContainer->getUtils()
->creditOrDebitUser($creditForm->type, $user, $creditForm->amount, $creditForm->mean_payment, $user);
->creditOrDebitUser($creditForm->type, $user, $creditForm->amount, $creditForm->mean_payment, $this->getUserCurrent());

if($creditForm->send_mail) {
$paymentContainer->getNotifier()
->notifyUserCreditMovement($user, $creditForm->type, $creditForm->amount);
if(!$user->email) {
$this->addFlash('error', "L'utilisateur n'a pas pu être prévenu car son adresse email n'est pas définie.");
}
}

$this->setFlash('success', 'Crédit mis à jour.');
$this->addFlash('success', 'Crédit mis à jour.');

return $this->refresh();
}

+ 22
- 16
common/logic/Payment/Service/PaymentNotifier.php Näytä tiedosto

@@ -18,21 +18,27 @@ class PaymentNotifier extends AbstractNotifier

public function notifyUserCreditMovement(User $user, string $type, float $amount)
{
$producer = $this->getProducerContext();
$credit = $this->userRepository->getCredit($user, true);

$this->mailer->sendFromProducer(
'Mouvement de crédit',
'creditUser',
[
'user' => $user,
'producer' => $producer,
'credit' => $credit,
'type' => $type,
'amount' => $amount
],
$user->email,
$producer
);
if($user->email) {
$producer = $this->getProducerContext();
$credit = $this->userRepository->getCredit($user, true);

$this->mailer->sendFromProducer(
'Mouvement de crédit',
'creditUser',
[
'user' => $user,
'producer' => $producer,
'credit' => $credit,
'type' => $type,
'amount' => $amount
],
$user->email,
$producer
);

return true;
}

return false;
}
}

Loading…
Peruuta
Tallenna