diff --git a/_inventory.html b/_inventory.html index b74bdbb..090a01d 100644 --- a/_inventory.html +++ b/_inventory.html @@ -4,12 +4,34 @@ inventaire des entrées/sorties des matériels permanents *}} +{{* filtrer selon la catégorie *}} +{{if $_GET.cat_key == null}} + {{:assign selected_category=$module.config.stock_cat_key}} + {{if $module.config.stock_cat_key != null}} + {{:assign cat_key=$selected_category|quote_sql}} + {{/if}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" stock_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:assign cat_key=$selected_category|quote_sql}} + {{:save key="config" stock_cat_key=$selected_category}} +{{/if}} + +{{* condition de filtrage *}} +{{if $selected_category != null}} + {{:assign cat_condition="$$.category = %s"|args:$cat_key}} +{{else}} + {{:assign cat_condition="1"}} +{{/if}} + {{* Sélecteur catégories *}} -{{:assign var="options." value="" label="Toutes les catégories" href="?prop=1"}} +{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1&prop=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&prop=1"|args:$key @@ -20,8 +42,8 @@ {{:dropdown title="Filtrer par catégorie" - options=$options - value="%s"|args:$_GET.cat_key + options=$cat_options + value="%s"|args:$selected_category }} @@ -29,14 +51,6 @@
Inventaire des matériels propriété de l'association
-{{* filtrer selon la catégorie *}} -{{if $_GET.cat_key == null}} - {{:assign condition="1"}} -{{else}} - {{:assign cat_key=$_GET.cat_key|quote_sql}} - {{:assign condition="$$.category = %s"|args:$cat_key}} -{{/if}} - {{#list select=" $$.name AS 'Matériel' ; @@ -48,7 +62,7 @@ (SELECT $$.stock - $$.out) AS 'Disponible' " type="equipment" - where="$$.status <> 'archived' AND $$.stock NOT NULL AND %s"|args:$condition + where="$$.status <> 'archived' AND $$.stock NOT NULL AND %s"|args:$cat_condition order=1 }} {{:assign var=cat_name from=categories.%s|args:$category}} diff --git a/_temp_inventory.html b/_temp_inventory.html index df4f8aa..d4b29d4 100644 --- a/_temp_inventory.html +++ b/_temp_inventory.html @@ -4,12 +4,34 @@ inventaire des entrées/sorties des matériels temporaires *}} +{{* filtrer selon la catégorie *}} +{{if $_GET.cat_key == null}} + {{:assign selected_category=$module.config.temp_cat_key}} + {{if $module.config.temp_cat_key != null}} + {{:assign cat_key=$selected_category|quote_sql}} + {{/if}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" temp_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:assign cat_key=$selected_category|quote_sql}} + {{:save key="config" temp_cat_key=$selected_category}} +{{/if}} + +{{* condition de filtrage *}} +{{if $selected_category != null}} + {{:assign cat_condition="$$.category = %s"|args:$cat_key}} +{{else}} + {{:assign cat_condition="1"}} +{{/if}} + {{* Sélecteur catégories *}} -{{:assign var="options." value="" label="Toutes les catégories" href="?prop=0"}} +{{:assign var="cat_options." value="" label="Toutes les catégories" href="?cat_key=-1&prop=0"}} {{#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&prop=0"|args:$key @@ -20,8 +42,8 @@ {{:dropdown title="Filtrer par catégorie" - options=$options - value="%s"|args:$_GET.cat_key + options=$cat_options + value="%s"|args:$selected_category }} @@ -29,14 +51,6 @@Inventaire des matériels empruntés ou loués
-{{* filtrer selon la catégorie *}} -{{if $_GET.cat_key == null}} - {{:assign condition="1"}} -{{else}} - {{:assign cat_key=$_GET.cat_key|quote_sql}} - {{:assign condition="$$.category = %s"|args:$cat_key}} -{{/if}} - {{#list select=" $$.name AS 'Matériel' ; @@ -46,7 +60,7 @@ $$.notowned AS 'Quantité' " type="equipment" - where="$$.status <> 'archived' AND $$.notowned != 0 AND %s"|args:$condition + where="$$.status <> 'archived' AND $$.notowned != 0 AND %s"|args:$cat_condition order=1 }} {{:assign var=cat_name from=categories.%s|args:$category}} diff --git a/equipment_history.html b/equipment_history.html index 786adbe..82b869e 100644 --- a/equipment_history.html +++ b/equipment_history.html @@ -147,14 +147,15 @@ {{#select mvt.key AS mvt_key, json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste - FROM {!$module.table} AS mvt - LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key') - LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') + FROM !table AS mvt + LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key') + LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') WHERE json_extract(mvt.document, '$.operation') IN !op AND json_extract(mvt.document, '$.equipment') = :eqpmt_key GROUP by mvt.key ; + !table=$module.table !op = $operations :eqpmt_key = $_GET.key }} @@ -250,14 +251,15 @@ {{#select mvt.key AS mvt_key, json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present - FROM {!$module.table} AS mvt - LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key') - LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') + FROM !table AS mvt + LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key') + LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') WHERE json_extract(mvt.document, '$.operation') IN !op AND json_extract(mvt.document, '$.equipment') = :eqpmt_key GROUP by mvt.key ; + !table=$module.table !op = $operations :eqpmt_key = $_GET.key }} diff --git a/global_history.html b/global_history.html index 81e576b..75b1889 100644 --- a/global_history.html +++ b/global_history.html @@ -13,12 +13,34 @@ {{* 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}} + {{: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}} + {{* 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 +51,8 @@ {{:dropdown title="Filtrer par catégorie" - options=$options - value="%s"|args:$_GET.cat_key + options=$cat_options + value="%s"|args:$selected_category }} @@ -38,18 +60,7 @@Historique de tous les mouvements de matériel
-{{* 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 +80,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 diff --git a/loan_history.html b/loan_history.html index 997ffa4..65fcddc 100644 --- a/loan_history.html +++ b/loan_history.html @@ -56,11 +56,11 @@ 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') + 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 @@ -69,6 +69,7 @@ HAVING remain != 0 ORDER BY out_date, nom ; + !table=$module.table !op = $output_ops }} {{if $premier}} diff --git a/member_history.html b/member_history.html index bf44103..cf47264 100644 --- a/member_history.html +++ b/member_history.html @@ -51,13 +51,13 @@ json_extract(mvt.document, '$.amount') as amount, COALESCE((SELECT json_extract(links.document, '$.temp_key') - FROM {!$module.table} AS links + FROM !table AS links WHERE json_extract(links.document, '$.temp_key') = mvt.key OR json_extract(links.document, '$.return') = mvt.key), mvt.key) AS out_temp_key - FROM {!$module.table} AS mvt + FROM !table AS mvt INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id - INNER JOIN {!$module.table} AS eqpmt + INNER JOIN !table AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key WHERE users.id = :user AND eqpmt.key = :eqpmt_key @@ -65,6 +65,7 @@ OR json_extract(mvt.document, '$.operation') IN !input_types) ORDER BY out_temp_key, date ; + !table=$module.table :user = $_GET.id :eqpmt_key = $_GET.key|trim !output_types=$output_types.temporaire diff --git a/movements/input_return.html b/movements/input_return.html index c4601b3..4512516 100644 --- a/movements/input_return.html +++ b/movements/input_return.html @@ -34,14 +34,15 @@ {{#select json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present - FROM {!$module.table} AS mvt - LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key') - LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') + FROM !table AS mvt + LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key') + LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') WHERE json_extract(mvt.document, '$.operation') IN !op AND mvt.key = :mvt_key GROUP by mvt.key ; + !table=$module.table !op = $operations :mvt_key = $_GET.key }} diff --git a/movements/output_return.html b/movements/output_return.html index 430f745..162fc37 100644 --- a/movements/output_return.html +++ b/movements/output_return.html @@ -34,14 +34,15 @@ {{#select json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS exterieur - FROM {!$module.table} AS mvt - LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key') - LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') + FROM !table AS mvt + LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key') + LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') WHERE json_extract(mvt.document, '$.operation') IN !op AND mvt.key = :mvt_key GROUP by mvt.key ; + !table=$module.table !op = $operations :mvt_key = $_GET.key }} diff --git a/snippets/_details.html b/snippets/_details.html index 00a6e0b..9ab9458 100644 --- a/snippets/_details.html +++ b/snippets/_details.html @@ -44,9 +44,9 @@ json_extract(mvt.document, '$.amount') AS qte, json_extract(mvt.document, '$.return_date') AS return_date, json_extract(mvt.document, '$.operation') AS operation - FROM {!$module.table} AS mvt + FROM !table AS mvt INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id - INNER JOIN {!$module.table} AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key + INNER JOIN !table AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key WHERE users.id = :user AND @@ -57,6 +57,7 @@ json_extract(mvt.document, '$.operation') IN !input_types) ORDER BY eqpmt_name, date ; + !table=$module.table :user = $user.id !output_types=$output_types.temporaire !input_types=$input_types.retour @@ -165,15 +166,16 @@ json_extract(mvt.document, '$.operation') as operation, MIN(json_extract(mvt.document, '$.date')) as date, SUM(json_extract(mvt.document, '$.amount')) as amount - FROM {!$module.table} AS mvt + FROM !table AS mvt INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id - INNER JOIN {!$module.table} AS eqpmt + INNER JOIN !table AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key WHERE users.id = :user AND json_extract(mvt.document, '$.operation') IN !output_types GROUP BY eqpmt_key, operation ORDER BY eqpmt_name, date ; + !table=$module.table :user = $user.id !output_types=$output_types.définitif assign="def_mat."