+{{:assign output_ops=$output_types|implode:","}}
+{{:assign output_ops="("|cat:$output_ops|cat:")"}}
{{:assign premier=true}}
{{#select
@@ -120,29 +61,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
- AND !cat_condition
+ 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 DESC, nom
+ ORDER BY out_date, nom
;
!table=$module.table
- !op = $out_keys
- !cat_condition=$cat_condition
+ !op = $output_ops
}}
{{if $premier}}
-
Matériel
-
Date prêt
-
Quantité
-
Membre
-
Date retour
-
Reste à rendre
-
Remarque
-
+
Matériel
+
Date prêt
+
Quantité
+
Membre
+
Date retour
+
Reste à rendre
+
Remarque
+
@@ -181,14 +122,9 @@
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=%s"|args:$mvt_key:$from
+ href="movements/movement_details.html?key=%s&prop=1&from=lh"|args:$mvt_key
shape="eye"
}}
diff --git a/loan_movements.html b/loan_movements.html
index 55d74f7..4425b03 100644
--- a/loan_movements.html
+++ b/loan_movements.html
@@ -3,66 +3,25 @@
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
{{*
- Afficher l'historique des prêts ou locations
+ Afficher l'historique des prêts
*}}
-{{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 prêts" custom_css="./style.css" current="module_equipment"}}
-{{: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"}}
-
{{* lister les mouvements *}}
@@ -134,9 +88,12 @@
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
@@ -166,11 +123,12 @@
)
SELECT * FROM sorties UNION SELECT * FROM entrees
)
- ORDER BY date DESC, user
+ 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}}
@@ -192,7 +150,7 @@
+
+{{* lister les mouvements *}}
+{{:assign premier=true}}
+{{#select * FROM
+ (WITH
+ sorties AS
+ (SELECT
+ mvt.key,
+ json_extract(mvt.document, '$.date') AS date,
+ json_extract(mvt.document, '$.direction') AS direction,
+ json_extract(mvt.document, '$.operation') AS operation,
+ json_extract(mat.document, '$.name') AS materiel,
+ json_extract(mat.document, '$.category') AS category,
+ json_extract(mvt.document, '$.amount') AS amount,
+ users.id AS user_id,
+ users.nom AS user,
+ json_extract(storage.document, '$.name') AS stockage,
+ json_extract(mvt.document, '$.transactions') AS transactions,
+ json_extract(mvt.document, '$.comment') AS comment,
+ json_extract(mvt.document, '$.return_date') AS return_date
+ FROM !table AS mvt
+ INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
+ LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
+ LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
+ WHERE json_extract(mvt.document, '$.type') = 'movement'
+ AND json_extract(mvt.document, '$.operation') IN !op
+ AND !cat_condition
+ ),
+ entrees AS
+ (SELECT
+ mvt.key,
+ json_extract(mvt.document, '$.date') AS date,
+ json_extract(mvt.document, '$.direction') AS direction,
+ json_extract(mvt.document, '$.operation') AS operation,
+ json_extract(mat.document, '$.name') AS materiel,
+ json_extract(mat.document, '$.category') AS category,
+ json_extract(mvt.document, '$.amount') AS amount,
+ users.id AS user_id,
+ users.nom AS user,
+ json_extract(storage.document, '$.name') AS stockage,
+ json_extract(mvt.document, '$.transactions') AS transactions,
+ json_extract(mvt.document, '$.comment') AS comment,
+ json_extract(mvt.document, '$.return_date') AS return_date
+ FROM !table AS mvt
+ INNER JOIN !table AS mat ON mat.key = json_extract(mvt.document, '$.equipment')
+ LEFT JOIN users ON users.id = json_extract(mvt.document, '$.user')
+ LEFT JOIN !table AS storage ON storage.key = json_extract(mvt.document, '$.storage')
+ INNER JOIN (
+ SELECT json_extract(links.document, '$.return') AS return_key
+ FROM !table AS links
+ INNER JOIN sorties ON json_extract(links.document, '$.temp_key') = sorties.key
+ ) AS filtered_links ON filtered_links.return_key = mvt.key
+ WHERE !cat_condition
+ )
+ SELECT * FROM sorties UNION SELECT * FROM entrees
+ )
+ ORDER BY date
+ ;
+ !table=$module.table
+ !op = $out_keys
+ !cat_condition=$cat_condition
+}}
+ {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
+ {{:assign file_path="%s/%s/"|args:$module.storage_root:$key}}
+ {{:assign file_path=$file_path|cat:"%"}}
+ {{#select count(*) AS nb FROM files WHERE path LIKE :file_path ; :file_path=$file_path}}
+ {{:assign nb_files=$nb}}
+ {{/select}}
+
+ {{if $premier}}
+