From c20be00ea49fd274055414e99a258812feb5ad02 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Mon, 18 Nov 2024 11:10:47 +0100 Subject: [PATCH] =?UTF-8?q?Simplification=20ajouter=5Fentree=20et=20am?= =?UTF-8?q?=C3=A9lioration=20retour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mouvements/ajouter_entree.html | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) 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}}