debut "creerEvenement", mais problème récuperation image

evenements
Clément VERDOIRE 1 year ago
parent 2be9ba66f2
commit 32b92c325c

@ -8,5 +8,5 @@ $dConfig['includes']= array('controleur/Validation.php');
//BD //BD
$base = 'mysql:host=localhost;dbname=dbAlica'; $base = 'mysql:host=localhost;dbname=dbAlica';
$login = 'root'; $login = 'test';
$mdp = ''; $mdp = 'test';

@ -19,7 +19,7 @@ class FrontControleur
"deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler" "deconnexion","proposerOffre","consulterProfil","modifierProfil","signaler"
], ],
"Utilisateur" => [ "Utilisateur" => [
"connection", "inscription", "accueil","consulterProfilLimite" "connection", "inscription", "accueil","consulterProfilLimite","listerEvenement"
] ]
); );

@ -21,7 +21,7 @@ class UtilisateurControleur
global $twig; global $twig;
if (!isset($_REQUEST["action"])) { if (!isset($_REQUEST["action"])) {
//$action = NULL; //$action = NULL;
$action = "listerEvenement"; $action = "creerEvenement";
} else { } else {
$action = \App\config\Validation::nettoyerString($_REQUEST["action"]); $action = \App\config\Validation::nettoyerString($_REQUEST["action"]);
} }
@ -55,6 +55,9 @@ class UtilisateurControleur
case "listerEvenement": case "listerEvenement":
$this->listerEvenement(); $this->listerEvenement();
break; break;
case "creerEvenement":
$this->creerEvenement();
break;
default: default:
$dVueErreur[] ="Action inconnue ou non autorisée"; $dVueErreur[] ="Action inconnue ou non autorisée";
echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]); echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]);
@ -128,19 +131,17 @@ class UtilisateurControleur
} }
// protected function publierOffre() protected function publierOffre()
// { {
$imgMdl = new ImageModele;
$offreMdl = new OffreModele();
// $imgMdl = new ImageModele;
// $offreMdl = new OffreModele();
// $img = $imgMdl->publierImage(); $img = $imgMdl->publierImage();
// $offreMdl->publierOffre($img); $offreMdl->publierOffre($img);
// global $twig; global $twig;
// echo $twig->render('Offres.html', [$offreMdl->getOffres()]); echo $twig->render('Offres.html', [$offreMdl->getOffres()]);
// } }
protected function testAction() protected function testAction()
{ {
@ -161,5 +162,19 @@ class UtilisateurControleur
$twig->addExtension(new TwigExtensions()); $twig->addExtension(new TwigExtensions());
echo $twig->render('evenement.html', ['evenements' => $evenements]); echo $twig->render('evenement.html', ['evenements' => $evenements]);
} }
}
?> protected function creerEvenement()
{
$imgMdl = new ImageModele;
$Usermdl = new \App\modele\UtilisateurModele();
echo "test";
$img = $imgMdl->publierImage();
$Usermdl->ajouterEvenement($img);
global $twig;
echo $twig->render('creerOffre.html', []);
}
}

