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
|
|
|
*}}
|
|
|
|
|
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-12-20 11:22:24 +01:00
|
|
|
{{#load key=$_GET.key assign="mvt_new"}}
|
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-12-20 11:22:24 +01:00
|
|
|
{{* infos pour affichage *}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{if $_GET.direction == "input"}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:assign mvt_nature=$mvt_new.input_nature}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{else}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:assign mvt_nature=$mvt_new.output_nature}}
|
2023-11-29 13:34:25 +01:00
|
|
|
{{/if}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:assign amount_init=$mvt_new.amount}}
|
|
|
|
{{:assign date_init=$mvt_new.date|date_short}}
|
|
|
|
{{:assign eqpmt_key=$mvt_new.equipment}}
|
2023-11-29 13:34:25 +01:00
|
|
|
|
2024-10-18 17:15:56 +02:00
|
|
|
{{* récupérer les infos du matériel associé *}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{#load key=$eqpmt_key assign="eqpmt"}}
|
2024-10-18 17:15:56 +02:00
|
|
|
{{else}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:error message="Aucun matériel avec la clé « %s »"|args:$eqpmt_key}}
|
2024-10-18 17:15:56 +02:00
|
|
|
{{/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}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{if $label == $mvt_new.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}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{if $label == $mvt_new.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
|
|
|
*}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{#form on="save"}}
|
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"}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{: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 $type_mvt == "temporaire"}}
|
|
|
|
{{:assign prop=0}}
|
|
|
|
{{else}}
|
|
|
|
{{:assign prop=1}}
|
|
|
|
{{/if}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{else}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:assign var="mvt_new.output_nature" value=$_POST.nature_operation}}
|
|
|
|
{{:assign var="type_mvt" from="config.output_nature.%s"|args:$mvt_new.output_nature}}
|
|
|
|
{{if $type_mvt == "retour"}}
|
|
|
|
{{:assign prop=0}}
|
|
|
|
{{else}}
|
|
|
|
{{:assign prop=1}}
|
|
|
|
{{/if}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2024-12-20 11:22:24 +01:00
|
|
|
|
|
|
|
{{:assign var="mvt_new.amount" value=$_POST.amount}}
|
|
|
|
{{:assign var="mvt_new.date" value=$_POST.date|parse_date}}
|
|
|
|
{{:assign var="mvt_new.comment" value=$_POST.comment}}
|
2023-12-06 09:59:11 +01:00
|
|
|
|
|
|
|
{{*
|
2024-12-20 11:22:24 +01:00
|
|
|
lister les mouvements
|
|
|
|
- ignorer le mouvement à modifier
|
|
|
|
- insérer le mvt modifié à sa place par date croissante
|
2023-12-06 09:59:11 +01:00
|
|
|
*}}
|
|
|
|
{{: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"
|
2024-12-20 11:22:24 +01:00
|
|
|
:eqpmt_key=$eqpmt_key
|
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}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{if! $insere}}
|
|
|
|
{{if
|
|
|
|
$_GET.direction == "input" && $date >= $mvt_new.date ||
|
|
|
|
$_GET.direction == "output" && $date > $mvt_new.date
|
|
|
|
}}
|
|
|
|
{{:assign var="movements_new." from=mvt_new}}
|
|
|
|
{{:assign insere=true}}
|
|
|
|
{{/if}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:assign var="movements_new." 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-12-20 11:22:24 +01:00
|
|
|
{{:assign var="movements_new." from=mvt_new}}
|
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"
|
2024-12-20 11:22:24 +01:00
|
|
|
movements=$movements_new
|
2023-12-06 09:59:11 +01:00
|
|
|
}}
|
|
|
|
|
|
|
|
{{if $erreur}}
|
|
|
|
<p class="block error">
|
2024-10-17 12:20:23 +02:00
|
|
|
Modification demandée impossible :
|
2024-12-20 11:22:24 +01:00
|
|
|
« {{$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}}
|
|
|
|
de {{$eqpmt.designation}} (qté : {{$mvt_new.amount}}) à la date du {{$mvt_new.date|date_short}} »
|
2023-12-06 09:59:11 +01:00
|
|
|
</p>
|
|
|
|
{{else}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{* vérification réussie : enregistrer le mouvement modifié *}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:save
|
2024-11-19 15:18:09 +01:00
|
|
|
key=$_GET.key
|
2024-12-20 11:22:24 +01:00
|
|
|
validate_schema="movement.schema.json"
|
2023-12-06 09:59:11 +01:00
|
|
|
type="movement"
|
2024-11-19 15:18:09 +01:00
|
|
|
direction=$_GET.direction
|
2024-12-20 11:22:24 +01:00
|
|
|
input_nature=$mvt_new.input_nature
|
|
|
|
output_nature=$mvt_new.output_nature
|
|
|
|
amount=$mvt_new.amount|intval
|
|
|
|
equipment=$eqpmt_key
|
|
|
|
date=$mvt_new.date
|
|
|
|
comment=$mvt_new.comment
|
2023-12-06 09:59:11 +01:00
|
|
|
}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$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
|
|
|
*}}
|
|
|
|
|
2024-12-20 11:22:24 +01:00
|
|
|
{{* récupérer les infos de la catégorie *}}
|
|
|
|
{{#load key=$eqpmt.category assign="category"}}{{/load}}
|
2023-11-29 13:34:25 +01:00
|
|
|
|
|
|
|
{{* formulaire de modification du mouvement *}}
|
|
|
|
<form method="post" action="">
|
|
|
|
|
2024-12-20 11:22:24 +01:00
|
|
|
<fieldset>
|
2024-11-19 15:18:09 +01:00
|
|
|
{{if $_GET.direction == "input"}}
|
2024-12-20 11:22:24 +01:00
|
|
|
<legend>Modifier l'entrée « {{$mvt_nature}} {{$eqpmt.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
2023-12-06 09:59:11 +01:00
|
|
|
<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}}
|
2024-12-20 11:22:24 +01:00
|
|
|
<legend>Modifier la sortie « {{$mvt_nature}} {{$eqpmt.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
2023-12-06 09:59:11 +01:00
|
|
|
<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}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:input type="date" name="date" label="Date" required=true default=$mvt_new.date}}
|
|
|
|
{{:input type="text" name="designation" label="Matériel" disabled=true default=$eqpmt.designation}}
|
2024-11-19 15:18:09 +01:00
|
|
|
{{:input type="text" name="category" label="Catégorie" disabled=true default=$category.name}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:input type="number" name="amount" label="Quantité" min=1 required=true default=$mvt_new.amount}}
|
|
|
|
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_new.comment}}
|
2023-12-06 09:59:11 +01:00
|
|
|
</dl>
|
|
|
|
</fieldset>
|
2024-12-20 11:22:24 +01:00
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
<p class="submit">
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
</p>
|
2023-11-29 13:34:25 +01:00
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
{{:admin_footer}}
|