diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index a0fc2bf..9331bb0 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -132,14 +132,13 @@ class UtilisateurControleur $imgMdl = new ImageModele; $offreMdl = new OffreModele(); - $imgid = $imgMdl->publierImage(); - $offreMdl->publierOffre($imgid); - - + $img = $imgMdl->publierImage(); + $offreMdl->publierOffre($img); + global $twig; + echo $twig->render('Offres.html', [$offreMdl->getOffres()]); } - protected function testAction() { echo "test action "; diff --git a/php/src/gateway/OffreGateway.php b/php/src/gateway/OffreGateway.php index ff691ac..67f19d8 100755 --- a/php/src/gateway/OffreGateway.php +++ b/php/src/gateway/OffreGateway.php @@ -1,6 +1,7 @@ array($offre->isRemote(), \PDO::PARAM_BOOL) )); } + + + public function obtenirOffres() : string + { + $alGw = new AlumniGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); + $query = 'SELECT * FROM Offre'; + $this->con->executeQuery($query, array()); + $res = $this->con->getResults(); + $offres = array(); + foreach ($res as $row) + { + $alumni = $alGw->findById($row['offreur']); + $offre = new Offre($row['id'], $alumni, $row['nom'], $row['description'], $row['imgId'], $row['typeContrat'], $row['ville'], $row['descriptifPoste'], $row['profil'], $row['experience'], $row['niveauEtudes'], $row['mailContact'], $row['numero'], $row['siteUrl'], $row['remote']); + array_push($offres, $offre); + } + return $offres; + } } \ No newline at end of file diff --git a/php/src/metier/Offre.php b/php/src/metier/Offre.php index 0da6555..5e786fa 100755 --- a/php/src/metier/Offre.php +++ b/php/src/metier/Offre.php @@ -88,7 +88,7 @@ class Offre //private \App\metier\NiveauEtudes $niveauEtudes; private string $niveauEtudes; - private int $imgId; + private Image $img; /** * @var string Email de contact @@ -128,7 +128,7 @@ class Offre Alumni $offreur, string $nom, string $description, - int $imgId, + Image $imgId, string $typeContrat, //\App\metier\TypeContrat $typeContrat, string $ville, @@ -188,7 +188,7 @@ class Offre public function getImgId(): int { - return $this->imgId; + return $this->img->getId(); } public function getTypeContrat(): string diff --git a/php/src/modele/ImageModele.php b/php/src/modele/ImageModele.php index e08a715..342439f 100644 --- a/php/src/modele/ImageModele.php +++ b/php/src/modele/ImageModele.php @@ -13,7 +13,7 @@ class ImageModele $this->gw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica","test","test")); } - public function publierImage() + public function publierImage() : Image { $img = new Image($this->gw->getNewId(), $_FILES["image"]["name"], @@ -23,7 +23,7 @@ class ImageModele $this->gw->insertImage($img); - return $this->gw->trouverParNom($img->getName())->getId(); + return $img; } public function insertImage(Image $img) diff --git a/php/src/modele/OffreModele.php b/php/src/modele/OffreModele.php index e28bf15..128056e 100644 --- a/php/src/modele/OffreModele.php +++ b/php/src/modele/OffreModele.php @@ -8,6 +8,7 @@ use App\metier\Alumni; use App\metier\TypeContrat; use App\metier\niveauEtudes; use App\metier\Offre; +use App\metier\Image; class OffreModele { @@ -19,7 +20,7 @@ class OffreModele $this->offreGw = new OffreGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); } - public function publierOffre($imgId) + public function publierOffre(Image $img) { $desc = $_POST["description"]; @@ -63,7 +64,7 @@ class OffreModele new Alumni(12,"test.mail@icloud.fr","password","admin"), $nom, $desc, - $imgId, + $img, $typeContrat, $ville, $entreprise, @@ -80,5 +81,10 @@ class OffreModele echo "offre inséerée"; } + public function obtenirOffres() : array + { + $offres = $this->offreGw->getOffres(); + return $offres; + } } \ No newline at end of file