mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-26 05:02:23 +00:00
Préparation pour la prise en charge du paiement
This commit is contained in:
parent
da8efde057
commit
1c6c480d4c
@ -9,6 +9,8 @@ require_once "server_files/classes/Team.php";
|
|||||||
require_once "server_files/classes/Tournament.php";
|
require_once "server_files/classes/Tournament.php";
|
||||||
require_once "server_files/classes/User.php";
|
require_once "server_files/classes/User.php";
|
||||||
require_once "server_files/classes/ValidationStatus.php";
|
require_once "server_files/classes/ValidationStatus.php";
|
||||||
|
require_once "server_files/classes/PaymentMethod.php";
|
||||||
|
require_once "server_files/classes/Payment.php";
|
||||||
require_once "server_files/services/mail.php";
|
require_once "server_files/services/mail.php";
|
||||||
require_once "server_files/utils.php";
|
require_once "server_files/utils.php";
|
||||||
require_once "server_files/model.php";
|
require_once "server_files/model.php";
|
||||||
@ -41,7 +43,8 @@ $ROUTES["^inscription/?$"] = ["server_files/controllers/inscription.php"];
|
|||||||
$ROUTES["^mon-compte/?$"] = ["server_files/controllers/mon_compte.php"];
|
$ROUTES["^mon-compte/?$"] = ["server_files/controllers/mon_compte.php"];
|
||||||
$ROUTES["^mon-equipe/(modifier)/?$"] = ["server_files/controllers/mon_equipe.php", "modifier"];
|
$ROUTES["^mon-equipe/(modifier)/?$"] = ["server_files/controllers/mon_equipe.php", "modifier"];
|
||||||
$ROUTES["^mon-equipe/?$"] = ["server_files/controllers/mon_equipe.php"];
|
$ROUTES["^mon-equipe/?$"] = ["server_files/controllers/mon_equipe.php"];
|
||||||
$ROUTES["^organisateurs"] = ["server_files/controllers/organisateurs.php"];
|
$ROUTES["^organisateurs/?$"] = ["server_files/controllers/organisateurs.php"];
|
||||||
|
$ROUTES["^paiement/?$"] = ["server_files/controllers/paiement.php"];
|
||||||
$ROUTES["^profils/?$"] = ["server_files/controllers/profils.php"];
|
$ROUTES["^profils/?$"] = ["server_files/controllers/profils.php"];
|
||||||
$ROUTES["^profils-(orphelins)/?$"] = ["server_files/controllers/profils.php", "orphans"];
|
$ROUTES["^profils-(orphelins)/?$"] = ["server_files/controllers/profils.php", "orphans"];
|
||||||
$ROUTES["^rejoindre_equipe/?$"] = ["server_files/controllers/rejoindre_equipe.php"];
|
$ROUTES["^rejoindre_equipe/?$"] = ["server_files/controllers/rejoindre_equipe.php"];
|
||||||
|
142
server_files/classes/Payment.php
Normal file
142
server_files/classes/Payment.php
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Payment
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $user_id;
|
||||||
|
private $tournament_id;
|
||||||
|
private $amount;
|
||||||
|
private $method;
|
||||||
|
private $transaction_infos;
|
||||||
|
private $validation_status;
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
public static function fromId($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `payments` WHERE `id` = ?;");
|
||||||
|
$req->execute([htmlspecialchars($id)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$payment = new Payment();
|
||||||
|
$payment->fill($data);
|
||||||
|
return $payment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fill($data)
|
||||||
|
{
|
||||||
|
$this->id = $data["id"];
|
||||||
|
$this->user_id = $data["user"];
|
||||||
|
$this->tournament_id = $data["tournament"];
|
||||||
|
$this->amount = $data["amount"];
|
||||||
|
$this->method = PaymentMethod::fromName($data["method"]);
|
||||||
|
$this->transaction_infos = $data["transaction_infos"];
|
||||||
|
$this->validation_status = ValidationStatus::fromName($data["validation_status"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getAmount()
|
||||||
|
{
|
||||||
|
return $this->amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getMethod()
|
||||||
|
{
|
||||||
|
return $this->method;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $method
|
||||||
|
*/
|
||||||
|
public function setMethod($method)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->method = $method;
|
||||||
|
$DB->prepare("UPDATE `payments` SET `method` = ? WHERE `id` = ?;")->execute([PaymentMethod::getName($method), $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getTournamentId()
|
||||||
|
{
|
||||||
|
return $this->tournament_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Tournament|null
|
||||||
|
*/
|
||||||
|
public function getTournament()
|
||||||
|
{
|
||||||
|
return Tournament::fromId($this->getTournamentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getUserId()
|
||||||
|
{
|
||||||
|
return $this->user_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return User|null
|
||||||
|
*/
|
||||||
|
public function getUser()
|
||||||
|
{
|
||||||
|
return User::fromId($this->getUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTransactionInfos()
|
||||||
|
{
|
||||||
|
return $this->transaction_infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $transaction_infos
|
||||||
|
*/
|
||||||
|
public function setTransactionInfos($transaction_infos)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->transaction_infos = $transaction_infos;
|
||||||
|
$DB->prepare("UPDATE `payments` SET `transaction_infos` = ? WHERE `id` = ?;")->execute([$transaction_infos, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getValidationStatus()
|
||||||
|
{
|
||||||
|
return $this->validation_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $validation_status
|
||||||
|
*/
|
||||||
|
public function setValidationStatus($validation_status)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->validation_status = $validation_status;
|
||||||
|
$DB->prepare("UPDATE `payments` SET `$validation_status` = ? WHERE `id` = ?;")->execute([ValidationStatus::fromName($validation_status), $this->id]);
|
||||||
|
}
|
||||||
|
}
|
55
server_files/classes/PaymentMethod.php
Normal file
55
server_files/classes/PaymentMethod.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class PaymentMethod
|
||||||
|
{
|
||||||
|
const CREDIT_CARD = 0;
|
||||||
|
const BANK_CHECK = 1;
|
||||||
|
const BANK_TRANSFER = 2;
|
||||||
|
const CASH = 3;
|
||||||
|
const SCHOLARSHIP = 4;
|
||||||
|
|
||||||
|
public static function getTranslatedName($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::BANK_CHECK:
|
||||||
|
return "Chèque";
|
||||||
|
case self::BANK_TRANSFER:
|
||||||
|
return "Virement";
|
||||||
|
case self::CASH:
|
||||||
|
return "Espèce";
|
||||||
|
case self::SCHOLARSHIP:
|
||||||
|
return "Je suis boursier";
|
||||||
|
default:
|
||||||
|
return "Carte bancaire";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::BANK_CHECK:
|
||||||
|
return "BANK_CHECK";
|
||||||
|
case self::BANK_TRANSFER:
|
||||||
|
return "BANK_TRANSFER";
|
||||||
|
case self::CASH:
|
||||||
|
return "CASH";
|
||||||
|
case self::SCHOLARSHIP:
|
||||||
|
return "SCHOLARSHIP";
|
||||||
|
default:
|
||||||
|
return "CREDIT_CARD";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case "BANK_CHECK":
|
||||||
|
return self::BANK_CHECK;
|
||||||
|
case "BANK_TRANSFER":
|
||||||
|
return self::BANK_TRANSFER;
|
||||||
|
case "CASH":
|
||||||
|
return self::CASH;
|
||||||
|
case "SCHOLARSHIP":
|
||||||
|
return self::SCHOLARSHIP;
|
||||||
|
default:
|
||||||
|
return self::CREDIT_CARD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
server_files/controllers/paiement.php
Normal file
2
server_files/controllers/paiement.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
require_once "server_files/views/paiement.php";
|
@ -28,11 +28,13 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link" href="/tournois">Liste des tournois</a>
|
<a class="nav-link" href="/tournois">Liste des tournois</a>
|
||||||
<ul class="deroule">
|
<?php if ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER) { ?>
|
||||||
<li class="nav-item active"><a class="nav-link" href="/profils-orphelins">Profils orphelins</a></li>
|
<ul class="deroule">
|
||||||
<li class="nav-item active"><a class="nav-link" href="/profils">Tous les profils</a></li>
|
<li class="nav-item active"><a class="nav-link" href="/profils-orphelins">Profils orphelins</a></li>
|
||||||
<li class="nav-item active"><a class="nav-link" href="/organisateurs">Organisateurs</a></li>
|
<li class="nav-item active"><a class="nav-link" href="/profils">Tous les profils</a></li>
|
||||||
</ul>
|
<li class="nav-item active"><a class="nav-link" href="/organisateurs">Organisateurs</a></li>
|
||||||
|
</ul>
|
||||||
|
<?php } ?>
|
||||||
</li>
|
</li>
|
||||||
<?php if (isset($_SESSION["user_id"])) { ?>
|
<?php if (isset($_SESSION["user_id"])) { ?>
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
@ -52,7 +54,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::VALIDATED || true) { ?>
|
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::VALIDATED || true) { ?>
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link" href="https://paypal.me/galaxyoyo42">Paiement</a>
|
<a class="nav-link" href="/paiement">Paiement</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link" href="/solutions">Solutions</a>
|
<a class="nav-link" href="/solutions">Solutions</a>
|
||||||
|
10
server_files/views/paiement.php
Normal file
10
server_files/views/paiement.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php"
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="mt-4 mb-4">
|
||||||
|
<h1 class="display-4">Paiement</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once "footer.php";
|
Loading…
Reference in New Issue
Block a user