php barre de recherche, ajout controller, update models

This commit is contained in:
laura.chevillet 2026-01-16 16:41:13 +01:00
parent 63da2a35b5
commit 3f87b615fa
6 changed files with 51 additions and 38 deletions

View file

@ -35,10 +35,16 @@
include('../app/views/partials/header.php');
//Récupérer les informations du Formulaire
$strKeywords = $_GET['keywords']??'';
$intAuthor = $_GET['author']??0;
$intPeriod = $_GET['period']??0;
$strDate = $_GET['date']??'';
$strStartDate = $_GET['startdate']??'';
$strEndDate = $_GET['enddate']??'';
// Récupération des Projects
$objProjectModel = new ProjectModel;
//$arrProject = findAll(0, $strKeywords, $intAuthor, $intPeriod, $strDate, $strStartDate, $strEndDate);
// Depuis PHP 8 - accès direct aux paramètres
$arrProject = $objProjectModel->findAll();
@ -60,4 +66,11 @@
include('../app/views/search.php');
include('../app/views/partials/footer.php');
}
public function project (){
include("../app/views/partials/header.php");
include('../app/views/project.php');
include('../app/views/partials/footer.php');
}
}

View file

@ -32,18 +32,11 @@ class UserCtrl{
$arrError[] = "Mail ou mot de passe invalide";
}else{
// Ajoute l'utilisateur en session
/*$_SESSION['firstname'] = $arrResult['user_firstname'];
$_SESSION['name'] = $arrResult['user_name'];
$_SESSION['id'] = $arrResult['user_id'];*/
// j'enlève le mot de passe avant la session
//unset($arrResult['user_pwd']);
$_SESSION['user'] = $arrResult;
$_SESSION['success'] = "Bienvenue, vous êtes bien connecté";
header("Location:index.php");
exit;
//var_dump($_SESSION);
//var_dump("Connecté");
}
}
}
@ -55,8 +48,6 @@ class UserCtrl{
public function logout(){
session_start();
/*session_destroy();
session_start();*/
// on supprime l'utilisateur en session
unset($_SESSION['user']);

View file

@ -19,4 +19,11 @@
}
}
protected function nettoyer(string $strText){
$strText = trim($strText);
$strText = str_replace("<script>", "", $strText);
$strText = str_replace("</script>", "", $strText);
return $strText;
}
}

View file

@ -58,11 +58,6 @@
public function insert(object $objUser):bool{
// 2. Construire la requête
/*$strRq = "INSERT INTO users (user_name, user_firstname, user_mail, user_pwd)
VALUES ('".$objUser->getName()."',
'".$objUser->getFirstname()."',
'".$objUser->getMail()."',
'".$objUser->getPwdHash()."')";*/
$strRq = "INSERT INTO users (user_name, user_firstname, user_mail, user_pwd)
VALUES (:name, :firstname, :mail, :pwd)";
// Préparer la requête
@ -74,8 +69,6 @@
$rqPrep->bindValue(":pwd", $objUser->getPwdHash(), PDO::PARAM_STR);
// 3. Executer la requête
//var_dump($strRq);die;
//return $db->exec($strRq);
return $rqPrep->execute();
}
}

View file

@ -1,6 +1,3 @@
<?php
include("../app/views/partials/header.php");
?>
<body>
<section class="container mt-5 p-5 d-flex flex-column align-items-center">
<div>

View file

@ -27,8 +27,18 @@
<div class="col-md-6">
<label for="author" class="form-label">Auteur</label>
<select class="form-select" id="author" name="author">
<option value="0">Tous les auteurs</option>
<option value="0" <?php echo ($intAuthor == 0)?'selected':''; ?>>Tous les auteurs</option>
<?php
foreach($arrUser as $arrDetUser){
?>
<option value="<?php echo $arrDetUser['user_id']; ?>"
<?php echo ($intAuthor == $arrDetUser['user_id'])?'selected':''; ?>
>
<?php echo $arrDetUser['user_firstname'].' '.$arrDetUser['user_name']; ?>
</option>
<?php
}
?>
</select>
</div>
@ -43,6 +53,7 @@
name="period"
id="period-exact"
value="0"
<?php echo ($intPeriod == 0)?'checked':'' ; ?>
aria-controls="date-exact date-range">
<label class="form-check-label" for="period-exact">
Date exacte
@ -55,6 +66,7 @@
name="period"
id="period-range"
value="1"
<?php echo ($intPeriod == 1)?'checked':'' ; ?>
aria-controls="date-exact date-range">
<label class="form-check-label" for="period-range">
Période
@ -71,7 +83,7 @@
id="date"
name="date"
aria-describedby="date-help"
value="" >
value="<?php echo $strDate; ?>" >
<small id="date-help" class="form-text text-muted">
Format: JJ/MM/AAAA
</small>
@ -86,7 +98,7 @@
class="form-control"
id="startdate"
name="startdate"
value="" >
value="<?php echo $strStartDate; ?>" >
</div>
<div class="col-md-6">
<label for="enddate" class="form-label">Date de fin</label>
@ -95,7 +107,7 @@
class="form-control"
id="enddate"
name="enddate"
value="" >
value="<?php echo $strEndDate; ?>" >
</div>
</div>
</div>
@ -132,4 +144,4 @@
</div>
</section>
</div>
</section>
</section>