-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
128 lines (107 loc) · 4.37 KB
/
admin.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
<?php
include_once "admin-verification.php";
include_once "info-helper.php";
include_once "accesbd.class.php";
$monacces = new AccesBD();
if (estRetourFormulaire()) {
$message = majAdmin($_POST);
}
//Affichage
include "header.php";
include_once "config.php";
?>
<div class="container">
<div class="page-header">
<div id="message">
<?php
if (isset($message)) {
echo $message;
}
?>
</div>
<h1>Section Administrateur</h1>
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#users" role="tab" data-toggle="tab">Utilisateurs</a></li>
<li><a href="#config" role="tab" data-toggle="tab">Configuration</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="users"><br>
<button class="btn btn-success alignleft" onclick="window.location.href='admin-put.php'">Nouvel
utilisateur
</button>
<br><br>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Image</th>
<th>Employé</th>
<th>Utilisateur</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$users = (new EmployeDao())->getAll();
foreach ($users as $user) {
echo "<tr>";
echo "<td><b>" . $user['id'] . "</b></td>";
if ($user['picture'] != "") {
echo "<td><img src='picture.php?id=" . $user['id'] . "' width=100px></td>";
} else {
echo "<td></td>";
}
echo "<td>" . $user['firstName'] . " " . $user['lastName'];
if ($user['isAdmin'] != 0) {
echo " (admin)";
}
echo "<br><a href=\"mailto:" . $user['email']
. "\">" . $user['email'] . "</a>";
if ($user['hasRpi']) {
echo "<br><b>RPi</b> (" . retourneRpiIp($user['id']) . ")";
}
echo "</td>";
echo "<td>" . $user['username'] . "</td>";
echo "<td><button class='btn btn-warning' onclick='window.location.href=\"admin-put.php?id=" . $user['id'] . "\"'>Modifier</button></td>";
echo "<td><button class='btn btn-danger' onclick=\"sweetConfirmDelete(" . $user['id'] . ");\">Supprimer</button></td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
<div class="tab-pane" id="config"><br>
<form method="post" action="admin.php">
<label>Réseau RPi :
<input type="text" name="rpiAddress" value="<?php echo RPI_IP_BEGINNING_ADRESS ?>"
maxlength="20">
</label><br>
<label>Domaine Mailgun :
<input type="text" name="mailgunDomain" value="<?php echo $monacces->getMailgunDomain() ?>">
</label><br>
<label>Clé API Mailgun :
<input type="text" name="mailgunApiKey" value="<?php echo $monacces->getMailgunApiKey() ?>">
</label><br>
<button class="btn btn-primary" type="submit">Modifier</button>
</form>
<p></div>
</div>
</div>
</div>
<script language="JavaScript">
function sweetConfirmDelete(id) {
swal({
title: "Suppression",
text: "Êtes-vous sûr de vouloir supprimer cet usager?",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Supprimer'
},
function () {
window.location.href = "admin-supprimer.php?id=" + id;
});
}
</script>
<?php include "footer.php"; ?>