Validation paiements
This commit is contained in:
parent
4b6d6f24ea
commit
b86675ba98
|
@ -16,6 +16,12 @@ if ($user === null)
|
|||
|
||||
$team = Team::fromId($user->getTeamId());
|
||||
|
||||
if ($team != null) {
|
||||
$documents = $user->getAllDocuments($team->getTournamentId());
|
||||
$payment = $user->getPayment();
|
||||
$tournament = Tournament::fromId($team->getTournamentId());
|
||||
}
|
||||
|
||||
$has_error = false;
|
||||
$error_message = null;
|
||||
|
||||
|
@ -41,6 +47,17 @@ if (isset($_POST["attribute_team"])) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_POST["validate_payment"])) {
|
||||
$validate_payment = new ValidatePayment($_POST);
|
||||
try {
|
||||
$validate_payment->makeVerifications();
|
||||
$validate_payment->validate();
|
||||
} catch (AssertionError $e) {
|
||||
$has_error = true;
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST["view_as"]) && $_SESSION["role"] == Role::ADMIN) {
|
||||
if (!isset($_SESSION["admin"]))
|
||||
$_SESSION["admin"] = $_SESSION["user_id"];
|
||||
|
@ -109,7 +126,39 @@ class AttributeTeam
|
|||
}
|
||||
}
|
||||
|
||||
if ($team != null)
|
||||
$documents = $user->getAllDocuments($team->getTournamentId());
|
||||
class ValidatePayment
|
||||
{
|
||||
private $accept, $reject;
|
||||
private $message;
|
||||
private $payment;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
global $user;
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
$this->$key = $value;
|
||||
|
||||
$this->payment = $user->getPayment();
|
||||
}
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
ensure($this->payment->getValidationStatus() == ValidationStatus::WAITING, "Le paiement n'était pas en attente.");
|
||||
ensure(isset($this->accept) ^ isset($this->reject), "La sélection de validation est invalide.");
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
global $user, $team, $tournament;
|
||||
|
||||
if ($this->accept)
|
||||
$this->payment->setValidationStatus(ValidationStatus::VALIDATED);
|
||||
else
|
||||
$this->payment->setValidationStatus(ValidationStatus::NOT_READY);
|
||||
|
||||
Mailer::sendValidatePayment($user, $team, $tournament, $this->payment, $this->message);
|
||||
}
|
||||
}
|
||||
|
||||
require_once "server_files/views/informations.php";
|
||||
|
|
|
@ -11,6 +11,7 @@ if (!isset($_SESSION["user_id"]))
|
|||
$user = $_SESSION["user"];
|
||||
$team = $_SESSION["team"];
|
||||
|
||||
if ($team != null)
|
||||
$tournament = Tournament::fromId($team->getTournamentId());
|
||||
|
||||
$has_error = false;
|
||||
|
@ -208,8 +209,10 @@ class SendDocument
|
|||
}
|
||||
}
|
||||
|
||||
if ($team != null) {
|
||||
$documents = $user->getAllDocuments($team->getTournamentId());
|
||||
if ($team->isSelectedForFinal())
|
||||
$documents_final = $user->getAllDocuments($FINAL->getId());
|
||||
}
|
||||
|
||||
require_once "server_files/views/mon_compte.php";
|
||||
|
|
|
@ -127,4 +127,47 @@ class Mailer
|
|||
|
||||
self::sendMail($organizer->getEmail(), "Ajout d'un organisateur pour le tournoi " . $tournament->getName() . " – TFJM² $YEAR", $content);
|
||||
}
|
||||
|
||||
public static function requestPaymentValidation(User $user, Team $team, Tournament $tournament, Payment $payment)
|
||||
{
|
||||
global $YEAR, $URL_BASE;
|
||||
|
||||
$content = self::getTemplate("request_payment_validation");
|
||||
$content = preg_replace("#{USER_FIRST_NAME}#", $user->getFirstName(), $content);
|
||||
$content = preg_replace("#{USER_SURNAME}#", $user->getSurname(), $content);
|
||||
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
|
||||
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
|
||||
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
|
||||
$content = preg_replace("#{AMOUNT}#", $payment->getAmount(), $content);
|
||||
$content = preg_replace("#{PAYMENT_METHOD}#", PaymentMethod::getTranslatedName($payment->getMethod()), $content);
|
||||
if ($payment->getMethod() == PaymentMethod::SCHOLARSHIP)
|
||||
$content = preg_replace("#{PAYMENT_INFOS}#", "<a href=\"$URL_BASE/file/" . $payment->getTransactionInfos() . "\">Voir la notification de bourse</a>", $content);
|
||||
else
|
||||
$content = preg_replace("#{PAYMENT_INFOS}#", $payment->getTransactionInfos(), $content);
|
||||
|
||||
self::sendMail($user->getEmail(), "Demande de validation de paiement pour le tournoi " . $tournament->getName() . " – TFJM² $YEAR", $content);
|
||||
}
|
||||
|
||||
public static function sendValidatePayment(User $user, Team $team, Tournament $tournament, Payment $payment, $message)
|
||||
{
|
||||
global $YEAR, $URL_BASE;
|
||||
|
||||
$content = self::getTemplate($payment->getValidationStatus() == ValidationStatus::VALIDATED ? "validate_payment" : "unvalidate_payment");
|
||||
$content = preg_replace("#{FIRST_NAME}#", $user->getFirstName(), $content);
|
||||
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
|
||||
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
|
||||
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
|
||||
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
|
||||
$content = preg_replace("#{AMOUNT}#", $payment->getAmount(), $content);
|
||||
$content = preg_replace("#{PAYMENT_METHOD}#", PaymentMethod::getTranslatedName($payment->getMethod()), $content);
|
||||
if ($payment->getMethod() == PaymentMethod::SCHOLARSHIP)
|
||||
$content = preg_replace("#{PAYMENT_INFOS}#", "<a href=\"$URL_BASE/file/" . $payment->getTransactionInfos() . "\">Voir la notification de bourse</a>", $content);
|
||||
else
|
||||
$content = preg_replace("#{PAYMENT_INFOS}#", $payment->getTransactionInfos(), $content);
|
||||
if (isset($message) && strlen($message) > 0) {
|
||||
$content = preg_replace("#{MESSAGE}#", "L'équipe d'organisation vous transmet les informations suivantes :<br /><br />" . $message . "<br />", $content);
|
||||
}
|
||||
|
||||
self::sendMail($user->getEmail(), "Paiement pour le tournoi " . $tournament->getName() . " – TFJM² $YEAR", $content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Non-validation du paiement pour le TFJM² {YEAR}</title>
|
||||
</head>
|
||||
<body>
|
||||
Bonjour {FIRST_NAME} {SURNAME},<br />
|
||||
<br />
|
||||
Votre paiement pour le TFJM² {YEAR} a malheureusement été rejeté. Pour rappel, vous aviez fourni ces informations :<br /><br />
|
||||
<strong>Équipe :</strong> {TEAM_NAME} ({TRIGRAM})<br />
|
||||
<strong>Tournoi :</strong> {TOURNAMENT_NAME}<br />
|
||||
<strong>Moyen de paiement :</strong> {PAYMENT_METHOD}<br />
|
||||
<strong>Montant :</strong> {AMOUNT} €<br />
|
||||
<strong>Informations sur le paiement :</strong> {PAYMENT_INFOS}<br />
|
||||
<br />
|
||||
{MESSAGE}
|
||||
<br />
|
||||
Cordialement,
|
||||
<br />
|
||||
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Validation du paiement pour le TFJM² {YEAR}</title>
|
||||
</head>
|
||||
<body>
|
||||
Bonjour {FIRST_NAME} {SURNAME},<br />
|
||||
<br />
|
||||
Votre paiement pour le TFJM² {YEAR} a bien été validé. Pour rappel, vous aviez fourni ces informations :<br /><br />
|
||||
<strong>Équipe :</strong> {TEAM_NAME} ({TRIGRAM})<br />
|
||||
<strong>Tournoi :</strong> {TOURNAMENT_NAME}<br />
|
||||
<strong>Moyen de paiement :</strong> {PAYMENT_METHOD}<br />
|
||||
<strong>Montant :</strong> {AMOUNT} €<br />
|
||||
<strong>Informations sur le paiement :</strong> {PAYMENT_INFOS}<br />
|
||||
<br />
|
||||
{MESSAGE}
|
||||
<br />
|
||||
Cordialement,
|
||||
<br />
|
||||
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||
</body>
|
||||
</html>
|
|
@ -14,9 +14,12 @@ if (!$has_error) {
|
|||
<div class="alert alert-success">
|
||||
La personne a bien rejoint l'équipe !
|
||||
</div>
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
<?php } elseif (isset($validate_payment)) { ?>
|
||||
<div class="alert alert-success">
|
||||
La paiement a bien été validé / rejeté ! Un mail a été transmis au participant.
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<strong>Rôle :</strong> <?= Role::getTranslatedName($user->getRole()) ?>
|
||||
|
@ -101,6 +104,49 @@ if (!$has_error) {
|
|||
Adresse e-mail du responsable légal : <a href="mailto:<?= $user->getResponsibleEmail() ?>"><?= $user->getResponsibleEmail() ?></a>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<strong>Récapitulatif du paiement :</strong><br /><br />
|
||||
|
||||
<?php if ($payment->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||
<div class="alert alert-danger">
|
||||
Cette personne n'a pas encore payé sa participation.
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<strong>Tournoi :</strong> <?= $tournament->getName() ?><br />
|
||||
<strong>Montant :</strong> <?= $payment->getAmount() ?> €<br />
|
||||
<strong>Moyen de paiement :</strong> <?= PaymentMethod::getTranslatedName($payment->getMethod()) ?><br />
|
||||
<?php if ($payment->getMethod() == PaymentMethod::SCHOLARSHIP) { ?>
|
||||
<strong>Notification de bourse :</strong> <a href="/file/<?= $payment->getTransactionInfos() ?>">Télécharger</a><br /><br />
|
||||
<?php } else { ?>
|
||||
<strong>Informations sur le paiement :</strong> <?= $payment->getTransactionInfos() ?><br /><br />
|
||||
<?php }
|
||||
|
||||
if ($payment->getValidationStatus() == ValidationStatus::WAITING) { ?>
|
||||
<div class="alert alert-warning">
|
||||
Le paiement n'a pas encore été validé.
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="validate_payment" value=""/>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="message">Message à adresser au participant :</label>
|
||||
<textarea class="form-control" id="message" name="message"></textarea>
|
||||
</div>
|
||||
|
||||
<input class="btn btn-primary btn-lg" style="width: 49%;"
|
||||
type="submit" name="accept" value="Valider le paiement"/>
|
||||
<input class="btn btn-light btn-lg" style="width: 49%;" type="submit" name="reject"
|
||||
value="Rejeter le paiement"/>
|
||||
</form>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="alert alert-success">
|
||||
Le paiement a été validé.
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php } elseif ($user->getDescription() != "") { ?>
|
||||
<div class="alert alert-info">
|
||||
Description : <?= $user->getDescription() ?>
|
||||
|
|
Loading…
Reference in New Issue