162 lines
5.9 KiB
PHP
162 lines
5.9 KiB
PHP
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
|
|
|
<div class="container my-5">
|
|
|
|
<div class="card card-rounded card-shadow border-0">
|
|
|
|
<!-- HEADER -->
|
|
|
|
<div class="card-header header-dark px-4 py-3">
|
|
|
|
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
|
|
|
<h4 class="mb-0 title-shadow">
|
|
<i class="fas fa-users icon-xl me-2"></i>
|
|
Selección de Cliente
|
|
</h4>
|
|
|
|
<div class="d-flex gap-2">
|
|
|
|
<!-- BOTÓN FANTASMA (mantiene el layout) -->
|
|
|
|
<a class="btn btn-success invisible">
|
|
<i class="fas fa-plus me-1"></i>
|
|
</a>
|
|
|
|
<a href="?opt=crear_servicio" class="btn btn-soft-secondary text-white">
|
|
<i class="fas fa-arrow-left me-1"></i>
|
|
Volver
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- BODY -->
|
|
|
|
<div class="card-body px-4 py-4">
|
|
|
|
<?php if (empty($clientes)): ?>
|
|
<div class="text-center text-muted py-5">
|
|
No hay clientes registrados.
|
|
</div>
|
|
<?php else: ?>
|
|
|
|
<!-- FILTRO POR COLUMNA + BUSCADOR -->
|
|
|
|
<!-- Input de búsqueda añadido automáticamente por DataTables -->
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-1">
|
|
|
|
<div id="filtrosIzquierda" class="d-flex align-items-center gap-2">
|
|
|
|
<select id="columnFilter"
|
|
class="form-select form-select-sm"
|
|
style="width:auto;">
|
|
<option value="">Todas las columnas</option>
|
|
<option value="0">ID</option>
|
|
<option value="1">Nombre</option>
|
|
<option value="2">Apellido</option>
|
|
<option value="3">Teléfono</option>
|
|
<option value="4">Email</option>
|
|
</select>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<form method="POST" action="index.php?opt=seleccionar_cliente_servicio" novalidate>
|
|
|
|
<!-- CAMPO OCULTO (para verificación de token) -->
|
|
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
|
|
<div class="table-responsive">
|
|
<table id="tablaClientes" class="table table-hover align-middle mb-0">
|
|
|
|
<thead class="table-dark">
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Nombre</th>
|
|
<th>Apellido</th>
|
|
<th>Teléfono</th>
|
|
<th>Email</th>
|
|
<th>Seleccionar</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<?php foreach ($clientes as $c): ?>
|
|
<tr>
|
|
<td><?= $c['id'] ?? '' ?></td>
|
|
<td><?= htmlspecialchars($c['nombre'] ?? '') ?></td>
|
|
<td><?= htmlspecialchars($c['apellido'] ?? '') ?></td>
|
|
<td><?= htmlspecialchars($c['telefono'] ?? '') ?></td>
|
|
<td><?= htmlspecialchars($c['email'] ?? '') ?></td>
|
|
|
|
<!-- CHECKBOX PARA SELECCIONAR CLIENTE -->
|
|
|
|
<td class="text-left">
|
|
<input type="checkbox"
|
|
name="id_cliente"
|
|
value="<?= $c['id'] ?>"
|
|
class="form-check-input">
|
|
</td>
|
|
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- BOTÓN FINALIZAR SELECCIÓN -->
|
|
|
|
<div class="mt-3 text-end">
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fas fa-check me-1"></i> Finalizar
|
|
</button>
|
|
</div>
|
|
|
|
</form>
|
|
<?php endif; ?>
|
|
|
|
<!-- Errores provenientes de servicioController -->
|
|
|
|
<!-- ERROR -->
|
|
|
|
<script>
|
|
const serverErrors = <?php
|
|
if (!empty($_SESSION['flash_error'])) {
|
|
$errorsArray = explode('<br>', $_SESSION['flash_error']);
|
|
unset($_SESSION['flash_error']);
|
|
echo json_encode($errorsArray);
|
|
} else {
|
|
echo '[]';
|
|
}
|
|
?>;
|
|
</script>
|
|
|
|
<!-- SUCCES -->
|
|
|
|
<script>
|
|
const serverSuccess = <?php
|
|
if (!empty($_SESSION['flash_success'])) {
|
|
$successArray = explode('<br>', $_SESSION['flash_success']);
|
|
unset($_SESSION['flash_success']);
|
|
echo json_encode($successArray);
|
|
} else {
|
|
echo '[]';
|
|
}
|
|
?>;
|
|
</script>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Validar mediante js -->
|
|
|
|
<script src="js/servicios/servicioValidator.js"></script>
|
|
|
|
<!-- Tabla, búsqueda y filtro por columnas -->
|
|
|
|
<script src="js/servicios/servicioTableCliente.js"></script>
|