refonte config types ES
This commit is contained in:
parent
b19904b05b
commit
08ff1f82fd
16 changed files with 133 additions and 208 deletions
|
|
@ -4,27 +4,20 @@
|
|||
Modifier un mouvement
|
||||
paramètres :
|
||||
- key : clé du mouvement à modifier
|
||||
- direction : du mouvement à modifier
|
||||
*}}
|
||||
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{:assign msg_direction="entrée"}}
|
||||
{{else}}
|
||||
{{:assign msg_direction="sortie"}}
|
||||
{{/if}}
|
||||
|
||||
{{* récupérer les infos du mouvement à modifier *}}
|
||||
{{#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}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="../_get_config.html" keep="config"}}
|
||||
|
||||
{{* infos pour affichage *}}
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{:assign mvt_nature=$mvt_new.input_nature}}
|
||||
{{else}}
|
||||
{{:assign mvt_nature=$mvt_new.output_nature}}
|
||||
{{/if}}
|
||||
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$mvt_new.direction:$mvt_new.operation}}
|
||||
{{:debug get=$_GET mvt_new=$mvt_new op_label=$op_label}}
|
||||
{{:assign amount_init=$mvt_new.amount}}
|
||||
{{:assign date_init=$mvt_new.date|date_short}}
|
||||
{{:assign eqpmt_key=$mvt_new.equipment}}
|
||||
|
|
@ -35,24 +28,15 @@
|
|||
{{:error message="Aucun matériel avec la clé « %s »"|args:$eqpmt_key}}
|
||||
{{/load}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="../_get_config.html" keep="config"}}
|
||||
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{if $mvt_new.direction == "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}}
|
||||
{{if $label == $mvt_new.input_nature}}
|
||||
{{:assign nature_defaut=$label}}
|
||||
{{/if}}
|
||||
{{#foreach from=$config.input_nature key=key}}
|
||||
{{:assign var="input_labels.%s"|args:$key value=$label}}
|
||||
{{/foreach}}
|
||||
{{else}}
|
||||
{{* types de sorties *}}
|
||||
{{#foreach from=$config.output_nature key="label" item="type"}}
|
||||
{{:assign var="output_labels.%s"|args:$label value="%s"|args:$label}}
|
||||
{{if $label == $mvt_new.output_nature}}
|
||||
{{:assign nature_defaut=$label}}
|
||||
{{/if}}
|
||||
{{#foreach from=$config.output_nature key=key}}
|
||||
{{:assign var="output_labels.%s"|args:$key value=$label}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -65,17 +49,17 @@
|
|||
{{/if}}
|
||||
|
||||
{{* préparer le mouvement modifié *}}
|
||||
{{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}}
|
||||
|
|
@ -105,8 +89,8 @@
|
|||
{{if $key != $_GET.key}}
|
||||
{{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}}
|
||||
|
|
@ -127,14 +111,11 @@
|
|||
}}
|
||||
|
||||
{{if $erreur}}
|
||||
{{:assign var="new_op_label" from="config.%s_nature.%s.label"|args:$mvt_new.direction:$mvt_new.operation}}
|
||||
<p class="block error">
|
||||
Modification demandée impossible :
|
||||
« {{$mvt_nature}} de {{$eqpmt.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
|
||||
{{if $_GET.direction == "input"}}
|
||||
« {{$mvt_new.input_nature}}
|
||||
{{else}}
|
||||
« {{$mvt_new.output_nature}}
|
||||
{{/if}}
|
||||
« {{$op_label}} de {{$eqpmt.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
|
||||
« {{$new_op_label}}
|
||||
de {{$eqpmt.designation}} (qté : {{$mvt_new.amount}}) à la date du {{$mvt_new.date|date_short}} »
|
||||
</p>
|
||||
{{else}}
|
||||
|
|
@ -143,9 +124,8 @@
|
|||
key=$_GET.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
|
||||
|
|
@ -168,13 +148,13 @@
|
|||
{{* formulaire de modification du mouvement *}}
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
<legend>Modifier « {{$mvt_nature}} {{$eqpmt.designation}} (Catégorie : {{$category.name}}) »</legend>
|
||||
{{if $_GET.direction == "input"}}
|
||||
<legend>Modifier « {{$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}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue