From e2c8ac2d8440ecb9e19eeb9d97b36f6cf618ce52 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Fri, 16 Jan 2026 12:14:09 +0100 Subject: [PATCH 01/10] =?UTF-8?q?D=C3=A9but=20r=C3=A9organisation=20naviga?= =?UTF-8?q?tion=20;=20inventaire=20:=20ajout=20filtre=20selon=20appartenan?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _inventory.html | 97 +++++++++++++++++++++++++++++++++++++++---------- _nav.html | 7 ++-- index.html | 18 ++------- 3 files changed, 84 insertions(+), 38 deletions(-) diff --git a/_inventory.html b/_inventory.html index b74bdbb..752e5f1 100644 --- a/_inventory.html +++ b/_inventory.html @@ -1,18 +1,59 @@ {{* -*- brindille -*- *}} {{* - inventaire des entrées/sorties des matériels permanents + Inventaire des matériels en stock dans l'association *}} -{{* Sélecteur catégories *}} -{{:assign var="options." value="" label="Toutes les catégories" href="?prop=1"}} +{{* 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}} + +{{* filtrer selon appartenance *}} +{{if $_GET.prop == null}} + {{:assign selected_prop=$module.config.stock_prop}} +{{elseif $_GET.prop == -1}} + {{:assign selected_prop=null}} + {{:save key="config" stock_prop=null}} +{{else}} + {{:assign selected_prop=$_GET.prop}} + {{:save key="config" stock_prop=$_GET.prop}} +{{/if}} + +{{if $selected_prop == null}} + {{:assign prop_condition="1"}} +{{elseif $selected_prop == 1}} + {{:assign prop_condition="$$.stock NOT NULL"}} +{{else}} + {{:assign prop_condition="$$.notowned != 0"}} +{{/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&prop=1"|args:$key + href="?cat_key=%s"|args:$key }} {{/load}} @@ -20,23 +61,28 @@ Filtrer par catégorie {{:dropdown title="Filtrer par catégorie" - options=$options - value="%s"|args:$_GET.cat_key + options=$cat_options + value="%s"|args:$selected_category + }} + + +{{: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"}} + +
+ Filtrer par appartenance + {{:dropdown + title="Filtrer par appartenance" + options=$prop_options + value="%s"|args:$selected_prop }}
-

Inventaire des matériels propriété de l'association

+

Inventaire des matériels présents dans 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' ; @@ -44,22 +90,32 @@ FROM @TABLE as cat WHERE cat.key = @TABLE.$$.category) AS 'Catégorie' ; $$.stock AS 'Stock' ; + (SELECT COALESCE($$.notowned, 0)) AS 'Temp' ; + (SELECT $$.stock + COALESCE($$.notowned, 0)) AS 'Total' ; $$.out AS 'Sorti' ; (SELECT $$.stock - $$.out) AS 'Disponible' " type="equipment" - where="$$.status <> 'archived' AND $$.stock NOT NULL AND %s"|args:$condition + where="$$.status <> 'archived' AND %s AND %s"|args:$cat_condition:$prop_condition order=1 }} {{:assign var=cat_name from=categories.%s|args:$category}} - {{:link href="equipment_history.html?key=%s&prop=1"|args:$key" label=$name}} + {{if $selected_prop == null}} + {{:assign prop=""}} + {{else}} + {{:assign prop="&prop=%s"|args:$selected_prop}} + {{/if}} + {{:link href="equipment_history.html?key=%s&prop=%s"|args:$key:$selected_prop" label=$name}} {{$cat_name}} {{$stock}} + {{$col4}} + {{$col5}} {{$out}} - {{$col5}} + {{$col7}} - {{if $col5 > 0}} +{{* + {{if $col7 > 0}} {{:linkbutton label="Sortie" shape="minus" @@ -71,6 +127,7 @@ shape="plus" href="movements/input_equipment.html?key=%s"|args:$key target="_dialog"}} +*}} {{:linkbutton label="Historique" href="equipment_history.html?key=%s&prop=1"|args:$key diff --git a/_nav.html b/_nav.html index 8ea688e..5c81e1a 100644 --- a/_nav.html +++ b/_nav.html @@ -12,16 +12,15 @@ {{/if}} {{if $current == 'inventaire'}} {{if $subsubcurrent == 'historique'}} diff --git a/index.html b/index.html index dce00cb..740bf3b 100644 --- a/index.html +++ b/index.html @@ -14,15 +14,6 @@ {{else}} {{#restrict block=true section="accounting" level="write"}}{{/restrict}} - {{if $_GET.prop == null || $_GET.prop}} - {{:assign proprio="proprio"}} - {{else}} - {{:assign proprio="nonproprio"}} - {{/if}} - - {{#load type="category" count=true assign="result"}}{{/load}} - {{:include file="_nav.html" current="inventaire" cat="%d"|args:$result.count subcurrent="%s"|args:$proprio}} - {{if $_GET.ok}} {{if $_GET.msg == "ajout" }}

Ajout effectué

@@ -37,14 +28,13 @@

Modification refusée

{{/if}} + {{#load type="category" count=true limit=1 assign="result"}}{{/load}} + {{:include file="_nav.html" current="inventaire" cat="%d"|args:$result.count subcurrent="stock"}} + {{if $result.count == 0}}

Il n'y a aucune catégorie : vous devez en ajouter.

{{else}} - {{if $_GET.prop == null || $_GET.prop == "1"}} - {{:include file="./_inventory.html"}} - {{else}} - {{:include file="./_temp_inventory.html"}} - {{/if}} + {{:include file="./_inventory.html"}} {{/if}} {{:admin_footer}} From 2f3785831e44515f132b37634983250c47d5ebf9 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Tue, 20 Jan 2026 09:57:58 +0100 Subject: [PATCH 02/10] =?UTF-8?q?global=5Fhistory=20:=20am=C3=A9lioration?= =?UTF-8?q?=20filtre=20cat=C3=A9gorie=20;=20ajout=20filtre=20appartenance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- global_history.html | 116 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 97 insertions(+), 19 deletions(-) diff --git a/global_history.html b/global_history.html index 81e576b..b741958 100644 --- a/global_history.html +++ b/global_history.html @@ -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 @@ Filtrer par catégorie {{:dropdown title="Filtrer par catégorie" - options=$options - value="%s"|args:$_GET.cat_key + options=$cat_options + value="%s"|args:$selected_category + }} + + +{{: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"}} + +
+ Filtrer par appartenance + {{:dropdown + title="Filtrer par appartenance" + options=$prop_options + value="%s"|args:$selected_prop }}
@@ -38,18 +127,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 +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 From 05b2b9b25216fa8a38febcd45023fa6ef2e49612 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Thu, 22 Jan 2026 11:53:15 +0100 Subject: [PATCH 03/10] equipment_history : ajout filtrage par appartenance --- equipment_history.html | 383 ++++++++++++++++++++++------------------- 1 file changed, 203 insertions(+), 180 deletions(-) diff --git a/equipment_history.html b/equipment_history.html index 786adbe..36283b9 100644 --- a/equipment_history.html +++ b/equipment_history.html @@ -12,14 +12,6 @@ - msg : message de retour *}} - -{{* barre de navigation *}} -{{if $_GET.prop == 1}} - {{:assign proprio="proprio"}} -{{else}} - {{:assign proprio="nonproprio"}} -{{/if}} - {{:assign equipment_key=$_GET.key|trim}} {{#load key=$equipment_key assign="equipment"}} {{else}} @@ -33,12 +25,13 @@ {{:admin_header title="Gestion des matériels" custom_css="./style.css" current="module_equipment"}} +{{* barre de navigation *}} {{if $_GET.current != null}} {{:assign current=$_GET.current}} {{else}} {{:assign current="inventaire"}} {{/if}} -{{:include file="./_nav.html" current=$current subcurrent=$proprio subsubcurrent="historique" eqpmt=$equipment.name category=$category.name}} +{{:include file="./_nav.html" current=$current subcurrent="stock" subsubcurrent="historique" eqpmt=$equipment.name category=$category.name}} {{if $_GET.ok}} {{if $_GET.msg == "modification"}} @@ -61,34 +54,69 @@ {{* récupérer la config des entrées/sorties *}} {{:include file="./_get_config.html" keep="config"}} -{{* déterminer les types de mouvements selon l'affection du matériel *}} -{{#foreach from=$config.input_nature}} - {{if $_GET.prop}} +{{* filtrer selon appartenance *}} +{{if $_GET.prop == null}} + {{:assign selected_prop=$module.config.eqpmt_hist_prop}} +{{elseif $_GET.prop == -1}} + {{:assign selected_prop=null}} + {{:save key="config" eqpmt_hist_prop=null}} +{{else}} + {{:assign selected_prop=$_GET.prop}} + {{:save key="config" eqpmt_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}} + {{if $type == 'temporaire'}} + {{:assign var="temp_inputs." value=$key|quote_sql}} + {{/if}} + {{elseif $selected_prop == 1}} {{* matériel propriété de l'asso *}} {{if $type != 'temporaire'}} - {{:assign var="input_types." value=$label}} + {{:assign var="mvt_keys." value=$key|quote_sql}} {{/if}} {{else}} {{* matériel non propriété de l'asso *}} {{if $type == 'temporaire'}} - {{:assign var="input_types." value=$label}} + {{:assign var="mvt_keys." value=$key|quote_sql}} + {{:assign var="temp_inputs." value=$key|quote_sql}} {{/if}} {{/if}} {{/foreach}} -{{#foreach from=$config.output_nature}} - {{if $_GET.prop}} +{{#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}} + {{if $type == "temporaire"}} + {{:assign var="temp_outputs." value=$key|quote_sql}} + {{/if}} + {{elseif $selected_prop == 1}} {{* matériel propriété de l'asso *}} {{if $type != 'retour'}} - {{:assign var="output_types." value=$label}} + {{:assign var="mvt_keys." value=$key|quote_sql}} + {{if $type == "temporaire"}} + {{:assign var="temp_outputs." value=$key|quote_sql}} + {{/if}} {{/if}} {{else}} {{* matériel non propriété de l'asso *}} {{if $type == 'retour'}} - {{:assign var="output_types." value=$label}} + {{: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}} {{* calculer et mémoriser les quantités pour que le tri de la liste affiche les valeurs correctes *}} {{:assign stock=0}} @@ -122,27 +150,10 @@ {{:assign var="quantites.%s.nonproprio"|args:$id value=$nonproprio}} {{/load}} -{{if $current != "archives"}} - -{{/if}} - -{{* lister tous les mouvements du matériel passé en paramètre *}} -{{if $_GET.prop}} - {{* calculer la quantité temporairement l'extérieur de chaque matériel *}} - {{#foreach from=$config.output_nature key=key}} - {{if $type == "temporaire"}} - {{:assign var="temp_outputs." value=$key|quote_sql}} - {{/if}} - {{/foreach}} - {{:assign operations=$temp_outputs|implode:","}} - {{:assign operations="("|cat:$operations|cat:")"}} +{{if $selected_prop == null || $selected_prop}} + {{* calculer la quantité sortie temporairement de chaque matériel *}} + {{:assign output_ops=$temp_outputs|implode:","}} + {{:assign output_ops="("|cat:$output_ops|cat:")"}} {{#select mvt.key AS mvt_key, @@ -155,97 +166,17 @@ AND json_extract(mvt.document, '$.equipment') = :eqpmt_key GROUP by mvt.key ; - !op = $operations + !op = $output_ops :eqpmt_key = $_GET.key }} {{:assign var="reste.%s"|args:$mvt_key value=$reste}} {{/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 'Stock'; - '' AS 'Sorti'; - '' AS 'Disponible'; - 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'; - '' AS 'Documents'; - $$.transactions AS 'Écritures' - "|args:$config.user_fields.name_sql - equipment=$equipment_key - order=1 - }} - {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}} - {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} - - {{if $direction === "input" && $op_label|in:$input_types || - $direction === "output"&& $op_label|in:$output_types - }} - {{:assign var="stock" from="quantites.%s.stock"|args:$id}} - {{:assign var="exterieur" from="quantites.%s.exterieur"|args:$id}} - {{:assign var="dispo" from="quantites.%s.dispo"|args:$id}} - - {{: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}} - - {{$date|date_short}} - {{$col2}} - {{$op_label}} - {{$amount}} - {{$stock}} - {{$exterieur}} - {{$dispo}} - {{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$col8}} - {{$col9}} - {{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}} - {{if $transactions|count > 0}}{{:icon shape="money"}}{{/if}} - - {{if $current != "archives"}} - {{if $direction == "output" && $type_mvt == "temporaire"}} - {{:assign var="temp_ext" from="reste.%s"|args:$key}} - {{if $temp_ext != null && $temp_ext > 0}} - {{:linkbutton - label="Retour" - href="movements/output_return.html?key=%s&prop=%s"|args:$key:$_GET.prop - shape="reset" - target="_dialog"}} - {{/if}} - {{/if}} - {{:linkbutton - label="Détails" - href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$_GET.prop - shape="eye" - }} - {{/if}} - - - {{/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}} + +
+ Filtrer par appartenance + {{:dropdown + title="Filtrer par appartenance" + options=$prop_options + value="%s"|args:$selected_prop }} - {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$col3}} - {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} +
- {{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}} - - {{$date|date_short}} - {{$col2}} - {{$op_label}} - {{$amount}} - {{$stock}} - {{$col6}} - {{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}} - {{if $transactions|count > 0}}{{:icon shape="money"}}{{/if}} - - {{if $direction == "input" && $type_mvt == "temporaire"}} - {{:assign var="temp_in" from="present.%s"|args:$key}} - {{if $temp_in != null && $temp_in > 0}} - {{:linkbutton - label="Retour" - href="movements/input_return.html?key=%s&prop=%s"|args:$key:$_GET.prop - shape="reset" - target="_dialog"}} - {{/if}} - {{/if}} - {{:linkbutton - label="Détails" - href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$_GET.prop - shape="eye" - }} - - +{{* lister les mouvements du matériel passé en paramètre *}} +{{#list + type="movement" + select="%s"|args:$select_clause + where="%s"|args:$prop_condition + equipment=$equipment_key + order=1 +}} + {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}} + {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} + + {{:assign var="stock" from="quantites.%s.stock"|args:$id}} + {{:assign var="exterieur" from="quantites.%s.exterieur"|args:$id}} + {{:assign var="dispo" from="quantites.%s.dispo"|args:$id}} + {{:assign var="tempo" from="quantites.%s.nonproprio"|args:$id}} + + {{: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 $selected_prop == null}} + {{:assign user_details=$col9}} + {{:assign storage=$col10}} + {{elseif $selected_prop}} + {{:assign user_details=$col8}} + {{:assign storage=$col9}} + {{else}} + {{:assign user_details=$col6}} + {{:assign storage=$col6}} + {{/if}} + + + {{$date|date_short}} + {{$col2}} + {{$op_label}} + {{$amount}} + {{if $selected_prop == null || $selected_prop}} + {{$stock}} + {{$exterieur}} + {{$dispo}} {{/if}} - {{/list}} + {{if $selected_prop == null || ! $selected_prop}} + {{$tempo}} + {{/if}} + {{if $selected_prop == null || $selected_prop}} + {{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$user_details}} + {{/if}} + {{$storage}} + {{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}} + {{if $transactions|count > 0}}{{:icon shape="money"}}{{/if}} + + {{if $current != "archives"}} + {{if $direction == "output" && $type_mvt == "temporaire"}} + {{:assign var="temp_ext" from="reste.%s"|args:$key}} + {{if $temp_ext != null && $temp_ext > 0}} + {{:linkbutton + label="Retour" + href="movements/output_return.html?key=%s&prop=%s"|args:$key:$selected_prop + shape="reset" + target="_dialog"}} + {{/if}} + {{/if}} + {{if $direction == "input" && $type_mvt == "temporaire"}} + {{:assign var="temp_in" from="present.%s"|args:$key}} + {{if $temp_in != null && $temp_in > 0}} + {{:linkbutton + label="Retour" + href="movements/input_return.html?key=%s&prop=%s"|args:$key:$selected_prop + shape="reset" + target="_dialog"}} + {{/if}} + {{/if}} + {{:linkbutton + label="Détails" + href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$selected_prop + shape="eye" + }} + {{/if}} + + +{{/list}} + +{{if $dispo_final == 0 && $stock > 0 && $current != "archives"}} + Il n'y a aucun matériel disponible, il n'est donc pas possible d'effectuer une sortie {{/if}} {{:admin_footer}} From 59b13e6e4c476c3766b42d7b1f46f941b47c7a84 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Fri, 23 Jan 2026 10:14:26 +0100 Subject: [PATCH 04/10] =?UTF-8?q?archives=20:=20am=C3=A9lioration=20filtre?= =?UTF-8?q?=20cat=C3=A9gorie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archives.html | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/archives.html b/archives.html index 261673c..efb1a22 100644 --- a/archives.html +++ b/archives.html @@ -9,11 +9,30 @@

Matériel remis en service

{{/if}} +{{* filtrer selon la catégorie *}} +{{if $_GET.cat_key == null}} + {{:assign selected_category=$module.config.archive_cat_key}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" archive_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:save key="config" archive_cat_key=$selected_category}} +{{/if}} + +{{* condition de filtrage *}} +{{if $selected_category == null}} + {{:assign cat_condition="1"}} +{{else}} + {{:assign cat_key=$selected_category|quote_sql}} + {{:assign cat_condition="$$.category == %s"|args:$cat_key}} +{{/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"}} {{#load type="category" order="$$.name"}} {{:assign - var="options." + var="cat_options." value=$key label=$name href="?cat_key=%s"|args:$key @@ -24,8 +43,8 @@ Filtrer par catégorie {{:dropdown title="Filtrer par catégorie" - options=$options - value="%s"|args:$_GET.cat_key + options=$cat_options + value="%s"|args:$selected_category }} @@ -33,14 +52,6 @@

Matériels qui ne sont plus dans 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}} - {{* Liste des matériels archivés *}} {{#list select=" @@ -50,7 +61,7 @@ WHERE cat.key = @TABLE.$$.category) AS "Catégorie" " type="equipment" - where="$$.status='archived' AND %s"|args:$condition + where="$$.status='archived' AND %s"|args:$cat_condition order=1 }} From 84b35adcfaa49d14c8c8c0184f78eb12ad8cb5ff Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Fri, 23 Jan 2026 10:20:45 +0100 Subject: [PATCH 05/10] =?UTF-8?q?R=C3=A9organisation=20navigation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _inventory.html | 5 +---- _nav.html | 15 ++++++--------- equipment_history.html | 2 +- global_history.html | 2 +- loan_history.html | 4 ++-- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/_inventory.html b/_inventory.html index 752e5f1..53e9566 100644 --- a/_inventory.html +++ b/_inventory.html @@ -7,20 +7,17 @@ {{* 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_key=$selected_category|quote_sql}} {{:assign cat_condition="$$.category = %s"|args:$cat_key}} {{else}} {{:assign cat_condition="1"}} diff --git a/_nav.html b/_nav.html index 5c81e1a..25db82c 100644 --- a/_nav.html +++ b/_nav.html @@ -13,25 +13,22 @@ {{if $current == 'inventaire'}} - - - {{if $subsubcurrent == 'historique'}} + {{if $subcurrent == 'historique'}}
  • Historique — {{$eqpmt}} ({{$category}})
{{/if}} - {{elseif $current == 'historique'}} + {{elseif $current == 'prêts'}} {{elseif $current == 'archives'}} {{if $subsubcurrent == 'historique'}} diff --git a/equipment_history.html b/equipment_history.html index 36283b9..e39d1e4 100644 --- a/equipment_history.html +++ b/equipment_history.html @@ -31,7 +31,7 @@ {{else}} {{:assign current="inventaire"}} {{/if}} -{{:include file="./_nav.html" current=$current subcurrent="stock" subsubcurrent="historique" eqpmt=$equipment.name category=$category.name}} +{{:include file="./_nav.html" current=$current subcurrent="historique" eqpmt=$equipment.name category=$category.name}} {{if $_GET.ok}} {{if $_GET.msg == "modification"}} diff --git a/global_history.html b/global_history.html index b741958..a3210ea 100644 --- a/global_history.html +++ b/global_history.html @@ -8,7 +8,7 @@ {{:admin_header title="Historique des mouvements" custom_css="./style.css" current="module_equipment"}} -{{:include file="./_nav.html" current="inventaire" subcurrent="historique"}} +{{:include file="./_nav.html" current="historique"}} {{* récupérer la config des entrées/sorties *}} {{:include file="./_get_config.html" keep="config"}} diff --git a/loan_history.html b/loan_history.html index 997ffa4..0442354 100644 --- a/loan_history.html +++ b/loan_history.html @@ -3,7 +3,7 @@ {{#restrict block=true section="accounting" level="write"}}{{/restrict}} {{:admin_header title="Matériels hors de l'asso" custom_css="../style.css" current="module_equipment"}} -{{:include file="./_nav.html" current="historique" subcurrent="prêts"}} +{{:include file="./_nav.html" current="prêts" subcurrent="encours"}} {{* vérifier l'existence de la table du module @@ -32,7 +32,7 @@ {{/if}}
-

Historique des prêts de matériel

+

Prêts de matériel en cours

{{* lecture config (défaut ou enregistrée) *}} From 1b1680af5c8ecdead3b0f7c883d638169ec75694 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Fri, 23 Jan 2026 10:21:15 +0100 Subject: [PATCH 06/10] =?UTF-8?q?Ajout=20historique=20des=20mouvements=20d?= =?UTF-8?q?e=20pr=C3=AAts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loan_movements.html | 130 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 loan_movements.html diff --git a/loan_movements.html b/loan_movements.html new file mode 100644 index 0000000..e23e8d1 --- /dev/null +++ b/loan_movements.html @@ -0,0 +1,130 @@ +{{* -*- brindille -*- *}} + +{{#restrict block=true section="accounting" level="write"}}{{/restrict}} + +{{* + Afficher l'historique des prêts +*}} + +{{:admin_header title="Historique des prêts" custom_css="./style.css" current="module_equipment"}} + +{{:include file="./_nav.html" current="prêts" subcurrent="historique"}} + +{{* 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.loan_cat_key}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" loan_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:save key="config" loan_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}} + +{{* déterminer les types de mouvements *}} +{{#foreach from=$config.input_nature key="key"}} + {{if $type == 'retour'}} + {{:assign var="mvt_keys." value=$key|quote_sql}} + {{/if}} +{{/foreach}} + +{{#foreach from=$config.output_nature key="key"}} + {{if $type == 'temporaire'}} + {{:assign var="mvt_keys." value=$key|quote_sql}} + {{/if}} +{{/foreach}} +{{:assign key_cond=$mvt_keys|implode:","}} +{{:assign key_cond="("|cat:$key_cond|cat:")"}} +{{:assign key_cond="$$.operation IN %s"|args:$key_cond}} + +{{* 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="categories.%s"|args:$key value=$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 + }} +
+ +
+

Historique des prêts

+
+ +{{* 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}} + + {{$date|date_short}} + {{$col2}} + {{$op_label}} + {{$col4}} + {{$amount}} + {{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$col6}} + {{$col7}} + {{$comment}} + + +{{else}} +

Aucun mouvement.

+{{/list}} +{{* *}} +{{:admin_footer}} + + + From b14463ecf288bbf36154460ec885f956ee597b0c Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Tue, 27 Jan 2026 17:17:54 +0100 Subject: [PATCH 07/10] =?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 08/10] =?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 @@
  • Inventaire
  • Historique
  • Prêts
  • +
  • Locations
  • Archives
  • Configuration
  • @@ -30,6 +31,11 @@
  • En cours
  • Historique
  • + {{elseif $current == 'location'}} + {{elseif $current == 'archives'}} {{if $subsubcurrent == 'historique'}}
      @@ -54,7 +60,9 @@ {{/if}} diff --git a/loan_history.html b/loan_history.html index 879ef55..1fb0985 100644 --- a/loan_history.html +++ b/loan_history.html @@ -2,7 +2,7 @@ {{#restrict block=true section="accounting" level="write"}}{{/restrict}} -{{:admin_header title="Matériels hors de l'asso" custom_css="../style.css" current="module_equipment"}} +{{:admin_header title="Prêts en cours" custom_css="../style.css" current="module_equipment"}} {{:include file="./_nav.html" current="prêts" subcurrent="encours"}} {{* diff --git a/loan_movements.html b/loan_movements.html index e23e8d1..4425b03 100644 --- a/loan_movements.html +++ b/loan_movements.html @@ -26,35 +26,24 @@ {{* 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}} + {{:assign cat_key=$selected_category|quote_sql}} + {{:assign cat_condition="category = %s"|args:$cat_key}} {{else}} {{:assign cat_condition=1}} {{/if}} {{* déterminer les types de mouvements *}} -{{#foreach from=$config.input_nature key="key"}} - {{if $type == 'retour'}} - {{:assign var="mvt_keys." value=$key|quote_sql}} - {{/if}} -{{/foreach}} - {{#foreach from=$config.output_nature key="key"}} - {{if $type == 'temporaire'}} - {{:assign var="mvt_keys." value=$key|quote_sql}} + {{if $type == 'temporaire' && $fee != 'payant'}} + {{:assign var="out_keys." value=$key|quote_sql}} {{/if}} {{/foreach}} -{{:assign key_cond=$mvt_keys|implode:","}} -{{:assign key_cond="("|cat:$key_cond|cat:")"}} -{{:assign key_cond="$$.operation IN %s"|args:$key_cond}} +{{: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="categories.%s"|args:$key value=$name*}} {{:assign var="cat_options." value=$key @@ -77,54 +66,120 @@ {{* 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 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="mvts." }} {{: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=false}} + {{/if}} + - - - + + + - - + + + + - + {{else}}

      Aucun mouvement.

      -{{/list}} -{{* *}} +{{/select}} + +
      DateMouvementOpérationMatérielQuantitéDépositaireStockageDocumentsÉcrituresRemarques
      {{$date|date_short}}{{$col2}}{{$op_label}}{{$col4}}{{if $direction == "input"}}Entrée{{else}}Sortie{{/if}}{{$op_label}}{{$materiel}} {{$amount}}{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$col6}}{{$col7}}{{:link href="/admin/users/details.php?id=%s"|args:$user_id label="%s"|args:$user}}{{$stockage}}{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}{{if $transactions != null}}{{:icon shape="money"}}{{/if}} {{$comment}} + {{:linkbutton + label="Détails" + href="movements/movement_details.html?key=%s"|args:$key + shape="eye" + }} +
      {{:admin_footer}} - - - diff --git a/rent_history.html b/rent_history.html new file mode 100644 index 0000000..ac4e5a1 --- /dev/null +++ b/rent_history.html @@ -0,0 +1,140 @@ +{{* -*- brindille -*- *}} + +{{#restrict block=true section="accounting" level="write"}}{{/restrict}} + +{{:admin_header title="Locations en cours" custom_css="../style.css" current="module_equipment"}} +{{:include file="./_nav.html" current="location" subcurrent="encours"}} + +{{* + vérifier l'existence de la table du module + eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans +*}} + +{{#load limit="1"}} + {{:assign table_presente=true}} +{{else}} + {{:assign table_presente=false}} +{{/load}} + +{{if $table_presente}} +{{if $_GET.ok}} + {{if $_GET.msg == "modification"}} +

      Modification enregistrée

      + {{elseif $_GET.msg == "copie"}} +

      Mouvement copié

      + {{elseif $_GET.msg == "suppression"}} +

      Mouvement supprimé

      + {{/if}} +{{elseif $_GET.err}} + {{if $_GET.msg == "suppression"}} +

      Ce mouvement ne peut être supprimé

      + {{/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"}} + {{if $type == 'temporaire' && $fee == 'payant'}} + {{:assign var="output_types." value=$key|quote_sql}} + {{/if}} +{{/foreach}} +{{:assign output_ops=$output_types|implode:","}} +{{:assign output_ops="("|cat:$output_ops|cat:")"}} + +{{: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 {!$module.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 + GROUP BY mvt.key + HAVING remain != 0 + ORDER BY out_date, nom + ; + !op = $output_ops +}} + {{if $premier}} + + + + + + + + + + + + + + + {{:assign premier=false}} + {{/if}} + + {{if $return_date != null}} + {{:assign ts_retour=$return_date|strtotime}} + {{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}} + {{/if}} + + + + + + + + + + +{{else}} +

      Aucun mouvement.

      +{{/select}} + +
      MatérielDate prêtQuantitéMembreDate retourReste à rendreRemarque
      {{$mat_name}}{{$out_date|date_short}}{{$out_amount}}{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$nom}}{{$return_date|date_short}}{{$remain}} + {{if $return_date != null}} + {{:assign jour="jour}} + {{if $nb_jours > 0}} + {{if $nb_jours > 1}}{{:assign jour="jours"}}{{/if}} + {{:tag color="darkred" label="Retard %s %s"|args:$nb_jours:$jour}} + {{elseif $nb_jours < 0}} + {{:assign delai="abs(%d)"|math:$nb_jours}} + {{if $nb_jours < -1}}{{:assign jour="jours"}}{{/if}} + {{"Reste %s %s"|args:$delai:$jour}} + {{else}} + {{:tag color="darkgreen" label="À rendre aujourd'hui"}} + {{/if}} + {{/if}} + + {{:linkbutton + label="Retour" + href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key + shape="reset" + target="_dialog"}} + {{:linkbutton + label="Détails" + href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key + shape="eye" + }} +
      +{{else}} +

      Aucun mouvement.

      +{{/if}} + +{{:admin_footer}} diff --git a/rent_movements.html b/rent_movements.html new file mode 100644 index 0000000..424e2ed --- /dev/null +++ b/rent_movements.html @@ -0,0 +1,181 @@ +{{* -*- brindille -*- *}} + +{{#restrict block=true section="accounting" level="write"}}{{/restrict}} + +{{* + Afficher l'historique des locations +*}} + +{{:admin_header title="Historique des locations" custom_css="./style.css" current="module_equipment"}} + +{{:include file="./_nav.html" current="location" subcurrent="historique"}} + +{{* 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.rent_cat_key}} +{{elseif $_GET.cat_key == -1}} + {{:assign selected_category=null}} + {{:save key="config" rent_cat_key=null}} +{{else}} + {{:assign selected_category=$_GET.cat_key}} + {{:save key="config" rent_cat_key=$selected_category}} +{{/if}} + +{{* condition de filtrage *}} +{{if $selected_category != null}} + {{:assign cat_key=$selected_category|quote_sql}} + {{:assign cat_condition="category = %s"|args:$cat_key}} +{{else}} + {{:assign cat_condition=1}} +{{/if}} + +{{* déterminer les types de mouvements *}} +{{#foreach from=$config.output_nature key="key"}} + {{if $type == 'temporaire' && $fee == 'payant'}} + {{:assign var="out_keys." value=$key|quote_sql}} + {{/if}} +{{/foreach}} +{{: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 + }} +
      + +
      +

      Historique des locations

      +
      + +{{* 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=false}} + {{/if}} + + + + + + + + + + + + + + +{{else}} +

      Aucun mouvement.

      +{{/select}} + +
      DateMouvementOpérationMatérielQuantitéDépositaireStockageDocumentsÉcrituresRemarques
      {{$date|date_short}}{{if $direction == "input"}}Entrée{{else}}Sortie{{/if}}{{$op_label}}{{$materiel}}{{$amount}}{{:link href="/admin/users/details.php?id=%s"|args:$user_id label="%s"|args:$user}}{{$stockage}}{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}{{if $transactions != null}}{{:icon shape="money"}}{{/if}}{{$comment}} + {{:linkbutton + label="Détails" + href="movements/movement_details.html?key=%s"|args:$key + shape="eye" + }} +
      +{{:admin_footer}} From 974f87e5a4bd872fc8d184a2c401dba6cb96d910 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Wed, 28 Jan 2026 13:37:11 +0100 Subject: [PATCH 09/10] =?UTF-8?q?Ajout=20filtre=20par=20cat=C3=A9gorie=20L?= =?UTF-8?q?ocation=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
      From 546a9ea6777cf427a9d7fd4e6b6e4b5db0b93279 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Thu, 29 Jan 2026 13:48:48 +0100 Subject: [PATCH 10/10] =?UTF-8?q?Mutualisation=20onglets=20pr=C3=AAt=20et?= =?UTF-8?q?=20location?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _nav.html | 14 +-- global_history.html | 2 +- loan_history.html | 49 ++++++--- loan_movements.html | 92 ++++++++++++---- movements/copy_movement.html | 23 +++- movements/delete_movement.html | 32 ++++-- movements/modify_movement.html | 23 +++- movements/movement_details.html | 1 + rent_history.html | 180 ------------------------------- rent_movements.html | 181 -------------------------------- 10 files changed, 176 insertions(+), 421 deletions(-) delete mode 100644 rent_history.html delete mode 100644 rent_movements.html diff --git a/_nav.html b/_nav.html index 8cd2262..dfdf9ef 100644 --- a/_nav.html +++ b/_nav.html @@ -14,8 +14,8 @@ @@ -26,15 +26,15 @@
    • Historique — {{$eqpmt}} ({{$category}})
    • {{/if}} - {{elseif $current == 'prêts'}} + {{elseif $current == 'prêt'}} {{elseif $current == 'location'}} {{elseif $current == 'archives'}} {{if $subsubcurrent == 'historique'}} diff --git a/global_history.html b/global_history.html index a3210ea..6038924 100644 --- a/global_history.html +++ b/global_history.html @@ -145,7 +145,7 @@ THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage) ELSE '' END as 'Stockage'; - $$.comment AS 'Commentaire' + $$.comment AS 'Remarque' "|args:$config.user_fields.name_sql where="%s AND %s"|args:$cat_condition:$prop_condition order=1 diff --git a/loan_history.html b/loan_history.html index 3c413f2..f825528 100644 --- a/loan_history.html +++ b/loan_history.html @@ -2,14 +2,21 @@ {{#restrict block=true section="accounting" level="write"}}{{/restrict}} -{{:admin_header title="Prêts en cours" custom_css="../style.css" current="module_equipment"}} -{{:include file="./_nav.html" current="prêts" subcurrent="encours"}} +{{if $_GET.output_type == "loan"}} + {{:assign label="prêt"}} +{{elseif $_GET.output_type == "rent"}} + {{:assign label="location"}} +{{else}} + {{:error message="Cette page n'existe pas !"}} +{{/if}} + +{{:admin_header title="%ss en cours"|args:$label|ucfirst custom_css="../style.css" current="module_equipment"}} +{{:include file="./_nav.html" current="%s"|args:$label subcurrent="encours"}} {{* vérifier l'existence de la table du module eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans *}} - {{#load limit="1"}} {{:assign table_presente=true}} {{else}} @@ -36,13 +43,21 @@ {{* filtrer selon la catégorie *}} {{if $_GET.cat_key == null}} - {{:assign selected_category=$module.config.loan_hist_cat_key}} + {{:assign var="selected_category" from="module.config.%s_hist_cat_key"|args:$_GET.output_type}} {{elseif $_GET.cat_key == -1}} {{:assign selected_category=null}} - {{:save key="config" loan_hist_cat_key=null}} + {{if $_GET.output_type == "loan"}} + {{:save key="config" loan_hist_cat_key=null}} + {{elseif $_GET.output_type == "rent"}} + {{:save key="config" rent_hist_cat_key=null}} + {{/if}} {{else}} {{:assign selected_category=$_GET.cat_key}} - {{:save key="config" loan_hist_cat_key=$selected_category}} + {{if $_GET.output_type == "loan"}} + {{:save key="config" loan_hist_cat_key=$selected_category}} + {{elseif $_GET.output_type == "rent"}} + {{:save key="config" rent_hist_cat_key=$selected_category}} + {{/if}} {{/if}} {{* condition de filtrage *}} @@ -54,7 +69,12 @@ {{/if}} {{#foreach from=$config.output_nature key="key"}} - {{if $type == 'temporaire' && $fee != 'payant'}} + {{if $type != 'temporaire'}} + {{:continue}} + {{/if}} + {{if $_GET.output_type == "loan" && $fee != 'payant'}} + {{:assign var="out_keys." value=$key|quote_sql}} + {{elseif $_GET.output_type == "rent" && $fee == 'payant'}} {{:assign var="out_keys." value=$key|quote_sql}} {{/if}} {{/foreach}} @@ -62,13 +82,13 @@ {{: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"}} +{{:assign var="cat_options." value="" label="Toutes les catégories" href="?output_type=%s&cat_key=-1"|args:$_GET.output_type}} {{#load type="category" order="$$.name"}} {{:assign var="cat_options." value=$key label=$name - href="?cat_key=%s"|args:$key + href="?output_type=%s&cat_key=%s"|args:$_GET.output_type:$key }} {{/load}} @@ -82,7 +102,7 @@
      -

      Location de matériel en cours

      +

      {{$label|ucfirst}} de matériel en cours

      {{:assign premier=true}} @@ -105,7 +125,7 @@ AND !cat_condition GROUP BY mvt.key HAVING remain != 0 - ORDER BY out_date, nom + ORDER BY out_date DESC, nom ; !table=$module.table !op = $out_keys @@ -161,9 +181,14 @@ href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key shape="reset" target="_dialog"}} + {{if $_GET.output_type == "loan"}} + {{:assign from="lh"}} + {{elseif $_GET.output_type == "rent"}} + {{:assign from="rh"}} + {{/if}} {{:linkbutton label="Détails" - href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key + href="movements/movement_details.html?key=%s&prop=1&from=%s"|args:$mvt_key:$from shape="eye" }} diff --git a/loan_movements.html b/loan_movements.html index 4425b03..55d74f7 100644 --- a/loan_movements.html +++ b/loan_movements.html @@ -3,25 +3,66 @@ {{#restrict block=true section="accounting" level="write"}}{{/restrict}} {{* - Afficher l'historique des prêts + Afficher l'historique des prêts ou locations *}} -{{:admin_header title="Historique des prêts" custom_css="./style.css" current="module_equipment"}} +{{if $_GET.output_type == "loan"}} + {{:assign label="prêt"}} +{{elseif $_GET.output_type == "rent"}} + {{:assign label="location"}} +{{else}} + {{:error message="Cette page n'existe pas !"}} +{{/if}} -{{:include file="./_nav.html" current="prêts" subcurrent="historique"}} +{{:admin_header title="Historique des %ss"|args:$label custom_css="./style.css" current="module_equipment"}} + +{{:include file="./_nav.html" current="%s"|args:$label subcurrent="historique"}} + +{{* + vérifier l'existence de la table du module + eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans +*}} +{{#load limit="1"}} + {{:assign table_presente=true}} +{{else}} + {{:assign table_presente=false}} +{{/load}} + +{{if $table_presente}} +{{if $_GET.ok}} + {{if $_GET.msg == "modification"}} +

      Modification enregistrée

      + {{elseif $_GET.msg == "copie"}} +

      Mouvement copié

      + {{elseif $_GET.msg == "suppression"}} +

      Mouvement supprimé

      + {{/if}} +{{elseif $_GET.err}} + {{if $_GET.msg == "suppression"}} +

      Ce mouvement ne peut être supprimé

      + {{/if}} +{{/if}} {{* 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.loan_cat_key}} + {{:assign var="selected_category" from="module.config.%s_cat_key"|args:$_GET.output_type}} {{elseif $_GET.cat_key == -1}} {{:assign selected_category=null}} - {{:save key="config" loan_cat_key=null}} + {{if $_GET.output_type == "loan"}} + {{:save key="config" loan_cat_key=null}} + {{elseif $_GET.output_type == "rent"}} + {{:save key="config" rent_cat_key=null}} + {{/if}} {{else}} {{:assign selected_category=$_GET.cat_key}} - {{:save key="config" loan_cat_key=$selected_category}} + {{if $_GET.output_type == "loan"}} + {{:save key="config" loan_cat_key=$selected_category}} + {{elseif $_GET.output_type == "rent"}} + {{:save key="config" rent_cat_key=$selected_category}} + {{/if}} {{/if}} {{* condition de filtrage *}} @@ -34,7 +75,12 @@ {{* déterminer les types de mouvements *}} {{#foreach from=$config.output_nature key="key"}} - {{if $type == 'temporaire' && $fee != 'payant'}} + {{if $type != 'temporaire'}} + {{:continue}} + {{/if}} + {{if $_GET.output_type == "loan" && $fee != 'payant'}} + {{:assign var="out_keys." value=$key|quote_sql}} + {{elseif $_GET.output_type == "rent" && $fee == 'payant'}} {{:assign var="out_keys." value=$key|quote_sql}} {{/if}} {{/foreach}} @@ -42,13 +88,13 @@ {{: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"}} +{{:assign var="cat_options." value="" label="Toutes les catégories" href="?output_type=%s&cat_key=-1"|args:$_GET.output_type}} {{#load type="category" order="$$.name"}} {{:assign var="cat_options." value=$key label=$name - href="?cat_key=%s"|args:$key + href="?output_type=%s&cat_key=%s"|args:$_GET.output_type:$key }} {{/load}} @@ -62,7 +108,7 @@
      -

      Historique des prêts

      +

      Historique des {{$label}}s

      {{* 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 @@
      - + @@ -170,9 +212,14 @@ @@ -181,5 +228,8 @@

      Aucun mouvement.

      {{/select}} -
      Stockage Documents ÉcrituresRemarquesRemarque
      {{if $transactions != null}}{{:icon shape="money"}}{{/if}} {{$comment}} + {{if $_GET.output_type == "loan"}} + {{:assign from="lm"}} + {{elseif $_GET.output_type == "rent"}} + {{:assign from="rm"}} + {{/if}} {{:linkbutton label="Détails" - href="movements/movement_details.html?key=%s"|args:$key + href="movements/movement_details.html?key=%s&prop=1&from=%s"|args:$key:$from shape="eye" }}
      + +{{else}} +

      Aucun mouvement.

      +{{/if}} {{:admin_footer}} diff --git a/movements/copy_movement.html b/movements/copy_movement.html index 84c0e2e..97f0302 100644 --- a/movements/copy_movement.html +++ b/movements/copy_movement.html @@ -207,12 +207,25 @@ transactions=$transactions return_date=$return_date|parse_date }} - {{if $_GET.from == "lh"}} - {{:assign from="../loan_history.html"}} - {{else}} - {{:assign from="../equipment_history.html"}} + + {{if $_GET.from|substr:0:1 == "l"}} + {{:assign output_type="loan"}} + {{elseif $_GET.from|substr:0:1 == "r"}} + {{:assign output_type="rent"}} + {{/if}} + {{if $_GET.from|substr:1:1 == "h"}} + {{:assign suffix="history"}} + {{elseif $_GET.from|substr:1:1 == "m"}} + {{:assign suffix="movements"}} + {{/if}} + + {{if $_GET.from == "eh"}} + {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}} + {{elseif $suffix == null}} + {{:redirect force="../index.html"}} + {{else}} + {{:redirect force="../loan_%s.html?output_type=%s&ok=1&key=%s&prop=%s&msg=copie"|args:$suffix:$output_type:$eqpmt_key:$prop}} {{/if}} - {{:redirect force="%s?ok=1&key=%s&prop=%s&msg=copie"|args:$from:$eqpmt_key:$prop}} {{/form}} {{if $mvt_new.direction == "input"}} diff --git a/movements/delete_movement.html b/movements/delete_movement.html index 506ebe4..0ecafb2 100644 --- a/movements/delete_movement.html +++ b/movements/delete_movement.html @@ -23,11 +23,25 @@ {{:include file="../_get_config.html" keep="config"}} {{#form on="delete"}} - {{if $_GET.from == "lh"}} - {{:assign from="../loan_history.html"}} - {{else}} - {{:assign from="../equipment_history.html"}} + {{if $_GET.from|substr:0:1 == "l"}} + {{:assign output_type="loan"}} + {{elseif $_GET.from|substr:0:1 == "r"}} + {{:assign output_type="rent"}} {{/if}} + {{if $_GET.from|substr:1:1 == "h"}} + {{:assign suffix="history"}} + {{elseif $_GET.from|substr:1:1 == "m"}} + {{:assign suffix="movements"}} + {{/if}} + {{if $_GET.from == "eh"}} + {{:assign from="../equipment_history.html"}} + {{elseif $suffix == null}} + {{:assign from="../index.html"}} + {{else}} + {{:assign from="../loan_%s.html"|args:$suffix}} + {{:assign param="&output_type=%s"|args:$output_type}} + {{/if}} + {{* vérifier s'il est possible de supprimer le mouvement *}} {{if $mvt_suppr.direction == 'input'}} {{:assign var="type_operation" from="config.input_nature.%s.type"|args:$mvt_suppr.operation}} @@ -36,7 +50,7 @@ {{:assign link_key=$key}} {{/load}} {{if $link_key != null}} - {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}} {{/if}} {{else}} {{:assign dispo=0}} @@ -69,7 +83,7 @@ {{* problème ? *}} {{if $dispo < 0 || $nonprop < 0}} - {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}} {{/if}} {{/if}} {{/load}} @@ -90,7 +104,7 @@ {{:assign link_key=$key}} {{/load}} {{if $link_key != null}} - {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?key=%s&prop=%s&err=1&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}} {{/if}} {{elseif $type_operation == 'retour'}} {{#load type="link" where="$$.return = :key" :key=$_GET.key}} @@ -155,11 +169,11 @@ out=$curr_eqpmt.out notowned=$curr_eqpmt.notowned }} - {{:redirect force="%s?ok=1&key=%s&prop=%s&msg=suppression"|args:$from:$mvt_suppr.equipment:$_GET.prop}} + {{:redirect force="%s?ok=1&key=%s&prop=%s&msg=suppression%s"|args:$from:$mvt_suppr.equipment:$_GET.prop:$param}} {{else}} {{* supprimer le matériel *}} {{:delete key=$curr_eqpmt.key}} - {{:redirect force="../index.html?ok=1&msg=supprmvtmat"}} + {{:redirect force="%s?ok=1&msg=supprmvtmat%s"|args:$from:$param}} {{/if}} {{/form}} diff --git a/movements/modify_movement.html b/movements/modify_movement.html index 542267f..d78c337 100644 --- a/movements/modify_movement.html +++ b/movements/modify_movement.html @@ -224,12 +224,25 @@ transactions=$transactions return_date=$return_date|parse_date }} - {{if $_GET.from == "lh"}} - {{:assign from="../loan_history.html"}} - {{else}} - {{:assign from="../equipment_history.html"}} + + {{if $_GET.from|substr:0:1 == "l"}} + {{:assign output_type="loan"}} + {{elseif $_GET.from|substr:0:1 == "r"}} + {{:assign output_type="rent"}} + {{/if}} + {{if $_GET.from|substr:1:1 == "h"}} + {{:assign suffix="history"}} + {{elseif $_GET.from|substr:1:1 == "m"}} + {{:assign suffix="movements"}} + {{/if}} + + {{if $_GET.from == "eh"}} + {{:redirect force="../equipment_history.html?ok=1&key=%s&prop=%s&msg=copie"|args:$eqpmt_key:$prop}} + {{elseif $suffix == null}} + {{:redirect force="../index.html"}} + {{else}} + {{:redirect force="../loan_%s.html?output_type=%s&ok=1&key=%s&prop=%s&msg=modification"|args:$suffix:$output_type:$eqpmt_key:$prop}} {{/if}} - {{:redirect force="%s?ok=1&key=%s&prop=%s&msg=modification"|args:$from:$eqpmt_key:$prop}} {{/form}} {{if $mvt_new.direction == "input"}} diff --git a/movements/movement_details.html b/movements/movement_details.html index ac2bb5a..ad367b3 100644 --- a/movements/movement_details.html +++ b/movements/movement_details.html @@ -9,6 +9,7 @@ paramètres : - key : clé du mouvement - prop = 1 si matériel appartient à l'asso + - from = page d'appel *}} {{:admin_header title="Détails du mouvement" custom_css="../style.css" current="module_equipment"}} diff --git a/rent_history.html b/rent_history.html deleted file mode 100644 index 0baa133..0000000 --- a/rent_history.html +++ /dev/null @@ -1,180 +0,0 @@ -{{* -*- brindille -*- *}} - -{{#restrict block=true section="accounting" level="write"}}{{/restrict}} - -{{:admin_header title="Locations en cours" custom_css="../style.css" current="module_equipment"}} -{{:include file="./_nav.html" current="location" subcurrent="encours"}} - -{{* - vérifier l'existence de la table du module - eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans -*}} - -{{#load limit="1"}} - {{:assign table_presente=true}} -{{else}} - {{:assign table_presente=false}} -{{/load}} - -{{if $table_presente}} -{{if $_GET.ok}} - {{if $_GET.msg == "modification"}} -

      Modification enregistrée

      - {{elseif $_GET.msg == "copie"}} -

      Mouvement copié

      - {{elseif $_GET.msg == "suppression"}} -

      Mouvement supprimé

      - {{/if}} -{{elseif $_GET.err}} - {{if $_GET.msg == "suppression"}} -

      Ce mouvement ne peut être supprimé

      - {{/if}} -{{/if}} - -{{* 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.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="out_keys." value=$key|quote_sql}} - {{/if}} -{{/foreach}} -{{: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 - 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}} - - - - - - - - - - - - - - - {{:assign premier=false}} - {{/if}} - - {{if $return_date != null}} - {{:assign ts_retour=$return_date|strtotime}} - {{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}} - {{/if}} - - - - - - - - - - -{{else}} -

      Aucun mouvement.

      -{{/select}} - -
      MatérielDate prêtQuantitéMembreDate retourReste à rendreRemarque
      {{$mat_name}}{{$out_date|date_short}}{{$out_amount}}{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$nom}}{{$return_date|date_short}}{{$remain}} - {{if $return_date != null}} - {{:assign jour="jour}} - {{if $nb_jours > 0}} - {{if $nb_jours > 1}}{{:assign jour="jours"}}{{/if}} - {{:tag color="darkred" label="Retard %s %s"|args:$nb_jours:$jour}} - {{elseif $nb_jours < 0}} - {{:assign delai="abs(%d)"|math:$nb_jours}} - {{if $nb_jours < -1}}{{:assign jour="jours"}}{{/if}} - {{"Reste %s %s"|args:$delai:$jour}} - {{else}} - {{:tag color="darkgreen" label="À rendre aujourd'hui"}} - {{/if}} - {{/if}} - - {{:linkbutton - label="Retour" - href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key - shape="reset" - target="_dialog"}} - {{:linkbutton - label="Détails" - href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key - shape="eye" - }} -
      -{{else}} -

      Aucun mouvement.

      -{{/if}} - -{{:admin_footer}} diff --git a/rent_movements.html b/rent_movements.html deleted file mode 100644 index 424e2ed..0000000 --- a/rent_movements.html +++ /dev/null @@ -1,181 +0,0 @@ -{{* -*- brindille -*- *}} - -{{#restrict block=true section="accounting" level="write"}}{{/restrict}} - -{{* - Afficher l'historique des locations -*}} - -{{:admin_header title="Historique des locations" custom_css="./style.css" current="module_equipment"}} - -{{:include file="./_nav.html" current="location" subcurrent="historique"}} - -{{* 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.rent_cat_key}} -{{elseif $_GET.cat_key == -1}} - {{:assign selected_category=null}} - {{:save key="config" rent_cat_key=null}} -{{else}} - {{:assign selected_category=$_GET.cat_key}} - {{:save key="config" rent_cat_key=$selected_category}} -{{/if}} - -{{* condition de filtrage *}} -{{if $selected_category != null}} - {{:assign cat_key=$selected_category|quote_sql}} - {{:assign cat_condition="category = %s"|args:$cat_key}} -{{else}} - {{:assign cat_condition=1}} -{{/if}} - -{{* déterminer les types de mouvements *}} -{{#foreach from=$config.output_nature key="key"}} - {{if $type == 'temporaire' && $fee == 'payant'}} - {{:assign var="out_keys." value=$key|quote_sql}} - {{/if}} -{{/foreach}} -{{: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 - }} -
      - -
      -

      Historique des locations

      -
      - -{{* 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=false}} - {{/if}} - - - - - - - - - - - - - - -{{else}} -

      Aucun mouvement.

      -{{/select}} - -
      DateMouvementOpérationMatérielQuantitéDépositaireStockageDocumentsÉcrituresRemarques
      {{$date|date_short}}{{if $direction == "input"}}Entrée{{else}}Sortie{{/if}}{{$op_label}}{{$materiel}}{{$amount}}{{:link href="/admin/users/details.php?id=%s"|args:$user_id label="%s"|args:$user}}{{$stockage}}{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}{{if $transactions != null}}{{:icon shape="money"}}{{/if}}{{$comment}} - {{:linkbutton - label="Détails" - href="movements/movement_details.html?key=%s"|args:$key - shape="eye" - }} -
      -{{:admin_footer}}