mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-25 18:17:28 +02:00
Validation paiements
This commit is contained in:
@ -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";
|
||||
|
Reference in New Issue
Block a user