simplification dupliquer mouvement
This commit is contained in:
parent
164c63dc14
commit
39733d8fcd
@ -1,5 +1,13 @@
|
|||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Dupliquer un mouvement
|
||||||
|
paramètres :
|
||||||
|
- key : clé du mouvement à dupliquer
|
||||||
|
- direction du mouvement input/output)
|
||||||
|
- prop : =1 si matériel propriété de l'asso
|
||||||
|
*}}
|
||||||
|
|
||||||
{{if $_GET.direction == "input"}}
|
{{if $_GET.direction == "input"}}
|
||||||
{{:assign msg_direction="entrée"}}
|
{{:assign msg_direction="entrée"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
@ -53,6 +61,9 @@
|
|||||||
{{:error message="Aucun matériel avec la clé « %s »"|args:$key_eqpmt_init}}
|
{{:error message="Aucun matériel avec la clé « %s »"|args:$key_eqpmt_init}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
|
||||||
|
{{* récupérer les infos de la catégorie *}}
|
||||||
|
{{#load type="category" key=$eqpmt_init.category assign="category"}}
|
||||||
|
{{/load}}
|
||||||
{{*
|
{{*
|
||||||
-------------------- Traiter la saisie --------------------
|
-------------------- Traiter la saisie --------------------
|
||||||
*}}
|
*}}
|
||||||
@ -61,34 +72,23 @@
|
|||||||
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}}
|
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* récupérer les infos de la catégorie *}}
|
|
||||||
{{#load type="category" key=$_POST.category assign="category"}}
|
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{* vérifier l'existence d'un matériel du même nom *}}
|
|
||||||
{{#load type="equipment" where="lower($$.designation) = :name" :name=$_POST.designation|trim|tolower}}
|
|
||||||
{{* utiliser la clé du matériel trouvé *}}
|
|
||||||
{{:assign equipment_key=$key}}
|
|
||||||
{{else}}
|
|
||||||
{{* nouveau matériel => nouvelle clé *}}
|
|
||||||
{{:assign equipment_key=""|uuid}}
|
|
||||||
|
|
||||||
{{* enregistrer un nouveau matériel *}}
|
|
||||||
{{*:debug key=$equipment_key category=$category.key designation=$_POST.designation|trim*}}
|
|
||||||
{{:save
|
|
||||||
key=$equipment_key
|
|
||||||
validate_schema="../equipment.schema.json"
|
|
||||||
type="equipment"
|
|
||||||
category=$category.key
|
|
||||||
designation=$_POST.designation|trim
|
|
||||||
}}
|
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{* préparer le mouvement copié *}}
|
{{* préparer le mouvement copié *}}
|
||||||
{{if $direction == "input"}}
|
{{if $direction == "input"}}
|
||||||
{{:assign var="mvt_copie.input_nature" from="input_labels.%s"|args:$_POST.type_operation}}
|
{{: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}}
|
{{else}}
|
||||||
{{:assign var="mvt_copie.output_nature" from="output_labels.%s"|args:$_POST.type_operation}}
|
{{: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}}
|
{{/if}}
|
||||||
{{:assign var="mvt_copie.amount" value=$_POST.amount}}
|
{{:assign var="mvt_copie.amount" value=$_POST.amount}}
|
||||||
{{:assign var="mvt_copie.date" value=$_POST.date|parse_date}}
|
{{:assign var="mvt_copie.date" value=$_POST.date|parse_date}}
|
||||||
@ -104,28 +104,15 @@
|
|||||||
input_nature=$mvt_copie.input_nature
|
input_nature=$mvt_copie.input_nature
|
||||||
output_nature=$mvt_copie.output_nature
|
output_nature=$mvt_copie.output_nature
|
||||||
amount=$mvt_copie.amount|intval
|
amount=$mvt_copie.amount|intval
|
||||||
equipment=$equipment_key
|
equipment=$key_eqpmt_init
|
||||||
date=$mvt_copie.date
|
date=$mvt_copie.date
|
||||||
comment=$mvt_copie.comment
|
comment=$mvt_copie.comment
|
||||||
}}
|
}}
|
||||||
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=%s"|args:$key_eqpmt_init:$_GET.prop:$msg_direction}}
|
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=%s"|args:$key_eqpmt_init:$prop:$msg_direction}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{:form_errors}}
|
{{:form_errors}}
|
||||||
|
|
||||||
{{*
|
|
||||||
-------------------- Préparer la saisie --------------------
|
|
||||||
*}}
|
|
||||||
|
|
||||||
{{* lister les catégories et matériels associés *}}
|
|
||||||
{{#load type="category" assign="category" order="$$.name"}}
|
|
||||||
{{:assign nom_cat=$category.name}}
|
|
||||||
{{:assign var="categories.%s"|args:$category.key value=$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}}
|
|
||||||
|
|
||||||
{{* formulaire de copie du mouvement *}}
|
{{* formulaire de copie du mouvement *}}
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
|
|
||||||
@ -139,18 +126,12 @@
|
|||||||
<dl>
|
<dl>
|
||||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels default=$type_defaut}}
|
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels default=$type_defaut}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:input type="date" name="date" label="Date" required=true default=$mvt_copie.date}}
|
{{: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="number" name="amount" label="Quantité" min=1 required=true default=$mvt_copie.amount}}
|
||||||
</dl>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset>
|
|
||||||
<legend>Matériel</legend>
|
|
||||||
<dl>
|
|
||||||
{{:input type="select" name="category" label="Catégorie" required=true options=$categories default=$eqpmt_init.category}}
|
|
||||||
{{:input type="text" name="designation" label="Désignation" required=true default=$eqpmt_init.designation}}
|
|
||||||
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_copie.comment}}
|
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_copie.comment}}
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
|
Loading…
Reference in New Issue
Block a user