Compare commits

...
Sign in to create a new pull request.

10 commits

Author SHA1 Message Date
Jean-Christophe Engel
546a9ea677 Mutualisation onglets prêt et location 2026-01-29 13:48:48 +01:00
Jean-Christophe Engel
974f87e5a4 Ajout filtre par catégorie Location et Prêts en cours 2026-01-28 13:37:11 +01:00
Jean-Christophe Engel
83c2b9af80 Séparation prêt et location 2026-01-28 13:36:38 +01:00
Jean-Christophe Engel
b14463ecf2 Paramétrisation nom table dans les requêtes 2026-01-27 17:17:54 +01:00
Jean-Christophe Engel
1b1680af5c Ajout historique des mouvements de prêts 2026-01-23 10:21:15 +01:00
Jean-Christophe Engel
84b35adcfa Réorganisation navigation 2026-01-23 10:20:45 +01:00
Jean-Christophe Engel
59b13e6e4c archives : amélioration filtre catégorie 2026-01-23 10:14:26 +01:00
Jean-Christophe Engel
05b2b9b252 equipment_history : ajout filtrage par appartenance 2026-01-22 11:53:15 +01:00
Jean-Christophe Engel
2f3785831e global_history : amélioration filtre catégorie ; ajout filtre appartenance 2026-01-22 10:34:42 +01:00
Jean-Christophe Engel
e2c8ac2d84 Début réorganisation navigation ; inventaire : ajout filtre selon appartenance 2026-01-22 10:33:47 +01:00
17 changed files with 851 additions and 343 deletions

View file

