-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdispositif.sql
85 lines (76 loc) · 2.25 KB
/
dispositif.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
SELECT 'redirect' AS component,
'signin.sql?error' AS link
WHERE NOT EXISTS (SELECT 1 FROM login_session WHERE id=sqlpage.cookie('session'));
SET group_id = (SELECT user_info.groupe FROM login_session join user_info on user_info.username=login_session.username WHERE id = sqlpage.cookie('session'));
SELECT 'redirect' AS component,
'index.sql?restriction' AS link
WHERE $group_id<3;
-- Enregistrer la notification dans la base
INSERT INTO dispositif(dispo, coordo)
SELECT :dispo as dispo,
coalesce(:coordo,0) as coordo
WHERE :dispo IS NOT NULL;
--Menu
SELECT 'dynamic' AS component, sqlpage.read_file_as_text('menu.json') AS properties;
-- Sous Menu
SET page='Dispositifs';
select 'dynamic' as component, sqlpage.run_sql('menu_parametres.sql') as properties;
-- Sous Menu Ajout/suppression dispositif
select
'button' as component,
'sm' as size,
'pill' as shape;
select
'Ajouter' as title,
'dispositif_ajout.sql' as link,
'square-rounded-plus' as icon,
$group_id<3 as disabled,
'green' as outline;
select
'Supprimer' as title,
'dispositif_delete.sql' as link,
'trash' as icon,
$group_id<3 as disabled,
'red' as outline;
-- Liste des dispositifs
SELECT 'table' as component,
'Liste des dispositifs' AS title,
'icone' as icon,
'Coordonnateur' as markdown,
'Accompagnement' as markdown;
SELECT
'lifebuoy' as icone,
dispo AS Dispositif,
CASE WHEN coordo=1 and $group_id>2
THEN '[
![](./icons/select.svg)
](/dispositif/indisponible.sql?id='||dispositif.id||')'
WHEN coordo=0 and $group_id>2
THEN '[
![](./icons/square.svg)
](/dispositif/disponible.sql?id='||dispositif.id||')'
WHEN coordo=1 and $group_id<3
THEN '[
![](./icons/select.svg)
]()'
ELSE '[
![](./icons/square.svg)
]()'
END as Coordonnateur,
CASE WHEN accomp=1 and $group_id>2
THEN '[
![](./icons/select.svg)
](/dispositif/accomp_moins.sql?id='||dispositif.id||')'
WHEN coalesce(accomp,0)=0 and $group_id>2
THEN '[
![](./icons/square.svg)
](/dispositif/accomp_plus.sql?id='||dispositif.id||')'
WHEN accomp=1 and $group_id<3
THEN '[
![](./icons/select.svg)
]()'
ELSE '[
![](./icons/square.svg)
]()'
END as Accompagnement
FROM dispositif order by dispo;