mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 05:42:23 +00:00
Page de paiement (en cours)
This commit is contained in:
parent
69c453c408
commit
d81ad02235
@ -1,18 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="tfjm@galaxyoyo.com" uuid="ce243a48-c634-4134-8105-e68ea53cd5ed">
|
||||
<data-source source="LOCAL" name="tfjm@ynerant.fr" uuid="ce243a48-c634-4134-8105-e68ea53cd5ed">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://galaxyoyo.com:3306/tfjm</jdbc-url>
|
||||
<jdbc-url>jdbc:mysql://ynerant.fr:3306/tfjm</jdbc-url>
|
||||
<driver-properties>
|
||||
<property name="autoReconnect" value="true" />
|
||||
<property name="zeroDateTimeBehavior" value="CONVERT_TO_NULL" />
|
||||
<property name="tinyInt1isBit" value="false" />
|
||||
<property name="characterEncoding" value="utf8" />
|
||||
<property name="characterSetResults" value="utf8" />
|
||||
<property name="yearIsDateType" value="false" />
|
||||
<property name="serverTimezone" value="GMT+1" />
|
||||
</driver-properties>
|
||||
<time-zone>GMT+1</time-zone>
|
||||
|
@ -2,13 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" autoUpload="Always" serverName="inscription.tfjm.org" autoUploadExternalChanges="true">
|
||||
<serverData>
|
||||
<paths name="galaxyoyo.com">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping deploy="/tfjm" local="$PROJECT_DIR$" web="/tfjm" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="inscription.tfjm.org">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
@ -16,6 +9,13 @@
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="ynerant.fr">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping deploy="/var/www/html/tfjm" local="$PROJECT_DIR$" web="/tfjm" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
<option name="myAutoUpload" value="ALWAYS" />
|
||||
</component>
|
||||
|
@ -2,14 +2,17 @@
|
||||
|
||||
class PaymentMethod
|
||||
{
|
||||
const CREDIT_CARD = 0;
|
||||
const BANK_CHECK = 1;
|
||||
const BANK_TRANSFER = 2;
|
||||
const CASH = 3;
|
||||
const SCHOLARSHIP = 4;
|
||||
const CREDIT_CARD = 1;
|
||||
const BANK_CHECK = 2;
|
||||
const BANK_TRANSFER = 3;
|
||||
const CASH = 4;
|
||||
const SCHOLARSHIP = 5;
|
||||
const NOT_PAID = 0;
|
||||
|
||||
public static function getTranslatedName($status) {
|
||||
switch ($status) {
|
||||
case self::CREDIT_CARD:
|
||||
return "Carte bancaire";
|
||||
case self::BANK_CHECK:
|
||||
return "Chèque";
|
||||
case self::BANK_TRANSFER:
|
||||
@ -19,12 +22,14 @@ class PaymentMethod
|
||||
case self::SCHOLARSHIP:
|
||||
return "Je suis boursier";
|
||||
default:
|
||||
return "Carte bancaire";
|
||||
return "Pas encore payé";
|
||||
}
|
||||
}
|
||||
|
||||
public static function getName($status) {
|
||||
switch ($status) {
|
||||
case self::CREDIT_CARD:
|
||||
return "CREDIT_CARD";
|
||||
case self::BANK_CHECK:
|
||||
return "BANK_CHECK";
|
||||
case self::BANK_TRANSFER:
|
||||
@ -34,12 +39,14 @@ class PaymentMethod
|
||||
case self::SCHOLARSHIP:
|
||||
return "SCHOLARSHIP";
|
||||
default:
|
||||
return "CREDIT_CARD";
|
||||
return "NOT_PAID";
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromName($name) {
|
||||
switch ($name) {
|
||||
case "CREDIT_CARD":
|
||||
return self::CREDIT_CARD;
|
||||
case "BANK_CHECK":
|
||||
return self::BANK_CHECK;
|
||||
case "BANK_TRANSFER":
|
||||
@ -49,7 +56,7 @@ class PaymentMethod
|
||||
case "SCHOLARSHIP":
|
||||
return self::SCHOLARSHIP;
|
||||
default:
|
||||
return self::CREDIT_CARD;
|
||||
return self::NOT_PAID;
|
||||
}
|
||||
}
|
||||
}
|
@ -110,6 +110,14 @@ class Team
|
||||
return $this->tournament;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tournament
|
||||
*/
|
||||
public function getEffectiveTournament()
|
||||
{
|
||||
return $this->isSelectedForFinal() ? Tournament::getFinalTournament() : Tournament::fromId($this->getTournamentId());
|
||||
}
|
||||
|
||||
public function setTournamentId($tournament)
|
||||
{
|
||||
global $DB;
|
||||
|
@ -422,6 +422,22 @@ class User
|
||||
return $docs;
|
||||
}
|
||||
|
||||
public function getPayment() {
|
||||
global $DB;
|
||||
|
||||
$team = Team::fromId($this->team_id);
|
||||
$tournament = $team->getEffectiveTournament();
|
||||
|
||||
$req = $DB->prepare("SELECT `id` FROM `payments` WHERE `user` = ? AND `tournament` = ?;");
|
||||
$req->execute([$this->id, $tournament->getId()]);
|
||||
|
||||
if (($data = $req->fetch()) !== false)
|
||||
return Payment::fromId($data["id"]);
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `payments`(`user`, `tournament`, `amount`, `method`, `transaction_infos`, `validation_status`) VALUES (?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$this->id, $tournament->getId(), 0, PaymentMethod::getName(PaymentMethod::NOT_PAID), "L'inscription n'est pas encore payée.", ValidationStatus::getName(ValidationStatus::NOT_READY)]);
|
||||
}
|
||||
|
||||
public function getOrganizedTournaments()
|
||||
{
|
||||
global $DB;
|
||||
|
@ -1,2 +1,16 @@
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION["user_id"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
|
||||
require_once "server_files/403.php";
|
||||
|
||||
/**
|
||||
* @var User $user
|
||||
* @var Team $team
|
||||
* @var Tournament $tournament
|
||||
*/
|
||||
$user = $_SESSION["user"];
|
||||
$team = $_SESSION["team"];
|
||||
$tournament = $team->getEffectiveTournament();
|
||||
$payment = $user->getPayment();
|
||||
|
||||
require_once "server_files/views/paiement.php";
|
@ -7,4 +7,36 @@ require_once "header.php"
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
if ($payment->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||
<div class="alert alert-danger">
|
||||
Il faut payer maintenant.
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<form method="POST">
|
||||
<label for="method"><strong>Mode de paiement :</strong></label>
|
||||
<select class="custom-select" id="method" name="method">
|
||||
<?php
|
||||
for ($method = PaymentMethod::NOT_PAID; $method <= PaymentMethod::SCHOLARSHIP; ++$method) { ?>
|
||||
<option value="<?= strtolower(PaymentMethod::getName($method)) ?>"><?= PaymentMethod::getTranslatedName($method) ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<label for="infos"><strong>Informations sur le paiement :</strong></label>
|
||||
<textarea class="form-control" name="infos" id="infos"></textarea>
|
||||
<label for="scholarship"><strong>Notification de bourse :</strong></label>
|
||||
<input type="file" class="form-control" name="scholarship" id="scholarship" />
|
||||
<input class="btn btn-primary btn-block" type="submit" name="pay" value="Envoyer" />
|
||||
</form>
|
||||
</div>
|
||||
<?php } else if ($payment->getValidationStatus() == ValidationStatus::WAITING) { ?>
|
||||
<div class="alert alert-warning">
|
||||
Votre paiement est en attente de validation.
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="alert alert-success">
|
||||
Votre paiement de <?= $payment->getAmount() ?> a bien été validé.
|
||||
</div>
|
||||
<?php }
|
||||
|
||||
require_once "footer.php";
|
Loading…
Reference in New Issue
Block a user