diff --git a/mouvements/ajouter_entree.html b/mouvements/ajouter_entree.html
index 022f71e..166e6d0 100644
--- a/mouvements/ajouter_entree.html
+++ b/mouvements/ajouter_entree.html
@@ -19,11 +19,8 @@
{{* lister les catégories et les matériels disponibles *}}
{{#load type="category" assign="category" order="$$.name"}}
- {{:assign nom_cat=$category.name}}
+ {{*:assign nom_cat=$category.name*}}
{{:assign var="categories.%s"|args:$category.key value=$category.name}}
- {{#load type="equipment" where="$$.category = :key" :key=$category.key assign="equipment"}}
- {{:assign var="equipments.%s.%s"|args:$nom_cat:$equipment.key value=$equipment.designation}}
- {{/load}}
{{/load}}
{{* Traiter l'envoi du formulaire *}}
@@ -34,21 +31,19 @@
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.quantite}}
{{/if}}
- {{:assign var=post_cat from="categories.%s"|args:$_POST.category}}
+ {{:assign post_mat=$_POST.designation|trim|tolower|ucfirst}}
{{* vérifier l'existence d'un matériel de même nom *}}
- {{:assign post_mat=$_POST.designation|trim|tolower|ucfirst}}
- {{:assign present=false}}
- {{#foreach from=$equipments key=nom_cat item=eqpmt}}
- {{#foreach from=$eqpmt key=key item=nom}}
- {{if $_POST.designation|trim|tolower == $nom|tolower}}
- {{:assign equipment_key=$key}}
- {{:assign present=true}}
- {{:break}}
- {{/if}}
- {{/foreach}}
- {{if $present}}{{:break}}{{/if}}
- {{/foreach}}
+ {{#load type="equipment"}}
+ {{if $_POST.designation|trim|tolower == $designation|tolower}}
+ {{:assign equipment_key=$key}}
+ {{:assign var=nom_cat from="categories.%s"|args:$category}}
+ {{:assign present=true}}
+ {{:break}}
+ {{/if}}
+ {{/load}}
+ {{:assign var=post_cat from="categories.%s"|args:$_POST.category}}
+
{{if $present}}
{{* voir si le matériel existe dans une autre catégorie *}}
{{if $nom_cat != $post_cat}}
@@ -64,7 +59,7 @@
key=$equipment_key
validate_schema="../equipment.schema.json"
type="equipment"
- category=$category.key
+ category=$_POST.category
designation=$post_mat
}}
{{/if}}
@@ -86,7 +81,12 @@
}}
{{:assign msg="Ajout de l'entrée « %s (%d) en date du %s » effectué"|args:$post_mat:$_POST.quantite:$_POST.date}}
- {{:redirect force="../index.html?ok=1&msg=%s"|args:$msg}}
+ {{:assign var=type_entree from="config.input_nature.%s"|args:$operation}}
+ {{if $type_entree == "temporaire"}}
+ {{:redirect force="../inventaire_nonprop.html?ok=1&msg=%s"|args:$msg}}
+ {{else}}
+ {{:redirect force="../index.html?ok=1&msg=%s"|args:$msg}}
+ {{/if}}
{{else}}
{{:form_errors}}
{{/form}}