page de connexion fonctionnelle avec bdd
This commit is contained in:
parent
85c00fde0a
commit
9f245f6578
@ -4,7 +4,6 @@ class Class_newFiche
|
||||
{
|
||||
private $pdo = null;
|
||||
|
||||
|
||||
public function __construct(PdoGsb $pDO)
|
||||
{
|
||||
$this->pdo = $pDO->getPdoGsb();
|
||||
|
31
Class/class.user.php
Normal file
31
Class/class.user.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* AJOUT COMPTABLE
|
||||
* INSERT INTO utilisateur
|
||||
* VALUES('cpt1', 'Renaudot', 'Pierre', 'pr07', 'pr', 'rue saint éloi', 21110, 'Marliens', NOW(), 3, 3, 4, 27, NOW(), NOW(), '120cv', 'essence')
|
||||
*/
|
||||
class Class_user
|
||||
{
|
||||
private $pdo = null;
|
||||
|
||||
public function __construct(PdoGsb $pDO)
|
||||
{
|
||||
$this->pdo = $pDO->getPdoGsb();
|
||||
}
|
||||
|
||||
public function connectUser(string $login, string $password): array
|
||||
{
|
||||
$req = 'SELECT "uId", "uNom", "uPrenom", "uAdresse", "uCp", "uVille", "uSecteur", "uLabo", "parametre"."pLibelle"
|
||||
FROM utilisateur
|
||||
INNER JOIN parametre ON "parametre"."pType" = \'statUti\'
|
||||
AND "utilisateur"."uStatut" = "parametre"."pIndice"
|
||||
WHERE "uLogin" = :login AND "uMdp" = :pwd ;';
|
||||
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam('login', $login);
|
||||
$result->bindParam('pwd', $password);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetch();
|
||||
}
|
||||
}
|
@ -1,12 +1,35 @@
|
||||
<?php
|
||||
// ***************************************'
|
||||
// Le CASTEL-BTS SIO/ PROJET PPE4 GSB '
|
||||
// Programme: c_connexion.php v2.0 '
|
||||
// Objet : gestion remboursements frais'
|
||||
// Client : laboratoires GSB '
|
||||
// Date : 03/05/2023 à 11H01 '
|
||||
// Auteur : pascal-blain@wanadoo.fr '
|
||||
//****************************************'
|
||||
require_once(__DIR__ . '/../Class/class.user.php');
|
||||
|
||||
$userClass = new Class_user($pdo);
|
||||
if (isset($_POST['login']) && isset($_POST['password'])) {
|
||||
//Récupère les données de l'utilisateur
|
||||
$data = $userClass->connectUser($_POST['login'], $_POST['password']);
|
||||
|
||||
//Si l'utilisateur existe ou pas
|
||||
if (count($data) === 0) {
|
||||
header('location: index.php?direction=connexion&msg=errorco');
|
||||
} else {
|
||||
$_SESSION['uId'] = $data['uId'];
|
||||
$_SESSION['uNom'] = $data['uNom'];
|
||||
$_SESSION['uPrenom'] = $data['uPrenom'];
|
||||
$_SESSION['uAdresse'] = $data['uAdresse'];
|
||||
$_SESSION['uCp'] = $data['uCp'];
|
||||
$_SESSION['uVille'] = $data['uVille'];
|
||||
$_SESSION['uSecteur'] = $data['uSecteur'];
|
||||
$_SESSION['uLabo'] = $data['uLabo'];
|
||||
$_SESSION['uType'] = $data['pLibelle'];
|
||||
|
||||
header('location: index.php?direction=home');
|
||||
}
|
||||
} else {
|
||||
header('location: index.php');
|
||||
}
|
||||
die;
|
||||
/*
|
||||
|
||||
|
||||
|
||||
header('location: index.php?direction=home');
|
||||
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
@ -44,7 +67,7 @@ switch ($action) {
|
||||
$leMoisPrecedent = (date('Y') - 1) * 100 + 12;
|
||||
}
|
||||
//penser ici à faire la cloture du mois précédent !
|
||||
if ($statut == 'V') /* si le remboursement pour le mois courant n'existe pas (=0) il faut le créer*/{
|
||||
if ($statut == 'V') // si le remboursement pour le mois courant n'existe pas (=0) il faut le créer{
|
||||
$leMois = date('Ym');
|
||||
$leRemboursement = $pdo->existeRemboursement($id, $leMois);
|
||||
if ($leRemboursement == 0) {
|
||||
@ -62,3 +85,4 @@ switch ($action) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
*/
|
||||
|
5
controleurs/c_deconnexion.php
Normal file
5
controleurs/c_deconnexion.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
|
||||
header('location: ../index.php');
|
@ -5,6 +5,8 @@ $newFiche = new Class_newFiche($pdo);
|
||||
|
||||
$_SESSION['userId'] = 'b34';
|
||||
$_SESSION['typeU'] = 'visiteur';
|
||||
$typeUser = $_SESSION['uType'];
|
||||
$userId = $_SESSION['uId'];
|
||||
$date = '202011';
|
||||
|
||||
/**
|
||||
@ -42,7 +44,7 @@ if (isset($_GET['currentList'])) {
|
||||
/**
|
||||
* Liste des frais forfaitaires du mois et de l'user :: sinon afficher les libelle
|
||||
*/
|
||||
$listeFraisForfaitaire = $newFiche->listFraisForfaitForU($_SESSION['userId'], $date);
|
||||
$listeFraisForfaitaire = $newFiche->listFraisForfaitForU($userId, $date);
|
||||
if (count($listeFraisForfaitaire) == 0) {
|
||||
$listeFraisForfaitaire = $newFiche->listFraisForfaitaires();
|
||||
}
|
||||
@ -50,11 +52,11 @@ if (count($listeFraisForfaitaire) == 0) {
|
||||
/**
|
||||
* Listes des frais HF
|
||||
*/
|
||||
$listeFraisHf = $newFiche->listFraisHF($_SESSION['userId'], $date);
|
||||
$listeFraisHf = $newFiche->listFraisHF($userId, $date);
|
||||
|
||||
/**
|
||||
* TOTAL DE LA FICHE
|
||||
*/
|
||||
$totalFraisFiche = $newFiche->getMontantValide($_SESSION['userId'], $date);
|
||||
$totalFraisFiche = $newFiche->getMontantValide($userId, $date);
|
||||
|
||||
include(__DIR__ . '/../vues/v_newFiche.php');
|
||||
|
@ -68,7 +68,7 @@
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a class="dropdown-item" href="#">Sign out</a></li>
|
||||
<li><a class="dropdown-item" href="controleurs/c_deconnexion.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
11
index.php
11
index.php
@ -21,12 +21,15 @@ if (!isset($_SESSION['userId'])) {
|
||||
$_REQUEST['direction'] = 'connexion';
|
||||
}
|
||||
*/
|
||||
if (!isset($_REQUEST['direction'])) {
|
||||
if (!isset($_REQUEST['direction']) && !isset($_SESSION['uId'])) {
|
||||
$_REQUEST['direction'] = 'connexion';
|
||||
} elseif (!isset($_REQUEST['direction']) && isset($_SESSION['uId'])) {
|
||||
$_REQUEST['direction'] = 'home';
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
@ -45,7 +48,11 @@ if (!isset($_REQUEST['direction'])) {
|
||||
<div class="container-fluid">
|
||||
<div class="row flex-nowrap">
|
||||
<?php
|
||||
if (!isset($_SESSION['uId'])) {
|
||||
$_REQUEST['direction'] = 'connexion';
|
||||
} else {
|
||||
include('include/menu.php');
|
||||
}
|
||||
?>
|
||||
<div class="col py-3">
|
||||
<?php
|
||||
|
69
vues/v_connexion.php
Normal file
69
vues/v_connexion.php
Normal file
@ -0,0 +1,69 @@
|
||||
<!-- 03/05/2023 à 11H01 -->
|
||||
<section class="vh-100 gradient-custom">
|
||||
<div class="container py-5 h-100">
|
||||
<div class="row d-flex justify-content-center align-items-center h-100">
|
||||
<div class="col-12 col-md-8 col-lg-6 col-xl-5">
|
||||
<div class="card bg-dark text-white" style="border-radius: 1rem;">
|
||||
<div class="card-body p-5 text-center">
|
||||
|
||||
<div class="mb-md-5 mt-md-4 pb-5">
|
||||
|
||||
<h2 class="fw-bold mb-2 text-uppercase">GSB Laboratoire</h2>
|
||||
<p class="text-white-50 mb-5">Entrez votre login et mot-de-passe</p>
|
||||
<form action="index.php" method="POST">
|
||||
<div class="form-outline form-white mb-4">
|
||||
<input type="text" id="typeEmailX"
|
||||
class="form-control form-control-lg" name="login"/>
|
||||
<label class="form-label" for="typeEmailX">Login</label>
|
||||
</div>
|
||||
|
||||
<div class="form-outline form-white mb-4">
|
||||
<input type="password" id="typePasswordX"
|
||||
class="form-control form-control-lg" name="password"/>
|
||||
<label class="form-label" for="typePasswordX">Mot-de-passe</label>
|
||||
</div>
|
||||
|
||||
<!-- <p class="small mb-5 pb-lg-2"><a class="text-white-50" href="#!">Forgot password?</a></p> -->
|
||||
|
||||
<button class="btn btn-outline-light btn-lg px-5"
|
||||
type="submit">Connexion</button>
|
||||
</form>
|
||||
<div class="d-flex justify-content-center text-center mt-4 pt-1">
|
||||
<a href="#!" class="text-white"><i
|
||||
class="fab fa-facebook-f fa-lg"></i></a>
|
||||
<a href="#!" class="text-white"><i
|
||||
class="fab fa-twitter fa-lg mx-4 px-2"></i></a>
|
||||
<a href="#!" class="text-white"><i class="fab fa-google fa-lg"></i></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!--
|
||||
|
||||
<div id="contenu">
|
||||
<h2>Identification utilisateur</h2>
|
||||
|
||||
|
||||
<form method="POST" action="index.php?uc=connexion&action=valideConnexion">
|
||||
|
||||
|
||||
<p>
|
||||
<label for="nom">Login*</label>
|
||||
<input id="login" type="text" name="login" size="30" maxlength="45">
|
||||
</p>
|
||||
<p>
|
||||
<label for="mdp">Mot de passe*</label>
|
||||
<input id="mdp" type="password" name="mdp" size="30" maxlength="45">
|
||||
</p>
|
||||
<input type="submit" value="Valider" name="valider">
|
||||
<input type="reset" value="Annuler" name="annuler">
|
||||
</p>
|
||||
</form>
|
||||
|
||||
</div>
|
@ -1 +1,4 @@
|
||||
<h4>BONJOUR VOUS ETES COMPTABLE</h4>
|
||||
<h4>BONJOUR VOUS ETES <?= strtoupper($_SESSION['uType']) ?></h4>
|
||||
<?php
|
||||
|
||||
var_dump($_SESSION);
|
||||
|
@ -85,11 +85,11 @@
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if ($_SESSION['typeU'] === 'comptable') { ?>
|
||||
if ($typeUser === 'comptable') { ?>
|
||||
<button type="button" class="btn btn-outline-primary btnRefuseFraisHf" id="frsSup-<?= $key ?>">
|
||||
Refuser
|
||||
</button>
|
||||
<?php } elseif ($_SESSION['typeU'] === 'visiteur') { ?>
|
||||
<?php } elseif ($typeUser === 'visiteur') { ?>
|
||||
<button type="button" class="btn btn-outline-primary btnSuprFraisHf" id="frsSup-<?= $key ?>">
|
||||
Supprimer
|
||||
</button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user