-
Notifications
You must be signed in to change notification settings - Fork 3
/
etab_classes_boutons.sql
231 lines (211 loc) · 8.51 KB
/
etab_classes_boutons.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
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,
'etablissement.sql?restriction' AS link
FROM eleve WHERE (SELECT user_info.etab FROM login_session join user_info on user_info.username=login_session.username WHERE id = sqlpage.cookie('session') and user_info.etab<>$id);
--Menu
SELECT 'dynamic' AS component,
CASE WHEN $group_id=1
THEN sqlpage.read_file_as_text('index.json')
ELSE sqlpage.read_file_as_text('menu.json')
END AS properties;
-- Sous-menu / bascule
select
'button' as component,
'sm' as size,
--'pill' as shape,
'center' as justify;
select
'AESH' as title,
'etab_aesh.sql?id=' || $id as link,
'user-plus' as icon,
'orange' as outline
WHERE $group_id>1;
select
'Suivis' as title,
'etab_suivi.sql?id=' || $id ||'&tab=Acc' as link,
'list-check' as icon,
'orange' as outline;
select
'Classes' as title,
'users-group' as icon,
'orange' as color;
select
'Dispositifs' as title,
'etab_dispositifs.sql?id=' || $id as link,
'lifebuoy' as icon,
'orange' as outline;
select
'Notifications' as title,
'etab_notif.sql?id=' || $id as link,
'certificate' as icon,
'orange' as outline;
select
'Examens' as title,
'etab_examen.sql?id=' || $id as link,
'school' as icon,
'orange' as outline;
select
'Carte' as title,
'etab_carte.sql?id=' || $id as link,
'map' as icon,
'teal' as outline;
select
'Stats' as title,
'etab_stats.sql?id=' || $id as link,
'chart-histogram' as icon,
'teal' as outline;
select
'Photos' as title,
'etab_trombi.sql?id=' || $id as link,
'camera' as icon,
'teal' as outline;
-- Sous-menu / classes
select
'button' as component,
'sm' as size,
'pill' as shape;
select
CASE WHEN $classe_select is Null THEN 'sélectionner une classe'
ELSE 'Classe : ' || $classe_select
END as title,
'users-group' as icon,
'red' as outline;
select
eleve.classe as title,
'etab_classes.sql?id=' || etab.id || '&classe_select=' || eleve.classe as link,
'users-group' as icon,
'green' as outline
FROM etab INNER JOIN eleve on eleve.etab_id=etab.id where etab.id=$id GROUP BY eleve.classe ORDER BY eleve.classe ASC;
-- Set a variable
SET NB_eleve = (SELECT count(distinct eleve.id) FROM eleve where eleve.etab_id=$id and eleve.classe=$classe_select);
-- Personnalisation NB_accomp pour version classe :
SET NB_accomp = (SELECT count(distinct suivi.eleve_id) FROM suivi JOIN eleve on suivi.eleve_id=eleve.id WHERE suivi.aesh_id<>1 and eleve.etab_id=$id and eleve.classe=$classe_select);
SET NB_notif = (SELECT count(notification.id) FROM notification JOIN eleve on notification.eleve_id = eleve.id WHERE eleve.etab_id = $id and eleve.classe=$classe_select);
SET NB_aesh = (SELECT count(distinct suivi.aesh_id) FROM suivi JOIN eleve on suivi.eleve_id=eleve.id WHERE eleve.etab_id=$id and eleve.classe=$classe_select and suivi.aesh_id<>1);
SELECT 'text' AS component, 'Classe : ' || $classe_select AS contents;
-- écrire les infos de l'établissement dans le titre de la page [GRILLE]
SELECT
'datagrid' as component,
type || ' ' || nom_etab ||' --- Classe : ' || $classe_select as title FROM etab WHERE id = $id;
SELECT
' Élèves accompagnés : ' as title,
$NB_accomp as description,
'users-plus' as icon;
SELECT
' Élèves à suivre : ' as title,
$NB_eleve as description,
TRUE as active,
'briefcase' as icon;
SELECT
' AESH ' as title,
$NB_aesh as description,
'user-plus' as icon;
--Onglets
SET tab=coalesce($tab,'Résumé');
select 'tab' as component;
select 'Résumé' as title, 'list-check' as icon, 1 as active, 'etab_classes.sql?id='||$id||'&classe_select='|| $classe_select||'&tab=Résumé' as link, CASE WHEN $tab='Résumé' THEN 'orange' ELSE 'green' END as color;
select 'Détails' as title, 'printer' as icon, 1 as active,'etab_classes.sql?id='||$id||'&classe_select='|| $classe_select||'&tab=Détails' as link, CASE WHEN $tab='Détails' THEN 'orange' ELSE 'green' END as color;
-- Liste des élèves
SELECT 'table' as component,
TRUE as hover,
TRUE as small,
'Actions' as markdown,
'Admin' as markdown,
1 as sort,
1 as search
where $tab='Résumé';
SELECT
eleve.nom as Nom,
eleve.prenom as Prénom,
group_concat(DISTINCT dispositif.dispo) as Dispositif,
group_concat(DISTINCT SUBSTR(aesh.aesh_firstname, 1, 1) ||'. '||aesh.aesh_name) as AESH,
-- suivi.objectifs as Objectifs,
CASE
WHEN EXISTS (SELECT eleve.id FROM amenag
WHERE eleve.id = amenag.eleve_id) THEN 'black'
ELSE 'red'
END AS _sqlpage_color,
CASE WHEN suivi.aesh_id>1 and $group_id>1 THEN '[
![](./icons/user-plus.svg)
](aesh_suivi.sql?id='||suivi.aesh_id||'&tab=Profils) [
![](./icons/briefcase.svg)
](notification.sql?id='||eleve.id||'&tab=Profil)'
WHEN EXISTS (SELECT eleve.id FROM amenag WHERE eleve.id = amenag.eleve_id)
THEN
'[
![](./icons/briefcase.svg)
](notification.sql?id='||eleve.id||')'
ELSE
'[
![](./icons/alert-triangle-filled.svg)
](notification.sql?id='||eleve.id||')'
END as Actions,
CASE WHEN EXISTS (SELECT eleve.id FROM examen_eleve WHERE eleve.id = examen_eleve.eleve_id)
THEN
'[
![](./icons/school.svg)
](notification.sql?id='||eleve.id||'&tab=Examen)'
ELSE ''
END as Actions,
CASE WHEN $group_id>2 THEN
'[
![](./icons/pencil.svg)
](eleve_edit.sql?id='||eleve.id||')'
ELSE
'[
![](./icons/pencil-off.svg)
]()'
END
as Admin
FROM eleve INNER JOIN etab on eleve.etab_id = etab.id LEFT JOIN affectation on eleve.id=affectation.eleve_id LEFT JOIN dispositif on dispositif.id=affectation.dispositif_id LEFT JOIN suivi on suivi.eleve_id=eleve.id LEFT JOIN aesh on suivi.aesh_id=aesh.id LEFT JOIN notification on notification.eleve_id=eleve.id WHERE eleve.etab_id=$id and eleve.classe=$classe_select and $tab='Résumé' GROUP BY eleve.id ORDER BY eleve.nom ASC;
-- Télécharger les données
SELECT
'csv' as component,
'Exporter les suivis de la classe '|| $classe_select as title,
'Suivis'||$classe_select as filename,
'file-download' as icon,
'green' as color
where $tab='Résumé';
SELECT
eleve.classe as Classe,
eleve.nom as Nom,
eleve.prenom as Prénom,
group_concat(DISTINCT dispositif.dispo) as Dispositif,
group_concat(DISTINCT SUBSTR(aesh.aesh_firstname, 1, 1) ||'. '||aesh.aesh_name) as AESH,
notification.modalite AS Suivi,
suivi.temps as Temps,
amenag.info AS Infos,
amenag.amenagements as Aménagements,
amenag.objectifs as Objectifs
FROM eleve INNER JOIN etab on eleve.etab_id = etab.id LEFT JOIN amenag on amenag.eleve_id=eleve.id LEFT JOIN affectation on eleve.id=affectation.eleve_id LEFT JOIN dispositif on dispositif.id=affectation.dispositif_id LEFT JOIN suivi on suivi.eleve_id=eleve.id LEFT JOIN aesh on suivi.aesh_id=aesh.id LEFT JOIN notification on notification.eleve_id=eleve.id WHERE eleve.etab_id=$id and eleve.classe=$classe_select and $tab='Résumé' GROUP BY amenag.id ORDER BY eleve.nom ASC;
-- fiche détaillée des élèves suivis
-- Vers page simplifiée pour impression
select
'button' as component,
'sm' as size,
--'pill' as shape,
'end' as justify
where $tab='Détails';
select
'Visualiser pour impression' as title,
'etab_classes_print.sql?id=' || $id ||'&classe_select='|| $classe_select as link,
'printer' as icon,
'green' as outline
where $tab='Détails';
SELECT 'text' as component,
'Fiches des élèves suivis' as title
where $tab='Détails';
SELECT 'table' as component,
TRUE as hover,
TRUE as small
where $tab='Détails';
SELECT
eleve.nom||' '||eleve.prenom as élève,
group_concat(DISTINCT dispositif.dispo) as Dispositif,
amenag.info AS commentaires,
amenag.amenagements AS Aménagements,
amenag.objectifs AS Objectifs
FROM eleve LEFT JOIN etab on eleve.etab_id = etab.id LEFT JOIN amenag on amenag.eleve_id=eleve.id LEFT JOIN affectation on eleve.id=affectation.eleve_id LEFT JOIN dispositif on dispositif.id=affectation.dispositif_id WHERE eleve.etab_id=$id and eleve.classe=$classe_select and $tab='Détails' GROUP BY amenag.id ORDER BY eleve.nom ASC;