-
Notifications
You must be signed in to change notification settings - Fork 3
/
etab_ajout_carte.sql
58 lines (45 loc) · 1.72 KB
/
etab_ajout_carte.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
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,
'parametres.sql?restriction' AS link
WHERE $group_id<'3';
--Menu
SELECT 'dynamic' AS component, sqlpage.read_file_as_text('menu.json') AS properties;
--Sous-menu
select 'dynamic' as component, sqlpage.run_sql('menu_parametres.sql') as properties;
-- Nouvel établissement depuis une carte
select
'form' as component,
'GET' as method,
'Chercher sur la carte' as validate;
select 'user_search' as name, 'Ville ou adresse' as label, :user_search as value;
set url = '{
"url": "https://nominatim.openstreetmap.org/search?format=json&q=' || sqlpage.url_encode(:user_search) ||'",
"headers": {"user-agent": "ecole-inclusive/1.0"}
}'
set api_results = sqlpage.fetch($url);
set lat = CAST($api_results->>0->>'lat' AS FLOAT)
set lon = CAST($api_results->>0->>'lon' AS FLOAT)
select 'map' as component,
15 as zoom,
$lat as latitude,
$lon as longitude
WHERE :user_search is not Null;
select :user_search as title,
$lat as latitude,
$lon as longitude
WHERE :user_search is not Null;
select
'button' as component,
'sm' as size,
'pill' as shape,
'center' as justify
WHERE :user_search is not Null;
select
'Ajouter dans le formulaire' as title,
'etab_ajout.sql?search='||:user_search||'&lat='||$lat||'&lon='||$lon||'&tab=2' as link,
'square-plus' as icon,
'green' as color
WHERE :user_search is not Null;