ajout d'une fiche si non existante et test selon l'etat de la fiche courante
This commit is contained in:
@@ -4,11 +4,34 @@ class Class_newFiche
|
||||
{
|
||||
private $pdo = null;
|
||||
|
||||
public function __construct(PdoGsb $pDO)
|
||||
private $month;
|
||||
private $userId;
|
||||
|
||||
public function __construct(PdoGsb $pDO, string $userId, string $month)
|
||||
{
|
||||
$this->pdo = $pDO->getPdoGsb();
|
||||
$this->month = $month;
|
||||
$this->userId = $userId;
|
||||
|
||||
$this->existingFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test et ajoute la fiche si elle n'existe pas
|
||||
*/
|
||||
private function existingFile(): void
|
||||
{
|
||||
$req = 'SELECT newremboursement(:idUser, :month); ';
|
||||
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam('idUser', $this->userId);
|
||||
$result->bindParam('month', $this->month);
|
||||
$result->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste les frais forfaitaires
|
||||
*/
|
||||
public function listFraisForfaitaires(): array
|
||||
{
|
||||
$req = 'SELECT "fLibelle", NULL AS "lfQuantite", round("fMontant", 2) AS "fMontant", 0 AS "fTotal", "fId" FROM forfait';
|
||||
@@ -18,7 +41,10 @@ class Class_newFiche
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public function listFraisForfaitForU(string $idUser, int $month): array
|
||||
/**
|
||||
* Liste les frais Forfetaires d'un user pour 1 mois
|
||||
*/
|
||||
public function listFraisForfaitForU(): array
|
||||
{
|
||||
$req = 'SELECT "fLibelle", "lfQuantite", ROUND("fMontant", 2) AS "fMontant", ROUND("lfQuantite" * "fMontant", 2) AS "fTotal", "fId"
|
||||
FROM remboursement
|
||||
@@ -27,14 +53,17 @@ class Class_newFiche
|
||||
WHERE "rVisiteur" = :idUser AND "rMois" = :monthF;';
|
||||
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam('idUser', $idUser);
|
||||
$result->bindParam('monthF', $month);
|
||||
$result->bindParam('idUser', $this->userId);
|
||||
$result->bindParam('monthF', $this->month);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public function listFraisHF(string $idVisiteur, int $month): array
|
||||
/**
|
||||
* Liste les frais hors forfait d'un user pour 1 mois
|
||||
*/
|
||||
public function listFraisHF(): array
|
||||
{
|
||||
$req = 'SELECT to_char("lhDate", \'YYYY-mm-dd\') AS "lhDate",
|
||||
"lhLibelle", ROUND("lhMontant",2) as "lhMontant",
|
||||
@@ -47,24 +76,43 @@ class Class_newFiche
|
||||
ORDER BY "lhDate";';
|
||||
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam(':idVisiteur', $idVisiteur);
|
||||
$result->bindParam(':mois', $month);
|
||||
$result->bindParam(':idVisiteur', $this->userId);
|
||||
$result->bindParam(':mois', $this->month);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public function getMontantValide(string $idVisiteur, int $month): float
|
||||
/**
|
||||
* Fonction qui renvoie le prix total validé d'une fiche de frais
|
||||
*
|
||||
* AJOUTER UNE FONCTION QUI CREE LA FICHE DE FRAIS LORS DU SELECT SI CELLE CI N'EXISTE PAS
|
||||
*/
|
||||
public function getMontantValide(): 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->bindParam(':idVisiteur', $this->userId);
|
||||
$result->bindParam(':mois', $this->month);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll()[0]['rMontantValide'];
|
||||
return $result->fetch()['rMontantValide'];
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
$req = 'select etat."eId" from remboursement
|
||||
INNER JOIN etat on etat."eId" = remboursement."rEtat"
|
||||
WHERE "rVisiteur" = :idVisiteur AND "rMois" = :mois ;';
|
||||
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->bindParam(':idVisiteur', $this->userId);
|
||||
$result->bindParam(':mois', $this->month);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetch()['eId'];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user