2024-10-28 09:53:29 +01:00
|
|
|
{{* -*- brindille -*- *}}
|
|
|
|
|
2024-11-12 16:53:53 +01:00
|
|
|
{{*
|
|
|
|
Dupliquer un mouvement
|
|
|
|
paramètres :
|
|
|
|
- key : clé du mouvement à dupliquer
|
2024-12-20 11:22:24 +01:00
|
|
|
- direction du mouvement à dupliquer
|
|
|
|
- prop = 1 si matériel appartient à l'asso
|
2024-11-12 16:53:53 +01:00
|
|
|
*}}
|
|
|
|
|
2024-10-28 09:53:29 +01:00
|
|
|
{{if $_GET.direction == "input"}}
|
|
|
|
{{:assign msg_direction="entrée"}}
|
|
|
|
{{else}}
|
|
|
|
{{:assign msg_direction="sortie"}}
|
|
|
|
{{/if}}
|
|
|
|
{{:admin_header title="Dupliquer une %s"|args:$msg_direction current="module_equipment"}}
|
|
|
|
|
|
|
|
{{* récupérer les infos du mouvement à dupliquer *}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{#load key=$_GET.key assign="mvt_new"}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{else}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$_GET.key}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{/load}}
|
2024-12-20 11:22:24 +01:00
|
|
|
|
|
|
|
{{* infos pour affichage *}}
|
|
|
|
{{if $_GET.direction == "input"}}
|
|
|
|
{{:assign mvt_nature=$mvt_new.input_nature}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{else}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:assign mvt_nature=$mvt_new.output_nature}}
|
2024-10-28 09:53:29 +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}}
|
|
|
|
|
|
|
|
{{* récupérer les infos du matériel associé *}}
|
|
|
|
{{#load key=$eqpmt_key assign="eqpmt"}}
|
|
|
|
{{else}}
|
|
|
|
{{:error message="Aucun matériel avec la clé « %s »"|args:$eqpmt_key}}
|
|
|
|
{{/load}}
|
2024-10-28 09:53:29 +01:00
|
|
|
|
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
|
|
|
{{:include file="../_get_config.html" keep="config"}}
|
|
|
|
|
2024-12-20 11:22:24 +01:00
|
|
|
{{* limiter les opérations possibles *}}
|
|
|
|
{{if $_GET.direction == "input"}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{* types d'entrées *}}
|
|
|
|
{{#foreach from=$config.input_nature key="label" item="type"}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{if $_GET.prop && $type != "temporaire" ||
|
|
|
|
! $_GET.prop && $type == "temporaire"
|
|
|
|
}}
|
|
|
|
{{:assign var="input_labels.%s"|args:$label value="%s"|args:$label}}
|
|
|
|
{{/if}}
|
|
|
|
{{if $label == $mvt_new.input_nature}}
|
|
|
|
{{:assign nature_defaut=$label}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
|
|
|
{{else}}
|
|
|
|
{{* types de sorties *}}
|
|
|
|
{{#foreach from=$config.output_nature key="label" item="type"}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{if $_GET.prop && $type != "retour" ||
|
|
|
|
! $_GET.prop && $type == "retour"
|
|
|
|
}}
|
|
|
|
{{:assign var="output_labels.%s"|args:$label value="%s"|args:$label}}
|
|
|
|
{{/if}}
|
|
|
|
{{if $label == $mvt_new.output_nature}}
|
|
|
|
{{:assign nature_defaut=$label}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{*
|
|
|
|
-------------------- Traiter la saisie --------------------
|
|
|
|
*}}
|
|
|
|
{{#form on="save"}}
|
2024-10-29 15:19:04 +01:00
|
|
|
{{if $_POST.amount <= 0}}
|
|
|
|
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}}
|
|
|
|
{{/if}}
|
|
|
|
|
2024-10-28 09:53:29 +01:00
|
|
|
{{* préparer le mouvement copié *}}
|
2024-12-20 11:22:24 +01:00
|
|
|
{{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}}
|
2024-11-12 16:53:53 +01:00
|
|
|
{{if $type_mvt == "temporaire"}}
|
|
|
|
{{:assign prop=0}}
|
|
|
|
{{else}}
|
|
|
|
{{:assign prop=1}}
|
|
|
|
{{/if}}
|
2024-10-28 09:53:29 +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}}
|
2024-11-12 16:53:53 +01:00
|
|
|
{{if $type_mvt == "retour"}}
|
|
|
|
{{:assign prop=0}}
|
|
|
|
{{else}}
|
|
|
|
{{:assign prop=1}}
|
|
|
|
{{/if}}
|
2024-10-28 09:53:29 +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}}
|
|
|
|
|
|
|
|
{{*
|
|
|
|
lister les mouvements
|
|
|
|
- insérer le mvt copié à sa place par date croissante
|
|
|
|
*}}
|
|
|
|
{{:assign insere=false}}
|
|
|
|
{{#load
|
|
|
|
where="
|
|
|
|
$$.type = 'movement'
|
|
|
|
AND
|
|
|
|
$$.equipment = :eqpmt_key"
|
|
|
|
:eqpmt_key=$eqpmt_key
|
|
|
|
order="$$.date"
|
|
|
|
assign="movement"
|
2024-10-28 09:53:29 +01:00
|
|
|
}}
|
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}}
|
|
|
|
{{/if}}
|
|
|
|
{{:assign var="movements_new." from=movement}}
|
|
|
|
{{/load}}
|
|
|
|
{{if ! $insere}}
|
|
|
|
{{:assign var="movements_new." from=mvt_new}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{* Vérifier la cohérence des mouvements du matériel *}}
|
|
|
|
{{:include
|
|
|
|
file="./valider_modification.html"
|
|
|
|
keep="erreur"
|
|
|
|
movements=$movements_new
|
|
|
|
}}
|
|
|
|
|
|
|
|
{{if $erreur}}
|
|
|
|
<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}}
|
|
|
|
de {{$eqpmt.designation}} (qté : {{$mvt_new.amount}}) à la date du {{$mvt_new.date|date_short}} »
|
|
|
|
</p>
|
|
|
|
{{else}}
|
|
|
|
{{* vérification réussie : enregistrer le mouvement modifié *}}
|
|
|
|
{{:assign mvt_key=""|uuid}}
|
|
|
|
{{:save
|
|
|
|
key=$mvt_key
|
|
|
|
validate_schema="movement.schema.json"
|
|
|
|
type="movement"
|
|
|
|
direction=$_GET.direction
|
|
|
|
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
|
|
|
|
}}
|
|
|
|
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
|
|
|
|
{{/if}}
|
|
|
|
{{else}}
|
|
|
|
{{:form_errors}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{/form}}
|
|
|
|
|
2024-12-20 11:22:24 +01:00
|
|
|
{{*
|
|
|
|
-------------------- Préparer la saisie --------------------
|
|
|
|
*}}
|
|
|
|
|
|
|
|
{{* récupérer les infos de la catégorie *}}
|
|
|
|
{{#load key=$eqpmt.category assign="category"}}{{/load}}
|
2024-10-28 09:53:29 +01:00
|
|
|
|
|
|
|
{{* formulaire de copie du mouvement *}}
|
|
|
|
<form method="post" action="">
|
|
|
|
|
2024-12-20 11:22:24 +01:00
|
|
|
<fieldset>
|
|
|
|
{{if $_GET.direction == "input"}}
|
|
|
|
<legend>Créer une copie de l'entrée « {{$mvt_nature}} {{$eqpmt.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
2024-10-28 09:53:29 +01:00
|
|
|
<dl>
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:input type="select" name="nature_operation" label="Type" required=true options=$input_labels default=$nature_defaut}}
|
2024-10-28 09:53:29 +01:00
|
|
|
{{else}}
|
2024-12-20 11:22:24 +01:00
|
|
|
<legend>Créer une copie de la sortie « {{$mvt_nature}} {{$eqpmt.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
2024-10-28 09:53:29 +01:00
|
|
|
<dl>
|
2024-12-20 11:22:24 +01:00
|
|
|
{{:input type="select" name="nature_operation" label="Type" required=true options=$output_labels default=$nature_defaut}}
|
2024-10-28 09:53:29 +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-12 16:53:53 +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}}
|
2024-11-12 16:53:53 +01:00
|
|
|
</dl>
|
2024-10-28 09:53:29 +01:00
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<p class="submit">
|
|
|
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
{{:admin_footer}}
|