'Visa', 'sentri' => 'Sentri/Global', 'pasaporte' => 'Pasaporte', 'adelanto_cita' => 'Adelanto Cita', 'doble_nacionalidad' => 'Doble Nacionalidad', ]; $estadoLabels = [ 'nuevo' => 'Nuevo', 'en_proceso' => 'En Proceso', 'en_revision' => 'En Revisión', 'completado' => 'Completado', 'cancelado' => 'Cancelado', ]; // Filters & Pagination $q = trim($_GET['q'] ?? ''); $fEstado = trim($_GET['estado'] ?? ''); $fTipo = trim($_GET['tipo'] ?? ''); $page = max(1, (int)($_GET['page'] ?? 1)); $perPage = 15; $offset = ($page - 1) * $perPage; // Validate filter values against allowed enums $validEstados = array_keys($estadoLabels); $validTipos = array_keys($tipoLabels); if ($fEstado !== '' && !in_array($fEstado, $validEstados, true)) $fEstado = ''; if ($fTipo !== '' && !in_array($fTipo, $validTipos, true)) $fTipo = ''; // Build WHERE clause dynamically $conditions = []; $params = []; if ($q !== '') { $conditions[] = 'c.nombre LIKE ?'; $params[] = '%' . $q . '%'; } if ($fEstado !== '') { $conditions[] = 't.estado = ?'; $params[] = $fEstado; } if ($fTipo !== '') { $conditions[] = 't.tipo = ?'; $params[] = $fTipo; } $where = ''; if (!empty($conditions)) { $where = 'WHERE ' . implode(' AND ', $conditions); } // Count total $countSql = "SELECT COUNT(*) FROM tramites t LEFT JOIN clientes c ON t.cliente_id = c.id $where"; $countStmt = $db->prepare($countSql); $countStmt->execute($params); $totalTramites = $countStmt->fetchColumn(); $totalPages = max(1, (int)ceil($totalTramites / $perPage)); // Ensure page is within range if ($page > $totalPages) $page = $totalPages; // Fetch tramites with client name $sql = "SELECT t.*, c.nombre AS cliente_nombre FROM tramites t LEFT JOIN clientes c ON t.cliente_id = c.id $where ORDER BY t.created_at DESC LIMIT $perPage OFFSET $offset"; $stmt = $db->prepare($sql); $stmt->execute($params); $tramites = $stmt->fetchAll(); // Check if any filters are active $hasFilters = ($q !== '' || $fEstado !== '' || $fTipo !== ''); ?>

Trámites

Gestión de procesos y trámites

Limpiar
Nuevo Trámite
Cliente Tipo Estado Fecha Solicitud Fecha Cita Precio Acción
Ver
1): ?>