HTML/CSS/PHP recherche par catégorie ok. creation et update entités, models et controllers
This commit is contained in:
parent
3f87b615fa
commit
47ee556a8c
4 changed files with 125 additions and 6 deletions
|
|
@ -1,17 +1,19 @@
|
|||
<?php
|
||||
require("../app/models/project_model.php");
|
||||
require("../app/entities/project_entity.php");
|
||||
require("../app/models/category_model.php");
|
||||
require("../app/entities/category_entity.php");
|
||||
|
||||
/**
|
||||
* Le controler des Project
|
||||
* @author Yasser
|
||||
* @author Yasser & Laura
|
||||
*/
|
||||
class ProjectCtrl{
|
||||
|
||||
|
||||
/**
|
||||
* Fonction d'affichage de la page d'acceuil
|
||||
*/
|
||||
|
||||
public function home(){
|
||||
|
||||
$objProjectModel = new ProjectModel;
|
||||
|
|
@ -29,6 +31,10 @@
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction d'affichage de la barre de recherche
|
||||
*/
|
||||
|
||||
public function search(){
|
||||
|
||||
// inclusion du header
|
||||
|
|
@ -41,6 +47,7 @@
|
|||
$strDate = $_GET['date']??'';
|
||||
$strStartDate = $_GET['startdate']??'';
|
||||
$strEndDate = $_GET['enddate']??'';
|
||||
$intCategory = $_GET['category']??0;
|
||||
|
||||
// Récupération des Projects
|
||||
$objProjectModel = new ProjectModel;
|
||||
|
|
@ -59,18 +66,27 @@
|
|||
}
|
||||
|
||||
// Récupération des utilisateurs
|
||||
require("../app/models/user_model.php");
|
||||
require_once("../app/models/user_model.php");
|
||||
$objUserModel = new UserModel;
|
||||
$arrUser = $objUserModel->findAllUsers();
|
||||
|
||||
// Récupération des catégories
|
||||
require_once("../app/models/category_model.php");
|
||||
$objCategoryModel = new CategoryModel;
|
||||
$arrCategory = $objCategoryModel->findAllCategory();
|
||||
|
||||
|
||||
include('../app/views/search.php');
|
||||
include('../app/views/partials/footer.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction d'affichage de la page projet
|
||||
*/
|
||||
|
||||
public function project (){
|
||||
include("../app/views/partials/header.php");
|
||||
include('../app/views/project.php');
|
||||
include('../app/views/project.php');
|
||||
include('../app/views/partials/footer.php');
|
||||
|
||||
}
|
||||
}
|
||||
55
app/entities/category_entity.php
Normal file
55
app/entities/category_entity.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
require_once("mother_entity.php");
|
||||
/**
|
||||
* Classe d'un objet Projet
|
||||
* @author Laura
|
||||
*/
|
||||
|
||||
class Category extends Entity{
|
||||
|
||||
private int $_id;
|
||||
protected string $_name = '';
|
||||
|
||||
/**
|
||||
* Constructeur (j'ai toujours pas compris à quoi ça sert)
|
||||
*/
|
||||
public function __construct(){
|
||||
$this->_prefix = 'category_';
|
||||
}
|
||||
|
||||
// Méthode Getter et Setter
|
||||
|
||||
/**
|
||||
* Récuperation de l'id du Projet
|
||||
* @return int l'id de la catégorie
|
||||
*/
|
||||
public function getId():int{
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour de l'id de la catégorie
|
||||
* @param int le nouvelle id
|
||||
*/
|
||||
public function setId($id){
|
||||
$this->_id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récuperation du nom de la catégorie
|
||||
* @return string nom de la catégorie
|
||||
*/
|
||||
public function getName(){
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour du nom de la catégorie
|
||||
* @param string le nouveau nom de la catégorie
|
||||
*/
|
||||
public function setName($name){
|
||||
$this->_name = $name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
25
app/models/category_model.php
Normal file
25
app/models/category_model.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
require_once('../config/database.php');
|
||||
|
||||
/**
|
||||
* Classe d'un objet Projet
|
||||
* @author Laura
|
||||
*/
|
||||
|
||||
class CategoryModel extends Connect{
|
||||
|
||||
public function findAllCategory(int $intLimit=0):array{
|
||||
|
||||
// Ecrire la requête
|
||||
$strRq = "SELECT category.*
|
||||
FROM category";
|
||||
|
||||
|
||||
if ($intLimit > 0){
|
||||
$strRq .= " LIMIT ".$intLimit;
|
||||
}
|
||||
|
||||
// Lancer la requête et récupérer les résultats
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div class="col-12">
|
||||
<div class="col-6">
|
||||
<fieldset>
|
||||
<legend class="form-label">Type de recherche par date</legend>
|
||||
<div class="form-check form-check-inline">
|
||||
|
|
@ -74,6 +74,29 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<!-- AJOUT RECHERCHE PAR CATEGORIE -->
|
||||
<div class="col-6">
|
||||
<fieldset>
|
||||
<legend class="form-label">Type de recherche par catégories</legend>
|
||||
<div class="col-md-6">
|
||||
<label for="author" class="form-label">Catégorie</label>
|
||||
<select class="form-select" id="category" name="category">
|
||||
<option value="0" <?php echo ($intCategory == 0)?'selected':''; ?>>Toutes les catégories</option>
|
||||
<?php
|
||||
foreach($arrCategory as $arrDetCategory){
|
||||
?>
|
||||
<option value="<?php echo $arrDetCategory['category_id']; ?>"
|
||||
<?php echo ($intCategory == $arrDetCategory['category_id'])?'selected':''; ?>
|
||||
>
|
||||
<?php echo $arrDetCategory['category_name']; ?>
|
||||
</option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6" id="date-exact">
|
||||
<label for="date" class="form-label">Date</label>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue