143 lines
4.8 KiB
HTML
143 lines
4.8 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
{{*
|
|
Dupliquer un mouvement
|
|
paramètres :
|
|
- key : clé du mouvement à dupliquer
|
|
- direction du mouvement input/output)
|
|
*}}
|
|
|
|
{{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"}}
|
|
|
|
{{:assign direction=$_GET.direction}}
|
|
{{:assign mvt_key=$_GET.key}}
|
|
|
|
{{* récupérer les infos du mouvement à dupliquer *}}
|
|
{{#load key=$mvt_key assign="mvt_copie"}}
|
|
{{else}}
|
|
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$mvt_key}}
|
|
{{/load}}
|
|
{{if $direction == "input"}}
|
|
{{:assign input_init=$mvt_copie.input_nature}}
|
|
{{:assign url="entrees/index.html"}}
|
|
{{else}}
|
|
{{:assign output_init=$mvt_copie.output_nature}}
|
|
{{:assign url="sorties/index.html"}}
|
|
{{/if}}
|
|
{{:assign amount_init=$mvt_copie.amount}}
|
|
{{:assign date_init=$mvt_copie.date|date_short}}
|
|
{{:assign key_eqpmt_init=$mvt_copie.equipment}}
|
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
|
{{:include file="../_get_config.html" keep="config"}}
|
|
|
|
{{if $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_copie.input_nature}}
|
|
{{:assign type_defaut=$label}}
|
|
{{/if}}
|
|
{{/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_copie.output_nature}}
|
|
{{:assign type_defaut=$label}}
|
|
{{/if}}
|
|
{{/foreach}}
|
|
{{/if}}
|
|
|
|
{{* 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}}
|
|
|
|
{{* récupérer les infos de la catégorie *}}
|
|
{{#load type="category" key=$eqpmt_init.category assign="category"}}
|
|
{{/load}}
|
|
{{*
|
|
-------------------- Traiter la saisie --------------------
|
|
*}}
|
|
{{#form on="save"}}
|
|
{{if $_POST.amount <= 0}}
|
|
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}}
|
|
{{/if}}
|
|
|
|
{{* préparer le mouvement copié *}}
|
|
{{if $direction == "input"}}
|
|
{{:assign var="mvt_copie.input_nature" from="input_labels.%s"|args:$_POST.type_operation}}
|
|
{{:assign var="type_mvt" from="config.input_nature.%s"|args:$mvt_copie.input_nature}}
|
|
{{if $type_mvt == "temporaire"}}
|
|
{{:assign prop=0}}
|
|
{{else}}
|
|
{{:assign prop=1}}
|
|
{{/if}}
|
|
{{else}}
|
|
{{:assign var="mvt_copie.output_nature" from="output_labels.%s"|args:$_POST.type_operation}}
|
|
{{:assign var="type_mvt" from="config.output_nature.%s"|args:$mvt_copie.output_nature}}
|
|
{{if $type_mvt == "retour"}}
|
|
{{:assign prop=0}}
|
|
{{else}}
|
|
{{:assign prop=1}}
|
|
{{/if}}
|
|
{{/if}}
|
|
{{:assign var="mvt_copie.amount" value=$_POST.amount}}
|
|
{{:assign var="mvt_copie.date" value=$_POST.date|parse_date}}
|
|
{{:assign var="mvt_copie.comment" value=$_POST.comment}}
|
|
|
|
{{* Enregistrer le mouvement *}}
|
|
{{:assign mvt_key=""|uuid}}
|
|
{{:save
|
|
key=$mvt_key
|
|
validate_schema="movement.schema.json"
|
|
type="movement"
|
|
direction=$direction
|
|
input_nature=$mvt_copie.input_nature
|
|
output_nature=$mvt_copie.output_nature
|
|
amount=$mvt_copie.amount|intval
|
|
equipment=$key_eqpmt_init
|
|
date=$mvt_copie.date
|
|
comment=$mvt_copie.comment
|
|
}}
|
|
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=%s"|args:$key_eqpmt_init:$prop:$msg_direction}}
|
|
{{/form}}
|
|
|
|
{{:form_errors}}
|
|
|
|
{{* formulaire de copie du mouvement *}}
|
|
<form method="post" action="">
|
|
|
|
<fieldset class="%s"|args:direction>
|
|
{{if $direction == "input"}}
|
|
<legend>Créer une copie de 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}}
|
|
{{else}}
|
|
<legend>Créer une copie de 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}}
|
|
{{/if}}
|
|
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
|
{{: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_copie.amount}}
|
|
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_copie.comment}}
|
|
</dl>
|
|
</fieldset>
|
|
|
|
<p class="submit">
|
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
|
</p>
|
|
|
|
</form>
|
|
|
|
{{:admin_footer}}
|