@ -16,7 +16,7 @@
{{:assign var="nature" from="module.config.%s_nature"|args:$direction}} {{:assign var="nature" from="module.config.%s_nature"|args:$direction}}
{{if $nature != null}} {{if $nature != null}}
{{#foreach from=$nature item="elem"}} {{#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}} {{:assign var="config.%s_nature.%s"|args:$direction:$key value=$item}}
{{/foreach}} {{/foreach}}
{{else}} {{else}}

View file

@ -1,18 +1,56 @@
{{* -*- brindille -*- *}} {{* -*- brindille -*- *}}
{{* {{*
inventaire des entrées/sorties des matériels permanents Inventaire des matériels en stock dans l'association
*}} *}}
{{* Sélecteur catégories *}} {{* filtrer selon la catégorie *}}
{{:assign var="options." value="" label="Toutes les catégories" href="?prop=1"}} {{if $_GET.cat_key == null}}
{{:assign selected_category=$module.config.stock_cat_key}}
{{elseif $_GET.cat_key == -1}}
{{:assign selected_category=null}}
{{:save key="config" stock_cat_key=null}}
{{else}}
{{:assign selected_category=$_GET.cat_key}}
{{: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"}}
{{/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"}} {{#load type="category" order="$$.name"}}
{{:assign var="categories.%s"|args:$key value=$name}} {{:assign var="categories.%s"|args:$key value=$name}}
{{:assign {{:assign
var="options." var="cat_options."
value=$key value=$key
label=$name label=$name
href="?cat_key=%s&prop=1"|args:$key href="?cat_key=%s"|args:$key
}} }}
{{/load}} {{/load}}
@ -20,23 +58,28 @@
<legend>Filtrer par catégorie</legend> <legend>Filtrer par catégorie</legend>
{{:dropdown {{:dropdown
title="Filtrer par catégorie" title="Filtrer par catégorie"
options=$options options=$cat_options
value="%s"|args:$_GET.cat_key value="%s"|args:$selected_category
}}
</fieldset>
{{: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"}}
<fieldset class="shortFormRight">
<legend>Filtrer par appartenance</legend>
{{:dropdown
title="Filtrer par appartenance"
options=$prop_options
value="%s"|args:$selected_prop
}} }}
</fieldset> </fieldset>
<div class="shortFormLeft"> <div class="shortFormLeft">
<p class="help">Inventaire des matériels propriété de l'association</p> <p class="help">Inventaire des matériels présents dans l'association</p>
</div> </div>
{{* 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 {{#list
select=" select="
$$.name AS 'Matériel' ; $$.name AS 'Matériel' ;
@ -44,22 +87,32 @@
FROM @TABLE as cat FROM @TABLE as cat
WHERE cat.key = @TABLE.$$.category) AS 'Catégorie' ; WHERE cat.key = @TABLE.$$.category) AS 'Catégorie' ;
$$.stock AS 'Stock' ; $$.stock AS 'Stock' ;
(SELECT COALESCE($$.notowned, 0)) AS 'Temp' ;
(SELECT $$.stock + COALESCE($$.notowned, 0)) AS 'Total' ;
$$.out AS 'Sorti' ; $$.out AS 'Sorti' ;
(SELECT $$.stock - $$.out) AS 'Disponible' (SELECT $$.stock - $$.out) AS 'Disponible'
" "
type="equipment" 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 order=1
}} }}
{{:assign var=cat_name from=categories.%s|args:$category}} {{:assign var=cat_name from=categories.%s|args:$category}}
<tr> <tr>
<td>{{:link href="equipment_history.html?key=%s&prop=1"|args:$key" label=$name}}</td> {{if $selected_prop == null}}
{{:assign prop=""}}
{{else}}
{{:assign prop="&prop=%s"|args:$selected_prop}}
{{/if}}
<td>{{:link href="equipment_history.html?key=%s&prop=%s"|args:$key:$selected_prop" label=$name}}</td>
<td>{{$cat_name}}</td> <td>{{$cat_name}}</td>
<td class="num">{{$stock}}</td> <td class="num">{{$stock}}</td>
<td class="num">{{$col4}}</td>
<td class="num">{{$col5}}
<td class="num">{{$out}}</td> <td class="num">{{$out}}</td>
<td class="num">{{$col5}}</td> <td class="num">{{$col7}}</td>
<td class="actions"> <td class="actions">
{{if $col5 > 0}} {{*
{{if $col7 > 0}}
{{:linkbutton {{:linkbutton
label="Sortie" label="Sortie"
shape="minus" shape="minus"
@ -71,6 +124,7 @@
shape="plus" shape="plus"
href="movements/input_equipment.html?key=%s"|args:$key href="movements/input_equipment.html?key=%s"|args:$key
target="_dialog"}} target="_dialog"}}
*}}
{{:linkbutton {{:linkbutton
label="Historique" label="Historique"
href="equipment_history.html?key=%s&prop=1"|args:$key href="equipment_history.html?key=%s&prop=1"|args:$key

View file

@ -12,27 +12,29 @@
{{/if}} {{/if}}
<ul> <ul>
<li {{if $current == 'inventaire'}} class="current"{{/if}}><a href="{{$module.url}}index.html?prop=1">Inventaire</a></li> <li {{if $current == 'inventaire'}} class="current"{{/if}}><a href="{{$module.url}}index.html">Inventaire</a></li>
<li {{if $current == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}global_history.html">Historique</a></li> <li {{if $current == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}global_history.html">Historique</a></li>
<li {{if $current == 'prêt'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=loan">Prêts</a></li>
<li {{if $current == 'location'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=rent">Locations</a></li>
<li {{if $current == 'archives'}} class="current"{{/if}}><a href="{{$module.url}}archives.html">Archives</a></li> <li {{if $current == 'archives'}} class="current"{{/if}}><a href="{{$module.url}}archives.html">Archives</a></li>
<li {{if $current == 'config'}} class="current"{{/if}}><a href="{{$module.url}}categories/index.html">Configuration</a></li> <li {{if $current == 'config'}} class="current"{{/if}}><a href="{{$module.url}}categories/index.html">Configuration</a></li>
</ul> </ul>
{{if $current == 'inventaire'}} {{if $current == 'inventaire'}}
<ul class="sub"> {{if $subcurrent == 'historique'}}
<li {{if $subcurrent == 'proprio'}} class="current"{{/if}}><a href="{{$module.url}}index.html?prop=1">Matériels permanents</a></li>
<li {{if $subcurrent == 'nonproprio'}} class="current"{{/if}}><a href="{{$module.url}}index.html?prop=0">Matériels temporaires</a></li>
</ul>
{{if $subsubcurrent == 'historique'}}
<ul class="sub"> <ul class="sub">
<li class="title"><strong>Historique — {{$eqpmt}} ({{$category}})</strong></li> <li class="title"><strong>Historique — {{$eqpmt}} ({{$category}})</strong></li>
</ul> </ul>
{{/if}} {{/if}}
{{elseif $current == 'historique'}} {{elseif $current == 'prêt'}}
<ul class="sub"> <ul class="sub">
<li {{if $subcurrent == 'tous'}} class="current"{{/if}}><a href="{{$module.url}}global_history.html">Tous</a></li> <li {{if $subcurrent == 'encours'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=loan">En cours</a></li>
<li {{if $subcurrent == 'prêts'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html">Prêts</a></li> <li {{if $subcurrent == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}loan_movements.html?output_type=loan">Historique</a></li>
</ul>
{{elseif $current == 'location'}}
<ul class="sub">
<li {{if $subcurrent == 'encours'}} class="current"{{/if}}><a href="{{$module.url}}loan_history.html?output_type=rent">En cours</a></li>
<li {{if $subcurrent == 'historique'}} class="current"{{/if}}><a href="{{$module.url}}loan_movements.html?output_type=rent">Historique</a></li>
</ul> </ul>
{{elseif $current == 'archives'}} {{elseif $current == 'archives'}}
{{if $subsubcurrent == 'historique'}} {{if $subsubcurrent == 'historique'}}
@ -58,7 +60,9 @@
<ul class="sub"> <ul class="sub">
<li {{if $subcurrent == 'categories'}} class="current"{{/if}}><a href="{{$module.url}}categories/index.html">Catégories</a></li> <li {{if $subcurrent == 'categories'}} class="current"{{/if}}><a href="{{$module.url}}categories/index.html">Catégories</a></li>
<li {{if $subcurrent == 'storage'}} class="current"{{/if}}><a href="{{$module.url}}storage/index.html">Lieux de stockage</a></li> <li {{if $subcurrent == 'storage'}} class="current"{{/if}}><a href="{{$module.url}}storage/index.html">Lieux de stockage</a></li>
{{*
<li {{if $subcurrent == 'typesES'}} class="current"{{/if}}><a href="{{$module.url}}config.html">Types d'entrées/sorties</a></li> <li {{if $subcurrent == 'typesES'}} class="current"{{/if}}><a href="{{$module.url}}config.html">Types d'entrées/sorties</a></li>
*}}
<li {{if $subcurrent == 'divers'}} class="current"{{/if}}><a href="{{$module.url}}config/misc.html">Divers</a></li> <li {{if $subcurrent == 'divers'}} class="current"{{/if}}><a href="{{$module.url}}config/misc.html">Divers</a></li>
</ul> </ul>
{{/if}} {{/if}}

View file

@ -9,11 +9,30 @@
<p class="block confirm">Matériel remis en service</p> <p class="block confirm">Matériel remis en service</p>
{{/if}} {{/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 *}} {{* 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"}} {{#load type="category" order="$$.name"}}
{{:assign {{:assign
var="options." var="cat_options."
value=$key value=$key
label=$name label=$name
href="?cat_key=%s"|args:$key href="?cat_key=%s"|args:$key
@ -24,8 +43,8 @@
<legend>Filtrer par catégorie</legend> <legend>Filtrer par catégorie</legend>
{{:dropdown {{:dropdown
title="Filtrer par catégorie" title="Filtrer par catégorie"
options=$options options=$cat_options
value="%s"|args:$_GET.cat_key value="%s"|args:$selected_category
}} }}
</fieldset> </fieldset>
@ -33,14 +52,6 @@
<p class="help">Matériels qui ne sont plus dans l'association</p> <p class="help">Matériels qui ne sont plus dans l'association</p>
</div> </div>
{{* 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 *}} {{* Liste des matériels archivés *}}
{{#list {{#list
select=" select="
@ -50,7 +61,7 @@
WHERE cat.key = @TABLE.$$.category) AS "Catégorie" WHERE cat.key = @TABLE.$$.category) AS "Catégorie"
" "
type="equipment" type="equipment"
where="$$.status='archived' AND %s"|args:$condition where="$$.status='archived' AND %s"|args:$cat_condition
order=1 order=1
}} }}

View file

@ -12,14 +12,6 @@
- msg : message de retour - 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}} {{:assign equipment_key=$_GET.key|trim}}
{{#load key=$equipment_key assign="equipment"}} {{#load key=$equipment_key assign="equipment"}}
{{else}} {{else}}
@ -33,12 +25,13 @@
{{:admin_header title="Gestion des matériels" custom_css="./style.css" current="module_equipment"}} {{:admin_header title="Gestion des matériels" custom_css="./style.css" current="module_equipment"}}
{{* barre de navigation *}}
{{if $_GET.current != null}} {{if $_GET.current != null}}
{{:assign current=$_GET.current}} {{:assign current=$_GET.current}}
{{else}} {{else}}
{{:assign current="inventaire"}} {{:assign current="inventaire"}}
{{/if}} {{/if}}
{{:include file="./_nav.html" current=$current subcurrent=$proprio 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.ok}}
{{if $_GET.msg == "modification"}} {{if $_GET.msg == "modification"}}
@ -61,34 +54,69 @@
{{* récupérer la config des entrées/sorties *}} {{* récupérer la config des entrées/sorties *}}
{{:include file="./_get_config.html" keep="config"}} {{:include file="./_get_config.html" keep="config"}}
{{* déterminer les types de mouvements selon l'affection du matériel *}} {{* filtrer selon appartenance *}}
{{#foreach from=$config.input_nature}} {{if $_GET.prop == null}}
{{if $_GET.prop}} {{: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 *}} {{* matériel propriété de l'asso *}}
{{if $type != 'temporaire'}} {{if $type != 'temporaire'}}
{{:assign var="input_types." value=$label}} {{:assign var="mvt_keys." value=$key|quote_sql}}
{{/if}} {{/if}}
{{else}} {{else}}
{{* matériel non propriété de l'asso *}} {{* matériel non propriété de l'asso *}}
{{if $type == 'temporaire'}} {{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}}
{{/if}} {{/if}}
{{/foreach}} {{/foreach}}
{{#foreach from=$config.output_nature}} {{#foreach from=$config.output_nature key="key"}}
{{if $_GET.prop}} {{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 *}} {{* matériel propriété de l'asso *}}
{{if $type != 'retour'}} {{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}} {{/if}}
{{else}} {{else}}
{{* matériel non propriété de l'asso *}} {{* matériel non propriété de l'asso *}}
{{if $type == 'retour'}} {{if $type == 'retour'}}
{{:assign var="output_types." value=$label}} {{:assign var="mvt_keys." value=$key|quote_sql}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/foreach}} {{/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 *}} {{* calculer et mémoriser les quantités pour que le tri de la liste affiche les valeurs correctes *}}
{{:assign stock=0}} {{:assign stock=0}}
@ -122,10 +150,111 @@
{{:assign var="quantites.%s.nonproprio"|args:$id value=$nonproprio}} {{:assign var="quantites.%s.nonproprio"|args:$id value=$nonproprio}}
{{/load}} {{/load}}
{{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,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
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
}}
{{:assign var="reste.%s"|args:$mvt_key value=$reste}}
{{/select}}
{{/if}}
{{if $selected_prop == null || ! $selected_prop}}
{{* calculer la quantité présente temporairement de chaque matériel *}}
{{:assign input_ops=$temp_inputs|implode:","}}
{{:assign input_ops="("|cat:$input_ops|cat:")"}}
{{#select
mvt.key AS mvt_key,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
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
}}
{{:assign var="present.%s"|args:$mvt_key value=$present}}
{{/select}}
{{/if}}
{{: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}}
<fieldset class="shortFormRight">
<legend>Filtrer par appartenance</legend>
{{:dropdown
title="Filtrer par appartenance"
options=$prop_options
value="%s"|args:$selected_prop
}}
</fieldset>
{{if $current != "archives"}} {{if $current != "archives"}}
<nav class="tabs"> <nav class="tabs">
<aside> <aside>
{{if $_GET.prop && $dispo_final > 0}} {{if $dispo_final > 0 && $selected_prop == null || $selected_prop}}
{{:linkbutton label="Sortie" shape="minus" href="movements/output_equipment.html?key=%s"|args:$_GET.key target="_dialog"}} {{:linkbutton label="Sortie" shape="minus" href="movements/output_equipment.html?key=%s"|args:$_GET.key target="_dialog"}}
{{/if}} {{/if}}
{{:linkbutton label="Entrée" shape="plus" href="movements/input_equipment.html?key=%s"|args:$_GET.key target="_dialog"}} {{:linkbutton label="Entrée" shape="plus" href="movements/input_equipment.html?key=%s"|args:$_GET.key target="_dialog"}}
@ -133,196 +262,92 @@
</nav> </nav>
{{/if}} {{/if}}
{{* lister tous les mouvements du matériel passé en paramètre *}} {{* lister les mouvements du matériel passé en paramètre *}}
{{if $_GET.prop}} {{#list
{{* calculer la quantité temporairement l'extérieur de chaque matériel *}} type="movement"
{{#foreach from=$config.output_nature key=key}} select="%s"|args:$select_clause
{{if $type == "temporaire"}} where="%s"|args:$prop_condition
{{:assign var="temp_outputs." value=$key|quote_sql}} equipment=$equipment_key
{{/if}} order=1
{{/foreach}} }}
{{:assign operations=$temp_outputs|implode:","}} {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}}
{{:assign operations="("|cat:$operations|cat:")"}} {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
{{#select {{:assign var="stock" from="quantites.%s.stock"|args:$id}}
mvt.key AS mvt_key, {{:assign var="exterieur" from="quantites.%s.exterieur"|args:$id}}
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste {{:assign var="dispo" from="quantites.%s.dispo"|args:$id}}
FROM {!$module.table} AS mvt {{:assign var="tempo" from="quantites.%s.nonproprio"|args:$id}}
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') {{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
WHERE {{:assign file_path=$file_path|cat:"%"}}
json_extract(mvt.document, '$.operation') IN !op {{#select count(*) AS nb FROM files WHERE path LIKE :file_path ; :file_path=$file_path}}
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key {{:assign nb_files=$nb}}
GROUP by mvt.key
;
!op = $operations
:eqpmt_key = $_GET.key
}}
{{:assign var="reste.%s"|args:$mvt_key value=$reste}}
{{/select}} {{/select}}
{{#list {{if $selected_prop == null}}
type="movement" {{:assign user_details=$col9}}
select=" {{:assign storage=$col10}}
($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date'; {{elseif $selected_prop}}
CASE $$.direction WHEN 'input' THEN 'Entrée' WHEN 'output' THEN 'Sortie' END AS 'Mouvement'; {{:assign user_details=$col8}}
$$.operation AS 'Opération'; {{:assign storage=$col9}}
$$.amount AS 'Quantité'; {{else}}
'' AS 'Stock'; {{:assign user_details=$col6}}
'' AS 'Sorti'; {{:assign storage=$col6}}
'' 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}}
<tr>
<td>{{$date|date_short}}</td>
<td>{{$col2}}</td>
<td class="nosort">{{$op_label}}</td>
<td class="num">{{$amount}}</td>
<td class="num nosort">{{$stock}}</td>
<td class="num nosort">{{$exterieur}}</td>
<td class="num nosort">{{$dispo}}</td>
<td>{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$col8}}</td>
<td>{{$col9}}</td>
<td class="num nosort">{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}</td>
<td class="num">{{if $transactions|count > 0}}{{:icon shape="money"}}{{/if}}</td>
<td class="actions">
{{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}}
</td>
</tr>
{{/if}}
{{/list}}
{{if $dispo_final === 0}}
<span class="help">Il n'y a aucun matériel disponible, il n'est donc pas possible d'effectuer une sortie</span>
{{/if}} {{/if}}
{{else}}
{{* calculer la quantité présente temporairement de chaque matériel *}} <tr>
{{#foreach from=$config.input_nature key=key}} <td>{{$date|date_short}}</td>
{{if $type == "temporaire"}} <td>{{$col2}}</td>
{{:assign var="temp_inputs." value=$key|quote_sql}} <td class="nosort">{{$op_label}}</td>
<td class="num">{{$amount}}</td>
{{if $selected_prop == null || $selected_prop}}
<td class="num nosort">{{$stock}}</td>
<td class="num nosort">{{$exterieur}}</td>
<td class="num nosort">{{$dispo}}</td>
{{/if}} {{/if}}
{{/foreach}} {{if $selected_prop == null || ! $selected_prop}}
{{:assign operations=$temp_inputs|implode:","}} <td class="num nosort">{{$tempo}}</td>
{{:assign operations="("|cat:$operations|cat:")"}} {{/if}}
{{if $selected_prop == null || $selected_prop}}
{{#select <td>{{:link href="/admin/users/details.php?id=%s"|args:$user label="%s"|args:$user_details}}</td>
mvt.key AS mvt_key, {{/if}}
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present <td>{{$storage}}</td>
FROM {!$module.table} AS mvt <td class="num nosort">{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}</td>
LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key') <td class="num">{{if $transactions|count > 0}}{{:icon shape="money"}}{{/if}}</td>
LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return') <td class="actions">
WHERE {{if $current != "archives"}}
json_extract(mvt.document, '$.operation') IN !op {{if $direction == "output" && $type_mvt == "temporaire"}}
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key {{:assign var="temp_ext" from="reste.%s"|args:$key}}
GROUP by mvt.key {{if $temp_ext != null && $temp_ext > 0}}
; {{:linkbutton
!op = $operations label="Retour"
:eqpmt_key = $_GET.key href="movements/output_return.html?key=%s&prop=%s"|args:$key:$selected_prop
}} shape="reset"
{{:assign var="present.%s"|args:$mvt_key value=$present}} target="_dialog"}}
{{/select}}
{{#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 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}}
{{: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}}
<tr>
<td>{{$date|date_short}}</td>
<td>{{$col2}}</td>
<td class="nosort">{{$op_label}}</td>
<td class="num">{{$amount}}</td>
<td class="num nosort">{{$stock}}</td>
<td>{{$col6}}</td>
<td class="num nosort">{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}</td>
<td class="num">{{if $transactions|count > 0}}{{:icon shape="money"}}{{/if}}</td>
<td class="actions">
{{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}} {{/if}}
{{:linkbutton {{/if}}
label="Détails" {{if $direction == "input" && $type_mvt == "temporaire"}}
href="movements/movement_details.html?key=%s&prop=%s&from=eh"|args:$key:$_GET.prop {{:assign var="temp_in" from="present.%s"|args:$key}}
shape="eye" {{if $temp_in != null && $temp_in > 0}}
}} {{:linkbutton
</td> label="Retour"
</tr> href="movements/input_return.html?key=%s&prop=%s"|args:$key:$selected_prop
{{/if}} shape="reset"
{{/list}} 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}}
</td>
</tr>
{{/list}}
{{if $dispo_final == 0 && $stock > 0 && $current != "archives"}}
<span class="help">Il n'y a aucun matériel disponible, il n'est donc pas possible d'effectuer une sortie</span>
{{/if}} {{/if}}
{{:admin_footer}} {{:admin_footer}}

View file

@ -8,17 +8,93 @@
{{:admin_header title="Historique des mouvements" custom_css="./style.css" current="module_equipment"}} {{: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="historique"}}
{{* récupérer la config des entrées/sorties *}} {{* récupérer la config des entrées/sorties *}}
{{:include file="./_get_config.html" keep="config"}} {{:include file="./_get_config.html" keep="config"}}
{{* Sélecteur catégories *}} {{* filtrer selon la catégorie *}}
{{:assign var="options." value="" label="Toutes les catégories" href="?"}} {{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"}} {{#load type="category" order="$$.name"}}
{{:assign var="categories.%s"|args:$key value=$name}} {{:assign var="categories.%s"|args:$key value=$name}}
{{:assign {{:assign
var="options." var="cat_options."
value=$key value=$key
label=$name label=$name
href="?cat_key=%s"|args:$key href="?cat_key=%s"|args:$key
@ -29,8 +105,21 @@
<legend>Filtrer par catégorie</legend> <legend>Filtrer par catégorie</legend>
{{:dropdown {{:dropdown
title="Filtrer par catégorie" title="Filtrer par catégorie"
options=$options options=$cat_options
value="%s"|args:$_GET.cat_key value="%s"|args:$selected_category
}}
</fieldset>
{{: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"}}
<fieldset class="shortFormRight">
<legend>Filtrer par appartenance</legend>
{{:dropdown
title="Filtrer par appartenance"
options=$prop_options
value="%s"|args:$selected_prop
}} }}
</fieldset> </fieldset>
@ -38,18 +127,7 @@
<p class="help">Historique de tous les mouvements de matériel</p> <p class="help">Historique de tous les mouvements de matériel</p>
</div> </div>
{{* condition de filtrage *}} {{* lister les mouvements *}}
{{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 *}}
{{#list {{#list
type="movement" type="movement"
select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date'; select="($$.date || '_' || substr('000000' || id, -6, 6)) AS 'Date';
@ -67,9 +145,9 @@
THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage) THEN (SELECT $$.name FROM @TABLE as storage WHERE storage.key = @TABLE.$$.storage)
ELSE '' ELSE ''
END as 'Stockage'; END as 'Stockage';
$$.comment AS 'Commentaire' $$.comment AS 'Remarque'
"|args:$config.user_fields.name_sql "|args:$config.user_fields.name_sql
where="%s"|args:$condition where="%s AND %s"|args:$cat_condition:$prop_condition
order=1 order=1
max=50 max=50
desc=true desc=true

View file

@ -14,15 +14,6 @@
{{else}} {{else}}
{{#restrict block=true section="accounting" level="write"}}{{/restrict}} {{#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.ok}}
{{if $_GET.msg == "ajout" }} {{if $_GET.msg == "ajout" }}
<p class="block confirm">Ajout effectué</p> <p class="block confirm">Ajout effectué</p>
@ -37,14 +28,13 @@
<p class="block error">Modification refusée</p> <p class="block error">Modification refusée</p>
{{/if}} {{/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}} {{if $result.count == 0}}
<p class="block alert">Il n'y a aucune catégorie : vous devez en ajouter.</p> <p class="block alert">Il n'y a aucune catégorie : vous devez en ajouter.</p>
{{else}} {{else}}
{{if $_GET.prop == null || $_GET.prop == "1"}} {{:include file="./_inventory.html"}}
{{:include file="./_inventory.html"}}
{{else}}
{{:include file="./_temp_inventory.html"}}
{{/if}}
{{/if}} {{/if}}
{{:admin_footer}} {{:admin_footer}}

View file

@ -2,14 +2,21 @@
{{#restrict block=true section="accounting" level="write"}}{{/restrict}} {{#restrict block=true section="accounting" level="write"}}{{/restrict}}
{{:admin_header title="Matériels hors de l'asso" custom_css="../style.css" current="module_equipment"}} {{if $_GET.output_type == "loan"}}
{{:include file="./_nav.html" current="historique" subcurrent="prêts"}} {{: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 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 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"}} {{#load limit="1"}}
{{:assign table_presente=true}} {{:assign table_presente=true}}
{{else}} {{else}}
@ -31,20 +38,72 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
<div class="shortFormLeft">
<p class="help">Historique des prêts de matériel</p>
</div>
{{* lecture config (défaut ou enregistrée) *}} {{* lecture config (défaut ou enregistrée) *}}
{{:include file="./_get_config.html" keep="config"}} {{:include file="./_get_config.html" keep="config"}}
{{* filtrer selon la catégorie *}}
{{if $_GET.cat_key == null}}
{{:assign var="selected_category" from="module.config.%s_hist_cat_key"|args:$_GET.output_type}}
{{elseif $_GET.cat_key == -1}}
{{:assign selected_category=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}}
{{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 *}}
{{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"}} {{#foreach from=$config.output_nature key="key"}}
{{if $type == 'temporaire'}} {{if $type != 'temporaire'}}
{{:assign var="output_types." value=$key|quote_sql}} {{: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}} {{/if}}
{{/foreach}} {{/foreach}}
{{:assign output_ops=$output_types|implode:","}} {{:assign out_keys=$out_keys|implode:","}}
{{:assign output_ops="("|cat:$output_ops|cat:")"}} {{:assign out_keys="("|cat:$out_keys|cat:")"}}
{{* sélecteur de catégorie *}}
{{: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="?output_type=%s&cat_key=%s"|args:$_GET.output_type:$key
}}
{{/load}}
<fieldset class="shortFormRight">
<legend>Filtrer par catégorie</legend>
{{:dropdown
title="Filtrer par catégorie"
options=$cat_options
value="%s"|args:$selected_category
}}
</fieldset>
<div class="shortFormLeft">
<p class="help">{{$label|ucfirst}} de matériel en cours</p>
</div>
{{:assign premier=true}} {{:assign premier=true}}
{{#select {{#select
@ -56,33 +115,34 @@
json_extract(mvt.document, '$.amount') AS out_amount, json_extract(mvt.document, '$.amount') AS out_amount,
json_extract(mvt.document, '$.return_date') AS return_date, json_extract(mvt.document, '$.return_date') AS return_date,
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(retour.document, '$.amount')), 0) AS remain 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 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 !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') LEFT JOIN !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') INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
WHERE WHERE json_extract(mvt.document, '$.type') = 'movement'
json_extract(mvt.document, '$.type') = 'movement' AND json_extract(mvt.document, '$.operation') IN !op
AND AND !cat_condition
json_extract(mvt.document, '$.operation') IN !op
GROUP BY mvt.key GROUP BY mvt.key
HAVING remain != 0 HAVING remain != 0
ORDER BY out_date, nom ORDER BY out_date DESC, nom
; ;
!op = $output_ops !table=$module.table
!op = $out_keys
!cat_condition=$cat_condition
}} }}
{{if $premier}} {{if $premier}}
<table class="list"> <table class="list">
<thead> <thead>
<tr> <tr>
<th>Matériel</th> <td>Matériel</td>
<th>Date prêt</th> <td>Date prêt</td>
<th>Quantité</th> <td>Quantité</td>
<th>Membre</th> <td>Membre</td>
<th>Date retour</th> <td>Date retour</td>
<th>Reste à rendre</th> <td>Reste à rendre</td>
<th>Remarque</th> <td>Remarque</td>
<th class="actions"></th> <td class="actions"></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -121,9 +181,14 @@
href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key href="movements/output_return.html?key=%s&prop=1"|args:$mvt_key
shape="reset" shape="reset"
target="_dialog"}} target="_dialog"}}
{{if $_GET.output_type == "loan"}}
{{:assign from="lh"}}
{{elseif $_GET.output_type == "rent"}}
{{:assign from="rh"}}
{{/if}}
{{:linkbutton {{:linkbutton
label="Détails" 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" shape="eye"
}} }}
</td> </td>

235
loan_movements.html Normal file
View file

@ -0,0 +1,235 @@
{{* -*- brindille -*- *}}
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
{{*
Afficher l'historique des prêts ou locations
*}}
{{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="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"}}
<p class="block confirm">Modification enregistrée</p>
{{elseif $_GET.msg == "copie"}}
<p class="block confirm">Mouvement copié</p>
{{elseif $_GET.msg == "suppression"}}
<p class="block confirm">Mouvement supprimé</p>
{{/if}}
{{elseif $_GET.err}}
{{if $_GET.msg == "suppression"}}
<p class="block error">Ce mouvement ne peut être supprimé</p>
{{/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 var="selected_category" from="module.config.%s_cat_key"|args:$_GET.output_type}}
{{elseif $_GET.cat_key == -1}}
{{:assign selected_category=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}}
{{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 *}}
{{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'}}
{{: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}}
{{: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="?output_type=%s&cat_key=-1"|args:$_GET.output_type}}
{{#load type="category" order="$$.name"}}
{{:assign
var="cat_options."
value=$key
label=$name
href="?output_type=%s&cat_key=%s"|args:$_GET.output_type:$key
}}
{{/load}}
<fieldset class="shortFormRight">
<legend>Filtrer par catégorie</legend>
{{:dropdown
title="Filtrer par catégorie"
options=$cat_options
value="%s"|args:$selected_category
}}
</fieldset>
<div class="shortFormLeft">
<p class="help">Historique des {{$label}}s</p>
</div>
{{* 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 DESC, user
;
!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}}
<table class="list">
<thead>
<tr>
<td>Date</td>
<td>Mouvement</td>
<td>Opération</td>
<td>Matériel</td>
<td class="num">Quantité</td>
<td>Dépositaire</td>
<td>Stockage</td>
<td>Documents</td>
<td>Écritures</td>
<td>Remarque</td>
<td class="actions"></td>
</tr>
</thead>
<tbody>
{{:assign premier=false}}
{{/if}}
<tr>
<td>{{$date|date_short}}</td>
<td>{{if $direction == "input"}}Entrée{{else}}Sortie{{/if}}</td>
<td>{{$op_label}}</td>
<td>{{$materiel}}</td>
<td class="num">{{$amount}}</td>
<td>{{:link href="/admin/users/details.php?id=%s"|args:$user_id label="%s"|args:$user}}</td>
<td>{{$stockage}}</td>
<td class="num">{{if $nb_files > 0}}{{:icon shape="attach"}}{{/if}}</td>
<td class="num">{{if $transactions != null}}{{:icon shape="money"}}{{/if}}</td>
<td>{{$comment}}</td>
<td class="actions">
{{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&prop=1&from=%s"|args:$key:$from
shape="eye"
}}
</td>
</tr>
{{else}}
<p class="block alert">Aucun mouvement.</p>
{{/select}}
</tbody>
</table>
{{else}}
<p class="block alert">Aucun mouvement.</p>
{{/if}}
{{:admin_footer}}

View file

@ -51,13 +51,13 @@
json_extract(mvt.document, '$.amount') as amount, json_extract(mvt.document, '$.amount') as amount,
COALESCE((SELECT COALESCE((SELECT
json_extract(links.document, '$.temp_key') json_extract(links.document, '$.temp_key')
FROM {!$module.table} AS links FROM !table AS links
WHERE json_extract(links.document, '$.temp_key') = mvt.key WHERE json_extract(links.document, '$.temp_key') = mvt.key
OR json_extract(links.document, '$.return') = mvt.key), mvt.key) OR json_extract(links.document, '$.return') = mvt.key), mvt.key)
AS out_temp_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 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 ON json_extract(mvt.document, '$.equipment') = eqpmt.key
WHERE users.id = :user WHERE users.id = :user
AND eqpmt.key = :eqpmt_key AND eqpmt.key = :eqpmt_key
@ -65,6 +65,7 @@
OR json_extract(mvt.document, '$.operation') IN !input_types) OR json_extract(mvt.document, '$.operation') IN !input_types)
ORDER BY out_temp_key, date ORDER BY out_temp_key, date
; ;
!table=$module.table
:user = $_GET.id :user = $_GET.id
:eqpmt_key = $_GET.key|trim :eqpmt_key = $_GET.key|trim
!output_types=$output_types.temporaire !output_types=$output_types.temporaire

View file

@ -207,12 +207,25 @@
transactions=$transactions transactions=$transactions
return_date=$return_date|parse_date return_date=$return_date|parse_date
}} }}
{{if $_GET.from == "lh"}}
{{:assign from="../loan_history.html"}} {{if $_GET.from|substr:0:1 == "l"}}
{{else}} {{:assign output_type="loan"}}
{{:assign from="../equipment_history.html"}} {{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}} {{/if}}
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=copie"|args:$from:$eqpmt_key:$prop}}
{{/form}} {{/form}}
{{if $mvt_new.direction == "input"}} {{if $mvt_new.direction == "input"}}

View file

@ -23,11 +23,25 @@
{{:include file="../_get_config.html" keep="config"}} {{:include file="../_get_config.html" keep="config"}}
{{#form on="delete"}} {{#form on="delete"}}
{{if $_GET.from == "lh"}} {{if $_GET.from|substr:0:1 == "l"}}
{{:assign from="../loan_history.html"}} {{:assign output_type="loan"}}
{{else}} {{elseif $_GET.from|substr:0:1 == "r"}}
{{:assign from="../equipment_history.html"}} {{:assign output_type="rent"}}
{{/if}} {{/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 *}} {{* vérifier s'il est possible de supprimer le mouvement *}}
{{if $mvt_suppr.direction == 'input'}} {{if $mvt_suppr.direction == 'input'}}
{{:assign var="type_operation" from="config.input_nature.%s.type"|args:$mvt_suppr.operation}} {{:assign var="type_operation" from="config.input_nature.%s.type"|args:$mvt_suppr.operation}}
@ -36,7 +50,7 @@
{{:assign link_key=$key}} {{:assign link_key=$key}}
{{/load}} {{/load}}
{{if $link_key != null}} {{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}} {{/if}}
{{else}} {{else}}
{{:assign dispo=0}} {{:assign dispo=0}}
@ -69,7 +83,7 @@
{{* problème ? *}} {{* problème ? *}}
{{if $dispo < 0 || $nonprop < 0}} {{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}}
{{/if}} {{/if}}
{{/load}} {{/load}}
@ -90,7 +104,7 @@
{{:assign link_key=$key}} {{:assign link_key=$key}}
{{/load}} {{/load}}
{{if $link_key != null}} {{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}} {{/if}}
{{elseif $type_operation == 'retour'}} {{elseif $type_operation == 'retour'}}
{{#load type="link" where="$$.return = :key" :key=$_GET.key}} {{#load type="link" where="$$.return = :key" :key=$_GET.key}}
@ -155,11 +169,11 @@
out=$curr_eqpmt.out out=$curr_eqpmt.out
notowned=$curr_eqpmt.notowned 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}} {{else}}
{{* supprimer le matériel *}} {{* supprimer le matériel *}}
{{:delete key=$curr_eqpmt.key}} {{: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}} {{/if}}
{{/form}} {{/form}}

View file

@ -34,14 +34,15 @@
{{#select {{#select
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
FROM {!$module.table} AS mvt FROM !table AS mvt
LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key') LEFT JOIN !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') LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE WHERE
json_extract(mvt.document, '$.operation') IN !op json_extract(mvt.document, '$.operation') IN !op
AND mvt.key = :mvt_key AND mvt.key = :mvt_key
GROUP by mvt.key GROUP by mvt.key
; ;
!table=$module.table
!op = $operations !op = $operations
:mvt_key = $_GET.key :mvt_key = $_GET.key
}} }}

View file

@ -224,12 +224,25 @@
transactions=$transactions transactions=$transactions
return_date=$return_date|parse_date return_date=$return_date|parse_date
}} }}
{{if $_GET.from == "lh"}}
{{:assign from="../loan_history.html"}} {{if $_GET.from|substr:0:1 == "l"}}
{{else}} {{:assign output_type="loan"}}
{{:assign from="../equipment_history.html"}} {{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}} {{/if}}
{{:redirect force="%s?ok=1&key=%s&prop=%s&msg=modification"|args:$from:$eqpmt_key:$prop}}
{{/form}} {{/form}}
{{if $mvt_new.direction == "input"}} {{if $mvt_new.direction == "input"}}

View file

@ -9,6 +9,7 @@
paramètres : paramètres :
- key : clé du mouvement - key : clé du mouvement
- prop = 1 si matériel appartient à l'asso - 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"}} {{:admin_header title="Détails du mouvement" custom_css="../style.css" current="module_equipment"}}

View file

@ -34,14 +34,15 @@
{{#select {{#select
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS exterieur json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS exterieur
FROM {!$module.table} AS mvt FROM !table AS mvt
LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key') LEFT JOIN !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') LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
WHERE WHERE
json_extract(mvt.document, '$.operation') IN !op json_extract(mvt.document, '$.operation') IN !op
AND mvt.key = :mvt_key AND mvt.key = :mvt_key
GROUP by mvt.key GROUP by mvt.key
; ;
!table=$module.table
!op = $operations !op = $operations
:mvt_key = $_GET.key :mvt_key = $_GET.key
}} }}

View file

@ -44,9 +44,9 @@
json_extract(mvt.document, '$.amount') AS qte, json_extract(mvt.document, '$.amount') AS qte,
json_extract(mvt.document, '$.return_date') AS return_date, json_extract(mvt.document, '$.return_date') AS return_date,
json_extract(mvt.document, '$.operation') AS operation 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 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 WHERE
users.id = :user users.id = :user
AND AND
@ -57,6 +57,7 @@
json_extract(mvt.document, '$.operation') IN !input_types) json_extract(mvt.document, '$.operation') IN !input_types)
ORDER BY eqpmt_name, date ORDER BY eqpmt_name, date
; ;
!table=$module.table
:user = $user.id :user = $user.id
!output_types=$output_types.temporaire !output_types=$output_types.temporaire
!input_types=$input_types.retour !input_types=$input_types.retour
@ -165,15 +166,16 @@
json_extract(mvt.document, '$.operation') as operation, json_extract(mvt.document, '$.operation') as operation,
MIN(json_extract(mvt.document, '$.date')) as date, MIN(json_extract(mvt.document, '$.date')) as date,
SUM(json_extract(mvt.document, '$.amount')) as amount 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 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 ON json_extract(mvt.document, '$.equipment') = eqpmt.key
WHERE users.id = :user WHERE users.id = :user
AND json_extract(mvt.document, '$.operation') IN !output_types AND json_extract(mvt.document, '$.operation') IN !output_types
GROUP BY eqpmt_key, operation GROUP BY eqpmt_key, operation
ORDER BY eqpmt_name, date ORDER BY eqpmt_name, date
; ;
!table=$module.table
:user = $user.id :user = $user.id
!output_types=$output_types.définitif !output_types=$output_types.définitif
assign="def_mat." assign="def_mat."