Afficher les quantités en stock, sorties et dispo dans l'historique

This commit is contained in:
Jean-Christophe Engel 2024-12-20 14:01:02 +01:00
parent e4ad0b6982
commit e8da809830

View File

@ -10,18 +10,6 @@
- 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>
@ -46,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 *}}
@ -80,38 +81,71 @@
{{/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
{{#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 '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
@ -132,6 +166,55 @@
</td>
</tr>
{{/if}}
{{/list}}
{{/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}}