['estado' => 'POR LLAMAR', 'titulo' => 'Pedidos por llamar'], 'reintentos' => ['estado' => 'REINTENTO', 'titulo' => 'Pedidos en reintento'], 'confirmados' => ['estado' => 'CONFIRMADO', 'titulo' => 'Pedidos confirmados'], 'todos' => ['estado' => null, 'titulo' => 'Todos los pedidos de prueba'], ]; if (!isset($allowedViews[$view])) { $view = 'pendientes'; } $errorMessage = null; $orders = []; $stats = [ 'total' => 0, 'pendientes' => 0, 'reintentos' => 0, 'confirmados' => 0, ]; $visibleOrders = []; $totalRows = 0; try { $preview = drive_test_fetch_orders(10); $totalRows = (int) ($preview['total_rows'] ?? 0); $orders = $preview['orders'] ?? []; $tracking = drive_test_fetch_tracking(db(), array_column($orders, 'source_key')); $orders = drive_test_merge_tracking($orders, $tracking); // Obtener conteo de llamadas $sourceKeys = array_column($orders, 'source_key'); $callCounts = []; if (!empty($sourceKeys)) { $placeholders = implode(',', array_fill(0, count($sourceKeys), '?')); $stmtCalls = db()->prepare("SELECT pedido_id, COUNT(*) as total FROM historial_llamadas WHERE pedido_id IN ($placeholders) GROUP BY pedido_id"); $stmtCalls->execute($sourceKeys); $callCounts = $stmtCalls->fetchAll(PDO::FETCH_KEY_PAIR); } foreach ($orders as &$order) { $order['total_llamadas'] = $callCounts[$order['source_key']] ?? 0; $stats['total']++; if ($order['estado'] === 'POR LLAMAR') { $stats['pendientes']++; } elseif ($order['estado'] === 'REINTENTO') { $stats['reintentos']++; } elseif ($order['estado'] === 'CONFIRMADO') { $stats['confirmados']++; } } $expectedState = $allowedViews[$view]['estado']; if ($expectedState === null) { $visibleOrders = $orders; } else { $visibleOrders = array_values(array_filter($orders, static function (array $order) use ($expectedState): bool { return ($order['estado'] ?? '') === $expectedState; })); } } catch (Throwable $exception) { $errorMessage = $exception->getMessage(); } function cc_test_badge_class(string $estado): string { return match ($estado) { 'CONFIRMADO' => 'bg-success-subtle text-success-emphasis', 'REINTENTO' => 'bg-info-subtle text-info-emphasis', default => 'bg-warning-subtle text-warning-emphasis', }; } function cc_test_display_value(?string $value, string $fallback = 'No registrado'): string { $value = trim((string) $value); return $value !== '' ? $value : $fallback; } function cc_test_format_price(?string $value): string { $value = trim((string) $value); return $value !== '' ? 'S/ ' . $value : 'No registrado'; } function cc_test_format_drive_datetime(?string $value): string { $value = trim((string) $value); if ($value === '') { return 'No registrada'; } try { return (new DateTimeImmutable($value))->format('d/m/Y h:i A'); } catch (Throwable $exception) { return $value; } } require_once 'layout_header.php'; ?>

Call Center de prueba

Este panel usa solo los últimos 10 registros de Importar Drive (Test) para confirmar pedidos sin tocar pedidos reales.

Fuente: Importar Drive (Test) Hoja detectada: registros Ver vista previa

Datos tomados solo desde Importar Drive (Test): nombre, celular, dirección, referencia, distrito, ciudad, producto, cantidad, precio, método, sede / ID, DNI y observaciones.

pedidos
Cliente y contacto Ubicación Pedido Seguimiento Acciones
No hay pedidos en esta vista del módulo de prueba.
Pedido:
Drive:
DNI:
Celular: No registrado
Ref.:
·
Ver ubicación
Cantidad: · Precio:
Método:
Sede / ID:
0): ?>
llamadas
Obs. Drive:
Nota interna: