mise à jour de la bdd pour les fiches de frais et suppression des hors forfait
This commit is contained in:
@@ -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,98 @@ 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 "rVisiteur" = :userId AND "rMois" = :monthF AND "lhId" = :idFrais;';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam(':stateF', $state);
|
||||
$result->bindParam(':idFrais', $idFrais);
|
||||
$result->bindParam(':userId', $this->userId);
|
||||
$result->bindParam(':monthF', $this->month);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user