Skip to content
Snippets Groups Projects
Commit 0bf490d7 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

Liste adhérents terminée.

parent ce1e779f
Branches
No related tags found
No related merge requests found
<?php
class ControleurAdherants
{
}
\ No newline at end of file
<?php
require_once("models/Adherent.php");
class ControleurAdherent
{
public static function lireAdherents()
{
$adherents = Adherent::getAllAdherents();
return view('adherents.liste-adherents', ['adherents' => $adherents]);
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ error_reporting(E_ALL);
require_once("config/Database.php");
require_once("helpers/views.php");
require_once("controller/ControleurAuteur.php");
require_once("controller/ControleurAdherent.php");
Database::connect();
......@@ -15,6 +16,9 @@ if(empty($_GET["action"])){
if(in_array($_GET["action"], get_class_methods('ControleurAuteur'))){
$action = $_GET["action"];
ControleurAuteur::$action();
}elseif(in_array($_GET["action"], get_class_methods('ControleurAdherent'))){
$action = $_GET["action"];
ControleurAdherent::$action();
}
}
......
......@@ -33,6 +33,38 @@ class Adherent
$this->numCategorie = $numCategorie;
}
public function __set($property, $value){
echo "test";
if($property === "dateAdhesion"){
$this->dateAdhesion = new DateTime($value);
}else{
$this->$property = $value;
}
}
public static function getAllAdherents(): array
{
// écriture de la requête
$requete = "SELECT * FROM Adherent;";
// envoi de la requête et stockage de la réponse
$resultat = Database::pdo()->query($requete);
// traitement de la réponse
$resultat->setFetchmode(PDO::FETCH_ASSOC);
$resultat = $resultat->fetchAll();
$tableau = array();
foreach ($resultat as $row){
$tableau[] = new Adherent($row['login'],
$row['mdp'],
$row['nomAdherent'],
$row['prenomAdherent'],
$row['email'],
new DateTime($row['dateAdhesion']),
$row['numCategorie']);
}
return $tableau;
}
/**
* @return string
*/
......
......@@ -3,9 +3,9 @@
class Auteur
{
// attributs
private int $numAuteur;
private string $nom;
private string $prenom;
private ?int $numAuteur;
private ?string $nom;
private ?string $prenom;
private ?int $anneeNaissance;
// getter
......
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Liste des adhérents</title>
<?=view('layouts.head')?>
</head>
<body class="">
<div class="container">
<h1>Liste de tous les adhérents</h1>
<p>Voici la liste de tous les adhérents</p>
<div class="d-flex flex-wrap justify-content-between">
<?php foreach ($adherents as $adherent) { ?>
<div class="card mb-2" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title"><?=$adherent->getPrenomAdherent()?> <?=$adherent->getNomAdherent()?></h5>
<p class="card-text">ID: <?=$adherent->getLogin()?><br>
Date de naissance: <?=$adherent->getDateAdhesion()->format("Y-m-d")?></p>
<a class="btn btn-primary"
href="index.php?controller=controleurAuteur&action=lireAuteur&numAuteur=<?=$adherent->getLogin()?>">
Lire les détails
</a>
</div>
</div>
<?php } ?>
</div>
</div>
<?=view('layouts.footer')?>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment