From 974f87e5a4bd872fc8d184a2c401dba6cb96d910 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Wed, 28 Jan 2026 13:37:11 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20filtre=20par=20cat=C3=A9gorie=20Locatio?= =?UTF-8?q?n=20et=20Pr=C3=AAts=20en=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loan_history.html | 79 +++++++++++++++++++++++++++++++++++------------ rent_history.html | 74 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 116 insertions(+), 37 deletions(-) diff --git a/loan_history.html b/loan_history.html index 1fb0985..3c413f2 100644 --- a/loan_history.html +++ b/loan_history.html @@ -31,20 +31,59 @@ {{/if}} {{/if}} -
-

Prêts de matériel en cours

-
- {{* lecture config (défaut ou enregistrée) *}} {{:include file="./_get_config.html" keep="config"}} +{{* filtrer selon la catégorie *}} +{{if $_GET.cat_key == null}} + {{:assign selected_category=$module.config.loan_hist_cat_key}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" loan_hist_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:save key="config" loan_hist_cat_key=$selected_category}} +{{/if}} + +{{* condition de filtrage *}} +{{if $selected_category != null}} + {{:assign cat_key=$selected_category|quote_sql}} + {{:assign cat_condition="json_extract(mat.document, '$.category') = %s"|args:$cat_key}} +{{else}} + {{:assign cat_condition=1}} +{{/if}} + {{#foreach from=$config.output_nature key="key"}} {{if $type == 'temporaire' && $fee != 'payant'}} - {{:assign var="output_types." value=$key|quote_sql}} + {{:assign var="out_keys." value=$key|quote_sql}} {{/if}} {{/foreach}} -{{:assign output_ops=$output_types|implode:","}} -{{:assign output_ops="("|cat:$output_ops|cat:")"}} +{{:assign out_keys=$out_keys|implode:","}} +{{:assign out_keys="("|cat:$out_keys|cat:")"}} + +{{* sélecteur de catégorie *}} +{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}} +{{#load type="category" order="$$.name"}} + {{:assign + var="cat_options." + value=$key + label=$name + href="?cat_key=%s"|args:$key + }} +{{/load}} + +
+ Filtrer par catégorie + {{:dropdown + title="Filtrer par catégorie" + options=$cat_options + value="%s"|args:$selected_category + }} +
+ +
+

Location de matériel en cours

+
{{:assign premier=true}} {{#select @@ -61,29 +100,29 @@ LEFT JOIN !table AS links ON mvt.key = json_extract(links.document, '$.temp_key') LEFT JOIN !table AS retour ON retour.key = json_extract(links.document, '$.return') INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment') - WHERE - json_extract(mvt.document, '$.type') = 'movement' - AND - json_extract(mvt.document, '$.operation') IN !op + WHERE json_extract(mvt.document, '$.type') = 'movement' + AND json_extract(mvt.document, '$.operation') IN !op + AND !cat_condition GROUP BY mvt.key HAVING remain != 0 ORDER BY out_date, nom ; !table=$module.table - !op = $output_ops + !op = $out_keys + !cat_condition=$cat_condition }} {{if $premier}} - - - - - - - - + + + + + + + + diff --git a/rent_history.html b/rent_history.html index ac4e5a1..0baa133 100644 --- a/rent_history.html +++ b/rent_history.html @@ -31,20 +31,59 @@ {{/if}} {{/if}} -
-

Location de matériel en cours

-
- {{* lecture config (défaut ou enregistrée) *}} {{:include file="./_get_config.html" keep="config"}} -{{#foreach from=$config.output_nature key="key" item="elem"}} +{{* filtrer selon la catégorie *}} +{{if $_GET.cat_key == null}} + {{:assign selected_category=$module.config.rent_hist_cat_key}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" rent_hist_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:save key="config" rent_hist_cat_key=$selected_category}} +{{/if}} + +{{* condition de filtrage *}} +{{if $selected_category != null}} + {{:assign cat_key=$selected_category|quote_sql}} + {{:assign cat_condition="json_extract(mat.document, '$.category') = %s"|args:$cat_key}} +{{else}} + {{:assign cat_condition=1}} +{{/if}} + +{{#foreach from=$config.output_nature key="key"}} {{if $type == 'temporaire' && $fee == 'payant'}} - {{:assign var="output_types." value=$key|quote_sql}} + {{:assign var="out_keys." value=$key|quote_sql}} {{/if}} {{/foreach}} -{{:assign output_ops=$output_types|implode:","}} -{{:assign output_ops="("|cat:$output_ops|cat:")"}} +{{:assign out_keys=$out_keys|implode:","}} +{{:assign out_keys="("|cat:$out_keys|cat:")"}} + +{{* sélecteur de catégorie *}} +{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1"}} +{{#load type="category" order="$$.name"}} + {{:assign + var="cat_options." + value=$key + label=$name + href="?cat_key=%s"|args:$key + }} +{{/load}} + +
+ Filtrer par catégorie + {{:dropdown + title="Filtrer par catégorie" + options=$cat_options + value="%s"|args:$selected_category + }} +
+ +
+

Location de matériel en cours

+
{{:assign premier=true}} {{#select @@ -56,20 +95,21 @@ json_extract(mvt.document, '$.amount') AS out_amount, json_extract(mvt.document, '$.return_date') AS return_date, json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(retour.document, '$.amount')), 0) AS remain - FROM {!$module.table} AS mvt + FROM !table AS mvt LEFT JOIN users ON json_extract(mvt.document, '$.user') = users.id - LEFT JOIN {!$module.table} AS links ON mvt.key = json_extract(links.document, '$.temp_key') - LEFT JOIN {!$module.table} AS retour ON retour.key = json_extract(links.document, '$.return') - INNER JOIN {!$module.table} AS mat ON mat.key = json_extract(mvt.document, '$.equipment') - WHERE - json_extract(mvt.document, '$.type') = 'movement' - AND - json_extract(mvt.document, '$.operation') IN !op + LEFT JOIN !table AS links ON mvt.key = json_extract(links.document, '$.temp_key') + LEFT JOIN !table AS retour ON retour.key = json_extract(links.document, '$.return') + INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment') + WHERE json_extract(mvt.document, '$.type') = 'movement' + AND json_extract(mvt.document, '$.operation') IN !op + AND !cat_condition GROUP BY mvt.key HAVING remain != 0 ORDER BY out_date, nom ; - !op = $output_ops + !table=$module.table + !op = $out_keys + !cat_condition=$cat_condition }} {{if $premier}}
MatérielDate prêtQuantitéMembreDate retourReste à rendreRemarqueMatérielDate prêtQuantitéMembreDate retourReste à rendreRemarque