Compare commits
11 Commits
v0.0.1.g-p
...
pagination
Author | SHA1 | Date | |
---|---|---|---|
e6b8c87744 | |||
c990aed3d3 | |||
af3771e786 | |||
8aafdf565b | |||
a2201a4eb3 | |||
89273aced9 | |||
4eac346ff2 | |||
63eddbbc8b | |||
aa49401a47 | |||
fcf292e823 | |||
df7599ab9b |
@ -3,6 +3,9 @@
|
||||
class Class_gestionFiche
|
||||
{
|
||||
private $pdo = null;
|
||||
public static $NB_LIGNES_PAGINATION = 12;
|
||||
public static $NB_LIGNES_FICHEAVALIDER = 15;
|
||||
|
||||
|
||||
public function __construct(PdoGsb $pDO)
|
||||
{
|
||||
@ -13,14 +16,72 @@ class Class_gestionFiche
|
||||
{
|
||||
$req = 'SELECT "uId", "uNom", "uPrenom" FROM utilisateur WHERE "uStatut"!=0 ORDER BY "uNom" ASC;';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result ->execute();
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public function utilisateur(string $idUtilisateur): array
|
||||
public function dateComplete(string $date): string
|
||||
{
|
||||
$req = '';
|
||||
return substr($date, 0, 4) . '-' . substr($date, 4);
|
||||
}
|
||||
|
||||
}
|
||||
public function get_ficheAvalider(int $nPage): array
|
||||
{
|
||||
$decalage = ($nPage - 1) * $this::$NB_LIGNES_FICHEAVALIDER;
|
||||
$req = 'SELECT "rMois", "rVisiteur", "rEtat", ROUND("rMontantValide", 2)
|
||||
as "rMontantValide", "eLibelle", "uNom", "uPrenom"
|
||||
from remboursement
|
||||
INNER JOIN utilisateur ON utilisateur."uId"=remboursement."rVisiteur"
|
||||
INNER JOIN etat ON etat."eId"=remboursement."rEtat"
|
||||
where "rEtat"=\'CL\'
|
||||
ORDER BY "rMois" ASC
|
||||
LIMIT :nbLignes offset :decalage;';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam('nbLignes', $this::$NB_LIGNES_FICHEAVALIDER);
|
||||
$result->bindParam('decalage', $decalage);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public function get_nbFicheAvalider(): int
|
||||
{
|
||||
$req = 'SELECT COUNT(*) as "nbFicheAvalider" from remboursement
|
||||
where "rEtat"=\'CL\'';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->execute();
|
||||
$result = $result->fetch();
|
||||
|
||||
return (int) $result['nbFicheAvalider'];
|
||||
}
|
||||
|
||||
public function get_nbRemboursement(string $idUtilisateur): int
|
||||
{
|
||||
$req = 'SELECT COUNT(*) as "nbRemboursement" from remboursement WHERE "rVisiteur"= :userId;';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam("userId", $idUtilisateur);
|
||||
$result->execute();
|
||||
$result = $result->fetch();
|
||||
|
||||
return (int) $result['nbRemboursement'];
|
||||
}
|
||||
|
||||
public function get_Page(int $nPage, string $idUtilisateur): array
|
||||
{
|
||||
$decalage = ($nPage - 1) * $this::$NB_LIGNES_PAGINATION;
|
||||
$req = 'SELECT "rMois", "rVisiteur", "rEtat", ROUND("rMontantValide", 2)
|
||||
as "rMontantValide", "eLibelle"
|
||||
FROM remboursement
|
||||
INNER JOIN etat ON etat."eId"=remboursement."rEtat"
|
||||
WHERE "rVisiteur"= :userId
|
||||
ORDER BY "rDateModif" DESC LIMIT :nbLignes offset :decalage;';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam('nbLignes', $this::$NB_LIGNES_PAGINATION);
|
||||
$result->bindParam('decalage', $decalage);
|
||||
$result->bindParam('userId', $idUtilisateur);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OBJECT QUI GERE LA PARTIE AFFICHAGE D'UNE FICHE
|
||||
*/
|
||||
|
||||
class Class_newFiche
|
||||
{
|
||||
private $pdo = null;
|
||||
|
||||
private $month;
|
||||
private $userId;
|
||||
|
||||
@ -17,7 +20,8 @@ class Class_newFiche
|
||||
}
|
||||
|
||||
/**
|
||||
* Test et ajoute la fiche si elle n'existe pas
|
||||
* Test et ajoute la fiche si elle n'existe pas dans remboursement
|
||||
* et les ligneForfaitaires nulles liées
|
||||
*/
|
||||
private function existingFile(): void
|
||||
{
|
||||
@ -65,7 +69,7 @@ class Class_newFiche
|
||||
*/
|
||||
public function listFraisHF(): array
|
||||
{
|
||||
$req = 'SELECT to_char("lhDate", \'YYYY-mm-dd\') AS "lhDate",
|
||||
$req = 'SELECT "lhId", to_char("lhDate", \'YYYY-mm-dd\') AS "lhDate",
|
||||
"lhLibelle", ROUND("lhMontant",2) as "lhMontant",
|
||||
"lhJustificatif", "lhRefus"
|
||||
FROM remboursement
|
||||
@ -102,6 +106,9 @@ class Class_newFiche
|
||||
return $result->fetch()['rMontantValide'];
|
||||
}
|
||||
|
||||
/**
|
||||
* RETOURNE LE STATUS DE LA FICHE
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
$req = 'select etat."eId" from remboursement
|
||||
@ -115,4 +122,97 @@ class Class_newFiche
|
||||
|
||||
return $result->fetch()['eId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE LES INFOS DE LA FICHE
|
||||
*/
|
||||
public function updateFile(int $nbJustif, float $mttValid): bool
|
||||
{
|
||||
$req = 'UPDATE remboursement
|
||||
SET "rNbJustificatifs" = :nbJustif,
|
||||
"rMontantValide" = :mttValid,
|
||||
"rDateModif" = NOW()
|
||||
WHERE "rVisiteur" = :idVisiteur AND "rMois" = :mois;';
|
||||
|
||||
$result = $this->pdo->prepare($req);
|
||||
|
||||
$result->bindParam(':nbJustif', $nbJustif);
|
||||
$result->bindParam(':mttValid', $mttValid);
|
||||
$result->bindParam(':idVisiteur', $this->userId);
|
||||
$result->bindParam(':mois', $this->month);
|
||||
|
||||
return $result->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJOUTE LES LIGNES HF
|
||||
*/
|
||||
public function addFraisHF(string $libelle, string $date, float $montant): bool
|
||||
{
|
||||
$req = 'SELECT MAX("lhId")+1
|
||||
FROM ligne_hors_forfait';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->execute();
|
||||
$idLigne = $result->fetch()[0];
|
||||
|
||||
$req = 'INSERT INTO ligne_hors_forfait
|
||||
VALUES (:idLigne, :userId, :monthF, :libelle, :dateL, :mttF, \'true\', \'false\');';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam(':idLigne', $idLigne);
|
||||
$result->bindParam(':libelle', $libelle);
|
||||
$result->bindParam(':dateL', $date);
|
||||
$result->bindParam(':mttF', $montant);
|
||||
$result->bindParam(':userId', $this->userId);
|
||||
$result->bindParam(':monthF', $this->month);
|
||||
|
||||
return $result->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Refuse ou accepte un frais HF
|
||||
*/
|
||||
public function accceptFrais(int $idFrais, bool $state)
|
||||
{
|
||||
$req = 'UPDATE ligne_hors_forfait
|
||||
SET "lhRefus" = :stateF
|
||||
WHERE "lhId" = :idFrais;';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$state = ($state) ? 'false' : 'true';
|
||||
$result->bindParam(':stateF', $state);
|
||||
$result->bindParam(':idFrais', $idFrais);
|
||||
|
||||
return $result->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE LA LIGNE FRAIS FORFAITAIRES
|
||||
*/
|
||||
public function updateFraisF(int $qttF, int $montant, string $idForfait): bool
|
||||
{
|
||||
$req = 'UPDATE ligne_forfait
|
||||
SET "lfQuantite" = :qttF,
|
||||
"lfMontant" = :mttF
|
||||
WHERE "lfVisiteur" = :userId AND "lfMois" = :monthF AND "lfForfait" = :idForfait;';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam(':qttF', $qttF);
|
||||
$result->bindParam(':mttF', $montant);
|
||||
$result->bindParam(':idForfait', $idForfait);
|
||||
$result->bindParam(':userId', $this->userId);
|
||||
$result->bindParam(':monthF', $this->month);
|
||||
|
||||
return $result->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* SUPPRIME LA LIGNE HF
|
||||
*/
|
||||
public function suprLigneHF(int $idLine): bool
|
||||
{
|
||||
$req = 'DELETE FROM ligne_hors_forfait
|
||||
WHERE "lhId" = :idLine';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam(':idLine', $idLine);
|
||||
|
||||
return $result->execute();
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ class Class_user
|
||||
$this->pdo = $pDO->getPdoGsb();
|
||||
}
|
||||
|
||||
public function connectUser(string $login, string $password): array
|
||||
public function connectUser(string $login, string $password): array|bool
|
||||
{
|
||||
$req = 'SELECT "uId", "uNom", "uPrenom", "uAdresse", "uCp", "uVille", "uSecteur", "uLabo", "parametre"."pLibelle"
|
||||
FROM utilisateur
|
||||
|
46
controleurs/c_actionFiche.php
Normal file
46
controleurs/c_actionFiche.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
//var_dump($_REQUEST['fraisHF']);
|
||||
require_once(__DIR__ . '/../Class/class.pdo.php');
|
||||
require_once(__DIR__ . '/../Class/class.newFiche.php');
|
||||
|
||||
|
||||
$id = explode('-', $_GET['fiche']); //id de la fiche "userID-date"
|
||||
$pdo = new PdoGsb;
|
||||
$pdoNewFiche = new Class_newFiche($pdo, $id[0], $id[1]);
|
||||
|
||||
switch ($_GET['action']) {
|
||||
case 'update':
|
||||
//FRAIS FORFAITAIRES
|
||||
foreach ($_REQUEST['fraisF'] as $value) {
|
||||
$pdoNewFiche->updateFraisF(
|
||||
$value['quantité'],
|
||||
intval($value['montant']),
|
||||
$value['id']
|
||||
);
|
||||
}
|
||||
//FRAIS HORS FORFAIT
|
||||
foreach ($_REQUEST['fraisHF'] as $value) {
|
||||
if ($value['id'] == NULL) {
|
||||
$pdoNewFiche->addFraisHF(
|
||||
$value['libelle'],
|
||||
$value['date'],
|
||||
$value['montant']
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'suprFraisHF':
|
||||
$pdoNewFiche->suprLigneHF($_GET['idFrais']);
|
||||
break;
|
||||
case 'refusFraisHF':
|
||||
$pdoNewFiche->accceptFrais(
|
||||
$_GET['idFrais'],
|
||||
boolval($_GET['state'])
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
@ -6,6 +6,11 @@ if (isset($_POST['login']) && isset($_POST['password'])) {
|
||||
//Récupère les données de l'utilisateur
|
||||
$data = $userClass->connectUser($_POST['login'], $_POST['password']);
|
||||
|
||||
if($data == false) {
|
||||
header('location: index.php');
|
||||
}
|
||||
|
||||
|
||||
//Si l'utilisateur existe ou pas
|
||||
if (count($data) === 0) {
|
||||
header('location: index.php?direction=connexion&msg=errorco');
|
||||
|
31
controleurs/c_ficheAvalider.php
Normal file
31
controleurs/c_ficheAvalider.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
$_SESSION["typeU"] = "comptable";
|
||||
|
||||
require_once(__DIR__ . '/../Class/class.gestionFiche.php');
|
||||
$gestionFiche = new Class_gestionFiche($pdo);
|
||||
|
||||
$LesUtilisateurs = $gestionFiche->getLesUtilisateurs(); //RENVOIE LISTE USERS
|
||||
|
||||
if ($_SESSION["typeU"] == "comptable") {
|
||||
if (isset($_REQUEST['selVisiteur'])) {
|
||||
$userId = $_REQUEST['selVisiteur'];
|
||||
} else {
|
||||
$userId = $LesUtilisateurs[0]['uId'];
|
||||
}
|
||||
} else {
|
||||
$userId = $_SESSION['uId'];
|
||||
}
|
||||
|
||||
//Pagination
|
||||
if(isset($_GET['page']) && !empty($_GET['page'])){
|
||||
$currentPage = (int) strip_tags($_GET['page']);
|
||||
}else{
|
||||
$currentPage = 1;
|
||||
}
|
||||
|
||||
$pages = ceil($gestionFiche->get_nbFicheAvalider() / $gestionFiche::$NB_LIGNES_FICHEAVALIDER);
|
||||
|
||||
$lesFiches = $gestionFiche->get_ficheAvalider($currentPage);
|
||||
|
||||
|
||||
include("vues/v_fichesAvalider.php");
|
@ -1,9 +1,31 @@
|
||||
<?php
|
||||
$_SESSION ["typeU"] = "comptable";
|
||||
$_SESSION["typeU"] = "comptable";
|
||||
|
||||
require_once(__DIR__ . '/../Class/class.gestionFiche.php');
|
||||
$gestionFiche = new Class_gestionFiche($pdo);
|
||||
|
||||
$LesUtilisateurs = $gestionFiche->getLesUtilisateurs(); //RENVOIE LISTE USERS
|
||||
|
||||
if ($_SESSION["typeU"] == "comptable") {
|
||||
if (isset($_REQUEST['selVisiteur'])) {
|
||||
$userId = $_REQUEST['selVisiteur'];
|
||||
} else {
|
||||
$userId = $LesUtilisateurs[0]['uId'];
|
||||
}
|
||||
} else {
|
||||
$userId = $_SESSION['uId'];
|
||||
}
|
||||
|
||||
//Pagination
|
||||
if(isset($_GET['page']) && !empty($_GET['page'])){
|
||||
$currentPage = (int) strip_tags($_GET['page']);
|
||||
}else{
|
||||
$currentPage = 1;
|
||||
}
|
||||
|
||||
$pages = ceil($gestionFiche->get_nbRemboursement($userId) / $gestionFiche::$NB_LIGNES_PAGINATION);
|
||||
|
||||
|
||||
$lesFiches = $gestionFiche->get_Page($currentPage, $userId);
|
||||
|
||||
include("vues/v_gestionFiches.php");
|
||||
|
@ -1,44 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* sudo date --set "YYYY-MM-DD HH:MM:SS"
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../Class/class.newFiche.php');
|
||||
|
||||
$typeUser = $_SESSION['uType']; //visiteur ou comptable
|
||||
$typeUser = 'visiteur';//$_SESSION['uType']; //visiteur ou comptable
|
||||
$userId = $_SESSION['uId']; //exemple: 'b34'
|
||||
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
//Timestamp de la date
|
||||
$dateTimeStamp = strtotime(date('Y-m-\01'));
|
||||
|
||||
//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'];
|
||||
//Données pour nourire la vue
|
||||
$userId = $_REQUEST['userId'];
|
||||
$date = $_REQUEST['dateListing'];
|
||||
|
||||
//Timestamp de la date
|
||||
$dateTimeStamp = strtotime(substr($date, 0, 4) . '-' . substr($date, 4) . '-01');
|
||||
|
||||
//Date du formulaire HF
|
||||
$dateFormHFMin = substr($date, 0, 4) . '-' . substr($date, 4) . '-01';
|
||||
$dateFormHFMax = date("Y-m-t", mktime(0, 0, 0, date('m', $dateTimeStamp), 1, date('Y', $dateTimeStamp))); // retourne le dernier jour du mois (30 ou 31)
|
||||
|
||||
}
|
||||
//Date du header en français
|
||||
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($dateFormat);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$dateHeader = date('F Y', $dateTimeStamp);
|
||||
}
|
||||
|
||||
$date = '202404';
|
||||
//$date = '202312'; //TESTVAR
|
||||
|
||||
//Instance de l'objet newFiche qui gère toute la partie bdd
|
||||
$newFiche = new Class_newFiche($pdo, $userId, $date);
|
||||
|
||||
/**
|
||||
@ -63,7 +81,7 @@ $totalFraisFiche = $newFiche->getMontantValide();
|
||||
* ETAT DE LA FICHE
|
||||
*/
|
||||
$status = $newFiche->getStatus();
|
||||
//$status = 'CR'; //créé
|
||||
$status = 'CR'; //créé
|
||||
$disabled = ($status !== 'CR') ? 'disabled' : '';
|
||||
|
||||
include(__DIR__ . '/../vues/v_newFiche.php');
|
||||
|
@ -13,7 +13,7 @@
|
||||
Partie visiteur
|
||||
-->
|
||||
<?php
|
||||
if($_SESSION['typeU'] == 'visiteur'):
|
||||
if($_SESSION['uType'] == 'visiteur'):
|
||||
?>
|
||||
<li>
|
||||
<a href="#submenu1" data-bs-toggle="collapse" class="nav-link px-0 align-middle">
|
||||
@ -34,7 +34,7 @@
|
||||
<a href="#" class="nav-link px-0 align-middle">
|
||||
<i class="fs-4 bi-table"></i> <span class="ms-1 d-none d-sm-inline">Visites</span></a>
|
||||
</li>
|
||||
<?php endif; if ($_SESSION['typeU'] == 'comptable'): ?>
|
||||
<?php endif; if ($_SESSION['uType'] == 'comptable'): ?>
|
||||
<!--
|
||||
Partie comptable
|
||||
-->
|
||||
@ -48,7 +48,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="nav-link px-0"> <span class="d-none d-sm-inline">Historique</span>
|
||||
<a href="index.php?direction=ficheAvalider" class="nav-link px-0"> <span class="d-none d-sm-inline">fiches a vérifier</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -62,7 +62,7 @@ $(document).ready(function () {
|
||||
|
||||
line.find('.btn').attr('id', 'frsSup-' + lastId)
|
||||
|
||||
var line = $('<tr id="fraisHf-' + lastId + '" class="fraisHF"></tr>');
|
||||
var line = $('<tr id="fraisHf-' + lastId + '" data-id="" class="fraisHF"></tr>');
|
||||
var tdDate = $('<th scope="row" id="dateFrsHF"></th>');
|
||||
tdDate.html(date.val());
|
||||
var tdLibelle = $('<td id="LibelleFrsHF"></td>');
|
||||
@ -88,29 +88,103 @@ $(document).ready(function () {
|
||||
calcPrixTotalFrsHorsF();
|
||||
updatePrixTotal();
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
/**
|
||||
* Refus d'un frais HF pour un comptable
|
||||
*/
|
||||
$(document).on('click', '.btnRefuseFraisHf', function () {
|
||||
idFrais = $(this).parent().parent().attr('data-id')
|
||||
fiche = $('#idFiche').attr('data-id')
|
||||
etatLigne = $(this).attr('data-status')
|
||||
console.log(etatLigne)
|
||||
//set on refus
|
||||
$.ajax({
|
||||
// url: "../controleurs/c_actionFiche.php?action=refusFraisHF&fiche=" + fiche + "&idFrais=" + idFrais + "&state=" + etatLigne,
|
||||
url: "controleurs/c_actionFiche.php?action=refusFraisHF&fiche=" + fiche + "&idFrais=" + idFrais + "&state=" + etatLigne,
|
||||
method: "POST",
|
||||
}).done(function () {
|
||||
location.reload();
|
||||
})
|
||||
})
|
||||
/**
|
||||
* Supprimer fraisHf
|
||||
*/
|
||||
$(document).on('click', '.btnSuprFraisHf', function () {
|
||||
id = $(this).attr('id').split('-')[1]
|
||||
console.log(id)
|
||||
fiche = $('#idFiche').attr('data-id')
|
||||
idFrais = $(this).parent().parent().attr('data-id')
|
||||
//SUPPRIME DE LA BD
|
||||
$.ajax({
|
||||
url: "controleurs/c_actionFiche.php?action=suprFraisHF&fiche=" + fiche + "&idFrais=" + idFrais,
|
||||
// url: "../controleurs/c_actionFiche.php?action=suprFraisHF&fiche=" + fiche + "&idFrais=" + idFrais,
|
||||
method: "POST",
|
||||
})
|
||||
|
||||
$('#fraisHf-' + id).remove()
|
||||
calcPrixTotalFrsHorsF();
|
||||
updatePrixTotal();
|
||||
})
|
||||
|
||||
/**
|
||||
* PARTIE ENVOIE DE LA FICHE
|
||||
*/
|
||||
$(document).on('click', '#sendFileBtn', function () {
|
||||
|
||||
//FRAIS FORFAITAIRES
|
||||
var listeFraisF = []
|
||||
$('tr.fraisForfaitaire').each(function () {
|
||||
quantite = parseInt($(this).find('.frsFrt').val())
|
||||
montant = parseFloat($(this).find('.mttFrsTotal').html())
|
||||
id = $(this).attr('data-id')
|
||||
|
||||
tabData = {
|
||||
'quantité': quantite,
|
||||
'montant': montant,
|
||||
'id': id
|
||||
}
|
||||
listeFraisF.push(tabData);
|
||||
})
|
||||
|
||||
//FRAIS HF
|
||||
var listeFraisHf = []
|
||||
$('tr.fraisHF').each(function () {
|
||||
date = $(this).find('#dateFrsHF').html()
|
||||
libelle = $(this).find('#LibelleFrsHF').html()
|
||||
montant = parseFloat($(this).find('#MttFrsHF').html())
|
||||
id = $(this).attr('data-id')
|
||||
|
||||
tabData = {
|
||||
'date': date,
|
||||
'libelle': libelle,
|
||||
'montant': montant,
|
||||
'id': id
|
||||
}
|
||||
listeFraisHf.push(tabData);
|
||||
})
|
||||
data = {
|
||||
fraisF: listeFraisF,
|
||||
fraisHF: listeFraisHf
|
||||
}
|
||||
fiche = $('#idFiche').attr('data-id')
|
||||
|
||||
$.ajax({
|
||||
url: "controleurs/c_actionFiche.php?action=update&fiche=" + fiche,
|
||||
// url: "../controleurs/c_actionFiche.php?action=update&fiche=" + fiche,
|
||||
method: "POST",
|
||||
data: data,
|
||||
}).done(function () {
|
||||
location.reload();
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* Calcul prix total frais forfaitaires
|
||||
*/
|
||||
function calcPrixTotalFrsF() {
|
||||
|
||||
var prixTotal = 0;
|
||||
$('td[id^="totalFrs-"]').each(function () {
|
||||
$('td.mttFrsTotal').each(function () {
|
||||
prixTotal += parseFloat($(this).html().replace('€', ''))
|
||||
})
|
||||
$('.prixTotalFrsF').html('<strong>TOTAL :</strong> ' + prixTotal.toFixed(2) + ' €')
|
||||
@ -121,6 +195,12 @@ function calcPrixTotalFrsF() {
|
||||
*/
|
||||
function calcPrixTotalFrsHorsF() {
|
||||
|
||||
console.log($('td#MttFrsHF').length)
|
||||
|
||||
if ($('td#MttFrsHF').length == 0) {
|
||||
vf
|
||||
}
|
||||
|
||||
var prixTotal = 0;
|
||||
$('td#MttFrsHF').each(function () {
|
||||
prixTotal += parseFloat($(this).html().replace('€', ''))
|
||||
|
@ -71,6 +71,10 @@ if (!isset($_REQUEST['direction']) && !isset($_SESSION['uId'])) {
|
||||
include(__DIR__ . "/controleurs/c_nouvelleFiche.php");
|
||||
break;
|
||||
|
||||
case 'ficheAvalider':
|
||||
include(__DIR__ . "/controleurs/c_ficheAvalider.php");
|
||||
break;
|
||||
|
||||
default:
|
||||
include("controleurs/c_homePage.php");
|
||||
break;
|
||||
|
55
sqlFunction.sql
Normal file
55
sqlFunction.sql
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
--Fonction pour créer une fiche si celle-ci n'existe pas
|
||||
CREATE OR REPLACE FUNCTION newRemboursement(userId CHAR(10), monthFile CHAR(10)) RETURNS int AS $$
|
||||
DECLARE
|
||||
returnValue INT;
|
||||
forfaitRecord RECORD;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO returnValue
|
||||
FROM remboursement
|
||||
WHERE "rVisiteur" = userId AND "rMois" = monthFile;
|
||||
|
||||
IF returnValue = 0 THEN
|
||||
-- Ajoute une nouvelle ligne à la table remboursement
|
||||
INSERT INTO remboursement
|
||||
VALUES(userId, monthFile, 0, 0, CURRENT_DATE, 'CR');
|
||||
|
||||
-- Parcours des lignes de la table forfait pour insérer dans ligne_hors_forfait
|
||||
FOR forfaitRecord IN SELECT * FROM forfait LOOP
|
||||
INSERT INTO ligne_forfait
|
||||
VALUES(userId, monthFile, forfaitRecord."fId", 0, 0);
|
||||
END LOOP;
|
||||
|
||||
-- Mettre à jour la valeur de returnValue après l'insertion
|
||||
returnValue := 1; -- Valeur pour indiquer qu'une ligne a été insérée
|
||||
END IF;
|
||||
|
||||
RETURN returnValue;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--AJOUTE LES LIGNES HF
|
||||
INSERT ligne_hors_forfait
|
||||
("lhVisiteur", "lhMois", "lhLibelle", "lhDate", "lhMontant", "lhJustificatif", "lhRefus")
|
||||
VALUES (:userId, :monthF, :libelle, :dateL, :mttF, 'true', 'false');
|
||||
|
||||
--UPDATE LES LIGNES HF SI REFUS
|
||||
UPDATE ligne_hors_forfait
|
||||
SET "lhRefus" = 'true'
|
||||
WHERE "rVisiteur" = '' AND "rMois" = '' AND "lhId" = '';
|
||||
|
||||
--UPDATE LES LIGNE FORFAIT
|
||||
UPDATE ligne_forfait
|
||||
SET "lfQuantite" = :qttF,
|
||||
"lfMontant" = :mttF
|
||||
WHERE "rVisiteur" = :userId AND "rMois" = :monthF AND "lfForfait" = :idForfait;
|
||||
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
|
||||
--Fonction pour créer une fiche si celle-ci n'existe pas
|
||||
|
||||
CREATE OR REPLACE FUNCTION newRemboursement(userId CHAR(10), monthFile CHAR(10)) RETURNS int AS $$
|
||||
DECLARE
|
||||
returnValue INT;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO returnValue
|
||||
FROM remboursement
|
||||
WHERE "rVisiteur" = userId AND "rMois" = monthFile;
|
||||
|
||||
IF returnValue = 0 THEN
|
||||
-- Ajoute une nouvelle ligne à la table remboursement
|
||||
INSERT INTO remboursement
|
||||
VALUES(userId, monthFile, 0, 0, CURRENT_DATE, 'CR');
|
||||
|
||||
-- Mettre à jour la valeur de returnValue après l'insertion
|
||||
returnValue := 1; -- Valeur pour indiquer qu'une ligne a été insérée
|
||||
END IF;
|
||||
|
||||
RETURN returnValue;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
70
vues/v_fichesAvalider.php
Normal file
70
vues/v_fichesAvalider.php
Normal file
@ -0,0 +1,70 @@
|
||||
<div class="text-center">
|
||||
<br>
|
||||
<h3>Fiches à valider</h3>
|
||||
</div>
|
||||
<div class="col-11 d-flex mx-auto">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Mois</th>
|
||||
<th scope="col">Nom Fiche</th>
|
||||
<th scope="col">Total</th>
|
||||
<th scope="col">Statut</th>
|
||||
<th scope="col">Détails</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($lesFiches as $uneFiche) { ?>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?= $gestionFiche->dateComplete($uneFiche['rMois']) ?>
|
||||
</th>
|
||||
<td>
|
||||
<?= $uneFiche['uNom'] ?>
|
||||
<?= $uneFiche['uPrenom'] ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $uneFiche['rMontantValide'] ?> €
|
||||
</td>
|
||||
<td>
|
||||
<?= $uneFiche['eLibelle'] ?>
|
||||
</td>
|
||||
<td><a
|
||||
href="index.php?direction=nouvelleFiche&userId=<?= $userId ?>&dateListing=<?= $uneFiche['rMois'] ?>">voir</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if ($pages > 0) { ?>
|
||||
<div class="col-4 d-flex mx-auto">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<!-- Lien vers la page précédente (désactivé si on se trouve sur la 1ère page) -->
|
||||
<li class="page-item <?= ($currentPage == 1) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=ficheAvalider&page=<?= $currentPage - 1 ?>"
|
||||
class="page-link">Précédente</a>
|
||||
</li>
|
||||
<?php for ($page = 1; $page <= $pages; $page++): ?>
|
||||
<!-- Lien vers chacune des pages (activé si on se trouve sur la page correspondante) -->
|
||||
<li class="page-item <?= ($currentPage == $page) ? "active" : "" ?>">
|
||||
<a href="index.php?direction=ficheAvalider&page=<?= $page ?>"
|
||||
class="page-link">
|
||||
<?= $page ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endfor ?>
|
||||
<!-- Lien vers la page suivante (désactivé si on se trouve sur la dernière page) -->
|
||||
<li class="page-item <?= ($currentPage == $pages) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=ficheAvalider&page=<?= $currentPage + 1 ?>"
|
||||
class="page-link">Suivante</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<?php
|
||||
};
|
||||
?>
|
@ -4,19 +4,29 @@
|
||||
<?php
|
||||
if ($_SESSION['typeU'] != 'comptable') {
|
||||
echo '<h3>Gérer mes fiches de frais</h3>';
|
||||
} else {
|
||||
echo '<h3>Gérer les fiches de frais de :</h3>';
|
||||
echo '<select class="form-select" name="selVisiteur" id="">';
|
||||
foreach ($LesUtilisateurs as $key => $value) {
|
||||
$id = $value['uId'];
|
||||
$prenom = $value['uPrenom'];
|
||||
$nom = $value['uNom'];
|
||||
} else { ?>
|
||||
|
||||
echo '<option value="' . $id . '">' . $nom . " " . $prenom . "</option>";
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
<form action="index.php?direction=gestionFiche" method="POST">
|
||||
<?php
|
||||
echo '<h3>Gérer les fiches de frais de :</h3>';
|
||||
echo '<select class="form-select" name="selVisiteur" id="">';
|
||||
foreach ($LesUtilisateurs as $key => $value) {
|
||||
$id = $value['uId'];
|
||||
$prenom = $value['uPrenom'];
|
||||
$nom = $value['uNom'];
|
||||
|
||||
if ($id == $userId) {
|
||||
echo '<option value="' . $id . '" selected>' . $nom . " " . $prenom . "</option>";
|
||||
} else {
|
||||
echo '<option value="' . $id . '">' . $nom . " " . $prenom . "</option>";
|
||||
}
|
||||
}
|
||||
echo '</select>'; ?>
|
||||
<button type="submit" class="btn btn-dark m-2">Selectionner</button>
|
||||
<!-- Fin du formulaire -->
|
||||
<?php }
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
</center>
|
||||
@ -32,45 +42,56 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">Novembre</th>
|
||||
<td>351 €</td>
|
||||
<td>en cours...</td>
|
||||
<td><a href="#">voir</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Octobre</th>
|
||||
<td>1458 €</td>
|
||||
<td>en cours...</td>
|
||||
<td><a href="#">voir</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Septembre</th>
|
||||
<td>1112 €</td>
|
||||
<td>classé</td>
|
||||
<td><a href="#">voir</a></td>
|
||||
</tr>
|
||||
<?php foreach ($lesFiches as $uneFiche) { ?>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?= $gestionFiche->dateComplete($uneFiche['rMois']) ?>
|
||||
</th>
|
||||
<td>
|
||||
<?= $uneFiche['rMontantValide'] ?> €
|
||||
</td>
|
||||
<td>
|
||||
<?= $uneFiche['eLibelle'] ?>
|
||||
</td>
|
||||
<td><a
|
||||
href="index.php?direction=nouvelleFiche&userId=<?= $userId ?>&dateListing=<?= $uneFiche['rMois'] ?>">voir</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
PAGINATION:// NE PAS TOUCHER
|
||||
PAGINATION:
|
||||
-->
|
||||
<div class="col-4 d-flex mx-auto">
|
||||
<nav aria-label="...">
|
||||
<ul class="pagination">
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link">Previous</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item active" aria-current="page">
|
||||
<a class="page-link" href="#">2</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<?php if ($pages > 0) { ?>
|
||||
<div class="col-4 d-flex mx-auto">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<!-- Lien vers la page précédente (désactivé si on se trouve sur la 1ère page) -->
|
||||
<li class="page-item <?= ($currentPage == 1) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=gestionFiche&page=<?= $currentPage - 1 ?>&selVisiteur=<?= $userId ?>"
|
||||
class="page-link">Précédente</a>
|
||||
</li>
|
||||
<?php for ($page = 1; $page <= $pages; $page++): ?>
|
||||
<!-- Lien vers chacune des pages (activé si on se trouve sur la page correspondante) -->
|
||||
<li class="page-item <?= ($currentPage == $page) ? "active" : "" ?>">
|
||||
<a href="index.php?direction=gestionFiche&page=<?= $page ?>&selVisiteur=<?= $userId ?>"
|
||||
class="page-link">
|
||||
<?= $page ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endfor ?>
|
||||
<!-- Lien vers la page suivante (désactivé si on se trouve sur la dernière page) -->
|
||||
<li class="page-item <?= ($currentPage == $pages) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=gestionFiche&page=<?= $currentPage + 1 ?>&selVisiteur=<?= $userId ?>"
|
||||
class="page-link">Suivante</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<?php
|
||||
};
|
||||
?>
|
@ -4,6 +4,10 @@
|
||||
<p>Mois de
|
||||
<?= $dateHeader ?>
|
||||
</p>
|
||||
<p class="color-grey" id='idFiche' data-id="<?= $userId . '-' . $date ?>">
|
||||
ID:
|
||||
<?= $userId . '-' . $date ?>
|
||||
</p>
|
||||
</center>
|
||||
<br>
|
||||
<!--
|
||||
@ -24,18 +28,18 @@
|
||||
<?php
|
||||
foreach ($listeFraisForfaitaire as $key => $value):
|
||||
?>
|
||||
<tr>
|
||||
<tr data-id="<?= $value['fId'] ?>" class="fraisForfaitaire">
|
||||
<th scope="row">
|
||||
<?= $value['fLibelle'] ?>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="fraisForfait-<?= $value['fId'] ?>" class="form-control frsFrt"
|
||||
id="<?= $key ?>" value="<?= $value['lfQuantite'] ?>" <?= $disabled ?>>
|
||||
<input type="text" name="fraisForfait" class="form-control frsFrt" id="<?= $key ?>"
|
||||
value="<?= $value['lfQuantite'] ?>" <?= $disabled ?>>
|
||||
</td>
|
||||
<td id="mttFrs-<?= $key ?>" data-price="<?= $value['fMontant'] ?>">
|
||||
<?= $value['fMontant'] ?> €
|
||||
</td>
|
||||
<td id="totalFrs-<?= $key ?>">
|
||||
<td class="mttFrsTotal" id="totalFrs-<?= $key ?>">
|
||||
<?= $value['fTotal'] ?>€
|
||||
</td>
|
||||
</tr>
|
||||
@ -70,7 +74,8 @@
|
||||
<?php
|
||||
foreach ($listeFraisHf as $key => $value):
|
||||
?>
|
||||
<tr id="fraisHf-<?= $key ?>" class="fraisHF <?= $value['lhRefus'] == 1 ? 'table-danger' : '' ?>">
|
||||
<tr id="fraisHf-<?= $key ?>" data-id="<?= $value['lhId'] ?>"
|
||||
class="fraisHF <?= $value['lhRefus'] == 1 ? 'table-danger' : '' ?>" data-id="<?= $value['lhId'] ?>">
|
||||
<th scope="row" id="dateFrsHF">
|
||||
<?= $value['lhDate'] ?>
|
||||
</th>
|
||||
@ -86,11 +91,13 @@
|
||||
<td>
|
||||
<?php
|
||||
if ($typeUser === 'comptable') { ?>
|
||||
<button type="button" class="btn btn-outline-primary btnRefuseFraisHf" id="frsSup-<?= $key ?>" <?= $disabled ?>>
|
||||
Refuser
|
||||
<button type="button" class="btn btn-outline-primary btnRefuseFraisHf"
|
||||
data-status="<?= $value['lhRefus'] | 0 ?>" id="frsSup-<?= $key ?>" <?= $disabled ?>>
|
||||
<?= ($value['lhRefus']) ? 'Accepter' : 'Refuser' ?>
|
||||
</button>
|
||||
<?php } elseif ($typeUser === 'visiteur') { ?>
|
||||
<button type="button" class="btn btn-outline-primary btnSuprFraisHf" id="frsSup-<?= $key ?>" <?= $disabled ?>>
|
||||
<button type="button" class="btn btn-outline-primary btnSuprFraisHf" id="frsSup-<?= $key ?>"
|
||||
<?= $disabled ?>>
|
||||
Supprimer
|
||||
</button>
|
||||
<?php } ?>
|
||||
@ -103,30 +110,29 @@
|
||||
Formulaire d'ajout de frais HF
|
||||
-->
|
||||
<?php
|
||||
if ($disabled !== 'disabled'):
|
||||
?>
|
||||
<tr class="newFraisForm">
|
||||
<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>
|
||||
<td><input type="text" name="mttHf" id="mttHf" class="form-control" placeholder="Saisir un Montant">
|
||||
</td>
|
||||
<td><input type="file" class="form-control"></td>
|
||||
<td><button type="button" class="btn btn-outline-primary validFraisHF">Valider</button></td>
|
||||
</tr>
|
||||
if ($disabled !== 'disabled' && $typeUser !== 'comptable'):
|
||||
?>
|
||||
<tr class="newFraisForm">
|
||||
<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>
|
||||
<td><input type="text" name="mttHf" id="mttHf" class="form-control" placeholder="Saisir un Montant">
|
||||
</td>
|
||||
<td><input type="file" class="form-control"></td>
|
||||
<td><button type="button" class="btn btn-outline-primary validFraisHF">Valider</button></td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
<tr>
|
||||
<td colspan="2" class="border-0"></td>
|
||||
<td class="table-primary" id="total-frais-HF">TOTAL: 0€</td> <!--COMPLETE HERE -->
|
||||
<td class="table-primary" id="total-frais-HF">TOTAL: 0€</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- <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">
|
||||
@ -134,13 +140,6 @@
|
||||
<?= $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>
|
||||
-->
|
||||
<?php
|
||||
/**
|
||||
* Affiche le bouton si fiche non cloturé
|
||||
@ -148,8 +147,10 @@
|
||||
if ($status === 'CR'):
|
||||
?>
|
||||
<div class="col-3 d-flex mx-auto my-5 justify-content-center">
|
||||
<button type="button" class="btn btn-outline-primary btn-lg" data-uType="<?= $typeUser ?>">Envoyer la Fiche
|
||||
<button type="button" class="btn btn-outline-primary btn-lg" id="sendFileBtn" data-uType="<?= $typeUser ?>">Envoyer
|
||||
la Fiche
|
||||
</button>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<script src="../include/newFiche.js"></script>
|
||||
<script src="include/newFiche.js"></script>
|
||||
<!-- <script src="../include/newFiche.js"></script> -->
|
Reference in New Issue
Block a user