Merge branch 'pagination-feature'
This commit is contained in:
commit
a00620beef
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ if ($_SESSION["typeU"] == "comptable") {
|
||||
$userId = $_SESSION['uId'];
|
||||
}
|
||||
|
||||
$lesFiches = $gestionFiche->get_ficheAvalider();
|
||||
|
||||
|
||||
|
||||
include("vues/v_fichesAvalider.php");
|
||||
|
@ -16,8 +16,16 @@ if ($_SESSION["typeU"] == "comptable") {
|
||||
$userId = $_SESSION['uId'];
|
||||
}
|
||||
|
||||
$lesFiches = $gestionFiche->get_ListesFiches($userId);
|
||||
//Pagination
|
||||
if(isset($_GET['page']) && !empty($_GET['page'])){
|
||||
$currentPage = (int) strip_tags($_GET['page']);
|
||||
}else{
|
||||
$currentPage = 1;
|
||||
}
|
||||
|
||||
$pages = ceil($gestionFiche->get_nbRemboursement($userId) / $gestionFiche::$NB_LIGNES_PAGINATION);
|
||||
|
||||
|
||||
$lesFiches = $gestionFiche->get_Page($currentPage, $userId);
|
||||
|
||||
include("vues/v_gestionFiches.php");
|
||||
|
@ -1,3 +1,7 @@
|
||||
<div class="text-center">
|
||||
<br>
|
||||
<h3>Fiches à valider</h3>
|
||||
</div>
|
||||
<div class="col-11 d-flex mx-auto">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
@ -32,4 +36,35 @@
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if ($pages > 0) { ?>
|
||||
<div class="col-4 d-flex mx-auto">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<!-- Lien vers la page précédente (désactivé si on se trouve sur la 1ère page) -->
|
||||
<li class="page-item <?= ($currentPage == 1) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=ficheAvalider&page=<?= $currentPage - 1 ?>"
|
||||
class="page-link">Précédente</a>
|
||||
</li>
|
||||
<?php for ($page = 1; $page <= $pages; $page++): ?>
|
||||
<!-- Lien vers chacune des pages (activé si on se trouve sur la page correspondante) -->
|
||||
<li class="page-item <?= ($currentPage == $page) ? "active" : "" ?>">
|
||||
<a href="index.php?direction=ficheAvalider&page=<?= $page ?>"
|
||||
class="page-link">
|
||||
<?= $page ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endfor ?>
|
||||
<!-- Lien vers la page suivante (désactivé si on se trouve sur la dernière page) -->
|
||||
<li class="page-item <?= ($currentPage == $pages) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=ficheAvalider&page=<?= $currentPage + 1 ?>"
|
||||
class="page-link">Suivante</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<?php
|
||||
};
|
||||
?>
|
@ -12,9 +12,9 @@
|
||||
echo '<select class="form-select" name="selVisiteur" id="">';
|
||||
foreach ($LesUtilisateurs as $key => $value) {
|
||||
$id = $value['uId'];
|
||||
$prenom = $value['uPrenom'];
|
||||
$prenom = $value['uPrenom'];
|
||||
$nom = $value['uNom'];
|
||||
|
||||
|
||||
if ($id == $userId) {
|
||||
echo '<option value="' . $id . '" selected>' . $nom . " " . $prenom . "</option>";
|
||||
} else {
|
||||
@ -22,7 +22,7 @@
|
||||
}
|
||||
}
|
||||
echo '</select>'; ?>
|
||||
<button type="submit" class="btn btn-dark m-2" >Selectionner</button>
|
||||
<button type="submit" class="btn btn-dark m-2">Selectionner</button>
|
||||
<!-- Fin du formulaire -->
|
||||
<?php }
|
||||
?>
|
||||
@ -63,22 +63,35 @@
|
||||
</div>
|
||||
|
||||
<!--
|
||||
PAGINATION:// NE PAS TOUCHER
|
||||
PAGINATION:
|
||||
-->
|
||||
<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>
|
||||
|
||||
<?php if ($pages > 0) { ?>
|
||||
<div class="col-4 d-flex mx-auto">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<!-- Lien vers la page précédente (désactivé si on se trouve sur la 1ère page) -->
|
||||
<li class="page-item <?= ($currentPage == 1) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=gestionFiche&page=<?= $currentPage - 1 ?>&selVisiteur=<?= $userId ?>"
|
||||
class="page-link">Précédente</a>
|
||||
</li>
|
||||
<?php for ($page = 1; $page <= $pages; $page++): ?>
|
||||
<!-- Lien vers chacune des pages (activé si on se trouve sur la page correspondante) -->
|
||||
<li class="page-item <?= ($currentPage == $page) ? "active" : "" ?>">
|
||||
<a href="index.php?direction=gestionFiche&page=<?= $page ?>&selVisiteur=<?= $userId ?>"
|
||||
class="page-link">
|
||||
<?= $page ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endfor ?>
|
||||
<!-- Lien vers la page suivante (désactivé si on se trouve sur la dernière page) -->
|
||||
<li class="page-item <?= ($currentPage == $pages) ? "disabled" : "" ?>">
|
||||
<a href="index.php?direction=gestionFiche&page=<?= $currentPage + 1 ?>&selVisiteur=<?= $userId ?>"
|
||||
class="page-link">Suivante</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<?php
|
||||
};
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user