Amélioration filtre par catégorie
This commit is contained in:
parent
feef51361e
commit
125fcf0250
3 changed files with 95 additions and 43 deletions
|
|
@ -13,12 +13,41 @@
|
|||
{{* récupérer la config des entrées/sorties *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
|
||||
{{* filtrer selon la catégorie *}}
|
||||
{{if $_GET.cat_key == null}}
|
||||
{{if $module.config.hist_cat_key != null}}
|
||||
{{:assign selected_category=$module.config.hist_cat_key}}
|
||||
{{:assign cat_key=$selected_category|quote_sql}}
|
||||
{{else}}
|
||||
{{:assign selected_category=null}}
|
||||
{{:save key="config" hist_cat_key=null}}
|
||||
{{/if}}
|
||||
{{elseif $_GET.cat_key == -1}}
|
||||
{{:assign selected_category=null}}
|
||||
{{:save key="config" hist_cat_key=null}}
|
||||
{{else}}
|
||||
{{:assign selected_category=$_GET.cat_key}}
|
||||
{{:assign cat_key=$selected_category|quote_sql}}
|
||||
{{: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}}
|
||||
|
||||
{{* Sélecteur catégories *}}
|
||||
{{:assign var="options." value="" label="Toutes les catégories" href="?"}}
|
||||
{{: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 +58,8 @@
|
|||
<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>
|
||||
|
||||
|
|
@ -38,18 +67,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 +87,7 @@
|
|||
END as 'Stockage';
|
||||
$$.comment AS 'Commentaire'
|
||||
"|args:$config.user_fields.name_sql
|
||||
where="%s"|args:$condition
|
||||
where="%s"|args:$cat_condition
|
||||
order=1
|
||||
max=50
|
||||
desc=true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue