diff --git a/call_center_pro.php b/call_center_pro.php index 5a1cd562..a40f36c3 100644 --- a/call_center_pro.php +++ b/call_center_pro.php @@ -347,12 +347,6 @@ $viewCards = $isTuaniRecuperablesStore ? [ 'active_class' => 'bg-light border', ], ] : [ - 'pendientes_hoy' => [ - 'label' => 'Bandeja principal', - 'heading' => 'Bandeja principal', - 'stat_key' => 'pendientes_hoy', - 'active_class' => 'bg-dark text-white', - ], 'nuevos_hoy' => [ 'label' => 'Asignados hoy', 'heading' => 'Pedidos asignados hoy', @@ -401,6 +395,12 @@ $viewCards = $isTuaniRecuperablesStore ? [ 'stat_key' => 'cerrados', 'active_class' => 'bg-secondary-subtle border border-secondary', ], + 'pendientes_hoy' => [ + 'label' => 'Bandeja principal', + 'heading' => 'Bandeja principal', + 'stat_key' => 'pendientes_hoy', + 'active_class' => 'bg-dark text-white', + ], 'todos' => [ 'label' => 'Todos', 'heading' => 'Todos los pedidos cargados', @@ -842,12 +842,33 @@ try { } if ($view === 'ultimos_3_dias') { + $aOrderNumber = static function (array $order): int { + $codigo = trim((string) ($order['codigo'] ?? '')); + if ($codigo !== '') { + $digits = preg_replace("/[^0-9]+/", '', $codigo); + if ($digits !== '') { + return (int) $digits; + } + } + + $sourceRow = (int) ($order['source_row'] ?? 0); + if ($sourceRow > 0) { + return $sourceRow; + } + + return (int) ($order['id'] ?? 0); + }; + $aOrderNumberValue = $aOrderNumber($a); + $bOrderNumberValue = $aOrderNumber($b); + if ($aOrderNumberValue !== $bOrderNumberValue) { + return $bOrderNumberValue <=> $aOrderNumberValue; + } $aRecent = cc_test_recent_followup_anchor($a); $bRecent = cc_test_recent_followup_anchor($b); $aRecentTs = $aRecent instanceof DateTimeImmutable ? $aRecent->getTimestamp() : null; $bRecentTs = $bRecent instanceof DateTimeImmutable ? $bRecent->getTimestamp() : null; if ($aRecentTs !== null && $bRecentTs !== null && $aRecentTs !== $bRecentTs) { - return $aRecentTs <=> $bRecentTs; + return $bRecentTs <=> $aRecentTs; } if ($aRecentTs !== null && $bRecentTs === null) { return -1; @@ -1833,13 +1854,10 @@ require_once 'layout_header.php';