2024-03-25 20:57:19 +01:00
|
|
|
{{* -*- brindille -*- *}}
|
|
|
|
|
2024-10-28 09:53:29 +01:00
|
|
|
{{*
|
2024-11-19 15:18:09 +01:00
|
|
|
Modifier un mouvement
|
2024-10-28 09:53:29 +01:00
|
|
|
paramètres :
|
|
|
|
- key : clé du mouvement à modifier
|
2024-11-19 15:18:09 +01:00
|
|
|
- direction : du mouvement à modifier
|
2024-10-28 09:53:29 +01:00
|
|
|
- prop : = 1 si matériel propriété
|
|
|
|
*}}
|
|
|
|
|
2024-03-25 20:57:19 +01:00
|
|
|
{{if $_GET.direction == "input"}}
|
2024-03-26 17:58:24 +01:00
|
|
|
{{:assign msg_direction="entrée"}}
|
2024-03-25 20:57:19 +01:00
|
|
|
{{else}}
|
2024-03-26 17:58:24 +01:00
|
|
|
{{:assign msg_direction="sortie"}}
|
2024-03-25 20:57:19 +01:00
|
|
|
{{/if}}
|
2024-03-26 17:58:24 +01:00
|
|
|
{{:admin_header title="Modifier une %s"|args:$msg_direction current="module_equipment"}}
|
2023-11-29 13:34:25 +01:00
|
|
|
|
|
|
|
{{* récupérer les infos du mouvement à modifier *}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{#load key=$_GET.key assign="mvt_modif"}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{else}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$_GET.key}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{/load}}
|
2024-10-18 17:15:56 +02:00
|
|
|
|
2024-11-19 15:18:09 +01:00
|
|
|
{{if $_GET.direction == "input"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign input_init=$mvt_modif.input_nature}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{else}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign output_init=$mvt_modif.output_nature}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{/if}}
|
2024-10-18 17:15:56 +02:00
|
|
|
|
2023-11-29 13:34:25 +01:00
|
|
|
{{:assign amount_init=$mvt_modif.amount}}
|
|
|
|
{{:assign date_init=$mvt_modif.date|date_short}}
|
|
|
|
{{:assign key_eqpmt_init=$mvt_modif.equipment}}
|
|
|
|
|
2024-10-18 17:15:56 +02:00
|
|
|
{{* récupérer les infos du matériel associé *}}
|
|
|
|
{{#load key=$key_eqpmt_init assign="eqpmt_init"}}
|
|
|
|
{{else}}
|
|
|
|
{{:error message="Aucun matériel avec la clé « %s »"|args:$key_eqpmt_init}}
|
|
|
|
{{/load}}
|
|
|
|
|
2023-11-30 18:14:46 +01:00
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
2023-12-05 10:07:01 +01:00
|
|
|
{{:include file="../_get_config.html" keep="config"}}
|
2023-11-30 18:14:46 +01:00
|
|
|
|
2024-11-19 15:18:09 +01:00
|
|
|
{{if $_GET.direction == "input"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* types d'entrées *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{#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}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:assign nature_defaut=$label}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{else}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* types de sorties *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{#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}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:assign nature_defaut=$label}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{*
|
2023-12-06 09:59:11 +01:00
|
|
|
-------------------- Traiter la saisie --------------------
|
2023-11-29 13:34:25 +01:00
|
|
|
*}}
|
|
|
|
{{#form on="change"}}
|
2024-10-29 14:52:34 +01:00
|
|
|
{{if $_POST.amount <= 0}}
|
|
|
|
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}}
|
|
|
|
{{/if}}
|
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* préparer le mouvement modifié *}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{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}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{else}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{: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}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
|
|
|
{{:assign var="mvt_modif.amount" value=$_POST.amount}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:assign var="mvt_modif.equipment" value=$key_eqpmt_init}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign var="mvt_modif.date" value=$_POST.date|parse_date}}
|
|
|
|
{{:assign var="mvt_modif.comment" value=$_POST.comment}}
|
|
|
|
|
|
|
|
{{*
|
|
|
|
lister les mouvements et remplacer le mouvement sélectionné par sa version modifiée
|
|
|
|
en l'insérant à sa place par date croissante
|
|
|
|
*}}
|
|
|
|
{{:assign insere=false}}
|
2023-12-06 10:46:00 +01:00
|
|
|
{{#load
|
|
|
|
where="
|
|
|
|
$$.type = 'movement'
|
2023-12-06 09:59:11 +01:00
|
|
|
AND
|
2024-11-19 15:18:09 +01:00
|
|
|
$$.equipment = :eqpmt_key"
|
|
|
|
:eqpmt_key=$key_eqpmt_init
|
2023-12-06 10:46:00 +01:00
|
|
|
order="$$.date"
|
2023-12-06 09:59:11 +01:00
|
|
|
assign="movement"
|
|
|
|
}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{if $key != $_GET.key}}
|
|
|
|
{{if $_GET.direction == "input" && ! $insere && $date >= $mvt_modif.date}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{:assign var="movements_modif." from=mvt_modif}}
|
|
|
|
{{:assign insere=true}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{elseif $_GET.direction == "output" && ! $insere && $date > $mvt_modif.date}}
|
2024-10-17 12:20:23 +02:00
|
|
|
{{:assign var="movements_modif." from=mvt_modif}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign insere=true}}
|
|
|
|
{{/if}}
|
2024-10-17 12:20:23 +02:00
|
|
|
{{:assign var="movements_modif." from=movement}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2023-12-06 10:46:00 +01:00
|
|
|
{{/load}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{if ! $insere}}
|
2024-10-17 12:20:23 +02:00
|
|
|
{{:assign var="movements_modif." from=mvt_modif}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
|
|
|
|
2024-11-19 15:18:09 +01:00
|
|
|
{{* Vérifier la cohérence des mouvements du matériel *}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:include
|
|
|
|
file="./valider_modification.html"
|
|
|
|
keep="erreur"
|
|
|
|
movements=$movements_modif
|
|
|
|
eqpmt_key=$key_eqpmt_init
|
|
|
|
}}
|
|
|
|
|
|
|
|
{{if $erreur}}
|
|
|
|
<p class="block error">
|
2024-10-17 12:20:23 +02:00
|
|
|
Modification demandée impossible :
|
2024-11-19 15:18:09 +01:00
|
|
|
{{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}} »
|
2023-12-06 09:59:11 +01:00
|
|
|
{{else}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{$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}} »
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
|
|
|
</p>
|
|
|
|
{{else}}
|
|
|
|
{{* vérification réussie : modifier le mouvement *}}
|
|
|
|
{{:save
|
2024-11-19 15:18:09 +01:00
|
|
|
key=$_GET.key
|
2023-12-06 09:59:11 +01:00
|
|
|
validate_schema="./movement.schema.json"
|
|
|
|
type="movement"
|
2024-11-19 15:18:09 +01:00
|
|
|
direction=$_GET.direction
|
2023-12-06 09:59:11 +01:00
|
|
|
input_nature=$mvt_modif.input_nature
|
|
|
|
output_nature=$mvt_modif.output_nature
|
|
|
|
amount=$mvt_modif.amount|intval
|
2024-11-19 15:18:09 +01:00
|
|
|
equipment=$key_eqpmt_init
|
2023-12-06 09:59:11 +01:00
|
|
|
date=$mvt_modif.date
|
|
|
|
comment=$mvt_modif.comment
|
|
|
|
}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=modification"|args:$key_eqpmt_init:$prop}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2024-10-29 14:52:34 +01:00
|
|
|
{{else}}
|
|
|
|
{{:form_errors}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{/form}}
|
|
|
|
|
|
|
|
{{*
|
2023-12-06 09:59:11 +01:00
|
|
|
-------------------- Préparer la saisie --------------------
|
2023-11-29 13:34:25 +01:00
|
|
|
*}}
|
|
|
|
|
|
|
|
{{* lister les catégories et matériels associés *}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{#load key=$eqpmt_init.category assign="category"}}{{/load}}
|
2023-11-29 13:34:25 +01:00
|
|
|
|
|
|
|
{{* formulaire de modification du mouvement *}}
|
|
|
|
<form method="post" action="">
|
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
<fieldset class="entree">
|
2024-11-19 15:18:09 +01:00
|
|
|
{{if $_GET.direction == "input"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
<legend>Modifier l'entrée « {{$input_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
|
|
|
<dl>
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:input type="select" name="nature_operation" label="Type" required=true options=$input_labels default=$nature_defaut}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{else}}
|
|
|
|
<legend>Modifier la sortie « {{$output_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
|
|
|
<dl>
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:input type="select" name="nature_operation" label="Type" required=true options=$output_labels default=$nature_defaut}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
|
|
|
{{:input type="date" name="date" label="Date" required=true default=$mvt_modif.date}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{: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}}
|
2024-10-29 15:19:04 +01:00
|
|
|
{{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_modif.amount}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_modif.comment}}
|
2023-12-06 09:59:11 +01:00
|
|
|
</dl>
|
|
|
|
</fieldset>
|
|
|
|
<p class="submit">
|
|
|
|
{{:button type="submit" name="change" label="Enregistrer" shape="right" class="main"}}
|
|
|
|
</p>
|
2023-11-29 13:34:25 +01:00
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
{{:admin_footer}}
|