This repository has been archived by the owner on Jul 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgestion-concours.php
219 lines (210 loc) · 8.63 KB
/
gestion-concours.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
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
<?php
require_once 'root.php';
if (isset($_GET['conc_id'])) {
// echo "<div style='background-color: red'>" . $_GET['conc_id'] . "</div>";
$conc_id = $_GET['conc_id'];
$result = $connection->query("SELECT * FROM concours WHERE conc_id='$conc_id'");
$row = $result->fetch_array(MYSQLI_ASSOC);
$theme = html_entity_decode($row['theme']);
$num_pl = $row['num_pl'];
$d_insc_debut = $row['d_insc_debut'];
$d_insc_fin = $row['d_insc_fin'];
$d_doc = $row['d_doc'];
$d_passe_conc = $row['d_passe_conc'];
$d_resu_conc = $row['d_resu_conc'];
$d_fin = $row['d_fin'];
// $result = $connection->query("SELECT * FROM etudiant WHERE conc_id='$conc_id'");
echo <<< _BEGIN
<div>
_BEGIN;
echo <<< _RESPONSE
<form method="GET" id="modify-conc">
<table>
<tr>
<th>Thème:</th>
<th>Nombre des places:</th>
<th>Debut d'inscription:</th>
<th>Fin d'inscription:</th>
<th>Fin d'acceptation des documents:</th>
<th>Date de l'éxamen:</th>
<th>Date de résultat:</th>
<th>Dernière date d'affichage:</th>
</tr>
<tr>
<td><input id="modify-theme" type="text" name="theme" required></td>
<td><input id="modify-num_pl" type="number" name="num_pl" required></td>
<td><input id="modify-d_insc_debut" type="date" name="d_insc_debut" required></td>
<td><input id="modify-d_insc_fin" type="date" name="d_insc_fin" required></td>
<td><input id="modify-d_doc" type="date" name="d_doc" required></td>
<td><input id="modify-d_passe_conc" type="date" name="d_passe_conc" required></td>
<td><input id="modify-d_resu_conc" type="date" name="d_resu_conc" required></td>
<td><input id="modify-d_fin" type="date" name="d_fin" required></td>
</tr>
</table>
</form>
<div id="modify-conc-msg"></div>
<input type="submit" form="modify-conc" value="Modifier" style="margin-top: 20px; float:right;">
<script id="modify-conc-script">
conc_tr = document.getElementById('modify-conc').children[0].children[0].children[1];
conc_tr.children[0].children[0].value = "$theme";
conc_tr.children[1].children[0].value = "$num_pl";
conc_tr.children[2].children[0].value = "$d_insc_debut";
conc_tr.children[3].children[0].value = "$d_insc_fin";
conc_tr.children[4].children[0].value = "$d_doc";
conc_tr.children[5].children[0].value = "$d_passe_conc";
conc_tr.children[6].children[0].value = "$d_resu_conc";
conc_tr.children[7].children[0].value = "$d_fin";
document.getElementById('modify-conc').onsubmit = (e) => {
e.preventDefault();
conc_id = document.getElementById('concours-select').value;
request = new XMLHttpRequest();
theme = document.getElementById('modify-theme').value;
num_pl = document.getElementById('modify-num_pl').value;
d_insc_debut = document.getElementById('modify-d_insc_debut').value;
d_insc_fin = document.getElementById('modify-d_insc_fin').value;
d_doc = document.getElementById('modify-d_doc').value;
d_passe_conc = document.getElementById('modify-d_passe_conc').value;
d_resu_conc = document.getElementById('modify-d_resu_conc').value;
d_fin = document.getElementById('modify-d_fin').value;
request.open("GET", `modify-concours.php?
conc_id=` + $conc_id + `&
theme=` + theme + `&
num_pl=` + num_pl + `&
d_insc_debut=` + d_insc_debut + `&
d_insc_fin=` + d_insc_fin + `&
d_doc=` + d_doc + `&
d_passe_conc=` + d_passe_conc + `&
d_resu_conc=` + d_resu_conc + `&
d_fin=` + d_fin, true
);
request.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseText != null) {
let modify_conc_msg = document.getElementById('modify-conc-msg');
modify_conc_msg.innerHTML = this.responseText
} else alert("Communication error: No data received")
} else alert("Communication error: " + this.statusText)
}
}
request.send(null)
}
</script>
_RESPONSE;
echo <<< _STUDENT_BEGIN
<div style="padding: 20px 20px 0;">
<form method="GET" id="etd" style="padding: 50px 50px 0;">
<table id="etat-etd" style="border: 1px black solid">
<tr>
<th>Nom:</th>
<th>Prénom:</th>
<th>État:</th>
<th>Note:</th>
</tr>
_STUDENT_BEGIN;
$result = $connection->query("SELECT * FROM etudiant WHERE conc_id='$conc_id'");
for ($i = 0; $i < $result->num_rows; ++$i) {
$row = $result->fetch_array(MYSQLI_ASSOC);
$mat = $row['mat'];
$nom = $row['nom'];
$prenom = $row['prenom'];
$etat = $row['etat'];
$note = $row['note'];
// echo '$note: ' . $note;
echo <<< _TD
<tr>
<td><p>$nom</p></td>
<td><p>$prenom</p></td>
<td>
<select name="etat-select" class="etat-select">
<option value="att">En Attente</option>
<option value="doc">Ses documents sont réçu</option>
<option value="ref">Les documents sont réfusés</option>
<option value="can">Les documents sont vérifiés</option>
<option value="pas">L'examen est passé</option>
<option value="reu">A réussi</option>
<option value="nre">Échoué</option>
</select>
</td>
<td>
<input type="number" name="note" class="note" step="0.25">
<input type="hidden" name="mat" value="$mat">
</td>
<script>
Array.from(document.getElementsByName('etat-select')[$i].children).forEach((element) => {
if (element.value == '$etat')
element.selected = true;
});
if('$note')
document.getElementsByName('note')[$i].value = '$note';
</script>
</tr>
_TD;
}
echo <<< _STUDENT_END
</table>
</form>
</div>
<div id="etd-msg"></div>
<input type="submit" form="etd" value="Mettre à jour" style="margin-top: 20px; float:right;">
<script>
var etatSelect = Array.from(document.getElementsByName('etat-select'));
var note = Array.from(document.getElementsByName('note'));
var mat = Array.from(document.getElementsByName('mat'));
var varsString = '';
document.getElementById('etd').onsubmit = (event) => {
event.preventDefault();
varsString = '';
for (i = 0; i < etatSelect.length; i++) {
varsString += 'etat[]=' + etatSelect[i].value +'&';
}
for (i = 0; i < note.length; i++) {
varsString += 'note[]=' + note[i].value +'&';
}
for (i = 0; i < mat.length; i++) {
varsString += 'mat[]=' + mat[i].value +'&';
}
request = new XMLHttpRequest();
request.open('GET', 'update-etudiants.php?' + varsString.substring(0, varsString.length-1), true);
request.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseText != null) {
document.getElementById('etd-msg').innerHTML = this.responseText;
} else alert("Communication error: No data received")
} else alert("Communication error: " + this.statusText)
}
}
request.send(null);
}
</script>
</div>
<div style="text-align: center; height: 50px; width: 100%; margin-top: 150px;">
<form id="rm-conc" action="delete-concours.php" method="get">
<input type="submit" value="Supprimer Le Concours" style="background-color: red; color: white;">
</form>
<script>
document.getElementById('rm-conc').onsubmit = (e) => {
e.preventDefault();
if (confirm("Est-ce que vous êtes sure de supprimer ce thème?")) {
console.log('hi')
conc_id = document.getElementsByName('conc_id')[0].value;
request = new XMLHttpRequest();
request.open('GET', 'delete-concours.php?' + `conc_id=${conc_id}`, true);
request.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseText != null) {
document.getElementById('concours-space').innerHTML = this.responseText;
} else alert("Communication error: No data received")
} else alert("Communication error: " + this.statusText)
}
}
request.send(null);
}
}
</script>
</div>
_STUDENT_END;
}
?>