Compare commits
2 Commits
v0.0.1d-pr
...
v0.0.1f-pr
Author | SHA1 | Date | |
---|---|---|---|
9f245f6578 | |||
85c00fde0a |
@ -4,7 +4,6 @@ class Class_newFiche
|
||||
{
|
||||
private $pdo = null;
|
||||
|
||||
|
||||
public function __construct(PdoGsb $pDO)
|
||||
{
|
||||
$this->pdo = $pDO->getPdoGsb();
|
||||
@ -39,7 +38,7 @@ class Class_newFiche
|
||||
{
|
||||
$req = 'SELECT to_char("lhDate", \'YYYY-mm-dd\') AS "lhDate",
|
||||
"lhLibelle", ROUND("lhMontant",2) as "lhMontant",
|
||||
"lhJustificatif", "lhRefus"
|
||||
"lhJustificatif", "lhRefus"
|
||||
FROM remboursement
|
||||
inner join "ligne_hors_forfait" on "rVisiteur" = "lhVisiteur"
|
||||
AND "rMois" = "lhMois"
|
||||
@ -54,4 +53,18 @@ class Class_newFiche
|
||||
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public function getMontantValide(string $idVisiteur, int $month): float
|
||||
{
|
||||
$req = 'SELECT "rMontantValide"
|
||||
FROM remboursement
|
||||
WHERE "rVisiteur" = :idVisiteur AND "rMois" = :mois ;';
|
||||
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam(':idVisiteur', $idVisiteur);
|
||||
$result->bindParam(':mois', $month);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll()[0]['rMontantValide'];
|
||||
}
|
||||
}
|
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) {
|
||||
@ -61,4 +84,5 @@ switch ($action) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
*/
|
||||
|
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');
|
@ -4,11 +4,47 @@ require_once(__DIR__ . '/../Class/class.newFiche.php');
|
||||
$newFiche = new Class_newFiche($pdo);
|
||||
|
||||
$_SESSION['userId'] = 'b34';
|
||||
$_SESSION['typeU'] = 'visiteur';
|
||||
$typeUser = $_SESSION['uType'];
|
||||
$userId = $_SESSION['uId'];
|
||||
$date = '202011';
|
||||
|
||||
/**
|
||||
* Gestion de la date selon la vue à afficher
|
||||
*/
|
||||
if (isset($_GET['currentList'])) {
|
||||
//Date des req SQL et function
|
||||
$date = date('Ym');
|
||||
|
||||
//Date du header
|
||||
try {
|
||||
//sudo timedatectl set-local-rtc 1
|
||||
$format = new IntlDateFormatter(
|
||||
'fr_FR',
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::FULL,
|
||||
'Europe/Paris',
|
||||
IntlDateFormatter::GREGORIAN,
|
||||
'MMMM Y'
|
||||
);
|
||||
$dateHeader = $format->format(time());
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$dateHeader = date('F Y');
|
||||
}
|
||||
|
||||
//Date du formulaire HF
|
||||
$dateFormHFMin = date('Y-m-\01');
|
||||
$dateFormHFMax = date("Y-m-t", mktime(0, 0, 0, date('m'), 1, date('Y'))); // retourne le dernier jour du mois (30 ou 31)
|
||||
|
||||
} elseif (isset($_GET['dateListing'])) {
|
||||
$date = $_GET['dateListing'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste des frais forfaitaires du mois et de l'user :: sinon afficher les libelle
|
||||
*/
|
||||
$listeFraisForfaitaire = $newFiche->listFraisForfaitForU($_SESSION['userId'], '202011');
|
||||
$listeFraisForfaitaire = $newFiche->listFraisForfaitForU($userId, $date);
|
||||
if (count($listeFraisForfaitaire) == 0) {
|
||||
$listeFraisForfaitaire = $newFiche->listFraisForfaitaires();
|
||||
}
|
||||
@ -16,7 +52,11 @@ if (count($listeFraisForfaitaire) == 0) {
|
||||
/**
|
||||
* Listes des frais HF
|
||||
*/
|
||||
$listeFraisHf = $newFiche->listFraisHF($_SESSION['userId'], '202011');
|
||||
$listeFraisHf = $newFiche->listFraisHF($userId, $date);
|
||||
|
||||
/**
|
||||
* TOTAL DE LA FICHE
|
||||
*/
|
||||
$totalFraisFiche = $newFiche->getMontantValide($userId, $date);
|
||||
|
||||
include(__DIR__ . '/../vues/v_newFiche.php');
|
||||
|
@ -25,7 +25,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="index.php?direction=nouvelleFiche" class="nav-link px-0"> <span class="d-none d-sm-inline">Fiche du mois</span>
|
||||
<a href="index.php?direction=nouvelleFiche¤tList" class="nav-link px-0"> <span class="d-none d-sm-inline">Fiche du mois</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@ -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>
|
||||
|
@ -1,6 +1,8 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
calcPrixTotalFrsF();
|
||||
calcPrixTotalFrsHorsF();
|
||||
updatePrixTotal();
|
||||
/**
|
||||
* Partie enregistrement frais F
|
||||
*/
|
||||
@ -19,6 +21,7 @@ $(document).ready(function () {
|
||||
formTotal.html((val * mttFrs).toFixed(2) + ' €');
|
||||
|
||||
calcPrixTotalFrsF();
|
||||
updatePrixTotal();
|
||||
}
|
||||
})
|
||||
|
||||
@ -56,16 +59,11 @@ $(document).ready(function () {
|
||||
if (canAdd == true) {
|
||||
var line = $('tr.fraisHF:first').clone();
|
||||
lastId = $('tr.fraisHF').length
|
||||
/*
|
||||
line.find("#dateFrsHF").html(date.val());
|
||||
line.find("#LibelleFrsHF").html(libelle.val());
|
||||
line.find("#MttFrsHF").html(parseFloat(montant.val()).toFixed(2) + ' €');
|
||||
*/
|
||||
|
||||
line.find('.btn').attr('id', 'frsSup-' + lastId)
|
||||
|
||||
var line = $('<tr id="fraisHf-' + lastId + '" class="fraisHF"></tr>');
|
||||
var tdDate = $('<td scope="row" id="dateFrsHF"></td>');
|
||||
var tdDate = $('<th scope="row" id="dateFrsHF"></th>');
|
||||
tdDate.html(date.val());
|
||||
var tdLibelle = $('<td id="LibelleFrsHF"></td>');
|
||||
tdLibelle.html(libelle.val());
|
||||
@ -81,7 +79,14 @@ $(document).ready(function () {
|
||||
$(line).append(btn)
|
||||
|
||||
line.insertBefore('.newFraisForm')
|
||||
|
||||
date.val('')
|
||||
libelle.val('')
|
||||
montant.val('')
|
||||
}
|
||||
|
||||
calcPrixTotalFrsHorsF();
|
||||
updatePrixTotal();
|
||||
})
|
||||
|
||||
|
||||
@ -95,10 +100,12 @@ $(document).on('click', '.btnSuprFraisHf', function () {
|
||||
console.log(id)
|
||||
|
||||
$('#fraisHf-' + id).remove()
|
||||
calcPrixTotalFrsHorsF();
|
||||
updatePrixTotal();
|
||||
})
|
||||
|
||||
/**
|
||||
* Calcul prix total
|
||||
* Calcul prix total frais forfaitaires
|
||||
*/
|
||||
function calcPrixTotalFrsF() {
|
||||
|
||||
@ -107,4 +114,26 @@ function calcPrixTotalFrsF() {
|
||||
prixTotal += parseFloat($(this).html().replace('€', ''))
|
||||
})
|
||||
$('.prixTotalFrsF').html('<strong>TOTAL :</strong> ' + prixTotal.toFixed(2) + ' €')
|
||||
$('.prixTotalFrsF').attr('data-prix', prixTotal.toFixed(2))
|
||||
}
|
||||
/**
|
||||
* Calcul prix total frais hors forfait
|
||||
*/
|
||||
function calcPrixTotalFrsHorsF() {
|
||||
|
||||
var prixTotal = 0;
|
||||
$('td#MttFrsHF').each(function () {
|
||||
prixTotal += parseFloat($(this).html().replace('€', ''))
|
||||
})
|
||||
$('#total-frais-HF').html('<strong>TOTAL :</strong> ' + prixTotal.toFixed(2) + ' €')
|
||||
$('#total-frais-HF').attr('data-prix', prixTotal.toFixed(2))
|
||||
}
|
||||
/**
|
||||
* Calcul prix total de la fiche
|
||||
*/
|
||||
function updatePrixTotal() {
|
||||
var total = parseFloat($('#total-frais-HF').attr('data-prix'))
|
||||
total += parseFloat($('.prixTotalFrsF').attr('data-prix'))
|
||||
|
||||
$('#total-fiche').html('<strong>TOTAL :</strong> ' + total.toFixed(2) + ' €')
|
||||
}
|
13
index.php
13
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
|
||||
include('include/menu.php');
|
||||
if (!isset($_SESSION['uId'])) {
|
||||
$_REQUEST['direction'] = 'connexion';
|
||||
} else {
|
||||
include('include/menu.php');
|
||||
}
|
||||
?>
|
||||
<div class="col py-3">
|
||||
<?php
|
||||
|
@ -1,4 +1,51 @@
|
||||
<!-- 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>
|
||||
|
||||
@ -6,13 +53,13 @@
|
||||
<form method="POST" action="index.php?uc=connexion&action=valideConnexion">
|
||||
|
||||
|
||||
<p>
|
||||
<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>
|
||||
<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">
|
||||
|
@ -1 +1,4 @@
|
||||
<h4>BONJOUR VOUS ETES COMPTABLE</h4>
|
||||
<h4>BONJOUR VOUS ETES <?= strtoupper($_SESSION['uType']) ?></h4>
|
||||
<?php
|
||||
|
||||
var_dump($_SESSION);
|
||||
|
@ -1,7 +1,9 @@
|
||||
<center>
|
||||
<h1>Nouvelle Fiche de frais</h1>
|
||||
<h1>Fiche de frais</h1>
|
||||
<br>
|
||||
<p>Mois de Novembre 2023</p>
|
||||
<p>Mois de
|
||||
<?= $dateHeader ?>
|
||||
</p>
|
||||
</center>
|
||||
<br>
|
||||
<!--
|
||||
@ -42,7 +44,7 @@
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="3" class="border-0"></td>
|
||||
<td class="prixTotalFrsF"></td>
|
||||
<td class="prixTotalFrsF table-primary"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -68,10 +70,10 @@
|
||||
<?php
|
||||
foreach ($listeFraisHf as $key => $value):
|
||||
?>
|
||||
<tr id="fraisHf-<?= $key ?>" class="fraisHF">
|
||||
<td scope="row" id="dateFrsHF">
|
||||
<tr id="fraisHf-<?= $key ?>" class="fraisHF <?= $value['lhRefus'] == 1 ? 'table-danger' : '' ?>">
|
||||
<th scope="row" id="dateFrsHF">
|
||||
<?= $value['lhDate'] ?>
|
||||
</td>
|
||||
</th>
|
||||
<td id="LibelleFrsHF">
|
||||
<?= $value['lhLibelle'] ?>
|
||||
</td>
|
||||
@ -82,9 +84,16 @@
|
||||
<?= $value['lhJustificatif'] == 1 ? 'ok' : 'non fournis' ?>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-outline-primary btnSuprFraisHf" id="frsSup-<?= $key ?>">
|
||||
Supprimer
|
||||
</button>
|
||||
<?php
|
||||
if ($typeUser === 'comptable') { ?>
|
||||
<button type="button" class="btn btn-outline-primary btnRefuseFraisHf" id="frsSup-<?= $key ?>">
|
||||
Refuser
|
||||
</button>
|
||||
<?php } elseif ($typeUser === 'visiteur') { ?>
|
||||
<button type="button" class="btn btn-outline-primary btnSuprFraisHf" id="frsSup-<?= $key ?>">
|
||||
Supprimer
|
||||
</button>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
@ -94,8 +103,10 @@
|
||||
Formulaire d'ajout de frais HF
|
||||
-->
|
||||
<tr class="newFraisForm">
|
||||
<td scope="row">
|
||||
<input name="dateHf" class="form-control" id="dateHf" type="date" min="2020-11-01" max="2020-11-30">
|
||||
<td>
|
||||
<!-- Date form -->
|
||||
<input name="dateHf" class="form-control" id="dateHf" type="date" min="<?= $dateFormHFMin ?>"
|
||||
max="<?= $dateFormHFMax ?>">
|
||||
</td>
|
||||
<td><input type="text" name="libelleHf" id="libelleHf" class="form-control"
|
||||
placeholder="saisir un titre"></td>
|
||||
@ -104,17 +115,29 @@
|
||||
<td><input type="file" class="form-control"></td>
|
||||
<td><button type="button" class="btn btn-outline-primary validFraisHF">Valider</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="border-0"></td>
|
||||
<td class="table-primary" id="total-frais-HF">TOTAL: 0€</td> <!--COMPLETE HERE -->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<span class="border-3 border-bottom border-black col-10 mx-auto my-5 d-flex"></span>
|
||||
|
||||
<!-- <span class="border-3 border-bottom border-black col-10 mx-auto my-5 d-flex"></span> -->
|
||||
<!-- TOTAL -->
|
||||
<div style="position:fixed; bottom:5px; right:5px; margin:0; padding:5px 3px;">
|
||||
<button type="button" class="btn btn-primary" id="total-fiche">
|
||||
<strong>TOTAL : </strong>
|
||||
<?= $totalFraisFiche ?>
|
||||
</button>
|
||||
</div>
|
||||
<!--
|
||||
<h3 class="fw-bold offset-1">Commentaire (facultatif)</h3>
|
||||
|
||||
<div class="col-8 d-flex mx-auto">
|
||||
<textarea name="commentaireFiche" id="commentaireFiche" class="form-control border-black"></textarea>
|
||||
</div>
|
||||
-->
|
||||
<div class="col-3 d-flex mx-auto my-5 justify-content-center">
|
||||
<button type="button" class="btn btn-outline-primary">Envoyer la Fiche</button>
|
||||
<button type="button" class="btn btn-outline-primary btn-lg">Envoyer la Fiche</button>
|
||||
</div>
|
||||
<script src="../include/newFiche.js"></script>
|
Reference in New Issue
Block a user