diff --git a/public/assets/css/public.css b/public/assets/css/public.css index 29fce40..5d97f31 100644 --- a/public/assets/css/public.css +++ b/public/assets/css/public.css @@ -1,4 +1,5 @@ @import url('fonts.css'); + /* Début de Classes et id global*/ .uk-alert{ background-color: white; @@ -193,3 +194,7 @@ footer a img { } .uk-subnav-pill>.uk-active>a{background-color:#a7d627;color:#fff} + +.uk-container { + min-height: 70vh; +} \ No newline at end of file diff --git a/src/Controller/AccountController.php b/src/Controller/AccountController.php index 7f1aa2f..53348ed 100644 --- a/src/Controller/AccountController.php +++ b/src/Controller/AccountController.php @@ -50,7 +50,7 @@ public function login() } } else { $message = "Le Mot de passe et l'adresse email ne correspondent pas."; - return $this->twig->render('Account/login.html.twig', ['message' => $message]); + return $this->twig->render('Account/index.html.twig', ['message' => $message]); } } } diff --git a/src/Controller/CatalogueUController.php b/src/Controller/CatalogueUController.php index b97480c..42376c4 100644 --- a/src/Controller/CatalogueUController.php +++ b/src/Controller/CatalogueUController.php @@ -4,6 +4,7 @@ use App\Model\CatalogueUManager; use App\Model\GalerieManager; +use spec\GrumPHP\Task\AntSpec; /** * Class ItemController @@ -88,6 +89,7 @@ public function update(int $id): string { if ($_SESSION['role'] == 'admin') { $catalogueUManager = new CatalogueUManager(); + $galerieManager = new GalerieManager(); $catalogueU = $catalogueUManager->selectOneById($id); if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (empty($_POST['nom']) || !is_string($_POST['nom'])) { @@ -99,10 +101,13 @@ public function update(int $id): string $message = "Veuillez remplir correctement le champ Prix s'il vous plaît"; return $this->twig->render('CatalogueU/edit.html.twig', ['message' => $message]); } + $catalogueU['id_cat'] = $_POST['id_cat']; $catalogueU['nom'] = $_POST['nom']; $catalogueU['type'] = $_POST['type']; $catalogueU['prix'] = number_format($_POST['prix'], 2, ".", ""); $catalogueU['couleur'] = $_POST['couleur']; + $type = "catalogue_unitaire"; + $galerieManager->update($id, $type, $catalogueU['nom']); $catalogueUManager->update($catalogueU); header('Location:/CatalogueU/index'); } diff --git a/src/Model/CatalogueUManager.php b/src/Model/CatalogueUManager.php index 2c08e9f..86dd8eb 100644 --- a/src/Model/CatalogueUManager.php +++ b/src/Model/CatalogueUManager.php @@ -60,7 +60,7 @@ public function update(array $catalogueU):bool $prix = $catalogueU['prix']; $statement = $this->pdo->prepare("UPDATE " . self::TABLE ." SET nom=:nom, type=:type, prix=".$prix.", couleur=:couleur WHERE id=:id"); - $statement->bindValue('id', $catalogueU['id'], \PDO::PARAM_INT); + $statement->bindValue('id', $catalogueU['id_cat'], \PDO::PARAM_INT); $statement->bindValue('nom', $catalogueU['nom'], \PDO::PARAM_STR); $statement->bindValue('type', $catalogueU['type'], \PDO::PARAM_STR); $statement->bindValue('couleur', $catalogueU['couleur'], \PDO::PARAM_STR); diff --git a/src/Model/GalerieManager.php b/src/Model/GalerieManager.php index 38aa68c..843cd9f 100644 --- a/src/Model/GalerieManager.php +++ b/src/Model/GalerieManager.php @@ -82,4 +82,11 @@ public function delete($id) $statement = $this->pdo->query("DELETE FROM ". self::TABLE . " WHERE id= $id"); $statement->execute(); } + + public function update($id, $type, $name) + { + $statement = $this->pdo->prepare("UPDATE ".self::TABLE." SET nom=:nom WHERE id_".$type." = $id"); + $statement->bindValue('nom', $name, \PDO::PARAM_STR); + $statement->execute(); + } } diff --git a/src/View/CatalogueU/edit.html.twig b/src/View/CatalogueU/edit.html.twig index f15d48f..0c074a4 100644 --- a/src/View/CatalogueU/edit.html.twig +++ b/src/View/CatalogueU/edit.html.twig @@ -8,7 +8,7 @@ <!-- Affichage du produit --> <div class="uk-card uk-card-default uk-grid-collapse uk-child-width-1-2@s uk-margin uk-height-medium" uk-grid> <div class="uk-card-media-left uk-cover-container uk-height-medium"> - <img src="https://getuikit.com/docs/images/light.jpg" alt="" uk-cover> + <img src="/{{ catalogueU.file1 }}" alt="{{ catalogueU.nom }}" uk-cover> <canvas width="600" height="400"></canvas> </div> <div> @@ -33,7 +33,7 @@ <p> <button class="uk-button uk-button-default uk-modal-close" title="Annuler la suppréssion du produit" type="button">Annuler</button> <button class="uk-button uk-button-danger " type="button"> - <a class="uk-text-secondary" title="Supprimer le produit" href="/catalogueU/delete/{{ catalogueU.id }}">Supprimer</a> + <a class="uk-text-secondary" title="Supprimer le produit" href="/catalogueU/delete/{{ catalogueU.id_catalogue_unitaire }}">Supprimer</a> </button> </p> </div> @@ -46,7 +46,7 @@ <div class="uk-alert uk-text-center uk-text-danger uk-text-bolder"> {{ message }} </div> - <input type="hidden" name="id" value="{{ catalogueU.id }}"> + <input type="hidden" name="id_cat" value="{{ catalogueU.id_catalogue_unitaire }}"> <input class="uk-inline uk-input uk-margin" value="{{ catalogueU.nom }}" type="text" name="nom" placeholder="Nom" required> <select class="uk-select uk-margin uk-inline" name="type" required> <option value="">Veuillez selectionner un type de produit</option> @@ -78,4 +78,5 @@ <a href="/CatalogueU/index" title="Retour vers le catalogue unitaire" class="uk-button uk-button-primary uk-margin">Retour</a> </div> </section> + {{ dump(catalogueU) }} {% endblock %} diff --git a/src/View/CatalogueU/index.html.twig b/src/View/CatalogueU/index.html.twig index 506ae39..e644cae 100644 --- a/src/View/CatalogueU/index.html.twig +++ b/src/View/CatalogueU/index.html.twig @@ -34,7 +34,7 @@ <p> <button class="uk-button uk-button-default uk-modal-close" type="button">Annuler</button> <button class="uk-button uk-button-danger " type="button"> - <a class="uk-text-secondary" href="/catalogueU/delete/{{ catalogueU.id }}">Supprimer</a> + <a class="uk-text-secondary" href="/catalogueU/delete/{{ catalogueU.id_catalogue_unitaire }}">Supprimer</a> </button> </p> </div> diff --git a/src/View/CatalogueU/show.html.twig b/src/View/CatalogueU/show.html.twig index b7f2f75..7145ade 100644 --- a/src/View/CatalogueU/show.html.twig +++ b/src/View/CatalogueU/show.html.twig @@ -18,7 +18,7 @@ <li class="uk-margin">Couleur : {{ catalogueU.couleur }}</li> </ul> <div> - <a href="/CatalogueU/update/{{ catalogueU.id }}" title="Modification du produit" class="uk-button uk-button-primary">Modifier</a> + <a href="/CatalogueU/update/{{ catalogueU.id_catalogue_unitaire }}" title="Modification du produit" class="uk-button uk-button-primary">Modifier</a> <a href="#modal-example" title="Supprimer le produit" class="uk-button uk-button-danger" uk-toggle>Supprimer</a> </div> </div> @@ -31,7 +31,7 @@ <p> <button class="uk-button uk-button-default uk-modal-close" title="Annuler la suppréssion du produit" type="button">Annuler</button> <button class="uk-button uk-button-danger " type="button"> - <a class="uk-text-secondary" title="Supprimer le produit" href="/catalogueU/delete/{{ catalogueU.id }}">Supprimer</a> + <a class="uk-text-secondary" title="Supprimer le produit" href="/catalogueU/delete/{{ catalogueU.id_catalogue_unitaire }}">Supprimer</a> </button> </p> </div> diff --git a/src/View/Galerie/_tableauImg.html.twig b/src/View/Galerie/_tableauImg.html.twig index 4684447..ae00b9a 100644 --- a/src/View/Galerie/_tableauImg.html.twig +++ b/src/View/Galerie/_tableauImg.html.twig @@ -1,6 +1,7 @@ <div class="uk-container"> - <div class="uk-text-right"> - <a href="/Bouquet/add" title="Ajouter un bouquet" class="uk-button uk-button-primary uk-margin">Ajouter</a> + <div class="uk-text-center"> + <a href="/Bouquet/add" title="Ajouter un bouquet" class="uk-button uk-button-primary">Ajouter un bouquet</a> + <a href="/CatalogueU/add" title="Ajouter un produit dans le catalogue" class="uk-button uk-button-primary">Ajouter un produit unitaire</a> </div> <h3 class="uk-text-center uk-margin uk-text-bold">Liste des images</h3> <div class="uk-child-width-1-3@m" uk-grid> @@ -17,7 +18,8 @@ </div> {% endfor %} </div> - <div class="uk-text-right"> - <a href="/Bouquet/add" title="Ajouter un bouquet" class="uk-button uk-button-primary uk-margin">Ajouter</a> + <div class="uk-text-center uk-margin-top"> + <a href="/Bouquet/add" title="Ajouter un bouquet" class="uk-button uk-button-primary">Ajouter un bouquet</a> + <a href="/CatalogueU/add" title="Ajouter un produit dans le catalogue" class="uk-button uk-button-primary">Ajouter un produit unitaire</a> </div> </div> \ No newline at end of file diff --git a/src/View/User/update.html.twig b/src/View/User/update.html.twig index 0514150..69dda9b 100644 --- a/src/View/User/update.html.twig +++ b/src/View/User/update.html.twig @@ -8,7 +8,7 @@ de {{ user.firstname ~" "~ user.lastname }} {% endif %}</h2> {% if session['role'] != 'admin' %} - <div class="uk-alert uk-text-center uk-text-danger uk-text-bolder"> + <div class="uk-text-center uk-text-danger uk-text-bolder"> {{ message }} </div> {% endif %}