@ -13,12 +13,22 @@ class EvenementGateway
$this->con = $con; $this->con = $con;
} }
public function insert(){ public function insertEvenement(Evenement $evenement)
$query='INSERT INTO Evenement VALUES ()'; {
$this->con->executeQuery($query, array()); $query='INSERT INTO Evenement VALUES (:i, :o, :t, :d, :date, :nb, :img)';
$this->con->executeQuery($query, array(
':i' => array($evenement->getId(), \PDO::PARAM_INT),
':o' => array($evenement->getOrganisateur(), \PDO::PARAM_STR),
':t' => array($evenement->getTitre(), \PDO::PARAM_STR),
':d' => array($evenement->getDescription(), \PDO::PARAM_STR),
':date' => array($evenement->getDate(), \PDO::PARAM_STR),
':nb' => array($evenement->getNbPlaceMax(), \PDO::PARAM_INT),
':img' => array($evenement->getImage(), \PDO::PARAM_INT)
));
} }
public function getAllEvenement(){ public function getAllEvenement()
{
$query='SELECT * FROM Evenement'; $query='SELECT * FROM Evenement';
$this->con->executeQuery($query); $this->con->executeQuery($query);
$res=$this->con->getResults(); $res=$this->con->getResults();

@ -56,10 +56,6 @@ class UtilisateurModele
// } // }
// } // }
/**
* @Lister les evenements
* @return array evenements
*/
public function getEvenement() : array public function getEvenement() : array
{ {
$dsn = "mysql:host=localhost;dbname=dbAlica"; $dsn = "mysql:host=localhost;dbname=dbAlica";
@ -105,4 +101,33 @@ class UtilisateurModele
} }
return $evenement; return $evenement;
} }
public function ajouterEvenement(Image $img)
{
$dsn = "mysql:host=localhost;dbname=dbAlica";
$login = "test";
$mdp = "test";
$con = new \App\gateway\Connection($dsn, $login, $mdp);
$gate = new \App\gateway\EvenementGateway($con);
$gateImage = new \App\gateway\ImageGateway($con);
$titre = $_POST["titre"];
$description = $_POST["description"];
$date = $_POST["date"];
$nbPlaceMax = $_POST["nbPlaceMax"];
$image = $_POST["image"];
$evenement = new Evenement(
$gate->getNewId(),
new Alumni(12,"test.mail@icloud.fr","password","admin"),
$titre,
$description,
$date,
$nbPlaceMax,
$img
);
$gate->insertEvenement($evenement);
}
} }

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Créer un Événement</title>
</head>
<body>
<h1>Créer un Événement</h1>
<form action="index.php?action=creerEvenement" method="post">
<label for="titre">Titre de l'Événement :</label>
<input type="text" id="titre" name="titre" required><br><br>
<label for="description">Description de l'Événement :</label>
<textarea id="description" name="description" rows="4" required></textarea><br><br>
<label for="date">Date de l'Événement :</label>
<input type="date" id="date" name="date" required><br><br>
<label for="nbPlaceMax">Nombre maximal d'inscrits :</label>
<input type="number" id="nbPlaceMax" name="nbPlaceMax" required><br><br>
<input type="file" name="image" id="image">
<br>
<input type="submit" value="Créer l'Événement">
</form>
</body>
</html>

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Publier une Offre</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header>
</header>
<main class="container mt-4">
<h1>Publier Une Offre</h1>
<form style="background-color: #00DBFF" class="p-4" enctype="multipart/form-data" action="index.php?action=publierOffre" method="post">
<p>Les champs contenant des astrérisques * sont obligatoires.</p>
<div class="form-group">
<label for="name">Intitulé de l'offre*</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Intitulé">
</div>
<div class="form-group">
<label for="entreprise">Nom de l'entreprise :*</label>
<input type="text" class="form-control" id="entreprise" name="entreprise" placeholder="Entreprise">
</div>
<div class="form-group">
<label for="description">Description*</label>
<textarea class="form-control" id="description" name="description" placeholder="Description rapide"></textarea>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="fullRemote" name="fullRemote">
<label class="form-check-label" for="fullRemote">Full Remote</label>
</div>
<div class="form-group">
<label for="ville">Ville</label>
<input type="text" class="form-control" id="ville" name="ville" placeholder="Ville">
</div>
<div class="form-group">
<label for="choixContrat">Choisissez un type de contrat :*</label>
<select class="form-control" id="choixContrat" name="typeContrat">
<option value="CDI">CDI</option>
<option value="CDD">CDD</option>
<option value="Alternance">Alternance</option>
<option value="Stage">Stage</option>
</select>
</div>
<div class="form-group">
<label for="descriptPoste">Descriptif du Poste :*</label>
<textarea class="form-control" id="descriptPoste" name="descriptPoste" placeholder="Description du Poste"></textarea>
</div>
<div class="form-group">
<label for="profilRecherche">Profil Recherché :*</label>
<textarea class="form-control" id="profilRecherche" name="profilRecherche" placeholder="Profil recherché"></textarea>
</div>
<div class="form-group">
<label for="choixExp">Experience Recherchée :*</label>
<select class="form-control" id="choixExp" name="choixExp">
<option value="Junior">Junior</option>
<option value="Senior">Senior</option>
<option value="Indifférent">Indifferent</option>
</select>
</div>
<label>Niveau d'études :*</label>
<div class="form-check-inline">
<input type="radio" class="form-check-input" id="indifferent" name="education" checked>
<label class="form-check-label" for="indifferent">Indifférent</label>
</div>
<div class="form-check-inline">
<input type="radio" class="form-check-input" id="bac2" name="education">
<label class="form-check-label" for="bac2">Bac +2</label>
</div>
<div class="form-check-inline">
<input type="radio" class="form-check-input" id="bac5" name="education">
<label class="form-check-label" for="bac5">Bac +3</label>
</div>
<div class="form-check-inline">
<input type="radio" class="form-check-input" id="bac8" name="education">
<label class="form-check-label" for="bac8">Bac +5</label>
</div>
<div class="form-group">
<label for="mail">Email de contact :*</label>
<input type="text" class="form-control" id="mail" name="mail" placeholder="Adresse de contact">
</div>
<div class="form-group">
<label for="num">Numero de contact :*</label>
<input type="text" class="form-control" id="num" name="num" placeholder="Numéro de contact">
</div>
<div class="form-group">
<label for="site">Site web de l'annonce ou entreprise :</label>
<input type="text" class="form-control" id="site" name="site" placeholder="Adresse web">
</div>
<input type="file" name="image" id="image">
<input type="submit" value="Publier L'annonce" name="submit" id="submit">
</form>
</main>
<!-- scripts : -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="../scripts/creerOffre.js"></script>
</body>
</html>
Loading…
Cancel
Save