-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreloadFilters.php
66 lines (52 loc) · 1.76 KB
/
reloadFilters.php
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
<?php
require 'vendor/autoload.php';
require 'include/web-functions.php';
use App\Cas;
use App\DroitsUtilisateur;
const VIEW_SERVICES = "services";
const VIEW_ETABS = "etabs";
function main(): void {
try {
$cas = Cas::getInstance();
$cas->init();
$mois = $_POST["mois"];
$pos = $_POST["pos"];
$departement = [];
$etabType = [];
$etabType2 = [];
if (isset($_POST["departement"])) {
$departement = array_map('intval', $_POST["departement"]);
}
if (isset($_POST["etabType"])) {
$etabType = array_map('intval', $_POST["etabType"]);
}
if (isset($_POST["etabType2"])) {
$etabType2 = array_map('intval', $_POST["etabType2"]);
}
if(!is_numeric($mois)) {
throw new Exception('donnée de mois invalide');
}
if(!is_numeric($pos)) {
throw new Exception('donnée de position invalide');
}
$mois = intval($mois);
$pos = intval($pos);
$res = [];
$droitsUtilisateur = new DroitsUtilisateur();
switch ($pos) {
case 1:
$res['departements'] = getDepartements($droitsUtilisateur, $mois);
case 2:
$res['types'] = getTypesEtablissements($droitsUtilisateur, $mois, $departement);
case 3:
$res['types2'] = getTypes2Etablissements($droitsUtilisateur, $mois, $departement, $etabType);
case 4:
$res['etabs'] = getEtablissements($droitsUtilisateur, $mois, $departement, $etabType, $etabType2);
}
header('Content-type: application/json');
echo json_encode($res);
} catch (Exception $e) {
showException($e);
}
}
main();