pagination gestion fiche

This commit is contained in:
Theo 2024-01-11 15:55:07 +01:00
parent af3771e786
commit c990aed3d3
5 changed files with 62 additions and 8 deletions

View File

@ -3,6 +3,7 @@
class Class_gestionFiche class Class_gestionFiche
{ {
private $pdo = null; private $pdo = null;
public $NB_LIGNES_PAGINATION = 12;
public function __construct(PdoGsb $pDO) 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;'; $req = 'SELECT "uId", "uNom", "uPrenom" FROM utilisateur WHERE "uStatut"!=0 ORDER BY "uNom" ASC;';
$result = $this->pdo->prepare($req); $result = $this->pdo->prepare($req);
$result ->execute(); $result->execute();
return $result->fetchAll(); return $result->fetchAll();
} }
@ -25,20 +26,20 @@ class Class_gestionFiche
INNER JOIN etat ON etat."eId"=remboursement."rEtat" INNER JOIN etat ON etat."eId"=remboursement."rEtat"
WHERE "rVisiteur"= :userId WHERE "rVisiteur"= :userId
ORDER BY "rMois" DESC'; ORDER BY "rMois" DESC';
$result = $this->pdo->prepare($req); $result = $this->pdo->prepare($req);
$result ->bindParam("userId", $idUtilisateur); $result->bindParam("userId", $idUtilisateur);
$result ->execute(); $result->execute();
return $result->fetchAll(); return $result->fetchAll();
} }
public function dateComplete(string $date) : string public function dateComplete(string $date): string
{ {
return substr($date, 0, 4) . '-' . substr($date, 4); 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" $req = 'SELECT "rMois", "rVisiteur", "rEtat", ROUND("rMontantValide", 2) as "rMontantValide", "eLibelle", "uNom", "uPrenom"
from remboursement from remboursement
@ -47,9 +48,30 @@ class Class_gestionFiche
where "rEtat"=\'CL\' where "rEtat"=\'CL\'
ORDER BY "rMois" ASC'; ORDER BY "rMois" ASC';
$result = $this->pdo->prepare($req); $result = $this->pdo->prepare($req);
$result ->execute(); $result->execute();
return $result->fetchAll(); 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);
}
} }

View File

@ -19,5 +19,4 @@ if ($_SESSION["typeU"] == "comptable") {
$lesFiches = $gestionFiche->get_ficheAvalider(); $lesFiches = $gestionFiche->get_ficheAvalider();
include("vues/v_fichesAvalider.php"); include("vues/v_fichesAvalider.php");

View File

@ -16,6 +16,17 @@ if ($_SESSION["typeU"] == "comptable") {
$userId = $_SESSION['uId']; $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); $lesFiches = $gestionFiche->get_ListesFiches($userId);

View File

@ -32,4 +32,22 @@
<?php } ?> <?php } ?>
</tbody> </tbody>
</table> </table>
</div>
<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> </div>

View File

@ -65,7 +65,11 @@
<!-- <!--
PAGINATION:// NE PAS TOUCHER PAGINATION:// NE PAS TOUCHER
--> -->
<div class="col-4 d-flex mx-auto"> <div class="col-4 d-flex mx-auto">
<?php
?>
<nav aria-label="..."> <nav aria-label="...">
<ul class="pagination"> <ul class="pagination">
<li class="page-item disabled"> <li class="page-item disabled">