diff --git a/Class/class.gestionFiche.php b/Class/class.gestionFiche.php index fd20890..0d16b70 100644 --- a/Class/class.gestionFiche.php +++ b/Class/class.gestionFiche.php @@ -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,43 +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 get_ListesFiches(string $idUtilisateur): array - { - $req = 'SELECT "rMois", "rEtat", "rNbJustificatifs", ROUND("rMontantValide", 2) as "rMontantValide", "eLibelle" - FROM remboursement - INNER JOIN etat ON etat."eId"=remboursement."rEtat" - WHERE "rVisiteur"= :userId - ORDER BY "rMois" DESC'; - - $result = $this->pdo->prepare($req); - $result ->bindParam("userId", $idUtilisateur); - $result ->execute(); - - return $result->fetchAll(); - } - - public function dateComplete(string $date) : string + public function dateComplete(string $date): string { return substr($date, 0, 4) . '-' . substr($date, 4); } - public function get_ficheAvalider() : array + public function get_ficheAvalider(int $nPage): array { - $req = 'SELECT "rMois", "rVisiteur", "rEtat", ROUND("rMontantValide", 2) as "rMontantValide", "eLibelle", "uNom", "uPrenom" + $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'; + ORDER BY "rMois" ASC + LIMIT :nbLignes offset :decalage;'; $result = $this->pdo->prepare($req); - $result ->execute(); + $result->bindParam('nbLignes', $this::$NB_LIGNES_FICHEAVALIDER); + $result->bindParam('decalage', $decalage); + $result->execute(); return $result->fetchAll(); } -} \ No newline at end of file + 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); + } +} diff --git a/controleurs/c_ficheAvalider.php b/controleurs/c_ficheAvalider.php index 12422ff..68c5d2f 100644 --- a/controleurs/c_ficheAvalider.php +++ b/controleurs/c_ficheAvalider.php @@ -16,6 +16,7 @@ if ($_SESSION["typeU"] == "comptable") { $userId = $_SESSION['uId']; } -$lesFiches = $gestionFiche->get_ficheAvalider(); + + include("vues/v_fichesAvalider.php"); diff --git a/controleurs/c_gestionFiche.php b/controleurs/c_gestionFiche.php index d68d2cf..1d19c29 100644 --- a/controleurs/c_gestionFiche.php +++ b/controleurs/c_gestionFiche.php @@ -18,6 +18,7 @@ if ($typeU == "comptable") { $userId = $_SESSION['uId']; } -$lesFiches = $gestionFiche->get_ListesFiches($userId); + + include("vues/v_gestionFiches.php"); diff --git a/vues/v_fichesAvalider.php b/vues/v_fichesAvalider.php index ff01b06..69ba3d9 100644 --- a/vues/v_fichesAvalider.php +++ b/vues/v_fichesAvalider.php @@ -1,3 +1,7 @@ +