Réorganisation module

This commit is contained in:
Jean-Christophe Engel 2024-10-28 09:53:29 +01:00
parent 84fb29c15d
commit 553cbdf978
21 changed files with 718 additions and 201 deletions

View file

@ -1,5 +1,12 @@
{{* -*- brindille -*- *}}
{{*
paramètres :
- direction : du mouvement à modifier
- key : clé du mouvement à modifier
- prop : = 1 si matériel propriété
*}}
{{if $_GET.direction == "input"}}
{{:assign msg_direction="entrée"}}
{{else}}
@ -7,7 +14,7 @@
{{/if}}
{{:admin_header title="Modifier une %s"|args:$msg_direction current="module_equipment"}}
{{:assign direction=$_GET.direction}}
{{:assign direction_mvt=$_GET.direction}}
{{:assign key_mvt=$_GET.key}}
{{* récupérer les infos du mouvement à modifier *}}
@ -16,7 +23,7 @@
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$key_mvt}}
{{/load}}
{{if $direction == "input"}}
{{if $direction_mvt == "input"}}
{{:assign input_init=$mvt_modif.input_nature}}
{{:assign url="entrees/index.html"}}
{{else}}
@ -37,7 +44,7 @@
{{* récupérer la config des entrées/sorties *}}
{{:include file="../_get_config.html" keep="config"}}
{{if $direction == "input"}}
{{if $direction_mvt == "input"}}
{{* types d'entrées *}}
{{#foreach from=$config.input_nature key="label" item="type"}}
{{:assign var="input_labels.%s"|args:$label value="%s"|args:$label}}
@ -60,7 +67,7 @@
*}}
{{#form on="change"}}
{{* préparer le mouvement modifié *}}
{{if $direction == "input"}}
{{if $direction_mvt == "input"}}
{{:assign var="mvt_modif.input_nature" from="input_labels.%s"|args:$_POST.type_operation}}
{{else}}
{{:assign var="mvt_modif.output_nature" from="output_labels.%s"|args:$_POST.type_operation}}
@ -86,7 +93,10 @@
assign="movement"
}}
{{if $key != $key_mvt}}
{{if $date > $mvt_modif.date && ! $insere}}
{{if $direction_mvt == "input" && ! $insere && $date >= $mvt_modif.date}}
{{:assign var="movements_modif." from=mvt_modif}}
{{:assign insere=true}}
{{elseif $direction_mvt == "output" && ! $insere && $date > $mvt_modif.date}}
{{:assign var="movements_modif." from=mvt_modif}}
{{:assign insere=true}}
{{/if}}
@ -119,7 +129,7 @@
{{if $erreur}}
<p class="block error">
Modification demandée impossible :
{{if $direction == "input"}}
{{if $direction_mvt == "input"}}
« {{$input_init}} de {{$eqpmt_init.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
« {{$mvt_modif.input_nature}} de {{$eqpmt.designation}} (qté : {{$mvt_modif.amount}}) à la date du {{$mvt_modif.date|date_short}} »
{{else}}
@ -133,7 +143,7 @@
key=$key_mvt
validate_schema="./movement.schema.json"
type="movement"
direction=$direction
direction=$direction_mvt
input_nature=$mvt_modif.input_nature
output_nature=$mvt_modif.output_nature
amount=$mvt_modif.amount|intval
@ -141,7 +151,11 @@
date=$mvt_modif.date
comment=$mvt_modif.comment
}}
{{:redirect force="%s?ok=1&msg=modification"|args:$url}}
{{if $key_eqpmt_init == $_POST.equipment}}
{{:redirect force="../historique.html?ok=1&key=%s&prop=%smsg=modification"|args:$_POST.equipment:$_GET.prop}}
{{else}}
{{:redirect force="../index.html?ok=1&msg=modification"}}
{{/if}}
{{/if}}
{{/form}}
@ -162,7 +176,7 @@
<form method="post" action="">
<fieldset class="entree">
{{if $direction == "input"}}
{{if $direction_mvt == "input"}}
<legend>Modifier l'entrée « {{$input_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
<dl>
{{:input type="select" name="type_operation" label="Type" required=true options=$input_labels default=$type_defaut}}