-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistado.php
137 lines (130 loc) · 5.16 KB
/
listado.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Listado de Productos</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.12.1/r-2.3.0/datatables.min.css" />
</head>
<?php
require "funcionamiento/conexion.php";
include "funcionamiento/elementos.php";
include "funcionamiento/querysR.php";
include "funcionamiento/querysCUD.php";
session_start();
if (empty($_SESSION)) include 'funcionamiento/inicio_sesion.php';
include 'funcionamiento/datos_sesion.php';
?>
<body style="background-color: <?php echo $colorfondo ?>; font-family: <?php echo $tipoletra ?>;">
<?php
!empty($_GET) && !array_key_exists('accion', $_GET) ? header('Location:listado.php') : "";
$accion = array_key_exists('accion', $_GET) ? $_GET['accion'] : "";
$accion == "Crear" ? crearPro($_GET) : "";
$accion == "Actualizar" ? actualizarPro($_GET) : "";
$accion == "Borrar" ? borrarPro($_GET) : "";
if ($accion == "Error_id") {
crearAlerta("danger", "<b>Error:</b> El ID no coincide con ningún Producto");
}
if ($accion == "Error_param") {
$tipo = array_key_exists('tipo', $_GET) ? $_GET['tipo'] : header('Location:listado.php');
crearAlerta("danger", "<b>Error:</b> Los parámetros para <b>" . $tipo . "</b>, no son los apropiados");
}
$productos = obtenerPros();
?>
<div class="d-flex justify-content-between align-items-center p-3">
<div class="d-flex align-items-center">
<a href="index.php" class="mx-2 btn btn-sm btn-danger"><i class="bi bi-power"></i></a>
<p class="m-0">Cerrar Sesión</p>
</div>
<div class="d-flex align-items-center">
<p class="m-0 font-monospace">Usuario: <b><?php echo $nombrecompleto ?></b></p>
<form method="POST" action="perfil.php">
<input type="hidden" name="php" value="listado.php">
<button type="submit" class="mx-2 btn btn-sm btn-secondary"><i class='bi bi-gear-fill'></i></button>
</form>
</div>
</div>
<div class="container">
<br>
<div class="row">
<div class="col-12">
<h1 class="font-monospace text-center">Gestión de Productos</h1>
</div>
</div>
<div class="row">
<div class="col-1">
<form method="GET" action="formulario.php">
<div class="d-grid gap-2">
<input type="hidden" name="accion" value="Crear">
<input type="submit" value="Crear" class="btn btn-success">
</div>
</form>
</div>
</div>
<br>
<div class="row">
<div class="col-12">
<table id="listado" class="display table table-striped align-middle text-center">
<thead>
<tr>
<th class="text-center">Detalle</th>
<th class="text-center">Código</th>
<th class="text-center">Nombre</th>
<th></th>
<th class="text-center">Acciones</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
foreach ($productos as $clave => $valor) {
echo "<tr>";
echo "<td>";
crearBoton("Detalle", "info", "detalle.php", $valor['id']);
echo "</td>";
echo "<td>" . $valor['id'] . "</td>";
echo "<td>" . $valor['nombre'] . "</td>";
echo "<td>";
crearBoton("Actualizar", "warning", "formulario.php", $valor['id']);
echo "</td>";
echo "<td>";
crearBoton("Borrar", "danger", "listado.php", $valor['id']);
echo "</td>";
echo "<td>";
crearBoton("Mover Stock", "primary", "moverstock.php", $valor['id']);
echo "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.1.slim.min.js" integrity="sha256-w8CvhFs7iHNVUtnSP0YKEg00p9Ih13rlL9zGqvLdePA=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.12.1/r-2.3.0/datatables.min.js" defer></script>
<script>
$(document).ready(function() {
$('#listado').DataTable({
language: {
search: "Buscar:",
lengthMenu: "Mostrar _MENU_ productos",
info: "Mostrando de _START_ a _END_ de _TOTAL_ productos",
infoEmpty: "Mostrando 0 productos",
infoFiltered: "(filtrado de _MAX_ productos totales)",
zeroRecords: "No hay productos para mostrar",
emptyTable: "No hay datos disponibles",
paginate: {
previous: "<i class='bi bi-arrow-left-short'></i>",
next: "<i class='bi bi-arrow-right-short'></i>",
}
}
});
});
</script>
</body>
</html>