Mutualisation calcul des entrées/sorties à une date donnée
This commit is contained in:
parent
2376a2d648
commit
0b356b6617
5 changed files with 158 additions and 210 deletions
111
inventaire.html
111
inventaire.html
|
|
@ -1,115 +1,7 @@
|
|||
{{* inventaire des entrées/sorties des matériels des catégories de la variable $categories *}}
|
||||
|
||||
{{:assign base_path="/m/%s"|args:$module.name}}
|
||||
|
||||
{{* 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
|
||||
ORDER BY
|
||||
json_extract(cat.document, '$.name'),
|
||||
json_extract(eqpmt.document, '$.designation'),
|
||||
json_extract(mvt.document, '$.date');
|
||||
!categories='cat_key'|sql_where:'IN':$categories
|
||||
}}
|
||||
|
||||
{{: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}}
|
||||
|
||||
{{if $direction === 'entrée'}}
|
||||
{{* chercher le type d'entrée parmi les types de la config *}}
|
||||
{{#foreach from=$module.config.inputNature item="elem"}}
|
||||
{{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 *}}
|
||||
{{#foreach from=$module.config.outputNature item="elem"}}
|
||||
{{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'}}
|
||||
{{: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}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{:include file="./_calcul_dispo.html" keep="equipments"}}
|
||||
|
||||
{{* Afficher les résultats *}}
|
||||
{{if $equipments === null}}
|
||||
|
|
@ -152,6 +44,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{:assign base_path="/m/%s"|args:$module.name}}
|
||||
{{* itérer sur les matériels de la catégorie *}}
|
||||
{{#foreach from=$category.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue