diff --git a/call_center_pro.php b/call_center_pro.php index 0b45ae3a..f770474a 100644 --- a/call_center_pro.php +++ b/call_center_pro.php @@ -24,70 +24,6 @@ if (!cc_test_current_user_can_access_module($pdo)) { exit(); } -if (isset($_GET['ajax']) && $_GET['ajax'] === 'panel_status') { - header('Content-Type: application/json; charset=utf-8'); - header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); - - $panelStoreKey = trim(mb_strtolower((string) ($_GET['store'] ?? 'flower'))); - $availablePanelStores = drive_test_available_stores(); - if (!isset($availablePanelStores[$panelStoreKey])) { - $panelStoreKey = 'flower'; - } - - $currentUserId = (int) ($_SESSION['user_id'] ?? 0); - if ($currentUserId <= 0) { - http_response_code(401); - echo json_encode([ - 'success' => false, - 'message' => 'Sesión no válida.', - ]); - exit(); - } - - try { - if ($panelStoreKey === 'tuani_recuperables') { - $panelOrders = drive_test_fetch_orders_from_db($pdo, $panelStoreKey); - $panelTracking = drive_test_fetch_tracking($pdo, array_column($panelOrders, 'source_key')); - $panelOrders = drive_test_merge_tracking($panelOrders, $panelTracking); - $panelOrders = array_values(array_filter($panelOrders, static function (array $order): bool { - return empty($order['eliminado']); - })); - $panelOrders = cc_test_mark_recoverables_duplicate_orders($pdo, $panelOrders, $panelStoreKey); - } else { - $stmtPanel = $pdo->prepare(" - SELECT source_key, user_id, estado, assigned_at, updated_at, eliminado_at - FROM callcenter_test_tracking - WHERE user_id = ? AND eliminado_at IS NULL - ORDER BY source_key - "); - $stmtPanel->execute([$currentUserId]); - $panelOrders = $stmtPanel->fetchAll(PDO::FETCH_ASSOC); - } - - $panelSignatureParts = [cc_test_panel_orders_signature($panelOrders)]; - if ($panelStoreKey === 'otra_tienda') { - $panelAssessors = cc_test_fetch_assessors($pdo); - $panelRepartoSettings = cc_test_fetch_reparto_settings($pdo, $panelStoreKey, $panelAssessors); - $panelSignatureParts[] = cc_test_reparto_settings_signature($panelRepartoSettings); - } - - echo json_encode([ - 'success' => true, - 'signature' => sha1(implode('|', $panelSignatureParts)), - 'total' => count($panelOrders), - ]); - } catch (Throwable $exception) { - error_log('Panel status check failed: ' . $exception->getMessage()); - http_response_code(500); - echo json_encode([ - 'success' => false, - 'message' => 'No se pudo verificar el panel.', - ]); - } - - exit(); -} - $sedesShalom = cc_test_fetch_shalom_sedes($pdo); function cc_test_parse_datetime(?string $value): ?DateTimeImmutable @@ -298,6 +234,7 @@ $parentStoreLabel = (string) ($storeNav['parent_label'] ?? ''); $isMainTuaniStore = cc_test_is_tuani_main_store_key($storeKey); $isTuaniRecuperablesStore = $storeKey === 'tuani_recuperables'; +$canShowTuaniLogisticaButton = $isMainTuaniStore || $isTuaniRecuperablesStore; $viewCardColumnClass = $isTuaniRecuperablesStore ? 'col-md-6 col-xl-2' : 'col-md-6 col-xl-2'; $viewCards = $isTuaniRecuperablesStore ? [ @@ -435,7 +372,6 @@ $stats = [ 'cerrados' => 0, ]; -$panelSignature = ''; $repartoSettings = [ 'store_key' => $storeKey, 'reparto_mode' => 'manual', @@ -687,7 +623,7 @@ try { $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'] = $isMainTuaniStore ? cc_test_pending_logistica_destination($order) : null; + $order['pendiente_logistica_destino'] = cc_test_is_tuani_store_key($storeKey) ? cc_test_pending_logistica_destination($order) : null; $order['pendiente_logistica'] = $order['pendiente_logistica_destino'] !== null; $order['es_nuevo_hoy'] = $assignedDate ? $assignedDate->format('Y-m-d') === $todayStart->format('Y-m-d') : false; @@ -772,11 +708,6 @@ try { 'footnote' => $performanceFootnote, ]); - $panelSignature = cc_test_panel_orders_signature($orders); - if ($isMainTuaniStore) { - $panelSignature .= '|'. cc_test_reparto_settings_signature($repartoSettings); - } - $visibleOrders = array_values(array_filter($orders, static function (array $order) use ($view, $selectedAssessorFilter, $todayStart): bool { if ($selectedAssessorFilter !== '' && !($order['matches_assessor_filter'] ?? false)) { return false; @@ -1094,7 +1025,7 @@ require_once 'layout_header.php'; } -
+
@@ -1133,8 +1064,9 @@ require_once 'layout_header.php'; Drive detectado: filas Agregados: : distribución desde fila · último procesado Extracción: desde fila - Auto actualización: activa + Actualización manual Ver vista previa Drive +
@@ -1262,28 +1194,28 @@ require_once 'layout_header.php'; default => '', }; $subirLogisticaButtonLabel = 'Subir pedido'; - $subirLogisticaNoteClass = 'small mt-2 text-muted'; + $subirLogisticaNoteClass = 'alert alert-secondary py-2 px-3 mt-2 mb-0'; $subirLogisticaNoteHtml = 'Selecciona CONFIRMADO CONTRAENTREGA o CONFIRMADO ENVIO para enviarlo a logística.'; - if ($isMainTuaniStore) { + if ($canShowTuaniLogisticaButton) { if ($order['estado'] === 'CONFIRMADO CONTRAENTREGA') { if (!empty($order['ruta_contraentrega_pedido_id'])) { $subirLogisticaButtonLabel = 'Actualizar en ruta'; - $subirLogisticaNoteClass = 'small mt-2 text-success fw-semibold'; + $subirLogisticaNoteClass = 'alert alert-success py-2 px-3 mt-2 mb-0'; $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.'; + $subirLogisticaNoteClass = 'alert alert-warning py-2 px-3 mt-2 mb-0'; + $subirLogisticaNoteHtml = 'ALERTA: este pedido está en CONFIRMADO CONTRAENTREGA, pero aún no se ha subido a Ruta Contraentrega. Usa este botón para subirlo.'; } } elseif ($order['estado'] === 'CONFIRMADO ENVIO') { if (!empty($order['pedido_rotulado_pedido_id'])) { $subirLogisticaButtonLabel = 'Actualizar rotulado'; - $subirLogisticaNoteClass = 'small mt-2 text-success fw-semibold'; + $subirLogisticaNoteClass = 'alert alert-success py-2 px-3 mt-2 mb-0'; $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.'; + $subirLogisticaNoteClass = 'alert alert-warning py-2 px-3 mt-2 mb-0'; + $subirLogisticaNoteHtml = 'ALERTA: este pedido está en CONFIRMADO ENVIO, pero aún no se ha subido a Pedidos Rotulados. Usa este botón para subirlo.'; } } } @@ -1463,7 +1395,7 @@ require_once 'layout_header.php';
- +
@@ -1498,8 +1430,8 @@ require_once 'layout_header.php'; - -
+ + @@ -1841,7 +1773,7 @@ require_once 'layout_header.php'; @@ -1844,28 +1850,28 @@ require_once 'layout_header.php'; default => '', }; $subirLogisticaButtonLabel = 'Subir pedido'; - $subirLogisticaNoteClass = 'small mt-2 text-muted'; + $subirLogisticaNoteClass = 'alert alert-secondary py-2 px-3 mt-2 mb-0'; $subirLogisticaNoteHtml = 'Selecciona CONFIRMADO CONTRAENTREGA o CONFIRMADO ENVIO para enviarlo a logística.'; - if ($isMainTuaniStore) { + if ($canShowTuaniLogisticaButton) { if ($order['estado'] === 'CONFIRMADO CONTRAENTREGA') { if (!empty($order['ruta_contraentrega_pedido_id'])) { $subirLogisticaButtonLabel = 'Actualizar en ruta'; - $subirLogisticaNoteClass = 'small mt-2 text-success fw-semibold'; + $subirLogisticaNoteClass = 'alert alert-success py-2 px-3 mt-2 mb-0'; $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.'; + $subirLogisticaNoteClass = 'alert alert-warning py-2 px-3 mt-2 mb-0'; + $subirLogisticaNoteHtml = 'ALERTA: este pedido está en CONFIRMADO CONTRAENTREGA, pero aún no se ha subido a Ruta Contraentrega. Usa este botón para subirlo.'; } } elseif ($order['estado'] === 'CONFIRMADO ENVIO') { if (!empty($order['pedido_rotulado_pedido_id'])) { $subirLogisticaButtonLabel = 'Actualizar rotulado'; - $subirLogisticaNoteClass = 'small mt-2 text-success fw-semibold'; + $subirLogisticaNoteClass = 'alert alert-success py-2 px-3 mt-2 mb-0'; $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.'; + $subirLogisticaNoteClass = 'alert alert-warning py-2 px-3 mt-2 mb-0'; + $subirLogisticaNoteHtml = 'ALERTA: este pedido está en CONFIRMADO ENVIO, pero aún no se ha subido a Pedidos Rotulados. Usa este botón para subirlo.'; } } } @@ -2073,7 +2079,7 @@ require_once 'layout_header.php';
- +
@@ -2108,8 +2114,8 @@ require_once 'layout_header.php'; - -
+ + @@ -2451,7 +2457,7 @@ require_once 'layout_header.php';