correction bug filtres offres

alexis-rendu
Baptiste D 1 year ago
parent e6f5518ebc
commit 02048befd8

@ -38,9 +38,10 @@ class FrontControleur
$router->map('POST','/[a:action]?','UtilisateurControleur');
$router->map('GET','/[a:action]/[i:id]?','UtilisateurControleur');
$router->map('GET|POST','/[a:action]/[i:id]?','UtilisateurControleur');
$router->map('GET|POST', '/user/[a:action]?', 'MembreControleur');
$router->map('GET|POST', '/user/[i:id]/[a:action]?', 'MembreControleur');
$router->map('GET|POST', '/user/[i:id]/[a:action]/[i:id2]?', 'MembreControleur');
@ -59,8 +60,6 @@ class FrontControleur
$id = array();
try{
$twig->render("accueil.html",[]);
if (!$match) {
$dVueErreur[] = "Error 404 Page not found";

@ -104,6 +104,14 @@ class UtilisateurControleur
echo 'not implemented yet';
}
public function resetFilters()
{
unset($_SESSION["niveauEtudes"]);
unset($_SESSION["typeContrat"]);
unset($_SESSION["experience"]);
$this->consultOffers(null);
}
public function consultOffers(?array $params)
{
$userMdl = new UtilisateurModele();
@ -117,16 +125,29 @@ class UtilisateurControleur
$nbOffers = 5 ;
if(isset($_POST["niveauEtudes"]) && Validation::validateTypeStudies($_POST["niveauEtudes"])) {
$niveauEtudes = $_POST["niveauEtudes"];
//$niveauEtudes = $_POST["niveauEtudes"];
$_SESSION["niveauEtudes"] = $_POST["niveauEtudes"];
$niveauEtudes = $_SESSION["niveauEtudes"];
}
else if(isset($_SESSION["niveauEtudes"]))
{$niveauEtudes = $_SESSION["niveauEtudes"];}
if(isset($_POST["typeContrat"]) && Validation::validateTypeContract($_POST["typeContrat"])) {
$typeContrat = $_POST["typeContrat"];
//$typeContrat = $_POST["typeContrat"];
$_SESSION["typeContrat"] = $_POST["typeContrat"];
$typeContrat = $_SESSION["typeContrat"];
}
else if(isset($_SESSION["typeContrat"]))
{$typeContrat = $_SESSION["typeContrat"];}
if(isset($_POST["experience"]) && Validation::validateExperience($_POST["experience"])) {
$exp = $_POST["experience"];
//$exp = $_POST["experience"];
$_SESSION["experience"] = $_POST["experience"];
$exp = $_SESSION["experience"];
}
else if(isset($_SESSION["experience"]))
{$exp = $_SESSION["experience"];}
if ($niveauEtudes == null && $typeContrat == null && $exp == null) {
$totalOffers = $userMdl->getNbOffers();
@ -144,8 +165,14 @@ class UtilisateurControleur
$numberPages = ceil($totalOffers / 5);
if (isset($_GET["page"]) && intval($_GET["page"]) != null) {
$page = intval($_GET["page"]);
//var_dump($params);
//echo "page : ".$params["id"];
/*if (isset($params["id"]) && intval($params["id"]) != null)*/
if(isset($_GET['id']) && intval($_GET['id']) != null)
{
$page = intval($_GET['id']);
//echo "page : ".$page;
if ($page > $numberPages || $page < 1) {
$dVueErreur[] = "Page introuvable";
echo $twig->render("erreur.html", ['dVueErreur' => $dVueErreur ]);

@ -79,7 +79,7 @@
</div>
<div>
<a href="{{dir}}/consultOffers" class="btn btn-info">Réinitialiser les filtres</a>
<a href="{{dir}}/resetFilters" class="btn btn-info">Réinitialiser les filtres</a>
</div>
</div>
@ -107,7 +107,7 @@
</div>
<div class="row3">
<img src="public/assets/location.png" alt="location">
<img src="{{dir}}/public/assets/location.png" alt="location">
<p>{{offre.getVille()}}</p>
</div>
<div class="d-flex justify-content-around">
@ -123,19 +123,15 @@
{% else %}
<li class="list-group-item">Aucune offre trouvée.</li>
{% endif %}
<nav style="text-align: center;">
<nav style="text-align: center;">
<nav class="pagination justify-content-center">
{% if numberPages is defined %}
{% if numberPages > 1 %}
{% if currentPage is defined %}
{% for i in 1..numberPages %}
{% if i == currentPage %}
<!--
index.php?action=consultOffers&page={{ i }}&typeContrat={{ typeContrat }}&experience={{ experience }}&niveauEtudes={{ niveauEtudes }}
-->
<a href="{{dir}}/consultOffers?page={{i}}{{valContrat}}{{valExp}}{{ValEtudes}}" class="current">{{ i }}</a>
<a href="{{ dir }}/consultOffers?id={{ i }}" class="page-item page-link current">{{ i }}</a>
{% else %}
<a href="{{dir}}/consultOffers?page={{i}}{{valContrat}}{{valExp}}{{ValEtudes}}">{{ i }}</a>
<a href="{{ dir }}/consultOffers?id={{ i }}" class="page-item page-link">{{ i }}</a>
{% endif %}
{% endfor %}
{% endif %}
@ -143,12 +139,12 @@
{% endif %}
</nav>
</nav>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

@ -23,7 +23,6 @@
{% endif %}
<img src="{{dir}}/public/uploads/{{offre.getLogo()}}" alt="Logo" class="img-thumbnail" style="max-height: 50px; max-width: 50px;"></li>
<li class="list-group-item"><img src="{{dir}}/public/uploads/{{offre.getImg()}}" alt="Offer Image" class="img-fluid"></li>
<!--<li class="list-group-item"><strong>ID:</strong> {{ offre.getId() }}</li> -->
<li class="list-group-item"><strong>Offreur:</strong> {{offre.getOffreur().Prenom()}} {{offre.getOffreur().getNom() }}</li>
<li class="list-group-item"><strong>Nom de l'offre:</strong> {{ offre.getNom() }}</li>
<li class="list-group-item"><strong>Entreprise :</strong> {{ offre.getEntreprise() }}</li>

Loading…
Cancel
Save