-
Notifications
You must be signed in to change notification settings - Fork 2
/
modif-educ.php
150 lines (140 loc) · 8.65 KB
/
modif-educ.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
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
<?php
session_start();
require_once("./function.php");
require_once("./db.php");
if (isset($_GET['action']) && !empty($_GET['action']) && $_GET['action'] == "logout") {
clean_php_session();
header("location: index.php");
}
if (isset($_GET["idEduc"]) && !empty($_GET["idEduc"]) && isInteger($_GET["idEduc"])) {
$idEduc = $_GET["idEduc"];
//recupérer les infos selon l'id educateur
$info = $db->prepare("SELECT educ.nom, educ.prenom, educ.mail, educ.responsable FROM educ WHERE educ.idEduc = ? AND educ.COSU = 0");
$info->bindValue(1, $idEduc);
$info->execute();
if ($info->rowCount() > 0) {
$getinfo = $info->fetch(PDO::FETCH_ASSOC);
$firstname_educ = $getinfo["prenom"];
$lastname_educ = $getinfo["nom"];
$mail_educ = $getinfo["mail"];
$resp_educ = $getinfo["responsable"];
//recuperer les categories selon l'id educateur
$info_categories = $db->prepare("SELECT categorieeduc.idCategorie FROM educ INNER JOIN categorieeduc ON categorieeduc.idEduc = educ.idEduc WHERE educ.idEduc = $idEduc");
$info_categories->execute();
if ($info_categories->rowCount() > 0) { //if the educ is associate with categorie(s), get the name of the categorie(s)
$getinfo_categories = $info_categories->fetchAll(PDO::FETCH_ASSOC);
foreach ($getinfo_categories as $value) {
$info_categorie = $db->prepare("SELECT nomCategorie FROM categorie INNER JOIN categorieeduc ON categorieeduc.idCategorie = categorie.idCategorie WHERE categorie.idCategorie = ? ");
$info_categorie->bindValue(1, $value["idCategorie"]);
$info_categorie->execute();
$getinfo_categorie = $info_categorie->fetch(PDO::FETCH_ASSOC);
$categories_educ[] = $getinfo_categorie["nomCategorie"];
}
}
} else { //Educateur est introuvable
header("location: ./educateurs.php");
create_flash_message("not_found", "Éducateur introuvable.", FLASH_ERROR);
exit();
}
} else {
header("location: ./educateurs.php");
create_flash_message("modif_error", "Une erreur est survenue, Veuillez réessayer.", FLASH_ERROR);
exit();
} ?>
<!DOCTYPE html>
<html lang="fr">
<head> <?php require("./components/head.php"); ?>
<title>Modification d'éducateur - A.S. BEUVRY LA FORÊT</title>
</head>
<body>
<?php if (is_logged()) : ?>
<div class="content">
<?php include('./components/header.php'); ?>
<div class="container">
<div class="container-content">
<?php include "./components/display_error.php"; ?>
<div class="modif-li-container">
<div class="modif-li-panel">
<h1>
Modifier un Éducateur
</h1>
<form action="./functions/educ-modif.php" method="POST">
<div class="form-modif-li">
<input value="<?= htmlspecialchars($lastname_educ) ?>" type="text" class="nom-licencie" placeholder="" name="nom-educ" maxlength="20">
<input value="<?= htmlspecialchars($firstname_educ) ?>" type="text" class="prenom-licencie" placeholder="" name="prenom-educ" maxlength="15">
</div>
<div class="form-modif-li">
<input type="password" class="password-licencie" name="password-educ" placeholder="••••••••" maxlength="40">
<label for="" style="display:flex; justify-content: space-between; align-items: center;" onclick="displayModal('cate-educ-div')">Catégories <i class="fa fa-angle-down"></i></label>
</div>
<div class="form-modif-li list-cate-div" id="cate-educ-div">
<div class="spacer-form"></div>
<div class="cate-lign" id="cate-educ">
<?php
$req = $db->prepare("CALL PRC_LSTCAT"); //Liste des catégories
$req->execute();
$rowCount = $req->rowCount();
if ($rowCount > 0) :
$rows = $req->fetchAll(PDO::FETCH_ASSOC);
$req->closeCursor();
foreach ($rows as $CAT) : ?>
<div class="cate-check">
<p style="cursor: default; border: none;"><?= $CAT["nomCategorie"] ?></p>
<input type="checkbox" name="<?= $CAT["nomCategorie"] ?>-cb" <?php
if (isset($categories_educ)) :
foreach ($categories_educ as $value) :
if ($value == $CAT["nomCategorie"]) : ?> checked <?php endif;
endforeach;
endif; ?>>
</div>
<?php
endforeach;
else :
?>
<span>Aucune catégorie disponible</span>
<?php
endif;
?>
</div>
</div>
<div class="mail-form-modif-li">
<input value="<?= htmlspecialchars($mail_educ) ?>" type="mail" class="mail-licencie" name="mail-educ" placeholder="" maxlength="40">
</div>
<div class="form-add form-modif-li list-cate-div">
<div class="responsable">
<label for="check-resp">
Responsable
</label>
<input id="check-resp" type="checkbox" style="margin:0;" <?php if ($resp_educ) : ?> checked <?php endif; ?>>
</div>
</div>
<input type="hidden" name="idEduc" value="<?php if (isset($idEduc)) {
echo $idEduc;
} ?>">
<div class="loading" id='loading'>
<img src="./public/images/Rolling-1s-200px-gray.svg">
</div>
<div class="form-modif-li">
<input type="submit" value="Enregistrer" name="submit-modif" class="bouton-ajouter" id="form-submit" onclick="loading()">
</div>
</form>
</div>
</div>
<!-- <div class="return deconnect">
<a href="./educateurs.php">Annuler</a>
</div> -->
</div>
</div>
</div>
<script>
function displayModal(idModal) {
document.getElementById(idModal).style.display = "flex";
}
function erase(idModal) {
document.getElementById(idModal).style.display = "none";
}
</script>
<?php require './components/footer.php'; ?>
<?php else : require "./components/form_login.php"; ?><?php endif; ?>
</body>
</html>