-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrolpanel.php
420 lines (319 loc) · 16.8 KB
/
controlpanel.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!DOCTYPE HTML>
<!--Se agrega la el archivo de conexión con la base de datos-->
<?php
include("SQL/selectdata.php");
include("SQL/deletedata.php");
$cedulaUsuario = json_decode(file_get_contents('SQL/txt/cedula.txt'));
$estado = json_decode(file_get_contents('SQL/txt/estado.txt'));
if(!($estado== 2)){
echo "<script>alert('Primero debes iniciar sesión!'); location.href = 'login.php'; </script>";
}
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Panel de Control - MyBunch</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="MyBunch Final Project 2018" />
<meta name="keywords" content="Pharmacy, Drugstore" />
<meta name="author" content="Andrés Bonilla" />
<!--
-----------------------------------------------
My Bunch, Proyecto de Graduación de Sexto 2018
------------------------------------------------
-->
<link rel="icon" href="images/dinosauricon.ico">
<link href="https://fonts.googleapis.com/css?family=Work+Sans:300,400,500,700,800" rel="stylesheet">
<!-- Animate.css -->
<link rel="stylesheet" href="css/animate.css">
<!-- Icomoon Icon Fonts-->
<link rel="stylesheet" href="css/icomoon.css">
<!-- Bootstrap -->
<link rel="stylesheet" href="css/bootstrap.css">
<!-- Magnific Popup -->
<link rel="stylesheet" href="css/magnific-popup.css">
<!-- Owl Carousel -->
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="css/style.css">
<!-- Modernizr JS -->
<script src="js/modernizr-2.6.2.min.js"></script>
<!-- FOR IE9 below -->
<!--[if lt IE 9]>
<script src="js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="fh5co-loader"></div>
<div id="page">
<nav class="fh5co-nav" role="navigation">
<div class="top-menu">
<div class="container">
<div class="row">
<div class="col-xs-12 text-right menu-1">
<ul>
<li><a href="indexadmin.php">Inicio</a></li>
<li><a href="newitemsform.php">Formulario Administrador</a></li>
<li class="active"><a href="controlpanel.php">Panel de Control</a></li>
<li><a href="login.php">Cerrar Sesión</a></li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4 animate-box"></div>
<div class="col-md-4 col-sm-4 animate-box">
<img class="img-responsive" style="height:125px; width:300px; margin-left:25px; margin-top:40px; margin-bottom:40px;" src="images/entrance.jpg" alt="trainer">
<div class="col-md-4 col-sm-4 animate-box"></div>
</div>
<div class="row"><div class="col-md-4 col-sm-4 animate-box"></div></div>
</div>
<div class="text-center">
<h3 style="font-family: Walkway; font-size: 30px;">Registros en BD <span style="font-family: Another Day in Paradise; font-size: 55px;">MyBunch</span></h3>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#usuarios">Usuarios</a></li>
<li><a data-toggle="tab" href="#bunchs">Bunchs</a></li>
<li><a data-toggle="tab" href="#productos">Productos</a></li>
<li><a data-toggle="tab" href="#ventas">Ventas</a></li>
</ul>
</div>
<div class="container">
<div class="tab-content">
<!--TABLA USUARIOS-->
<div id="usuarios" class="tab-pane fade in active">
<h3 class="text-center" style="font-family: Walkway; font-size: 28px; margin-top:20px;">Tabla Usuarios</h3>
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">Cédula</th>
<th scope="col">Nombre</th>
<th scope="col">1er Apellido</th>
<th scope="col">Correo</th>
<th scope="col">Teléfono</th>
<th scope="col">Contraseña</th>
<th scope="col">Tipo</th>
<th scope="col">Modificar</th>
<th scope="col">Eliminar</th>
</tr>
</thead>
<!--Codigo PHP para hacer la consulta a la base de datos sobre los usuarios-->
<?php
///////////////////////////////
//CONSULTA USUARIOS
//////////////////////////////
$consultauser = "SELECT cedulaUsuario,nombreUsuario,primerApellido,segundoApellido,correoUsuario,direccion,telefono,contrasena,puntosUsuario,tipoUsuario,nivel FROM Usuario, Nivel WHERE idnivel = nivel ORDER BY nombreUsuario ASC";
$ejecutaruser = sqlsrv_query($con, $consultauser);
$iusers = 0;
while($filausers = sqlsrv_fetch_array($ejecutaruser)){
$cedulaUsuario = $filausers ['cedulaUsuario'];
$nombreUsuario = $filausers ['nombreUsuario'];
$primerApellido = $filausers ['primerApellido'];
$segundoApellido = $filausers ['segundoApellido'];
$correoUsuario = $filausers ['correoUsuario'];
$direccion = $filausers ['direccion'];
$telefono = $filausers ['telefono'];
$contrasena = $filausers ['contrasena'];
$puntosUsuario = $filausers ['puntosUsuario'];
$tipoUsuario = $filausers ['tipoUsuario'];
$nivel = $filausers ['nivel'];
$iusers = $iusers+1;
?>
<tbody>
<tr>
<td><?php echo $cedulaUsuario; ?></td>
<td><?php echo $nombreUsuario; ?></td>
<td><?php echo $primerApellido; ?></td>
<td><?php echo $correoUsuario; ?></td>
<td><?php echo $telefono; ?></td>
<td><?php echo $contrasena; ?></td>
<td><?php echo $tipoUsuario; ?></td>
<td><a href="controlpanel.php?editarusuario=<?php echo $cedulaUsuario;?>">Editar</a></td>
<td><a href="controlpanel.php?borrarusuario=<?php echo $cedulaUsuario;?>">Borrar</a></td>
</tr>
</tbody>
<!--Cierre del ciclo PHP-->
<?php } ?>
<?php
if(isset($_GET['editarusuario'])){
include("SQL/updateusers.php");
}
?>
</table>
</div>
<div id="bunchs" class="tab-pane fade">
<h3 class="text-center" style="font-family: Walkway; font-size: 28px; margin-top:20px;">Tabla Usuarios</h3>
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">ID Bunch</th>
<th scope="col">Nombre</th>
<th scope="col">Precio</th>
<th scope="col">Experiencia</th>
<th scope="col">Padecimiento</th>
<th scope="col">Modificar</th>
<th scope="col">Eliminar</th>
</tr>
</thead>
<!--Codigo PHP para hacer la consulta a la base de datos sobre los usuarios-->
<?php
///////////////////////////////
//CONSULTA BUNCHS
//////////////////////////////
$consultabunch = "SELECT idBunch,nombreBunch,CONVERT(int,precio) as precio,puntosotorgados, nombrePadecimiento FROM Bunch,Padecimiento WHERE Padecimiento = idPadecimiento ORDER BY nombreBunch ASC";
$ejecutarbunch = sqlsrv_query($con, $consultabunch);
$ibunch = 0;
while($filabunch = sqlsrv_fetch_array($ejecutarbunch)){
$idbunch = $filabunch ['idBunch'];
$nombrebunch = $filabunch ['nombreBunch'];
$preciobunch = $filabunch ['precio'];
$experienciabunch = $filabunch ['puntosotorgados'];
$padecimientobunch = $filabunch ['nombrePadecimiento'];
$ibunch = $ibunch+1;
?>
<tbody>
<tr>
<td><?php echo $idbunch; ?></td>
<td><?php echo $nombrebunch; ?></td>
<td>$<?php echo $preciobunch; ?></td>
<td><?php echo $experienciabunch; ?></td>
<td><?php echo $padecimientobunch; ?></td>
<td><a href="controlpanel.php?editarbunch=<?php echo $idbunch;?>">Editar</a></td>
<td><a href="controlpanel.php?borrarbunch=<?php echo $idbunch;?>">Borrar</a></td>
</tr>
</tbody>
<!--Cierre del ciclo PHP-->
<?php } ?>
<?php
if(isset($_GET['editarbunch'])){
include("SQL/updatebunch.php");
}
?>
</table>
</div>
<!--TABLA PRODUCTOS-->
<div id="productos" class="tab-pane fade">
<h3 class="text-center" style="font-family: Walkway; font-size: 28px; margin-top:20px;">Tabla Productos</h3>
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">ID Producto</th>
<th scope="col">Nombre</th>
<th scope="col">Descripción</th>
<th scope="col">Tipo</th>
<th scope="col">Modificar</th>
<th scope="col">Eliminar</th>
</tr>
</thead>
<!--Codigo PHP para hacer la consulta a la base de datos sobre los productos-->
<?php
///////////////////////////////
//CONSULTA PRODUCTOS
//////////////////////////////
$consultaprod = "SELECT idProducto,nombreProducto,descripcion,tipo from Producto,TipoProducto where idtipo = idTipoProducto";
$ejecutarprod = sqlsrv_query($con, $consultaprod);
$iprod = 0;
while($filaprod = sqlsrv_fetch_array($ejecutarprod)){
$idproducto = $filaprod ['idProducto'];
$nombreproducto = $filaprod ['nombreProducto'];
$descripcionproducto = $filaprod ['descripcion'];
$tipoproducto = $filaprod ['tipo'];
$iprod = $iprod+1;
?>
<tbody>
<tr>
<td><?php echo $idproducto; ?></td>
<td><?php echo $nombreproducto; ?></td>
<td><?php echo $descripcionproducto; ?></td>
<td><?php echo $tipoproducto; ?></td>
<td><a href="controlpanel.php?editarproducto=<?php echo $idproducto;?>">Editar</a></td>
<td><a href="controlpanel.php?borrarproducto=<?php echo $idproducto;?>">Borrar</a></td>
</tr>
</tbody>
<!--Cierre del ciclo PHP-->
<?php } ?>
<!--Si se presiona el boton editar se agrega y ejecuta el archivo updatedata.php-->
<?php
if(isset($_GET['editarproducto'])){
include("SQL/updateprod.php");
}
?>
</table>
</div>
<div id="ventas" class="tab-pane fade">
<h3 class="text-center" style="font-family: Walkway; font-size: 28px; margin-top:20px;">Tabla Ventas</h3>
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">ID Compra</th>
<th scope="col">Cédula</th>
<th scope="col">Nombre</th>
<th scope="col">Apellido</th>
<th scope="col">Bunch</th>
<th scope="col">Monto</th>
</tr>
</thead>
<!--Codigo PHP para hacer la consulta a la base de datos sobre los productos-->
<?php
///////////////////////////////
//CONSULTA VENTAS
//////////////////////////////
$consultaventas = "SELECT idCompra,cedulaUsuario, nombreUsuario, primerApellido,nombreBunch, CONVERT(int,montoCompra) as montoCompra FROM Usuario, Compra, Bunch_Compra,Bunch WHERE (idUsuario = cedulaUsuario) AND (idBunch = idBunchRel) AND (idCompra = idCompraRel) AND (estado = 'Completado') ORDER BY idCompra ASC";
$ejecutarventas = sqlsrv_query($con, $consultaventas);
$iventas = 0;
while($filaventa = sqlsrv_fetch_array($ejecutarventas)){
$idcompra = $filaventa ['idCompra'];
$nombreusuario = $filaventa ['nombreUsuario'];
$cedula = $filaventa ['cedulaUsuario'];
$apellido = $filaventa ['primerApellido'];
$nombrebunch = $filaventa ['nombreBunch'];
$monto = $filaventa ['montoCompra'];
$iventas = $iventas+1;
?>
<tbody>
<tr>
<td><?php echo $idcompra; ?></td>
<td><?php echo $cedula; ?></td>
<td><?php echo $nombreusuario; ?></td>
<td><?php echo $apellido; ?></td>
<td><?php echo $nombrebunch; ?></td>
<td>$<?php echo $monto; ?></td>
</tr>
</tbody>
<!--Cierre del ciclo PHP-->
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="gototop js-top">
<a href="#" class="js-gotop"><i class="icon-arrow-up"></i></a>
</div>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- jQuery Easing -->
<script src="js/jquery.easing.1.3.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- Waypoints -->
<script src="js/jquery.waypoints.min.js"></script>
<!-- Stellar Parallax -->
<script src="js/jquery.stellar.min.js"></script>
<!-- Carousel -->
<script src="js/owl.carousel.min.js"></script>
<!-- countTo -->
<script src="js/jquery.countTo.js"></script>
<!-- Magnific Popup -->
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/magnific-popup-options.js"></script>
<!-- Google Map -->
<!-- Main -->
<script src="js/main.js"></script>
</body>
</html>