Paramétrisation nom table dans les requêtes
This commit is contained in:
parent
a2c343956c
commit
71646c9dcd
6 changed files with 31 additions and 23 deletions
|
|
@ -147,14 +147,15 @@
|
|||
{{#select
|
||||
mvt.key AS mvt_key,
|
||||
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS reste
|
||||
FROM {!$module.table} AS mvt
|
||||
LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key')
|
||||
LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
||||
FROM !table AS mvt
|
||||
LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key')
|
||||
LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
||||
WHERE
|
||||
json_extract(mvt.document, '$.operation') IN !op
|
||||
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
|
||||
GROUP by mvt.key
|
||||
;
|
||||
!table=$module.table
|
||||
!op = $operations
|
||||
:eqpmt_key = $_GET.key
|
||||
}}
|
||||
|
|
@ -250,14 +251,15 @@
|
|||
{{#select
|
||||
mvt.key AS mvt_key,
|
||||
json_extract(mvt.document, '$.amount') - IFNULL(SUM(json_extract(mvt2.document, '$.amount')), 0) AS present
|
||||
FROM {!$module.table} AS mvt
|
||||
LEFT JOIN {!$module.table} AS link ON mvt.key = json_extract(link.document, '$.temp_key')
|
||||
LEFT JOIN {!$module.table} AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
||||
FROM !table AS mvt
|
||||
LEFT JOIN !table AS link ON mvt.key = json_extract(link.document, '$.temp_key')
|
||||
LEFT JOIN !table AS mvt2 ON mvt2.key = json_extract(link.document, '$.return')
|
||||
WHERE
|
||||
json_extract(mvt.document, '$.operation') IN !op
|
||||
AND json_extract(mvt.document, '$.equipment') = :eqpmt_key
|
||||
GROUP by mvt.key
|
||||
;
|
||||
!table=$module.table
|
||||
!op = $operations
|
||||
:eqpmt_key = $_GET.key
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue