Skip to content

Commit

Permalink
last modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
typhained committed May 27, 2020
1 parent 4e8839a commit c238278
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 13 deletions.
5 changes: 5 additions & 0 deletions public/assets/css/public.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import url('fonts.css');

/* Début de Classes et id global*/
.uk-alert{
background-color: white;
Expand Down Expand Up @@ -193,3 +194,7 @@ footer a img {
}

.uk-subnav-pill>.uk-active>a{background-color:#a7d627;color:#fff}

.uk-container {
min-height: 70vh;
}
2 changes: 1 addition & 1 deletion src/Controller/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Controller/CatalogueUController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Model\CatalogueUManager;
use App\Model\GalerieManager;
use spec\GrumPHP\Task\AntSpec;

/**
* Class ItemController
Expand Down Expand Up @@ -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'])) {
Expand All @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/CatalogueUManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/Model/GalerieManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
7 changes: 4 additions & 3 deletions src/View/CatalogueU/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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 %}
2 changes: 1 addition & 1 deletion src/View/CatalogueU/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions src/View/CatalogueU/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
10 changes: 6 additions & 4 deletions src/View/Galerie/_tableauImg.html.twig
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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>
2 changes: 1 addition & 1 deletion src/View/User/update.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit c238278

Please sign in to comment.