Преглед изворни кода

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

feature/souke
Guillaume Bourgeois пре 1 година
родитељ
комит
6aa9b0575b
2 измењених фајлова са 27 додато и 18 уклоњено
  1. +5
    -2
      backend/controllers/UserController.php
  2. +22
    -16
      common/logic/Payment/Service/PaymentNotifier.php

+ 5
- 2
backend/controllers/UserController.php Прегледај датотеку

@@ -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 Прегледај датотеку

@@ -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…
Откажи
Сачувај