2023-11-20 11:18:50 +01:00
|
|
|
{{*
|
|
|
|
Calcul des entrées/sorties de matériels à une date donnée
|
|
|
|
paramètres :
|
|
|
|
- liste de catégories
|
|
|
|
- date
|
|
|
|
*}}
|
|
|
|
|
|
|
|
{{* liste des catégories *}}
|
|
|
|
{{if $categories === null}}
|
|
|
|
{{#select
|
|
|
|
key
|
|
|
|
FROM module_data_equipment as cat
|
|
|
|
WHERE json_extract(cat.document, '$.type') = 'category'}}
|
|
|
|
{{:assign var="categories." value=$key}}
|
|
|
|
{{/select}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{* date *}}
|
|
|
|
{{if $date === null}}
|
2023-12-01 12:11:25 +01:00
|
|
|
{{* :assign date=$now|date:"Y-m-d" *}}
|
|
|
|
{{:assign date="31/12/9999"|parse_date"}}
|
|
|
|
{{* si on veut aussi lister les mouvements du futur :-) *}}
|
2023-11-20 11:18:50 +01:00
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{* Extraire et compiler les infos de la base *}}
|
|
|
|
{{#select
|
|
|
|
json_extract(mvt.document, '$.date') as 'date',
|
|
|
|
eqpmt.key as 'eqpmt_key',
|
|
|
|
json_extract(eqpmt.document, '$.designation') as 'designation',
|
|
|
|
cat.key as 'cat_key',
|
|
|
|
json_extract(cat.document, '$.name') as 'category',
|
|
|
|
mvt.key as 'mvt_key',
|
|
|
|
json_extract(mvt.document, '$.direction') as 'direction',
|
|
|
|
CASE json_extract(mvt.document, '$.direction')
|
|
|
|
WHEN 'entrée' THEN json_extract(mvt.document, '$.inputNature')
|
|
|
|
WHEN 'sortie' THEN json_extract(mvt.document, '$.outputNature')
|
|
|
|
END
|
|
|
|
AS 'operation',
|
|
|
|
json_extract(mvt.document, '$.amount') AS 'nombre'
|
|
|
|
FROM module_data_equipment as eqpmt
|
|
|
|
INNER JOIN module_data_equipment as cat
|
|
|
|
ON json_extract(eqpmt.document, '$.category') = cat.key
|
|
|
|
INNER JOIN module_data_equipment as mvt
|
|
|
|
ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
|
|
|
WHERE json_extract(eqpmt.document, '$.type') = "equipment"
|
|
|
|
AND !categories
|
|
|
|
AND json_extract(mvt.document, '$.date') <= :date
|
|
|
|
ORDER BY
|
|
|
|
json_extract(cat.document, '$.name'),
|
|
|
|
json_extract(eqpmt.document, '$.designation'),
|
|
|
|
json_extract(mvt.document, '$.date');
|
|
|
|
!categories='cat_key'|sql_where:'IN':$categories
|
|
|
|
:date=$date
|
|
|
|
}}
|
|
|
|
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.name"|args:$cat_key
|
|
|
|
value=$category}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.eqpmt.%s.designation"|args:$cat_key:$eqpmt_key
|
|
|
|
value=$designation}}
|
|
|
|
|
|
|
|
{{* matériel propriété de l'asso en stock *}}
|
|
|
|
{{:assign
|
|
|
|
var="stock"
|
|
|
|
from="equipments.%s.eqpmt.%s.stock"|args:$cat_key:$eqpmt_key}}
|
|
|
|
{{if $stock === null}}
|
|
|
|
{{:assign stock=0}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{* matériel propriété de l'asso à l'extérieur *}}
|
|
|
|
{{:assign
|
|
|
|
var="exterieur"
|
|
|
|
from="equipments.%s.eqpmt.%s.exterieur"|args:$cat_key:$eqpmt_key}}
|
|
|
|
{{if $exterieur === null}}
|
|
|
|
{{:assign exterieur=0}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{* matériel non propriété de l'asso *}}
|
|
|
|
{{:assign
|
|
|
|
var="nonproprio"
|
|
|
|
from="equipments.%s.eqpmt.%s.nonproprio"|args:$cat_key:$eqpmt_key}}
|
|
|
|
{{if $nonproprio === null}}
|
|
|
|
{{:assign nonproprio=0}}
|
|
|
|
{{/if}}
|
|
|
|
|
2023-11-30 18:14:46 +01:00
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
|
|
|
{{:include file="/%s/_get_config.html"|args:$module.name keep="config"}}
|
|
|
|
|
2023-11-20 11:18:50 +01:00
|
|
|
{{if $direction === 'entrée'}}
|
|
|
|
{{* chercher le type d'entrée parmi les types de la config *}}
|
2023-11-30 18:14:46 +01:00
|
|
|
{{#foreach from=$config.inputNature item="elem"}}
|
2023-11-20 11:18:50 +01:00
|
|
|
{{if $operation == $elem.label}}
|
|
|
|
{{if $elem.type == 'définitif'}}
|
|
|
|
{{:assign stock="%d+%d"|math:$stock:$nombre}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.eqpmt.%s.stock"|args:$cat_key:$eqpmt_key
|
|
|
|
from=stock}}
|
|
|
|
{{elseif $elem.type == 'retour'}}
|
|
|
|
{{:assign exterieur="%d-%d"|math:$exterieur:$nombre}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.eqpmt.%s.exterieur"|args:$cat_key:$eqpmt_key
|
|
|
|
from=exterieur}}
|
|
|
|
{{elseif $elem.type == 'temporaire'}}
|
|
|
|
{{:assign nonproprio="%d+%d"|math:$nonproprio:$nombre}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.eqpmt.%s.nonproprio"|args:$cat_key:$eqpmt_key
|
|
|
|
from=nonproprio}}
|
|
|
|
{{/if}}
|
|
|
|
{{:break}}
|
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
|
|
|
{{elseif $direction === 'sortie'}}
|
|
|
|
{{* chercher le type de sortie parmi les types de la config *}}
|
2023-11-30 18:14:46 +01:00
|
|
|
{{#foreach from=$config.outputNature item="elem"}}
|
2023-11-20 11:18:50 +01:00
|
|
|
{{if $operation == $elem.label}}
|
|
|
|
{{if $elem.type == 'définitif'}}
|
|
|
|
{{:assign stock="%d-%d"|math:$stock:$nombre}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.eqpmt.%s.stock"|args:$cat_key:$eqpmt_key
|
|
|
|
from=stock}}
|
|
|
|
{{elseif $elem.type == 'temporaire'}}
|
|
|
|
{{:assign exterieur="%d+%d"|math:$exterieur:$nombre}}
|
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.eqpmt.%s.exterieur"|args:$cat_key:$eqpmt_key
|
|
|
|
from=exterieur}}
|
|
|
|
{{elseif $elem.type == 'retour'}}
|
2023-11-20 12:31:39 +01:00
|
|
|
{{:assign nonproprio="%d-%d"|math:$nonproprio:$nombre}}
|
2023-11-20 11:18:50 +01:00
|
|
|
{{:assign
|
|
|
|
var="equipments.%s.eqpmt.%s.nonproprio"|args:$cat_key:$eqpmt_key
|
|
|
|
from=nonproprio}}
|
|
|
|
{{/if}}
|
|
|
|
{{:break}}
|
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
|
|
|
{{/if}}
|
|
|
|
{{/select}}
|