Compare commits
4 Commits
1c395c48e0
...
e8da809830
Author | SHA1 | Date | |
---|---|---|---|
e8da809830 | |||
e4ad0b6982 | |||
77b8f892cc | |||
d40b17ef2c |
129
historique.html
129
historique.html
@ -10,21 +10,11 @@
|
||||
- msg : message de retour
|
||||
*}}
|
||||
|
||||
{{:assign equipment_key=$_GET.key|trim}}
|
||||
{{#load key=$_GET.key assign="equipment"}}
|
||||
{{else}}
|
||||
{{:error message="Pas de matériel avec la clé %s"|args:$equipment_key}}
|
||||
{{/load}}
|
||||
|
||||
{{#load type="category" where="key = :cle" :cle=$equipment.category assign="category"}}
|
||||
{{else}}
|
||||
{{:error message="Le matériel %s n'appartient à aucune catégorie"|args:$equipment.designation}}
|
||||
{{/load}}
|
||||
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg == "modification"}}
|
||||
<p class="block confirm">Modification enregistrée</p>
|
||||
{{elseif $_GET.msg == "copie"}}
|
||||
<p class="block confirm">Mouvement copié</p>
|
||||
{{elseif $_GET.msg == "suppression"}}
|
||||
<p class="block confirm">Mouvement supprimé</p>
|
||||
{{else}}
|
||||
@ -44,12 +34,25 @@
|
||||
{{else}}
|
||||
{{:assign proprio="nonproprio"}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign equipment_key=$_GET.key|trim}}
|
||||
{{#load key=$equipment_key assign="equipment"}}
|
||||
{{else}}
|
||||
{{:error message="Pas de matériel avec la clé %s"|args:$equipment_key}}
|
||||
{{/load}}
|
||||
|
||||
{{#load type="category" where="key = :cle" :cle=$equipment.category assign="category"}}
|
||||
{{else}}
|
||||
{{:error message="Le matériel %s n'appartient à aucune catégorie"|args:$equipment.designation}}
|
||||
{{/load}}
|
||||
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
|
||||
|
||||
{{:include file="./_nav.html" current="inventaire" subcurrent=$proprio subsubcurrent="mouvements" eqpmt=$equipment.designation category=$category.name}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
|
||||
{{* déterminer les type de mouvements selon l'affection du matériel *}}
|
||||
{{* déterminer les types de mouvements selon l'affection du matériel *}}
|
||||
{{#foreach from=$config.input_nature key=mvt item=type_mvt}}
|
||||
{{if $_GET.prop}}
|
||||
{{* matériel propriété de l'asso *}}
|
||||
@ -78,12 +81,41 @@
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* calculer et mémoriser les quantités pour que le tri de la liste affiche les valeurs correctes *}}
|
||||
{{:assign stock=0}}
|
||||
{{:assign exterieur=0}}
|
||||
{{:assign nonproprio=0}}
|
||||
|
||||
{{#load type="movement" where="$$.equipment = :key" :key=$equipment_key order="$$.date"}}
|
||||
{{if $direction == 'input'}}
|
||||
{{:assign var="type_mvt" from="config.input_nature.%s"|args:$input_nature}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock="%d+%d"|math:$stock:$amount}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign exterieur="%d-%d"|math:$exterieur:$amount}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign nonproprio="%d+%d"|math:$nonproprio:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign var="type_mvt" from="config.output_nature.%s"|args:$output_nature}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock="%d-%d"|math:$stock:$amount}}
|
||||
{{elseif $type_mvt == 'temporaire'}}
|
||||
{{:assign exterieur="%d+%d"|math:$exterieur:$amount}}
|
||||
{{elseif $type_mvt == 'retour'}}
|
||||
{{:assign nonproprio="%d-%d"|math:$nonproprio:$amount}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{:assign dispo="%d-%d"|math:$stock:$exterieur}}
|
||||
{{:assign var="quantites.%s.stock"|args:$id value=$stock}}
|
||||
{{:assign var="quantites.%s.exterieur"|args:$id value=$exterieur}}
|
||||
{{:assign var="quantites.%s.dispo"|args:$id value=$dispo}}
|
||||
{{:assign var="quantites.%s.nonproprio"|args:$id value=$nonproprio}}
|
||||
{{/load}}
|
||||
|
||||
{{* lister tous les mouvements du matériel passé en paramètre *}}
|
||||
{{if $_GET.prop}}
|
||||
<h3>Matériel propriété de l'association</h3>
|
||||
{{else}}
|
||||
<h3>Matériel temporairement dans l'association</h3>
|
||||
{{/if}}
|
||||
|
||||
{{#list
|
||||
type="movement"
|
||||
@ -91,30 +123,34 @@
|
||||
CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mvt';
|
||||
CASE $$.direction WHEN 'input' THEN $$.input_nature WHEN 'output' THEN $$.output_nature END AS 'Opération';
|
||||
$$.amount AS 'Quantité';
|
||||
"" as 'Stock';
|
||||
"" as 'Sorti';
|
||||
"" as 'Dispo';
|
||||
$$.comment AS 'Commentaire'"
|
||||
equipment=$equipment_key
|
||||
order=1
|
||||
}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$direction:$col3}}
|
||||
{{if $direction == 'input'}}
|
||||
{{:assign sens="entree"}}
|
||||
{{else}}
|
||||
{{:assign sens="sortie"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $direction === "input" && $input_nature|in:$input_types ||
|
||||
$direction === "output"&& $output_nature|in:$output_types
|
||||
}}
|
||||
{{:assign var="stock" from="quantites.%s.stock"|args:$id}}
|
||||
{{:assign var="exterieur" from="quantites.%s.exterieur"|args:$id}}
|
||||
{{:assign var="dispo" from="quantites.%s.dispo"|args:$id}}
|
||||
<tr>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{$col2}}</td>
|
||||
<td>{{$col3}}</td>
|
||||
<td>{{$amount}}</td>
|
||||
<td>{{$stock}}</td>
|
||||
<td>{{$exterieur}}</td>
|
||||
<td>{{$dispo}}</td>
|
||||
<td>{{$comment}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Dupliquer"
|
||||
href="mouvements/dupliquer_mouvement.html?key=%s&direction=%s"|args:$key:$direction
|
||||
href="mouvements/dupliquer_mouvement.html?key=%s&direction=%s&prop=%s"|args:$key:$direction:$_GET.prop
|
||||
shape="plus"
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
@ -132,4 +168,53 @@
|
||||
{{/if}}
|
||||
{{/list}}
|
||||
|
||||
{{else}}
|
||||
<h3>Matériel temporairement dans l'association</h3>
|
||||
|
||||
{{#list
|
||||
type="movement"
|
||||
select="$$.date AS 'Date';
|
||||
CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mvt';
|
||||
CASE $$.direction WHEN 'input' THEN $$.input_nature WHEN 'output' THEN $$.output_nature END AS 'Opération';
|
||||
$$.amount AS 'Quantité';
|
||||
"" as 'Présent';
|
||||
$$.comment AS 'Commentaire'"
|
||||
equipment=$equipment_key
|
||||
order=1
|
||||
}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$direction:$col3}}
|
||||
|
||||
{{if $direction === "input" && $input_nature|in:$input_types ||
|
||||
$direction === "output"&& $output_nature|in:$output_types
|
||||
}}
|
||||
{{:assign var="stock" from="quantites.%s.nonproprio"|args:$id}}
|
||||
<tr>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{$col2}}</td>
|
||||
<td>{{$col3}}</td>
|
||||
<td>{{$amount}}</td>
|
||||
<td>{{$stock}}</td>
|
||||
<td>{{$comment}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Dupliquer"
|
||||
href="mouvements/dupliquer_mouvement.html?key=%s&direction=%s&prop=%s"|args:$key:$direction:$_GET.prop
|
||||
shape="plus"
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
label="Modifier"
|
||||
href="mouvements/modifier_mouvement.html?key=%s&direction=%s"|args:$key:$direction
|
||||
shape="edit"
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
label="Supprimer"
|
||||
href="mouvements/supprimer_mouvement.html?key=%s&direction=%s&prop=%s"|args:$key:$direction:$_GET.prop
|
||||
shape="delete"
|
||||
target="_dialog"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{/list}}
|
||||
{{/if}}
|
||||
|
||||
{{:admin_footer}}
|
||||
|
@ -4,7 +4,8 @@
|
||||
Dupliquer un mouvement
|
||||
paramètres :
|
||||
- key : clé du mouvement à dupliquer
|
||||
- direction du mouvement input/output)
|
||||
- direction du mouvement à dupliquer
|
||||
- prop = 1 si matériel appartient à l'asso
|
||||
*}}
|
||||
|
||||
{{if $_GET.direction == "input"}}
|
||||
@ -14,55 +15,58 @@
|
||||
{{/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"}}
|
||||
{{#load key=$_GET.key assign="mvt_new"}}
|
||||
{{else}}
|
||||
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$mvt_key}}
|
||||
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$_GET.key}}
|
||||
{{/load}}
|
||||
{{if $direction == "input"}}
|
||||
{{:assign input_init=$mvt_copie.input_nature}}
|
||||
{{:assign url="entrees/index.html"}}
|
||||
|
||||
{{* infos pour affichage *}}
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{:assign mvt_nature=$mvt_new.input_nature}}
|
||||
{{else}}
|
||||
{{:assign output_init=$mvt_copie.output_nature}}
|
||||
{{:assign url="sorties/index.html"}}
|
||||
{{:assign mvt_nature=$mvt_new.output_nature}}
|
||||
{{/if}}
|
||||
{{:assign amount_init=$mvt_copie.amount}}
|
||||
{{:assign date_init=$mvt_copie.date|date_short}}
|
||||
{{:assign key_eqpmt_init=$mvt_copie.equipment}}
|
||||
{{: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}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="../_get_config.html" keep="config"}}
|
||||
|
||||
{{if $direction == "input"}}
|
||||
{{* limiter les opérations possibles *}}
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{* types d'entrées *}}
|
||||
{{#foreach from=$config.input_nature key="label" item="type"}}
|
||||
{{if $_GET.prop && $type != "temporaire" ||
|
||||
! $_GET.prop && $type == "temporaire"
|
||||
}}
|
||||
{{:assign var="input_labels.%s"|args:$label value="%s"|args:$label}}
|
||||
{{if $label == $mvt_copie.input_nature}}
|
||||
{{:assign type_defaut=$label}}
|
||||
{{/if}}
|
||||
{{if $label == $mvt_new.input_nature}}
|
||||
{{:assign nature_defaut=$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{else}}
|
||||
{{* types de sorties *}}
|
||||
{{#foreach from=$config.output_nature key="label" item="type"}}
|
||||
{{if $_GET.prop && $type != "retour" ||
|
||||
! $_GET.prop && $type == "retour"
|
||||
}}
|
||||
{{:assign var="output_labels.%s"|args:$label value="%s"|args:$label}}
|
||||
{{if $label == $mvt_copie.output_nature}}
|
||||
{{:assign type_defaut=$label}}
|
||||
{{/if}}
|
||||
{{if $label == $mvt_new.output_nature}}
|
||||
{{:assign nature_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 --------------------
|
||||
*}}
|
||||
@ -72,64 +76,121 @@
|
||||
{{/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 $_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}}
|
||||
{{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}}
|
||||
{{: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}}
|
||||
{{/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 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"
|
||||
}}
|
||||
{{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=$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
|
||||
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=%s"|args:$key_eqpmt_init:$prop:$msg_direction}}
|
||||
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
{{/form}}
|
||||
|
||||
{{:form_errors}}
|
||||
{{*
|
||||
-------------------- Préparer la saisie --------------------
|
||||
*}}
|
||||
|
||||
{{* récupérer les infos de la catégorie *}}
|
||||
{{#load key=$eqpmt.category assign="category"}}{{/load}}
|
||||
|
||||
{{* 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>
|
||||
<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>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$input_labels default=$type_defaut}}
|
||||
{{:input type="select" name="nature_operation" label="Type" required=true options=$input_labels default=$nature_defaut}}
|
||||
{{else}}
|
||||
<legend>Créer une copie de la sortie « {{$output_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<legend>Créer une copie de la sortie « {{$mvt_nature}} {{$eqpmt.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}}
|
||||
{{:input type="select" name="nature_operation" label="Type" required=true options=$output_labels default=$nature_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="date" name="date" label="Date" required=true default=$mvt_new.date}}
|
||||
{{:input type="text" name="designation" label="Matériel" disabled=true default=$eqpmt.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}}
|
||||
{{: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}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
@ -15,25 +15,25 @@
|
||||
{{:admin_header title="Modifier une %s"|args:$msg_direction current="module_equipment"}}
|
||||
|
||||
{{* récupérer les infos du mouvement à modifier *}}
|
||||
{{#load key=$_GET.key assign="mvt_modif"}}
|
||||
{{#load key=$_GET.key assign="mvt_new"}}
|
||||
{{else}}
|
||||
{{:error message="Aucune %s avec la clé %s"|args:$msg_direction:$_GET.key}}
|
||||
{{/load}}
|
||||
|
||||
{{* infos pour affichage *}}
|
||||
{{if $_GET.direction == "input"}}
|
||||
{{:assign input_init=$mvt_modif.input_nature}}
|
||||
{{:assign mvt_nature=$mvt_new.input_nature}}
|
||||
{{else}}
|
||||
{{:assign output_init=$mvt_modif.output_nature}}
|
||||
{{:assign mvt_nature=$mvt_new.output_nature}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign amount_init=$mvt_modif.amount}}
|
||||
{{:assign date_init=$mvt_modif.date|date_short}}
|
||||
{{:assign key_eqpmt_init=$mvt_modif.equipment}}
|
||||
{{: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=$key_eqpmt_init assign="eqpmt_init"}}
|
||||
{{#load key=$eqpmt_key assign="eqpmt"}}
|
||||
{{else}}
|
||||
{{:error message="Aucun matériel avec la clé « %s »"|args:$key_eqpmt_init}}
|
||||
{{:error message="Aucun matériel avec la clé « %s »"|args:$eqpmt_key}}
|
||||
{{/load}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
@ -43,7 +43,7 @@
|
||||
{{* 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_modif.input_nature}}
|
||||
{{if $label == $mvt_new.input_nature}}
|
||||
{{:assign nature_defaut=$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
@ -51,7 +51,7 @@
|
||||
{{* 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_modif.output_nature}}
|
||||
{{if $label == $mvt_new.output_nature}}
|
||||
{{:assign nature_defaut=$label}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
@ -60,32 +60,38 @@
|
||||
{{*
|
||||
-------------------- Traiter la saisie --------------------
|
||||
*}}
|
||||
{{#form on="change"}}
|
||||
{{#form on="save"}}
|
||||
{{if $_POST.amount <= 0}}
|
||||
{{:error message="La quantité (%s) doit être strictement positive !!"|args:$_POST.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{* préparer le mouvement modifié *}}
|
||||
{{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}}
|
||||
{{else}}
|
||||
{{: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}}
|
||||
{{: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}}
|
||||
{{:assign var="mvt_modif.amount" value=$_POST.amount}}
|
||||
{{:assign var="mvt_modif.equipment" value=$key_eqpmt_init}}
|
||||
{{:assign var="mvt_modif.date" value=$_POST.date|parse_date}}
|
||||
{{:assign var="mvt_modif.comment" value=$_POST.comment}}
|
||||
{{else}}
|
||||
{{: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}}
|
||||
{{/if}}
|
||||
|
||||
{{: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 et remplacer le mouvement sélectionné par sa version modifiée
|
||||
en l'insérant à sa place par date croissante
|
||||
lister les mouvements
|
||||
- ignorer le mouvement à modifier
|
||||
- insérer le mvt modifié à sa place par date croissante
|
||||
*}}
|
||||
{{:assign insere=false}}
|
||||
{{#load
|
||||
@ -93,59 +99,60 @@
|
||||
$$.type = 'movement'
|
||||
AND
|
||||
$$.equipment = :eqpmt_key"
|
||||
:eqpmt_key=$key_eqpmt_init
|
||||
:eqpmt_key=$eqpmt_key
|
||||
order="$$.date"
|
||||
assign="movement"
|
||||
}}
|
||||
{{if $key != $_GET.key}}
|
||||
{{if $_GET.direction == "input" && ! $insere && $date >= $mvt_modif.date}}
|
||||
{{:assign var="movements_modif." from=mvt_modif}}
|
||||
{{:assign insere=true}}
|
||||
{{elseif $_GET.direction == "output" && ! $insere && $date > $mvt_modif.date}}
|
||||
{{:assign var="movements_modif." from=mvt_modif}}
|
||||
{{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}}
|
||||
{{:assign var="movements_modif." from=movement}}
|
||||
{{/if}}
|
||||
{{:assign var="movements_new." from=movement}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{if ! $insere}}
|
||||
{{:assign var="movements_modif." from=mvt_modif}}
|
||||
{{: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_modif
|
||||
eqpmt_key=$key_eqpmt_init
|
||||
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"}}
|
||||
{{$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}} »
|
||||
« {{$mvt_new.input_nature}}
|
||||
{{else}}
|
||||
{{$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}} »
|
||||
« {{$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 : modifier le mouvement *}}
|
||||
{{* vérification réussie : enregistrer le mouvement modifié *}}
|
||||
{{:save
|
||||
key=$_GET.key
|
||||
validate_schema="./movement.schema.json"
|
||||
validate_schema="movement.schema.json"
|
||||
type="movement"
|
||||
direction=$_GET.direction
|
||||
input_nature=$mvt_modif.input_nature
|
||||
output_nature=$mvt_modif.output_nature
|
||||
amount=$mvt_modif.amount|intval
|
||||
equipment=$key_eqpmt_init
|
||||
date=$mvt_modif.date
|
||||
comment=$mvt_modif.comment
|
||||
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=modification"|args:$key_eqpmt_init:$prop}}
|
||||
{{:redirect force="../historique.html?ok=1&key=%s&prop=%s&msg=modification"|args:$eqpmt_key:$prop}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
@ -155,31 +162,32 @@
|
||||
-------------------- Préparer la saisie --------------------
|
||||
*}}
|
||||
|
||||
{{* lister les catégories et matériels associés *}}
|
||||
{{#load key=$eqpmt_init.category assign="category"}}{{/load}}
|
||||
{{* récupérer les infos de la catégorie *}}
|
||||
{{#load key=$eqpmt.category assign="category"}}{{/load}}
|
||||
|
||||
{{* formulaire de modification du mouvement *}}
|
||||
<form method="post" action="">
|
||||
|
||||
<fieldset class="entree">
|
||||
<fieldset>
|
||||
{{if $_GET.direction == "input"}}
|
||||
<legend>Modifier l'entrée « {{$input_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<legend>Modifier l'entrée « {{$mvt_nature}} {{$eqpmt.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="nature_operation" label="Type" required=true options=$input_labels default=$nature_defaut}}
|
||||
{{else}}
|
||||
<legend>Modifier la sortie « {{$output_init}} {{$eqpmt_init.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<legend>Modifier la sortie « {{$mvt_nature}} {{$eqpmt.designation}} ({{$amount_init}}) en date du {{$date_init}} »</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="nature_operation" label="Type" required=true options=$output_labels default=$nature_defaut}}
|
||||
{{/if}}
|
||||
{{:input type="date" name="date" label="Date" required=true default=$mvt_modif.date}}
|
||||
{{:input type="text" name="designation" label="Matériel" disabled=true default=$eqpmt_init.designation}}
|
||||
{{: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}}
|
||||
{{: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_modif.amount}}
|
||||
{{:input type="textarea" name="comment" label="Remarques" cols="40", rows="3" required=false default=$mvt_modif.comment}}
|
||||
{{: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}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="change" label="Enregistrer" shape="right" class="main"}}
|
||||
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
@ -106,13 +106,13 @@
|
||||
{{/form}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="equipments"}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="categories,equipments"}}
|
||||
{{:assign var=present from="equipments.%s.nonproprio"|args:$_GET.key}}
|
||||
|
||||
{{if $present > 0}}
|
||||
{{* déterminer le matériel concerné par le mouvement *}}
|
||||
{{#load key=$_GET.key assign="equipment"}}
|
||||
{{/load}}
|
||||
{{#load key=$_GET.key assign="equipment"}}{{/load}}
|
||||
{{:assign var=cat_name from=categories.%s|args:$equipment.category}}
|
||||
|
||||
{{* formulaire de sortie de matériel *}}
|
||||
<form method="post" action="">
|
||||
@ -122,7 +122,8 @@
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels}}
|
||||
{{:input type="date" name="date" label="Date de sortie" required=true default=$now|date_short}}
|
||||
{{:input type="text" name="equipment" label="Matériel" required=true disabled=true default=$equipment.designation}}
|
||||
{{:input type="text" name="present" label="Qté présente" disabled=true default=$present}}
|
||||
{{:input type="text" name="category" label="Catégorie" required=true disabled=true default=$cat_name}}
|
||||
{{:input type="text" name="present" label="Quantité présente" disabled=true default=$present}}
|
||||
<p><span class="alert">La quantité présente est celle à la date du jour</span></p>
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1 min=1}}
|
||||
{{:input type="textarea" name="remarques" label="Remarques" cols="40" rows="3" required=false}}
|
||||
|
@ -143,7 +143,7 @@
|
||||
{{:input type="date" name="date" label="Date de sortie" required=true default=$now|date_short}}
|
||||
{{:input type="text" name="equipment" label="Matériel" required=true disabled=true default=$equipment.designation}}
|
||||
{{:input type="text" name="category" label="Catégorie" required=true disabled=true default=$cat_name}}
|
||||
{{:input type="text" name="dispo" label="Qté disponible" disabled=true default=$dispo}}
|
||||
{{:input type="text" name="dispo" label="Quantité disponible" disabled=true default=$dispo}}
|
||||
<p><span class="alert">La quantité indiquée est celle à la date du jour</span></p>
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1 min=1}}
|
||||
{{:input type="textarea" name="remarques" label="Remarques" cols="40" rows="3" required=false}}
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
Vérifier la cohérence des E/S d'un matériel
|
||||
- paramètres :
|
||||
- movements : liste de mouvements
|
||||
- eqpmt_key : clé du matériel à vérifier
|
||||
- movements : liste de mouvements d'un matériel
|
||||
*}}
|
||||
|
||||
{{* récupérer la config des entrées/sorties *}}
|
||||
@ -13,12 +12,12 @@
|
||||
{{:assign stock=0}}
|
||||
{{:assign exterieur=0}}
|
||||
{{:assign nonprop=0}}
|
||||
|
||||
{{#foreach from=$movements item="mvt"}}
|
||||
{{* déterminer le type de mouvement *}}
|
||||
{{:assign var="mvt_nature" from="mvt.%s_nature"|args:$mvt.direction}}
|
||||
{{:assign var="type_mvt" from="config.%s_nature.%s"|args:$mvt.direction:$mvt_nature}}
|
||||
|
||||
{{if $mvt.equipment == $eqpmt_key}}
|
||||
{{if $mvt.direction == 'input'}}
|
||||
{{if $type_mvt == 'définitif'}}
|
||||
{{:assign stock="%d+%d"|math:$stock:$mvt.amount}}
|
||||
@ -36,10 +35,10 @@
|
||||
{{:assign nonprop="%d-%d"|math:$nonprop:$mvt.amount}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign dispo="%d-%d"|math:$stock:$exterieur}}
|
||||
{{if $dispo < 0 || $stock < 0 || $exterieur < 0 || $nonprop < 0}}
|
||||
{{:assign erreur=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
Loading…
Reference in New Issue
Block a user