- {{/if}}
- {{/list}}
- {{if $dispo_final === 0}}
- Il n'y a aucun matériel disponible, il n'est donc pas possible d'effectuer une sortie
- {{/if}}
-{{else}}
+{{if $selected_prop == null || ! $selected_prop}}
{{* calculer la quantité présente temporairement de chaque matériel *}}
- {{#foreach from=$config.input_nature key=key}}
- {{if $type == "temporaire"}}
- {{:assign var="temp_inputs." value=$key|quote_sql}}
- {{/if}}
- {{/foreach}}
- {{:assign operations=$temp_inputs|implode:","}}
- {{:assign operations="("|cat:$operations|cat:")"}}
+ {{:assign input_ops=$temp_inputs|implode:","}}
+ {{:assign input_ops="("|cat:$input_ops|cat:")"}}
{{#select
mvt.key AS mvt_key,
@@ -258,71 +189,163 @@
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
GROUP by mvt.key
;
- !op = $operations
+ !op = $input_ops
:eqpmt_key = $_GET.key
}}
{{:assign var="present.%s"|args:$mvt_key value=$present}}
{{/select}}
+{{/if}}
- {{#list
- type="movement"
- select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
- CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement';
- $$.operation AS 'Opération';
- $$.amount AS 'Quantité';
- "" as 'Présent';
- CASE WHEN $$.storage NOT NULL
- THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
- ELSE ''
- END as 'Stockage';
- '' AS 'Documents';
- $$.transactions AS 'Écritures'
- "
- equipment=$equipment_key
- order=1
+{{:assign
+ select_debut="
+ ($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
+ CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement';
+ $$.operation AS 'Opération';
+ $$.amount AS 'Quantité';"
+}}
+{{:assign
+ select_prop="'' AS 'Stock';
+ '' AS 'Sorti';
+ '' AS 'Disponible';"
+}}
+{{:assign
+ select_depositaire="CASE WHEN $$.user NOT NULL
+ THEN (SELECT %s AS nom FROM users WHERE id = $$.user)
+ ELSE ''
+ END AS 'Dépositaire';
+ "|args:$config.user_fields.name_sql
+}}
+{{:assign
+ select_non_prop="'' as 'Temporaire';"
+}}
+{{:assign select_final="
+ CASE WHEN $$.storage NOT NULL
+ THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
+ ELSE ''
+ END AS 'Stockage';
+ '' AS 'Documents';
+ $$.transactions AS 'Écritures'
+ "
+}}
+
+{{if $selected_prop == null}}
+ {{:assign select_clause=$select_debut|cat:$select_prop|cat:$select_non_prop|cat:$select_depositaire|cat:$select_final}}
+{{elseif $selected_prop}}
+ {{:assign select_clause=$select_debut|cat:$select_prop|cat:$select_depositaire|cat:$select_final}}
+{{else}}
+ {{:assign select_clause=$select_debut|cat:$select_non_prop|cat:$select_final}}
+{{/if}}
+
+{{:assign var="prop_options." value="" label="Tous les matériels" href="?key=%s&prop=-1"|args:$_GET.key}}
+{{:assign var="prop_options." value="1" label="Matériels propriété de l'association" href="?key=%s&prop=1"|args:$_GET.key}}
+{{:assign var="prop_options." value="0" label="Matériels NON propriété de l'association" href="?key=%s&prop=0"|args:$_GET.key}}
+
+
- {{if $direction === "input" && $op_label|in:$input_types ||
- $direction === "output"&& $op_label|in:$output_types
- }}
- {{:assign var="stock" from="quantites.%s.nonproprio"|args:$id}}
+{{if $current != "archives"}}
+
+{{/if}}
- {{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
- {{:assign file_path=$file_path|cat:"%"}}
- {{#select count(*) AS nb FROM files WHERE path LIKE :file_path ; :file_path=$file_path}}
- {{:assign nb_files=$nb}}
- {{/select}}
-
+
+{{* lister les mouvements *}}
+{{#list
+ type="movement"
+ select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
+ CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement';
+ $$.operation AS 'Opération';
+ (SELECT $$.name
+ FROM @TABLE AS mat
+ WHERE mat.key = @TABLE.$$.equipment) AS 'Matériel' ;
+ $$.amount AS 'Quantité';
+ CASE WHEN $$.user NOT NULL
+ THEN (SELECT %s AS nom FROM users WHERE id = $$.user)
+ ELSE ''
+ END as 'Dépositaire';
+ CASE WHEN $$.storage NOT NULL
+ THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
+ ELSE ''
+ END as 'Stockage';
+ $$.comment AS 'Commentaire'
+ "|args:$config.user_fields.name_sql
+ where="%s AND %s"|args:$key_cond:$cat_condition
+ order=1
+ max=50
+ desc=true
+}}
+ {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
+
+{{/list}}
+{{* *}}
+{{:admin_footer}}
+
+
+
From 71646c9dcd29cb29e68eeb9d0e57248f754a50a7 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Engel
Date: Tue, 27 Jan 2026 17:00:24 +0100
Subject: [PATCH 08/14] =?UTF-8?q?Param=C3=A9trisation=20nom=20table=20dans?=
=?UTF-8?q?=20les=20requ=C3=AAtes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
equipment_history.html | 14 ++++++++------
loan_history.html | 9 +++++----
member_history.html | 7 ++++---
movements/input_return.html | 7 ++++---
movements/output_return.html | 7 ++++---
snippets/_details.html | 10 ++++++----
6 files changed, 31 insertions(+), 23 deletions(-)
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/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."
From b14463ecf288bbf36154460ec885f956ee597b0c Mon Sep 17 00:00:00 2001
From: Jean-Christophe Engel
Date: Tue, 27 Jan 2026 17:17:54 +0100
Subject: [PATCH 09/14] =?UTF-8?q?Param=C3=A9trisation=20nom=20table=20dans?=
=?UTF-8?q?=20les=20requ=C3=AAtes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
equipment_history.html | 14 ++++++++------
loan_history.html | 11 ++++++-----
member_history.html | 7 ++++---
movements/input_return.html | 7 ++++---
movements/output_return.html | 7 ++++---
snippets/_details.html | 10 ++++++----
6 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/equipment_history.html b/equipment_history.html
index e39d1e4..26a3ead 100644
--- a/equipment_history.html
+++ b/equipment_history.html
@@ -158,14 +158,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 = $output_ops
:eqpmt_key = $_GET.key
}}
@@ -181,14 +182,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 = $input_ops
:eqpmt_key = $_GET.key
}}
diff --git a/loan_history.html b/loan_history.html
index 0442354..879ef55 100644
--- a/loan_history.html
+++ b/loan_history.html
@@ -39,7 +39,7 @@
{{:include file="./_get_config.html" keep="config"}}
{{#foreach from=$config.output_nature key="key"}}
- {{if $type == 'temporaire'}}
+ {{if $type == 'temporaire' && $fee != 'payant'}}
{{:assign var="output_types." value=$key|quote_sql}}
{{/if}}
{{/foreach}}
@@ -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."
From 83c2b9af8070209cd567cf39098a31b672b7e8f1 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Engel
Date: Wed, 28 Jan 2026 12:05:55 +0100
Subject: [PATCH 10/14] =?UTF-8?q?S=C3=A9paration=20pr=C3=AAt=20et=20locati?=
=?UTF-8?q?on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
_get_config.html | 2 +-
_nav.html | 8 ++
loan_history.html | 2 +-
loan_movements.html | 171 +++++++++++++++++++++++++++--------------
rent_history.html | 140 ++++++++++++++++++++++++++++++++++
rent_movements.html | 181 ++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 444 insertions(+), 60 deletions(-)
create mode 100644 rent_history.html
create mode 100644 rent_movements.html
diff --git a/_get_config.html b/_get_config.html
index 119a20b..671a20e 100644
--- a/_get_config.html
+++ b/_get_config.html
@@ -16,7 +16,7 @@
{{:assign var="nature" from="module.config.%s_nature"|args:$direction}}
{{if $nature != null}}
{{#foreach from=$nature item="elem"}}
- {{:assign var="item" label=$label type=$type}}
+ {{:assign var="item" label=$label type=$type fee=$fee}}
{{:assign var="config.%s_nature.%s"|args:$direction:$key value=$item}}
{{/foreach}}
{{else}}
diff --git a/_nav.html b/_nav.html
index 25db82c..8cd2262 100644
--- a/_nav.html
+++ b/_nav.html
@@ -15,6 +15,7 @@
+
+{{* lister les mouvements *}}
+{{:assign premier=true}}
+{{#select * FROM
+ (WITH
+ sorties AS
+ (SELECT
+ mvt.key,
+ json_extract(mvt.document, '$.date') AS date,
+ json_extract(mvt.document, '$.direction') AS direction,
+ json_extract(mvt.document, '$.operation') AS operation,
+ json_extract(mat.document, '$.name') AS materiel,
+ json_extract(mat.document, '$.category') AS category,
+ json_extract(mvt.document, '$.amount') AS amount,
+ users.id AS user_id,
+ users.nom AS user,
+ json_extract(storage.document, '$.name') AS stockage,
+ json_extract(mvt.document, '$.transactions') AS transactions,
+ json_extract(mvt.document, '$.comment') AS comment,
+ json_extract(mvt.document, '$.return_date') AS return_date
+ FROM !table AS mvt
+ INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
+ LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
+ LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
+ WHERE json_extract(mvt.document, '$.type') = 'movement'
+ AND json_extract(mvt.document, '$.operation') IN !op
+ AND !cat_condition
+ ),
+ entrees AS
+ (SELECT
+ mvt.key,
+ json_extract(mvt.document, '$.date') AS date,
+ json_extract(mvt.document, '$.direction') AS direction,
+ json_extract(mvt.document, '$.operation') AS operation,
+ json_extract(mat.document, '$.name') AS materiel,
+ json_extract(mat.document, '$.category') AS category,
+ json_extract(mvt.document, '$.amount') AS amount,
+ users.id AS user_id,
+ users.nom AS user,
+ json_extract(storage.document, '$.name') AS stockage,
+ json_extract(mvt.document, '$.transactions') AS transactions,
+ json_extract(mvt.document, '$.comment') AS comment,
+ json_extract(mvt.document, '$.return_date') AS return_date
+ FROM !table AS mvt
+ INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
+ LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
+ LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
+ INNER JOIN (
+ SELECT json_extract(links.document, '$.return') AS return_key
+ FROM !table AS links
+ INNER JOIN sorties ON json_extract(links.document, '$.temp_key') = sorties.key
+ ) AS filtered_links ON filtered_links.return_key = mvt.key
+ WHERE !cat_condition
+ )
+ SELECT * FROM sorties UNION SELECT * FROM entrees
+ )
+ ORDER BY date
+ ;
+ !table=$module.table
+ !op = $out_keys
+ !cat_condition=$cat_condition
+}}
+ {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
+ {{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
+ {{:assign file_path=$file_path|cat:"%"}}
+ {{#select count(*) AS nb FROM files WHERE path LIKE :file_path ; :file_path=$file_path}}
+ {{:assign nb_files=$nb}}
+ {{/select}}
+
+ {{if $premier}}
+
{{: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}}
{{: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}}
{{* lister les mouvements *}}
@@ -88,12 +134,9 @@
INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
- WHERE
- json_extract(mvt.document, '$.type') = 'movement'
- AND
- json_extract(mvt.document, '$.operation') IN !op
- AND
- !cat_condition
+ WHERE json_extract(mvt.document, '$.type') = 'movement'
+ AND json_extract(mvt.document, '$.operation') IN !op
+ AND !cat_condition
),
entrees AS
(SELECT
@@ -123,12 +166,11 @@
)
SELECT * FROM sorties UNION SELECT * FROM entrees
)
- ORDER BY date
+ ORDER BY date DESC, user
;
!table=$module.table
!op = $out_keys
!cat_condition=$cat_condition
- assign="mvts."
}}
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
{{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
@@ -150,7 +192,7 @@
-
-{{:assign premier=true}}
-{{#select
- users.nom AS nom,
- users.id AS user,
- mvt.key AS mvt_key,
- json_extract(mat.document, '$.name') AS mat_name,
- json_extract(mvt.document, '$.date') AS out_date,
- 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 !table AS mvt
- LEFT JOIN users ON json_extract(mvt.document, '$.user') = users.id
- 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
- ;
- !table=$module.table
- !op = $out_keys
- !cat_condition=$cat_condition
-}}
- {{if $premier}}
-
-
-{{* lister les mouvements *}}
-{{:assign premier=true}}
-{{#select * FROM
- (WITH
- sorties AS
- (SELECT
- mvt.key,
- json_extract(mvt.document, '$.date') AS date,
- json_extract(mvt.document, '$.direction') AS direction,
- json_extract(mvt.document, '$.operation') AS operation,
- json_extract(mat.document, '$.name') AS materiel,
- json_extract(mat.document, '$.category') AS category,
- json_extract(mvt.document, '$.amount') AS amount,
- users.id AS user_id,
- users.nom AS user,
- json_extract(storage.document, '$.name') AS stockage,
- json_extract(mvt.document, '$.transactions') AS transactions,
- json_extract(mvt.document, '$.comment') AS comment,
- json_extract(mvt.document, '$.return_date') AS return_date
- FROM !table AS mvt
- INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
- LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
- LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
- WHERE json_extract(mvt.document, '$.type') = 'movement'
- AND json_extract(mvt.document, '$.operation') IN !op
- AND !cat_condition
- ),
- entrees AS
- (SELECT
- mvt.key,
- json_extract(mvt.document, '$.date') AS date,
- json_extract(mvt.document, '$.direction') AS direction,
- json_extract(mvt.document, '$.operation') AS operation,
- json_extract(mat.document, '$.name') AS materiel,
- json_extract(mat.document, '$.category') AS category,
- json_extract(mvt.document, '$.amount') AS amount,
- users.id AS user_id,
- users.nom AS user,
- json_extract(storage.document, '$.name') AS stockage,
- json_extract(mvt.document, '$.transactions') AS transactions,
- json_extract(mvt.document, '$.comment') AS comment,
- json_extract(mvt.document, '$.return_date') AS return_date
- FROM !table AS mvt
- INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
- LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
- LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
- INNER JOIN (
- SELECT json_extract(links.document, '$.return') AS return_key
- FROM !table AS links
- INNER JOIN sorties ON json_extract(links.document, '$.temp_key') = sorties.key
- ) AS filtered_links ON filtered_links.return_key = mvt.key
- WHERE !cat_condition
- )
- SELECT * FROM sorties UNION SELECT * FROM entrees
- )
- ORDER BY date
- ;
- !table=$module.table
- !op = $out_keys
- !cat_condition=$cat_condition
-}}
- {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
- {{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
- {{:assign file_path=$file_path|cat:"%"}}
- {{#select count(*) AS nb FROM files WHERE path LIKE :file_path ; :file_path=$file_path}}
- {{:assign nb_files=$nb}}
- {{/select}}
-
- {{if $premier}}
-