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

Adhérent terminé.

parent 0bf490d7
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,15 @@ class ControleurAdherent
public static function lireAdherents()
{
$adherents = Adherent::getAllAdherents();
return view('adherents.liste-adherents', ['adherents' => $adherents]);
return view('adherents.les-adherents', ['adherents' => $adherents]);
}
public static function lireAdherent()
{
if (empty($_GET["login"])) {
die("Le paramètre login n'est pas spécifié.");
}
$adherent = Adherent::getAdherentByLogin($_GET["login"]);
return view('adherents.un-adherent', ['adherent' => $adherent]);
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ class ControleurAuteur
public static function lireAuteurs()
{
$auteurs = Auteur::getAllAuteurs();
return view('auteurs.liste-auteurs', ['auteurs' => $auteurs]);
return view('auteurs.les-auteurs', ['auteurs' => $auteurs]);
}
public static function lireAuteur()
......@@ -15,7 +15,7 @@ class ControleurAuteur
die("Le paramètre numAuteur n'est pas spécifié.");
}
$auteur = Auteur::getAuteurByNum($_GET["numAuteur"]);
return view('auteurs.auteur-info', ['auteur' => $auteur]);
return view('auteurs.un-auteur', ['auteur' => $auteur]);
}
}
......
......@@ -33,15 +33,6 @@ 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
......@@ -65,6 +56,35 @@ class Adherent
return $tableau;
}
public static function getAdherentByLogin($login) : Adherent
{
// écriture de la requête
$requetePreparee = "SELECT * FROM Adherent WHERE login = :login;";
$req_prep = Database::pdo()->prepare($requetePreparee);
// le tableau des valeurs
$valeurs = array("login" => $login);
$response = null;
try {
// envoi de la requête
$req_prep->execute($valeurs);
// traitement de la réponse
$req_prep->setFetchmode(PDO::FETCH_ASSOC);
// récupération de l'auteur
$row = $req_prep->fetch();
$response = new Adherent($row['login'],
$row['mdp'],
$row['nomAdherent'],
$row['prenomAdherent'],
$row['email'],
new DateTime($row['dateAdhesion']),
$row['numCategorie']);
} catch (PDOException $e) {
echo $e->getMessage();
}
return $response;
}
/**
* @return string
*/
......
......@@ -39,18 +39,20 @@ class Auteur
$req_prep = Database::pdo()->prepare($requetePreparee);
// le tableau des valeurs
$valeurs = array("num_tag" => $numAuteur);
$response = null;
try {
// envoi de la requête
$req_prep->execute($valeurs);
// traitement de la réponse
$req_prep->setFetchmode(PDO::FETCH_CLASS, 'Auteur');
// récupération de l'auteur
$a = $req_prep->fetch();
$response = $req_prep->fetch();
// retour
return $a;
} catch (PDEException $e) {
} catch (PDOException $e) {
echo $e->getMessage();
}
return $response;
}
public function getNumAuteur()
......
......@@ -2,7 +2,7 @@
<head>
<meta charset="utf-8">
<title>Liste des adhérents</title>
<?=view('layouts.head')?>
<?=view('components.head')?>
</head>
<body class="">
<div class="container">
......@@ -16,7 +16,7 @@
<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()?>">
href="index.php?action=lireAdherent&login=<?=$adherent->getLogin()?>">
Lire les détails
</a>
</div>
......@@ -24,6 +24,6 @@
<?php } ?>
</div>
</div>
<?=view('layouts.footer')?>
<?=view('components.footer')?>
</body>
</html>
\ No newline at end of file
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Info de l'adhérent</title>
<?=view('components.head')?>
</head>
<body class="">
<div class="container">
<h1>Information de l'adhérent</h1>
<?=$adherent->afficher()?>
</div>
<?=view('components.footer')?>
</body>
</html><?php
\ No newline at end of file
......@@ -2,7 +2,7 @@
<head>
<meta charset="utf-8">
<title>Liste des auteurs</title>
<?=view('layouts.head')?>
<?=view('components.head')?>
</head>
<body class="">
<div class="container">
......@@ -16,7 +16,7 @@
<p class="card-text">ID: <?=$auteur->getNumAuteur()?><br>
Date de naissance: <?=$auteur->getAnneeNaissance()?></p>
<a class="btn btn-primary"
href="index.php?controller=controleurAuteur&action=lireAuteur&numAuteur=<?=$auteur->getNumAuteur()?>">
href="index.php?action=lireAuteur&numAuteur=<?=$auteur->getNumAuteur()?>">
Lire les détails
</a>
</div>
......@@ -24,6 +24,6 @@
<?php } ?>
</div>
</div>
<?=view('layouts.footer')?>
<?=view('components.footer')?>
</body>
</html>
\ No newline at end of file
......@@ -2,13 +2,13 @@
<head>
<meta charset="utf-8">
<title>Info de l'auteur</title>
<?=view('layouts.head')?>
<?=view('components.head')?>
</head>
<body class="">
<div class="container">
<h1>Information de l'auteur</h1>
<?=$auteur->afficher()?>
</div>
<?=view('layouts.footer')?>
<?=view('components.footer')?>
</body>
</html><?php
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment