global_history : amélioration filtre catégorie ; ajout filtre appartenance

This commit is contained in:
Jean-Christophe Engel 2026-01-20 09:57:58 +01:00
parent e2c8ac2d84
commit 2f3785831e

View file

@ -8,17 +8,93 @@
{{:admin_header title="Historique des mouvements" custom_css="./style.css" current="module_equipment"}}
{{:include file="./_nav.html" current="historique" subcurrent="tous"}}
{{:include file="./_nav.html" current="inventaire" subcurrent="historique"}}
{{* récupérer la config des entrées/sorties *}}
{{:include file="./_get_config.html" keep="config"}}
{{* Sélecteur catégories *}}
{{:assign var="options." value="" label="Toutes les catégories" href="?"}}
{{* filtrer selon la catégorie *}}
{{if $_GET.cat_key == null}}
{{:assign selected_category=$module.config.hist_cat_key}}
{{elseif $_GET.cat_key == -1}}
{{:assign selected_category=null}}
{{:save key="config" hist_cat_key=null}}
{{else}}
{{:assign selected_category=$_GET.cat_key}}
{{:save key="config" hist_cat_key=$selected_category}}
{{/if}}
{{* condition de filtrage *}}
{{if $selected_category != null}}
{{:assign cat_condition="(SELECT key
FROM @TABLE AS cat
WHERE cat.key = (SELECT $$.category
FROM @TABLE AS mat
WHERE mat.key = @TABLE.$$.equipment)) = '%s'"|args:$selected_category}}
{{else}}
{{:assign cat_condition=1}}
{{/if}}
{{* filtrer selon appartenance *}}
{{if $_GET.prop == null}}
{{:assign selected_prop=$module.config.hist_prop}}
{{elseif $_GET.prop == -1}}
{{:assign selected_prop=null}}
{{:save key="config" hist_prop=null}}
{{else}}
{{:assign selected_prop=$_GET.prop}}
{{:save key="config" hist_prop=$_GET.prop}}
{{/if}}
{{* déterminer les types de mouvements selon l'appartenance du matériel *}}
{{#foreach from=$config.input_nature key="key"}}
{{if $selected_prop == null}}
{{* les deux sortes de matériel *}}
{{:assign var="mvt_keys." value=$key|quote_sql}}
{{elseif $selected_prop == 1}}
{{* matériel propriété de l'asso *}}
{{if $type != 'temporaire'}}
{{:assign var="mvt_keys." value=$key|quote_sql}}
{{/if}}
{{else}}
{{* matériel non propriété de l'asso *}}
{{if $type == 'temporaire'}}
{{:assign var="mvt_keys." value=$key|quote_sql}}
{{/if}}
{{/if}}
{{/foreach}}
{{#foreach from=$config.output_nature key="key"}}
{{if $selected_prop == null}}
{{* les deux sortes de matériel *}}
{{:assign var="mvt_keys." value=$key|quote_sql}}
{{elseif $selected_prop == 1}}
{{* matériel propriété de l'asso *}}
{{if $type != 'retour'}}
{{:assign var="mvt_keys." value=$key|quote_sql}}
{{/if}}
{{else}}
{{* matériel non propriété de l'asso *}}
{{if $type == 'retour'}}
{{:assign var="mvt_keys." value=$key|quote_sql}}
{{/if}}
{{/if}}
{{/foreach}}
{{:assign key_cond=$mvt_keys|implode:","}}
{{:assign key_cond="("|cat:$key_cond|cat:")"}}
{{if $selected_prop == null}}
{{:assign prop_condition="1"}}
{{else}}
{{:assign prop_condition="$$.operation in %s"|args:$key_cond}}
{{/if}}
{{* sélecteurs de catégorie et d'appartenance *}}
{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}}
{{#load type="category" order="$$.name"}}
{{:assign var="categories.%s"|args:$key value=$name}}
{{:assign
var="options."
var="cat_options."
value=$key
label=$name
href="?cat_key=%s"|args:$key
@ -29,8 +105,21 @@
<legend>Filtrer par catégorie</legend>
{{:dropdown
title="Filtrer par catégorie"
options=$options
value="%s"|args:$_GET.cat_key
options=$cat_options
value="%s"|args:$selected_category
}}
</fieldset>
{{:assign var="prop_options." value="" label="Tous les matériels" href="?prop=-1"}}
{{:assign var="prop_options." value="1" label="Matériels propriété de l'association" href="?prop=1"}}
{{:assign var="prop_options." value="0" label="Matériels NON propriété de l'association" href="?prop=0"}}
<fieldset class="shortFormRight">
<legend>Filtrer par appartenance</legend>
{{:dropdown
title="Filtrer par appartenance"
options=$prop_options
value="%s"|args:$selected_prop
}}
</fieldset>
@ -38,18 +127,7 @@
<p class="help">Historique de tous les mouvements de matériel</p>
</div>
{{* condition de filtrage *}}
{{if $_GET.cat_key != null}}
{{:assign condition="(SELECT key
FROM @TABLE AS cat
WHERE cat.key = (SELECT $$.category
FROM @TABLE AS mat
WHERE mat.key = @TABLE.$$.equipment)) = '%s'"|args:$_GET.cat_key}}
{{else}}
{{:assign condition=1}}
{{/if}}
{{* lister tous les mouvements *}}
{{* lister les mouvements *}}
{{#list
type="movement"
select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
@ -69,7 +147,7 @@
END as 'Stockage';
$$.comment AS 'Commentaire'
"|args:$config.user_fields.name_sql
where="%s"|args:$condition
where="%s AND %s"|args:$cat_condition:$prop_condition
order=1
max=50
desc=true