{{:assign premier=true}}
{{#select
@@ -61,29 +120,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
+ ORDER BY out_date DESC, nom
;
!table=$module.table
- !op = $output_ops
+ !op = $out_keys
+ !cat_condition=$cat_condition
}}
{{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
+
@@ -122,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"}}
+
{{* 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 @@
-
-{{* 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}}
-