From c1dd787c2d9a98a63887dde1c56bd4ecbecb5475 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 10 Jul 2026 08:48:37 +0000 Subject: [PATCH] Autosave: 20260710-084941 --- call_center_pro.php | 423 ++++++++++++++++-- gestiones_callcenter.php | 514 ++++++++++++++++++---- includes/callcenter_test_helpers.php | 222 +++++++++- includes/drive_test_orders.php | 197 +++++---- update_callcenter_test_tracking.php | 630 +++++++++++++++++++++++++-- 5 files changed, 1755 insertions(+), 231 deletions(-) diff --git a/call_center_pro.php b/call_center_pro.php index fb2327e0..14242956 100644 --- a/call_center_pro.php +++ b/call_center_pro.php @@ -8,6 +8,7 @@ require_once 'includes/contraentrega_cobertura.php'; $provinciasPorDepartamentoContraentrega = contraentregaProvinciasPorDepartamento(); $distritosPorProvinciaContraentrega = contraentregaDistritosPorProvincia(); $departamentosContraentrega = array_keys($provinciasPorDepartamentoContraentrega); +$sedesShalom = cc_test_fetch_shalom_sedes(db()); $pageTitle = 'Pedidos Asignados | Bandeja de la asesora'; $pageDescription = 'Bandeja para que cada asesora gestione sus pedidos asignados con la misma interfaz, estados, historial y acciones.'; @@ -147,10 +148,11 @@ function cc_test_followup_semaforo(array $order): ?array $view = $_GET['view'] ?? 'pendientes_hoy'; $allowedViews = [ - 'pendientes_hoy' => 'Pendientes por llamar', + 'pendientes_hoy' => 'Bandeja principal', 'nuevos_hoy' => 'Nuevos de hoy', 'confirmados' => 'Confirmados', 'seguimiento' => 'Seguimiento', + 'promo_final' => 'Promo Final', 'observados' => 'Observados', 'cerrados' => 'Cerrados / descartados', 'todos' => 'Todos los pedidos cargados', @@ -185,6 +187,7 @@ $stats = [ 'nuevos_hoy' => 0, 'confirmados' => 0, 'seguimiento' => 0, + 'promo_final' => 0, 'observados' => 0, 'cerrados' => 0, ]; @@ -301,25 +304,39 @@ try { $order['total_llamadas'] = (int) ($callCounts[$order['source_key']] ?? 0); $importDate = cc_test_parse_datetime($order['import_id'] ?? null); $proximaDate = cc_test_parse_datetime($order['proxima_llamada_at'] ?? null); + $followupDayInfo = cc_test_followup_day_info($order); + $order['seguimiento_dia_info'] = $followupDayInfo; + $order['dias_seguimiento'] = $followupDayInfo['day_number'] ?? null; + $order['promo_final_habilitado'] = !empty($followupDayInfo['is_promo_final']); + $order['promo_final_evidencia_cargada'] = trim((string) ($order['promo_final_evidencia_path'] ?? '')) !== ''; + $order['es_promo_final'] = $order['promo_final_habilitado'] && $order['promo_final_evidencia_cargada']; + $order['promo_final_pendiente'] = $order['promo_final_habilitado'] && !$order['promo_final_evidencia_cargada']; + $order['pendiente_logistica_destino'] = $storeKey === 'otra_tienda' + ? cc_test_pending_logistica_destination($order) + : null; + $order['pendiente_logistica'] = $order['pendiente_logistica_destino'] !== null; $order['es_nuevo_hoy'] = $importDate ? $importDate->format('Y-m-d') === $todayStart->format('Y-m-d') : false; - $order['es_pendiente_hoy'] = in_array($order['estado'], $openStates, true); + $order['es_pendiente_hoy'] = !$order['es_promo_final'] && (in_array($order['estado'], $openStates, true) || $order['pendiente_logistica']); $order['es_cerrado'] = in_array($order['estado'], $closedStates, true); $stats['total']++; if ($order['es_nuevo_hoy']) { $stats['nuevos_hoy']++; } + if ($order['es_promo_final']) { + $stats['promo_final']++; + } if ($order['es_pendiente_hoy']) { $stats['pendientes_hoy']++; } if (in_array($order['estado'], cc_test_confirmed_states(), true)) { $stats['confirmados']++; } - if ($order['estado'] === 'SE ENVIO NUMERO DE CUENTA') { + if ($order['estado'] === 'SE ENVIO NUMERO DE CUENTA' && !$order['es_promo_final']) { $stats['seguimiento']++; } - if ($order['estado'] === 'OBSERVADO') { + if ($order['estado'] === 'OBSERVADO' && !$order['es_promo_final']) { $stats['observados']++; } if ($order['es_cerrado']) { @@ -333,14 +350,15 @@ try { 'pendientes_hoy' => (bool) ($order['es_pendiente_hoy'] ?? false), 'nuevos_hoy' => (bool) ($order['es_nuevo_hoy'] ?? false), 'confirmados' => in_array(($order['estado'] ?? ''), cc_test_confirmed_states(), true), - 'seguimiento' => ($order['estado'] ?? '') === 'SE ENVIO NUMERO DE CUENTA', - 'observados' => ($order['estado'] ?? '') === 'OBSERVADO', + 'seguimiento' => ($order['estado'] ?? '') === 'SE ENVIO NUMERO DE CUENTA' && !($order['es_promo_final'] ?? false), + 'promo_final' => (bool) ($order['es_promo_final'] ?? false), + 'observados' => ($order['estado'] ?? '') === 'OBSERVADO' && !($order['es_promo_final'] ?? false), 'cerrados' => (bool) ($order['es_cerrado'] ?? false), default => true, }; })); - usort($visibleOrders, static function (array $a, array $b) use ($view): int { + usort($visibleOrders, static function (array $a, array $b) use ($view, $storeKey): int { $aAgregado = !empty($a['is_agregado']); $bAgregado = !empty($b['is_agregado']); if ($aAgregado !== $bAgregado) { @@ -350,11 +368,30 @@ try { $aImport = cc_test_import_time($a); $bImport = cc_test_import_time($b); - if ($aImport !== $bImport) { - return $bImport <=> $aImport; + if ($view === 'promo_final') { + $aDays = (int) ($a['dias_seguimiento'] ?? 0); + $bDays = (int) ($b['dias_seguimiento'] ?? 0); + if ($aDays !== $bDays) { + return $bDays <=> $aDays; + } + if ($aImport !== $bImport) { + return $aImport <=> $bImport; + } } if ($view === "pendientes_hoy") { + $aPendientePromoFinal = !empty($a['promo_final_pendiente']); + $bPendientePromoFinal = !empty($b['promo_final_pendiente']); + if ($aPendientePromoFinal !== $bPendientePromoFinal) { + return $aPendientePromoFinal ? -1 : 1; + } + + $aPendienteLogistica = !empty($a['pendiente_logistica']); + $bPendienteLogistica = !empty($b['pendiente_logistica']); + if ($aPendienteLogistica !== $bPendienteLogistica) { + return $aPendienteLogistica ? -1 : 1; + } + $aDue = cc_test_parse_datetime($a["proxima_llamada_at"] ?? null); $bDue = cc_test_parse_datetime($b["proxima_llamada_at"] ?? null); if ($aDue && $bDue && $aDue != $bDue) { @@ -366,6 +403,18 @@ try { if (!$aDue && $bDue) { return -1; } + + if ($storeKey === 'otra_tienda') { + $aSourceRow = (int) ($a['source_row'] ?? 0); + $bSourceRow = (int) ($b['source_row'] ?? 0); + if ($aSourceRow > 0 && $bSourceRow > 0 && $aSourceRow !== $bSourceRow) { + return $bSourceRow <=> $aSourceRow; + } + } + } + + if ($aImport !== $bImport) { + return $bImport <=> $aImport; } return cc_test_order_time($b) <=> cc_test_order_time($a); @@ -400,7 +449,7 @@ require_once 'layout_header.php';
Drive detectado: filas Agregados: - TUANI: último procesado · próxima desde Extracción: desde fila + TUANI: distribución desde fila · último procesado Extracción: desde fila Auto actualización: cada 10 min Ver vista previa Drive
@@ -423,7 +472,7 @@ require_once 'layout_header.php';
-
Pendientes por llamar
+
Bandeja principal
@@ -459,6 +508,16 @@ require_once 'layout_header.php';
+
+ +
+
+
Promo Final
+
+
+
+
+
@@ -495,7 +554,7 @@ require_once 'layout_header.php';

-

Estados disponibles: Por llamar, Devolver llamada, Observado, Se envió número de cuenta, Confirmado contraentrega, Confirmado envío, Cancelado y Repetido.

+

Estados disponibles: Por llamar, Devolver llamada, Observado, Se envió número de cuenta, Confirmado contraentrega, Confirmado envío, Cancelado y Repetido. Promo Final se habilita desde el Día 4 y exige imagen de sustento para mover el pedido.

pedidos en esta bandeja
@@ -530,12 +589,48 @@ require_once 'layout_header.php'; $distritosSeleccionados = $distritosPorProvinciaContraentrega[$provinciaSeleccionada] ?? []; $modalId = 'modalDriveTest' . $order['source_key']; $badgeClass = cc_test_badge_class($order['estado']); + $followupDayInfo = $order['seguimiento_dia_info'] ?? null; $semaforoCuenta = cc_test_followup_semaforo($order); $historial = cc_test_fetch_historial(db(), $order['source_key']); + $logisticaPendienteLabel = !empty($order['pendiente_logistica']) ? cc_test_pending_logistica_label($order) : null; + $logisticaPendienteDetalle = match ($order['pendiente_logistica_destino'] ?? null) { + 'ruta' => 'Falta subirlo a Ruta Contraentrega.', + 'rotulado' => 'Falta subirlo a Pedidos Rotulados.', + default => '', + }; + $subirLogisticaButtonLabel = 'Subir pedido'; + $subirLogisticaNoteClass = 'small mt-2 text-muted'; + $subirLogisticaNoteHtml = 'Selecciona CONFIRMADO CONTRAENTREGA o CONFIRMADO ENVIO para enviarlo a logística.'; + if ($storeKey === 'otra_tienda') { + if ($order['estado'] === 'CONFIRMADO CONTRAENTREGA') { + if (!empty($order['ruta_contraentrega_pedido_id'])) { + $subirLogisticaButtonLabel = 'Actualizar en ruta'; + $subirLogisticaNoteClass = 'small mt-2 text-success fw-semibold'; + $subirLogisticaNoteHtml = 'En Ruta Contraentrega #' . (int) $order['ruta_contraentrega_pedido_id'] . '. Si cambias algo, usa este botón para actualizarlo.'; + } else { + $subirLogisticaButtonLabel = 'Subir a ruta'; + $subirLogisticaNoteClass = 'small mt-2 text-warning-emphasis'; + $subirLogisticaNoteHtml = 'PENDIENTE A SUBIR: este pedido ya está en CONFIRMADO CONTRAENTREGA. Súbelo a Ruta Contraentrega con este botón.'; + } + } elseif ($order['estado'] === 'CONFIRMADO ENVIO') { + if (!empty($order['pedido_rotulado_pedido_id'])) { + $subirLogisticaButtonLabel = 'Actualizar rotulado'; + $subirLogisticaNoteClass = 'small mt-2 text-success fw-semibold'; + $subirLogisticaNoteHtml = 'En Pedidos Rotulados #' . (int) $order['pedido_rotulado_pedido_id'] . '. Si cambias algo, usa este botón para actualizarlo.'; + } else { + $subirLogisticaButtonLabel = 'Subir a rotulados'; + $subirLogisticaNoteClass = 'small mt-2 text-warning-emphasis'; + $subirLogisticaNoteHtml = 'PENDIENTE A SUBIR: este pedido ya está en CONFIRMADO ENVIO. Súbelo a Pedidos Rotulados con este botón.'; + } + } + } ob_start(); ?> + +
+
ID Drive:
@@ -565,13 +660,25 @@ require_once 'layout_header.php';
llamadas + + + Seguimiento
+ +
+
Número de cuenta enviado hace día ·
+ +
Seguimiento: · desde
+ +
+ +
Próxima llamada:
Entrega programada:
@@ -579,6 +686,9 @@ require_once 'layout_header.php';
Subido a Ruta Contraentrega # ·
+ +
Subido a Pedidos Rotulados # ·
+
Última gestión:
Nota:
@@ -606,6 +716,8 @@ require_once 'layout_header.php'; $assignFormClass .= ' bg-primary-subtle border-primary'; } elseif ($assignedAssessorKey === 'ESTEFANYA') { $assignFormClass .= ' bg-success-subtle border-success'; + } elseif ($assignedAssessorKey === 'CARMEN') { + $assignFormClass .= ' bg-warning-subtle border-warning'; } else { $assignFormClass .= ' bg-secondary-subtle border-secondary'; } @@ -629,6 +741,8 @@ require_once 'layout_header.php'; KARINA ESTEFANYA + + CARMEN Asignado @@ -683,23 +797,52 @@ require_once 'layout_header.php';

@@ -876,8 +1055,10 @@ require_once 'layout_header.php';
- + + +
Obligatorias para Subir pedido a Ruta Contraentrega.
-
+
-
- - +
+ + >
-
+
+
Obligatorio para CONFIRMADO ENVIO.
-
- - +
+ +
@@ -1002,7 +1184,7 @@ require_once 'layout_header.php'; + + + + + + +