inventaire : ajout tri par quantité

This commit is contained in:
Jean-Christophe Engel 2025-02-21 13:34:49 +01:00
parent 17052676df
commit 0be13c1c11
2 changed files with 200 additions and 131 deletions

View File

@ -4,19 +4,17 @@
inventaire des entrées/sorties des matériels permanents inventaire des entrées/sorties des matériels permanents
*}} *}}
{{* Extraire et compiler les infos de la base *}}
{{:include file="./_calcul_dispo.html" keep="categories,equipments"}}
{{* Sélecteur catégories *}} {{* Sélecteur catégories *}}
{{:assign var="options." value="" label="Toutes les catégories" href="?prop=1"}} {{:assign var="options." value="" label="Toutes les catégories" href="?prop=1"}}
{{#foreach from=$categories key=key item=name}} {{#load type="category" order="$$.name"}}
{{:assign var="categories.%s"|args:$key value=$name}}
{{:assign {{:assign
var="options." var="options."
value=$key value=$key
label=$name label=$name
href="?cat_key=%s&prop=1"|args:$key href="?cat_key=%s&prop=1"|args:$key
}} }}
{{/foreach}} {{/load}}
<fieldset class="shortFormRight"> <fieldset class="shortFormRight">
<legend>Filtrer par catégorie</legend> <legend>Filtrer par catégorie</legend>
@ -31,13 +29,29 @@
<p class="help">Inventaire des matériels propriété de l'association</p> <p class="help">Inventaire des matériels propriété de l'association</p>
</div> </div>
{{* Vérifier s'il y a au moins un matériel non archivé propriété de l'asso *}} {{* types d'entrées et sorties *}}
{{:assign mat_present=false}} {{:include file="./_get_config.html" keep="config"}}
{{#foreach from=$equipments key=key item=eqpmt}}
{{if $eqpmt|has_key:"stock" && $eqpmt.status != "archived"}} {{#foreach from=$config.input_nature key=key}}
{{:assign mat_present=true}} {{:assign var="types.input.%s."|args:$type value=$key}}
{{:break}} {{/foreach}}
{{/if}}
{{#foreach from=$types.input key=key}}
{{:assign var=elem from="types.input.%s"|args:$key}}
{{:assign elem=$elem|quote_sql|implode:","}}
{{:assign elem="("|cat:$elem|cat:")"}}
{{:assign var="input_types.%s"|args:$key value=$elem}}
{{/foreach}}
{{#foreach from=$config.output_nature key=key}}
{{:assign var="types.output.%s."|args:$type value=$key}}
{{/foreach}}
{{#foreach from=$types.output key=key}}
{{:assign var=elem from="types.output.%s"|args:$key}}
{{:assign elem=$elem|quote_sql|implode:","}}
{{:assign elem="("|cat:$elem|cat:")"}}
{{:assign var="output_types.%s"|args:$key value=$elem}}
{{/foreach}} {{/foreach}}
{{* filtrer selon la catégorie *}} {{* filtrer selon la catégorie *}}
@ -48,72 +62,100 @@
{{:assign condition="$$.category == %s"|args:$cat_key}} {{:assign condition="$$.category == %s"|args:$cat_key}}
{{/if}} {{/if}}
{{if $mat_present}} {{#list
{{#list select="
select=" $$.name AS 'Matériel' ;
$$.name AS 'Matériel' ; (SELECT $$.name
(SELECT $$.name FROM @TABLE as cat
FROM @TABLE as cat WHERE cat.key = @TABLE.$$.category) AS 'Catégorie' ;
WHERE cat.key = @TABLE.$$.category) AS "Catégorie" ; (SELECT
"" AS 'Stock' ; SUM($$.amount)
"" AS 'Sorti' ; FROM module_data_equipment AS mvt
"" AS 'Dispo' WHERE
" $$.type = 'movement'
type="equipment" AND
where="$$.status<>'archived' AND %s"|args:$condition $$.operation IN %s
order=1 AND
$$.equipment = module_data_equipment.key
) -
(SELECT
COALESCE(SUM($$.amount), 0)
FROM module_data_equipment AS mvt
WHERE
$$.type = 'movement'
AND
$$.operation IN %s
AND
$$.equipment = module_data_equipment.key
) AS 'Stock' ;
(SELECT
COALESCE(SUM($$.amount), 0)
FROM module_data_equipment AS mvt
WHERE
$$.type = 'movement'
AND
$$.operation IN %s
AND
$$.equipment = module_data_equipment.key
) -
(SELECT
COALESCE(SUM($$.amount), 0)
FROM module_data_equipment AS mvt
WHERE
$$.type = 'movement'
AND
$$.operation IN %s
AND
$$.equipment = module_data_equipment.key
) AS 'Sorti' ;
'' AS 'Disponible'
"|args:$input_types.définitif:$output_types.définitif:$output_types.temporaire:$input_types.retour
type="equipment"
where="$$.status <> 'archived' AND %s"|args:$condition
group="col1 HAVING col3 NOT NULL"
order=1
}} }}
{{:assign var=eqpmt_key value=$key}} {{:assign var=cat_name from=categories.%s|args:$category}}
{{:assign var=cat_name from=categories.%s|args:$category}} {{:assign dispo="%d-%d"|math:$col3:$col4}}
{{:assign var=stock from="equipments.%s.stock"|args:$eqpmt_key}}
{{:assign var=exterieur from="equipments.%s.exterieur"|args:$eqpmt_key}}
{{:assign dispo="%d-%d"|math:$stock:$exterieur}}
{{:assign var=eqpmt from="equipments.%s"|args:$eqpmt_key}}
{{if ! $eqpmt|has_key:"stock"}} <tr>
{{* aucune unité permanente de ce matériel *}} <td>{{$name}}</td>
{{:continue}} <td>{{$cat_name}}</td>
{{/if}} <td class="num">{{$col3}}</td>
<td class="num">{{$col4}}</td>
<tr> <td class="num">{{$dispo}}</td>
<td>{{$name}}</td> <td class="actions">
<td>{{$cat_name}}</td> {{if $col4 > 0}}
<td class="num">{{$stock}}</td>
<td class="num">{{if $exterieur == null}}0{{else}}{{$exterieur}}{{/if}}</td>
<td class="num">{{$dispo}}</td>
<td class="actions">
{{if $exterieur > 0}}
{{:linkbutton
label="Retour"
href="mouvements/entrees/retour.html?key=%s"|args:$eqpmt_key
shape="history"
target="_dialog"}}
{{/if}}
{{if $dispo > 0}}
{{:linkbutton
label="Sortie"
shape="minus"
href="mouvements/sorties/stock_disponible.html?key=%s"|args:$eqpmt_key
target="_dialog"}}
{{/if}}
{{:linkbutton {{:linkbutton
label="Entrée" label="Retour"
shape="plus" href="mouvements/entrees/retour.html?key=%s"|args:$key
href="mouvements/entrees/repertorie.html?key=%s"|args:$eqpmt_key shape="history"
target="_dialog"}} target="_dialog"}}
{{/if}}
{{if $dispo > 0}}
{{:linkbutton {{:linkbutton
label="Historique" label="Sortie"
href="historique.html?key=%s&prop=1"|args:$eqpmt_key shape="minus"
shape="table"}} href="mouvements/sorties/stock_disponible.html?key=%s"|args:$key
{{:linkbutton
label="Modifier"
href="modifier_materiel.html?key=%s&prop=1&stock=%s"|args:$eqpmt_key:$stock
shape="edit"
target="_dialog"}} target="_dialog"}}
</td> {{/if}}
</tr> {{:linkbutton
{{/list}} label="Entrée"
shape="plus"
href="mouvements/entrees/repertorie.html?key=%s"|args:$key
target="_dialog"}}
{{:linkbutton
label="Historique"
href="historique.html?key=%s&prop=1"|args:$key
shape="table"}}
{{:linkbutton
label="Modifier"
href="modifier_materiel.html?key=%s&prop=1&stock=%s"|args:$key:$col3
shape="edit"
target="_dialog"}}
</td>
</tr>
{{else}} {{else}}
<p class="block alert">Aucun matériel.</p> <p class="block alert">Aucun matériel.</p>
{{/if}} {{/list}}

View File

@ -4,19 +4,17 @@
inventaire des entrées/sorties des matériels temporaires inventaire des entrées/sorties des matériels temporaires
*}} *}}
{{* Extraire et compiler les infos de la base *}}
{{:include file="./_calcul_dispo.html" keep="categories,equipments"}}
{{* Sélecteur catégories *}} {{* Sélecteur catégories *}}
{{:assign var="options." value="" label="Toutes les catégories" href="?prop=0"}} {{:assign var="options." value="" label="Toutes les catégories" href="?prop=0"}}
{{#foreach from=$categories key=key item=name}} {{#load type="category" order="$$.name"}}
{{:assign var="categories.%s"|args:$key value=$name}}
{{:assign {{:assign
var="options." var="options."
value=$key value=$key
label=$name label=$name
href="?cat_key=%s&prop=0"|args:$key href="?cat_key=%s&prop=0"|args:$key
}} }}
{{/foreach}} {{/load}}
<fieldset class="shortFormRight"> <fieldset class="shortFormRight">
<legend>Filtrer par catégorie</legend> <legend>Filtrer par catégorie</legend>
@ -31,13 +29,29 @@
<p class="help shortFormLeft">Inventaire des matériels empruntés ou loués</p> <p class="help shortFormLeft">Inventaire des matériels empruntés ou loués</p>
</div> </div>
{{* Vérifier s'il y a au moins un matériel non propriété de l'asso *}} {{* types d'entrées et sorties *}}
{{:assign mat_present=false}} {{:include file="./_get_config.html" keep="config"}}
{{#foreach from=$equipments key=key item=eqpmt}}
{{if $eqpmt|has_key:"nonproprio" && $eqpmt.status != "archived"}} {{#foreach from=$config.input_nature key=key}}
{{:assign mat_present=true}} {{:assign var="types.input.%s."|args:$type value=$key}}
{{:break}} {{/foreach}}
{{/if}}
{{#foreach from=$types.input key=key}}
{{:assign var=elem from="types.input.%s"|args:$key}}
{{:assign elem=$elem|quote_sql|implode:","}}
{{:assign elem="("|cat:$elem|cat:")"}}
{{:assign var="input_types.%s"|args:$key value=$elem}}
{{/foreach}}
{{#foreach from=$config.output_nature key=key}}
{{:assign var="types.output.%s."|args:$type value=$key}}
{{/foreach}}
{{#foreach from=$types.output key=key}}
{{:assign var=elem from="types.output.%s"|args:$key}}
{{:assign elem=$elem|quote_sql|implode:","}}
{{:assign elem="("|cat:$elem|cat:")"}}
{{:assign var="output_types.%s"|args:$key value=$elem}}
{{/foreach}} {{/foreach}}
{{* filtrer selon la catégorie *}} {{* filtrer selon la catégorie *}}
@ -48,56 +62,69 @@
{{:assign condition="$$.category == %s"|args:$cat_key}} {{:assign condition="$$.category == %s"|args:$cat_key}}
{{/if}} {{/if}}
{{if $mat_present}} {{#list
{{#list select="
select=" $$.name AS 'Matériel' ;
$$.name AS 'Matériel' ; (SELECT $$.name
(SELECT $$.name FROM @TABLE as cat
FROM @TABLE as cat WHERE cat.key = @TABLE.$$.category) AS 'Catégorie' ;
WHERE cat.key = @TABLE.$$.category) AS "Catégorie" ; (SELECT
"" AS 'Quantité' SUM($$.amount)
" FROM module_data_equipment AS mvt
type="equipment" WHERE
where="%s"|args:$condition $$.type = 'movement'
order=1 AND
}} $$.operation IN %s
{{:assign var=eqpmt_key value=$key}} AND
{{:assign var=cat_name from=categories.%s|args:$category}} $$.equipment = module_data_equipment.key
{{:assign var=qte from="equipments.%s.nonproprio"|args:$eqpmt_key}} ) -
(SELECT
COALESCE(SUM($$.amount), 0)
FROM module_data_equipment AS mvt
WHERE
$$.type = 'movement'
AND
$$.operation IN %s
AND
$$.equipment = module_data_equipment.key
) AS 'Quantité'
"|args:$input_types.temporaire:$output_types.retour
type="equipment"
where="$$.status <> 'archived' AND %s"|args:$condition
group="col1 HAVING (col3 NOT NULL AND col3 > 0)"
order=1
}}
{{if $qte == null}} {{:assign var=cat_name from=categories.%s|args:$category}}
{{:continue}}
{{/if}}
<tr> <tr>
<td>{{$name}}</td> <td>{{$name}}</td>
<td>{{$cat_name}}</td> <td>{{$cat_name}}</td>
<td class="num">{{$qte}}</td> <td class="num">{{$col3}}</td>
<td class="actions"> <td class="actions">
{{if $qte > 0}} {{if $col3 > 0}}
{{:linkbutton
label="Retour"
href="mouvements/sorties/emprunte.html?key=%s"|args:$eqpmt_key
shape="history"
target="_dialog"}}
{{/if}}
{{:linkbutton {{:linkbutton
label="Entrée" label="Retour"
shape="plus" href="mouvements/sorties/emprunte.html?key=%s"|args:$key
href="mouvements/entrees/repertorie.html?key=%s"|args:$eqpmt_key shape="history"
target="_dialog"}} target="_dialog"}}
{{:linkbutton {{/if}}
label="Historique" {{:linkbutton
href="historique.html?key=%s&prop=0"|args:$eqpmt_key label="Entrée"
shape="table"}} shape="plus"
{{:linkbutton href="mouvements/entrees/repertorie.html?key=%s"|args:$key
label="Modifier" target="_dialog"}}
href="modifier_materiel.html?key=%s&prop=0"|args:$eqpmt_key {{:linkbutton
shape="edit" label="Historique"
target="_dialog"}} href="historique.html?key=%s&prop=0"|args:$key
</td> shape="table"}}
</tr> {{:linkbutton
{{/list}} label="Modifier"
href="modifier_materiel.html?key=%s&prop=0"|args:$key
shape="edit"
target="_dialog"}}
</td>
</tr>
{{else}} {{else}}
<p class="block alert">Aucun matériel.</p> <p class="block alert">Aucun matériel.</p>
{{/if}} {{/list}}