-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusuario.php
234 lines (215 loc) · 6.04 KB
/
usuario.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
session_start();
if(!isset($_SESSION['logado'])){
header("location: login.php");
}
if($_SESSION['permissao']==1){
header("location: redirect.php");
}
require 'connect.php';
?>
<!------BY BRUNO VASCONCELLOS - VIP DESENVOLVIMENTO------->
<!DOCTYPE html>
<!------BY BRUNO VASCONCELLOS - VIP DESENVOLVIMENTO------->
<html>
<head>
<title>Usuario</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="icon" type="icon" href="img/favicon.png">
<script src="js/jquery-3.2.1.slim.min.js"></script>
<script src="js/bootstrap.js"></script>
<style>
.del{
border-radius: 100%;
background-color: #ff0000a8;
padding-top: 3px;
color: white;
font-weight: bold;
font-family: Arial;
width: 30px;
}
.del:hover{
background-color: red;
}
</style>
<script>
function deletarUser(tx){
var opp = confirm("Deseja realmente deletar Usuario?");
if(opp){
location.href = "deluser.php?ident="+tx;
}
}
</script>
</head>
<body>
<table align="center" width="100%" style="background-color: #150a50" border="0">
<tr>
<td align="right" style="width: 46%">
<a href="index2.php">
<img src="img/vip-white.png" width="100%" style="max-width: 200px">
</a>
</td>
<td>
<font style="font-weight: bold; font-size: 24px; font-family: Verdana; color: white">Usuario</font>
</td>
</tr>
</table>
<div style="position: absolute; right: 2px; top: 2px;" onclick="sair()">
<img src="img/sairr.png" width="60px" title='Sair'>
</div>
<script>
function sair(){
var op = confirm("Deseja realmente sair?");
if(op){
location.href = 'logout.php';
}
}
</script>
<div class="container">
<center>
<button class="btn btn-success" style="margin: 20px;" data-toggle='modal' data-target='#novo'>Adicionar Novo</button>
<button class="btn btn-success" style="margin: 20px;" data-toggle='modal' data-target='#self'>Trocar senha</button>
</center>
<?php
$query = "SELECT * FROM usuarios where id != '1' ";
$result = mysqli_query($connection, $query);
$result->data_seek(0);
echo "<table class='table'>";
echo "<th>Nome</th> <th>Usuario</th> <th>Tipo</th>";
while($row = $result->fetch_assoc()){
$tipo = $row['tipo'];
if($tipo == 0){
$tipo = "Administrador";
}else{
$tipo = "Agente";
}
echo "
<tr>
<td>
".$row['name']."
</td>
<td>
".$row['username']."
</td>
<td>
".$tipo."
</td>
<td>
<button class='del' onclick='deletarUser(".$row['id'].")'>X</button>
</td>
</tr>
";
}
echo "</table>";
?>
</div>
<div class='modal fade' id='novo' tabindex='-1' role='dialog' aria-labelledby='novo' aria-hidden='true'>
<div class='modal-dialog' role='document'>
<div class='modal-content'>
<div class='modal-header'>
<h5 class='modal-title' id='Novo'>Novo Usuario</h5>
<button type='button' class='close' data-dismiss='modal' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>
<form action='addnewuser.php' method='POST'>
<div class='modal-body'>
<table>
<tr>
<td align="right">
<label>Nome Completo:</label>
</td>
<td>
<input type="text" name="nome" class="form-control" minlength="3" required autofocus>
</td>
</tr>
<tr>
<td align="right">
<label>Usuario:</label>
</td>
<td>
<input type="text" name="user_name" class="form-control" minlength="3" required>
</td>
</tr>
<tr>
<td align="right">
<label>Senha:</label>
</td>
<td>
<input type="password" name="password" class="form-control" minlength="3" required>
</td>
</tr>
<tr>
<td align="right">
<label>Tipo:</label>
</td>
<td>
<select name='tipo' class="form-control">
<option value="1">Agente</option>
<option value="0">Administrador</option>
</select>
</td>
</tr>
</table>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-outline-danger' data-dismiss='modal'>Cancelar</button>
<button type='submit' class='btn btn-primary'>Adicionar</button>
</div>
</form>
</div>
</div>
</div>
<div class='modal fade' id='self' tabindex='-1' role='dialog' aria-labelledby='self' aria-hidden='true'>
<div class='modal-dialog' role='document'>
<div class='modal-content'>
<div class='modal-header'>
<h5 class='modal-title' id='self'>Atualizar</h5>
<button type='button' class='close' data-dismiss='modal' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>
<form action='ttsstt.php' method='POST'>
<div class='modal-body'>
<table>
<tr>
<td align="right">
<label>Usuario:</label>
</td>
<td>
<input type="text" name="user_name" class="form-control" minlength="3" value="<?= $_SESSION['userr']; ?>" required>
</td>
</tr>
<tr>
<td align="right">
<label>Senha:</label>
</td>
<td>
<input type="password" name="password" class="form-control" minlength="3" required>
</td>
</tr>
</table>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-outline-danger' data-dismiss='modal'>Cancelar</button>
<button type='submit' name="submit" class='btn btn-primary'>Atualizar</button>
</div>
</form>
</div>
</div>
</div>
<?php
if(isset($_SESSION['alert'])){
if($_SESSION['alert']==1){
$_SESSION['alert']=0;
$msg = $_SESSION['msg'];
$tipo = $_SESSION['classe'];
echo '
<div class="alert bg-'.$tipo.' text-white" role="alert" style="position: fixed; bottom: 20px; left: 20px">
'.$msg.'
</div>';
}
}
?>
</body>
</html>