diff --git a/Class/class.gestionFiche.php b/Class/class.gestionFiche.php index fd20890..8a085ad 100644 --- a/Class/class.gestionFiche.php +++ b/Class/class.gestionFiche.php @@ -3,6 +3,7 @@ class Class_gestionFiche { private $pdo = null; + public $NB_LIGNES_PAGINATION = 12; public function __construct(PdoGsb $pDO) { @@ -13,7 +14,7 @@ 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(); } @@ -25,20 +26,20 @@ class Class_gestionFiche 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(); + $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(): array { $req = 'SELECT "rMois", "rVisiteur", "rEtat", ROUND("rMontantValide", 2) as "rMontantValide", "eLibelle", "uNom", "uPrenom" from remboursement @@ -47,9 +48,30 @@ class Class_gestionFiche where "rEtat"=\'CL\' ORDER BY "rMois" ASC'; $result = $this->pdo->prepare($req); - $result ->execute(); + $result->execute(); return $result->fetchAll(); } + 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_nbPage(int $decalage): array + { + $req = 'SELECT * FROM remboursement ORDER BY "rDateModif" DESC LIMIT :nbLignes offset :decalage;'; + $result = $this->pdo->prepare($req); + $result->bindParam('nbLigne', $this->NB_LIGNES_PAGINATION); + $result->bindParam('decalage', $decalage); + $result->execute(); + + return $result->fetchAll(PDO::FETCH_ASSOC); + } } \ No newline at end of file diff --git a/controleurs/c_ficheAvalider.php b/controleurs/c_ficheAvalider.php index bf2e9ab..dfc5c3c 100644 --- a/controleurs/c_ficheAvalider.php +++ b/controleurs/c_ficheAvalider.php @@ -19,5 +19,4 @@ if ($_SESSION["typeU"] == "comptable") { $lesFiches = $gestionFiche->get_ficheAvalider(); - include("vues/v_fichesAvalider.php"); \ No newline at end of file diff --git a/controleurs/c_gestionFiche.php b/controleurs/c_gestionFiche.php index 393ddb9..b6924d4 100644 --- a/controleurs/c_gestionFiche.php +++ b/controleurs/c_gestionFiche.php @@ -16,6 +16,17 @@ if ($_SESSION["typeU"] == "comptable") { $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) / 12); + + + $lesFiches = $gestionFiche->get_ListesFiches($userId); diff --git a/vues/v_fichesAvalider.php b/vues/v_fichesAvalider.php index ff01b06..97afab7 100644 --- a/vues/v_fichesAvalider.php +++ b/vues/v_fichesAvalider.php @@ -32,4 +32,22 @@ + + +
+
\ No newline at end of file diff --git a/vues/v_gestionFiches.php b/vues/v_gestionFiches.php index 9f2495e..422fc66 100644 --- a/vues/v_gestionFiches.php +++ b/vues/v_gestionFiches.php @@ -65,7 +65,11 @@ +
+