refonte config types ES

This commit is contained in:
Jean-Christophe Engel 2025-02-17 14:11:25 +01:00
parent b19904b05b
commit 08ff1f82fd
16 changed files with 133 additions and 208 deletions

View file

@ -4,28 +4,16 @@
Dupliquer un mouvement
paramètres :
- key : clé du mouvement à dupliquer
- direction du mouvement à dupliquer
- prop = 1 si matériel appartient à l'asso
*}}
{{if $_GET.direction == "input"}}
{{:assign msg_direction="entrée"}}
{{else}}
{{:assign msg_direction="sortie"}}
{{/if}}
{{* récupérer les infos du mouvement à dupliquer *}}
{{#load key=$_GET.key assign="mvt_new"}}
{{else}}
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$_GET.key}}
{{:error message="Aucun mouvement avec la clé %s"|args:$_GET.key}}
{{/load}}
{{* infos pour affichage *}}
{{if $_GET.direction == "input"}}
{{:assign mvt_nature=$mvt_new.input_nature}}
{{else}}
{{:assign mvt_nature=$mvt_new.output_nature}}
{{/if}}
{{:assign amount_init=$mvt_new.amount}}
{{:assign date_init=$mvt_new.date|date_short}}
{{:assign eqpmt_key=$mvt_new.equipment}}
@ -40,28 +28,22 @@
{{:include file="../_get_config.html" keep="config"}}
{{* limiter les opérations possibles *}}
{{if $_GET.direction == "input"}}
{{if $mvt_new.direction == "input"}}
{{* types d'entrées *}}
{{#foreach from=$config.input_nature key="label" item="type"}}
{{#foreach from=$config.input_nature key=key}}
{{if $_GET.prop && $type != "temporaire" ||
! $_GET.prop && $type == "temporaire"
}}
{{:assign var="input_labels.%s"|args:$label value="%s"|args:$label}}
{{/if}}
{{if $label == $mvt_new.input_nature}}
{{:assign nature_defaut=$label}}
{{:assign var="input_labels.%s"|args:$key value=$label}}
{{/if}}
{{/foreach}}
{{else}}
{{* types de sorties *}}
{{#foreach from=$config.output_nature key="label" item="type"}}
{{#foreach from=$config.output_nature key=key}}
{{if $_GET.prop && $type != "retour" ||
! $_GET.prop && $type == "retour"
}}
{{:assign var="output_labels.%s"|args:$label value="%s"|args:$label}}
{{/if}}
{{if $label == $mvt_new.output_nature}}
{{:assign nature_defaut=$label}}
{{:assign var="output_labels.%s"|args:$key value=$label}}
{{/if}}
{{/foreach}}
{{/if}}
@ -75,17 +57,17 @@
{{/if}}
{{* préparer le mouvement copié *}}
{{if $_GET.direction == "input"}}
{{:assign var="mvt_new.input_nature" value=$_POST.nature_operation}}
{{:assign var="type_mvt" from="config.input_nature.%s"|args:$mvt_new.input_nature}}
{{if $mvt_new.direction == "input"}}
{{:assign var="mvt_new.input_nature" value=$_POST.operation}}
{{:assign var="type_mvt" from="config.input_nature.%s.type"|args:$mvt_new.operation}}
{{if $type_mvt == "temporaire"}}
{{:assign prop=0}}
{{else}}
{{:assign prop=1}}
{{/if}}
{{else}}
{{:assign var="mvt_new.output_nature" value=$_POST.nature_operation}}
{{:assign var="type_mvt" from="config.output_nature.%s"|args:$mvt_new.output_nature}}
{{:assign var="mvt_new.output_nature" value=$_POST.operation}}
{{:assign var="type_mvt" from="config.output_nature.%s.type"|args:$mvt_new.operation}}
{{if $type_mvt == "retour"}}
{{:assign prop=0}}
{{else}}
@ -113,8 +95,8 @@
}}
{{if! $insere}}
{{if
$_GET.direction == "input" && $date >= $mvt_new.date ||
$_GET.direction == "output" && $date > $mvt_new.date
$mvt_new.direction == "input" && $date >= $mvt_new.date ||
$mvt_new.direction == "output" && $date > $mvt_new.date
}}
{{:assign var="movements_new." from=mvt_new}}
{{:assign insere=true}}
@ -136,7 +118,7 @@
{{if $erreur}}
<p class="block error">
Impossible d'enregistrer ce mouvement :
{{if $_GET.direction == "input"}}
{{if $mvt_new.direction == "input"}}
« {{$mvt_new.input_nature}}
{{else}}
« {{$mvt_new.output_nature}}
@ -150,9 +132,8 @@
key=$mvt_key
validate_schema="movement.schema.json"
type="movement"
direction=$_GET.direction
input_nature=$mvt_new.input_nature
output_nature=$mvt_new.output_nature
direction=$mvt_new.direction
operation=$_POST.operation
amount=$mvt_new.amount|intval
equipment=$eqpmt_key
date=$mvt_new.date
@ -171,17 +152,18 @@
{{* récupérer les infos de la catégorie *}}
{{#load key=$eqpmt.category assign="category"}}{{/load}}
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$mvt_new.direction:$mvt_new.operation}}
{{* formulaire de copie du mouvement *}}
<form method="post" action="">
<fieldset>
<legend>Créer une copie de « {{$mvt_nature}} {{$eqpmt.designation}} (Catégorie : {{$category.name}}) »</legend>
{{if $_GET.direction == "input"}}
<legend>Créer une copie de « {{$op_label}} {{$eqpmt.designation}} (Catégorie : {{$category.name}}) »</legend>
{{if $mvt_new.direction == "input"}}
<dl>
{{:input type="select" name="nature_operation" label="Type" required=true options=$input_labels|sort default=$nature_defaut}}
{{:input type="select" name="operation" label="Type" required=true options=$input_labels|sort default=$mvt_new.operation}}
{{else}}
<dl>
{{:input type="select" name="nature_operation" label="Type" required=true options=$output_labels|sort default=$nature_defaut}}
{{:input type="select" name="operation" label="Type" required=true options=$output_labels|sort default=$mvt_new.operation}}
{{/if}}
{{:input type="date" name="date" label="Date" required=true default=$mvt_new.date}}
{{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_new.amount}}