-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientes.php
79 lines (72 loc) · 3.2 KB
/
Clientes.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
<?php
require_once "../Header.php";
require_once "../Service/ClienteService.php";
require_once "../Service/Utils.php"; // Incluir el nuevo archivo
$clienteService = new ClienteService();
$Clientes = $clienteService->Consultar();
// Referencia a los servicios para la entidad cliente
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$clienteService->manejarPost($_POST); // Llamada al nuevo método
header("Location: Clientes.php");
}
?>
<!-- Modal para el formulario de nuevo artículo -->
<div id="formModal" class="modal" tabindex="-1" role="dialog" style="display:none;">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header bg-secondary text-white">
<h5 class="modal-title fw-bold" id="modalTitle"></h5>
</div>
<div class="modal-body">
<!-- Referencia al formulario de los articulos -->
<?php include 'AddEditClientes.php'; ?>
</div>
</div>
</div>
</div>
<div class="container">
<h2>Listado de Clientes</h2>
<a onclick="showForm(0);"class="btn btn-primary mb-3 text-black">Agregar Cliente</a>
<table class="table table-striped">
<thead class="table-dark">
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Dirección</th>
<th>Teléfono</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php foreach ($Clientes as $cliente): ?>
<tr>
<th><?= $cliente['Id'] ?></th>
<td><?= $cliente['Nombre'] ?></td>
<td><?= $cliente['Direccion'] ?></td>
<td> <!-- Para manejar el formato de esta propieda cree el archivo Utils.php -->
<?= formatPhoneNumber($cliente['Telefono']) ?>
</td>
<td>
<a class="btn btn-warning btn-sm fw-bold" onclick="showForm(<?php echo $cliente['Id']; ?>);
fillForm('<?php echo $cliente['Id']; ?>', '<?php echo $cliente['Nombre']; ?>',
'<?php echo $cliente['Direccion']; ?>', '<?php echo $cliente['Telefono']; ?>');">
EDIT
</a>
<button type="button" class="btn btn-danger btn-sm text-black fw-bold"
onclick="if(confirmDelete()) {
document.getElementById('deleteForm<?php echo $cliente['Id']; ?>').submit(); }">
DELETE
</button>
<form id="deleteForm<?php echo $cliente['Id']; ?>" method="post" style="display:none;">
<input type="hidden" name="id" value="<?php echo $cliente['Id']; ?>">
<input type="hidden" name="eliminar-cliente" value="1">
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- Referencia a los metodos Javascript en ArticuloMethod.js -->
<script src="../Shared/js/ClienteMethod.js"></script>
<?php require_once "../Footer.php"; ?>