diff --git a/categories/index.html b/categories/index.html index 2574b18..8dbd7a2 100644 --- a/categories/index.html +++ b/categories/index.html @@ -14,12 +14,9 @@ {{* afficher les catégories déjà enregistrées *}}
- {{#list select="$$.name AS 'Catégorie'; $$.id AS 'Id'; $$.type AS 'Type'; $$.key AS 'Clé'" order="1" where="$$.type = 'category'"}} + {{#list select="$$.name AS 'Catégorie'" order="1" where="$$.type = 'category'"}} {{$name}} - {{$id}} - {{$type}} - {{$key}} {{:linkbutton label="Liste des matériels" href="list_equipment.html?key=%s&dialog"|args:$key shape="search" target="_dialog"}} {{:linkbutton label="Modifier" href="modify_category.html?key=%s"|args:$key shape="edit" target="_dialog"}} @@ -33,6 +30,14 @@ {{* Traiter l'envoi du formulaire *}} {{#form on="save"}} + + {{* Vérifier s'il existe déjà une catégorie avec le même nom *}} + {{#load type="category"}} + {{if $name|trim|tolower == $_POST.name|trim|tolower }} + {{:error message="Impossible d'ajouter la catégorie « %s » car elle existe déjà !"|args:$name|trim}} + {{/if}} + {{/load}} + {{:assign key=""|uuid}} {{:save key=$key