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)
{ {
@ -52,4 +53,25 @@ class Class_gestionFiche
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

@ -33,3 +33,21 @@
</tbody> </tbody>
</table> </table>
</div> </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>

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">