simplification modifier_mouvements
This commit is contained in:
parent
79a3719892
commit
09e4ce2a42
@ -1,9 +1,10 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Modifier un mouvement
|
||||
paramètres :
|
||||
- direction : du mouvement à modifier
|
||||
- key : clé du mouvement à modifier
|
||||
- direction : du mouvement à modifier
|
||||
- prop : = 1 si matériel propriété
|
||||
*}}
|
||||
|
||||
@ -14,21 +15,16 @@
|
||||
{{/if}}
|
||||
{{:admin_header title="Modifier une %s"|args:$msg_direction current="module_equipment"}}
|
||||
|
||||
{{:assign direction_mvt=$_GET.direction}}
|
||||
{{:assign key_mvt=$_GET.key}}
|
||||
|
||||
{{* récupérer les infos du mouvement à modifier *}}
|
||||
{{#load key=$key_mvt assign="mvt_modif"}}
|
||||
{{#load key=$_GET.key assign="mvt_modif"}}
|
||||
{{else}}
|
||||
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$key_mvt}}
|
||||
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$_GET.key}}
|
||||
{{/load}}
|
||||
|
||||
{{if $direction_mvt == "input"}}
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{:assign input_init=$mvt_modif.input_nature}}
|
||||
{{:assign url="entrees/index.html"}}
|
||||
{{else}}
|
||||
{{:assign output_init=$mvt_modif.output_nature}}
|
||||
{{:assign url="sorties/index.html"}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign amount_init=$mvt_modif.amount}}
|
||||
@ -44,12 +40,12 @@
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="../_get_config.html" keep="config"}}
|
||||
|
||||
{{if $direction_mvt == "input"}}
|
||||
{{if $_GET.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_modif.input_nature}}
|
||||
{{:assign type_defaut=$label}}
|
||||
{{:assign nature_defaut=$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{else}}
|
||||
@ -57,7 +53,7 @@
|
||||
{{#foreach from=$config.output_nature key="label" item="type"}}
|
||||
{{:assign var="output_labels.%s"|args:$label value="%s"|args:$label}}
|
||||
{{if $label == $mvt_modif.output_nature}}
|
||||
{{:assign type_defaut=$label}}
|
||||
{{:assign nature_defaut=$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
@ -71,13 +67,20 @@
|
||||
{{/if}}
|
||||
|
||||
{{* préparer le mouvement modifié *}}
|
||||
{{if $direction_mvt == "input"}}
|
||||
{{:assign var="mvt_modif.input_nature" from="input_labels.%s"|args:$_POST.type_operation}}
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{:assign var="mvt_modif.input_nature" from="input_labels.%s"|args:$_POST.nature_operation}}
|
||||
{{:assign var=type_mvt from="config.input_nature.%s"|args:$mvt_modif.input_nature}}
|
||||
{{else}}
|
||||
{{:assign var="mvt_modif.output_nature" from="output_labels.%s"|args:$_POST.type_operation}}
|
||||
{{:assign var="mvt_modif.output_nature" from="output_labels.%s"|args:$_POST.nature_operation}}
|
||||
{{:assign var=type_mvt from="config.outut_nature.%s"|args:$mvt_modif.input_nature}}
|
||||
{{/if}}
|
||||
{{if $type_mvt == "temporaire"}}
|
||||
{{:assign prop=0}}
|
||||
{{else}}
|
||||
{{:assign prop=1}}
|
||||
{{/if}}
|
||||
{{:assign var="mvt_modif.amount" value=$_POST.amount}}
|
||||
{{:assign var="mvt_modif.equipment" value=$_POST.equipment}}
|
||||
{{:assign var="mvt_modif.equipment" value=$key_eqpmt_init}}
|
||||
{{:assign var="mvt_modif.date" value=$_POST.date|parse_date}}
|
||||
{{:assign var="mvt_modif.comment" value=$_POST.comment}}
|
||||
|
||||
@ -90,17 +93,16 @@
|
||||
where="
|
||||
$$.type = 'movement'
|
||||
AND
|
||||
($$.equipment = :old_eqpmt_key OR $$.equipment = :new_eqpmt_key)"
|
||||
:old_eqpmt_key=$key_eqpmt_init
|
||||
:new_eqpmt_key=$_POST.equipment
|
||||
$$.equipment = :eqpmt_key"
|
||||
:eqpmt_key=$key_eqpmt_init
|
||||
order="$$.date"
|
||||
assign="movement"
|
||||
}}
|
||||
{{if $key != $key_mvt}}
|
||||
{{if $direction_mvt == "input" && ! $insere && $date >= $mvt_modif.date}}
|
||||
{{if $key != $_GET.key}}
|
||||
{{if $_GET.direction == "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}}
|
||||
{{elseif $_GET.direction == "output" && ! $insere && $date > $mvt_modif.date}}
|
||||
{{:assign var="movements_modif." from=mvt_modif}}
|
||||
{{:assign insere=true}}
|
||||
{{/if}}
|
||||
@ -111,7 +113,7 @@
|
||||
{{:assign var="movements_modif." from=mvt_modif}}
|
||||
{{/if}}
|
||||
|
||||
{{* Vérifier la cohérence des opérations de l'ancien matériel *}}
|
||||
{{* Vérifier la cohérence des mouvements du matériel *}}
|
||||
{{:include
|
||||
file="./valider_modification.html"
|
||||
keep="erreur"
|
||||
@ -119,47 +121,32 @@
|
||||
eqpmt_key=$key_eqpmt_init
|
||||
}}
|
||||
|
||||
{{* Si le matériel a changé, vérifier la cohérence des opérations du nouveau matériel *}}
|
||||
{{if ! $erreur && $key_eqpmt_init != $_POST.equipment}}
|
||||
{{:include
|
||||
file="./valider_modification.html"
|
||||
keep="erreur"
|
||||
movements=$movements_modif
|
||||
eqpmt_key=$_POST.equipment
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{#load key=$mvt_modif.equipment assign="eqpmt"}}{{/load}}
|
||||
{{if $erreur}}
|
||||
<p class="block error">
|
||||
Modification demandée impossible :
|
||||
{{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}} »
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{$input_init}} de « {{$eqpmt_init.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
|
||||
« {{$mvt_modif.input_nature}} de {{$eqpmt_init.designation}} (qté : {{$mvt_modif.amount}}) à la date du {{$mvt_modif.date|date_short}} »
|
||||
{{else}}
|
||||
« {{$output_init}} de {{$eqpmt_init.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
|
||||
« {{$mvt_modif.output_nature}} de {{$eqpmt.designation}} (qté : {{$mvt_modif.amount}}) à la date du {{$mvt_modif.date|date_short}} »
|
||||
{{$output_init}} de « {{$eqpmt_init.designation}} (qté : {{$amount_init}}) en date du {{$date_init}} » vers
|
||||
« {{$mvt_modif.output_nature}} de {{$eqpmt_init.designation}} (qté : {{$mvt_modif.amount}}) à la date du {{$mvt_modif.date|date_short}} »
|
||||
{{/if}}
|
||||
</p>
|
||||
{{else}}
|
||||
{{* vérification réussie : modifier le mouvement *}}
|
||||
{{:save
|
||||
key=$key_mvt
|
||||
key=$_GET.key
|
||||
validate_schema="./movement.schema.json"
|
||||
type="movement"
|
||||
direction=$direction_mvt
|
||||
direction=$_GET.direction
|
||||
input_nature=$mvt_modif.input_nature
|
||||
output_nature=$mvt_modif.output_nature
|
||||
amount=$mvt_modif.amount|intval
|
||||
equipment=$mvt_modif.equipment
|
||||
equipment=$key_eqpmt_init
|
||||
date=$mvt_modif.date
|
||||
comment=$mvt_modif.comment
|
||||
}}
|
||||
{{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}}
|
||||
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=modification"|args:$key_eqpmt_init:$prop}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
@ -170,39 +157,28 @@
|
||||
*}}
|
||||
|
||||
{{* lister les catégories et matériels associés *}}
|
||||
{{#load type="category" assign="category" order="$$.name"}}
|
||||
{{:assign nom_cat=$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}}
|
||||
{{#load key=$eqpmt_init.category assign="category"}}{{/load}}
|
||||
|
||||
{{* formulaire de modification du mouvement *}}
|
||||
<form method="post" action="">
|
||||
|
||||
<fieldset class="entree">
|
||||
{{if $direction_mvt == "input"}}
|
||||
{{if $_GET.direction == "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}}
|
||||
{{:input type="select" name="nature_operation" label="Type" required=true options=$input_labels default=$nature_defaut}}
|
||||
{{else}}
|
||||
<legend>Modifier la sortie « {{$output_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels default=$type_defaut}}
|
||||
{{:input type="select" name="nature_operation" label="Type" required=true options=$output_labels default=$nature_defaut}}
|
||||
{{/if}}
|
||||
{{:input type="date" name="date" label="Date" required=true default=$mvt_modif.date}}
|
||||
{{:input type="text" name="designation" label="Matériel" disabled=true default=$eqpmt_init.designation}}
|
||||
{{:input type="text" name="category" label="Catégorie" disabled=true default=$category.name}}
|
||||
{{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_modif.amount}}
|
||||
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_modif.comment}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Matériel</legend>
|
||||
<dl>
|
||||
{{:input type="select_groups" name="equipment" label="Matériel" required=true options=$equipments default=$key_eqpmt_init}}
|
||||
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_modif.comment}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="change" label="Enregistrer" shape="right" class="main"}}
|
||||
</p>
|
||||
|
Loading…
Reference in New Issue
Block a user