@php $rutaActualNotificaciones = trim(request()->path(), '/'); $moduloTarjetasActual = null; $esRutaBancos = $rutaActualNotificaciones === 'bancos' || strpos($rutaActualNotificaciones, 'bancos/') === 0 || $rutaActualNotificaciones === 'bancos-real' || strpos($rutaActualNotificaciones, 'bancos-real/') === 0 || $rutaActualNotificaciones === 'bancos-legacy' || strpos($rutaActualNotificaciones, 'bancos-legacy/') === 0; $nombreRutaActual = request()->route() ? request()->route()->getName() : ''; $esRutaAccesoSeguroBancos = strpos((string) $nombreRutaActual, 'bancos.real.seguridad.') === 0; $accesoSeguroBancosValidado = app(\App\Services\BancoContextService::class) ->tieneAccesoTemporal(); // Las tarjetas bancarias requieren estar dentro del área protegida. $mostrarTarjetasBancos = $esRutaBancos && !$esRutaAccesoSeguroBancos && $accesoSeguroBancosValidado; if ($rutaActualNotificaciones === 'cobranza' || strpos($rutaActualNotificaciones, 'cobranza/') === 0) { $moduloTarjetasActual = 'cobranza'; } elseif ($rutaActualNotificaciones === 'facturacion' || strpos($rutaActualNotificaciones, 'facturacion/') === 0 || strpos($rutaActualNotificaciones, 'facturacion_cliente') === 0 || $rutaActualNotificaciones === 'facturacion_sw' || strpos($rutaActualNotificaciones, 'facturacion_sw/') === 0 || strpos($rutaActualNotificaciones, 'facturacion_sw_cliente') === 0 || strpos($rutaActualNotificaciones, 'facturacion_cliente_sw') === 0) { $moduloTarjetasActual = 'facturacion'; } $notificacionesTarjetaGlobal = collect(isset($notificaciones_usuario) ? $notificaciones_usuario : []) ->filter(function ($notificacionUsuario) use ($moduloTarjetasActual, $mostrarTarjetasBancos) { if (!$notificacionUsuario || !$notificacionUsuario->datos_notificacion) { return false; } $datosNotificacion = $notificacionUsuario->datos_notificacion; $moduloNotificacion = $datosNotificacion->moduloNamespace(); // Cobranza y Facturación conservan su ubicación exclusiva. if (in_array($moduloNotificacion, ['cobranza', 'facturacion'], true) && $moduloNotificacion !== $moduloTarjetasActual) { return false; } // Bancos solo muestra tarjetas después de validar el acceso seguro. if ($moduloNotificacion === 'bancos' && !$mostrarTarjetasBancos) { return false; } // La validación de modificaciones conserva su ubicación en Informes. if ($moduloNotificacion === 'modificaciones_validacion' && !request()->routeIs('informes.index')) { return false; } if ((int) $datosNotificacion->requiere_accion === 1) { return !method_exists($notificacionUsuario, 'estaAtendida') || !$notificacionUsuario->estaAtendida(); } return (int) $notificacionUsuario->visto !== 1; }) ->unique('id_notificacion_x_usuario') ->sort(function ($notificacionUsuarioA, $notificacionUsuarioB) { $notificacionA = $notificacionUsuarioA->datos_notificacion; $notificacionB = $notificacionUsuarioB->datos_notificacion; $comparacionModulo = strcmp( $notificacionA->moduloClaveOrdenVisual(), $notificacionB->moduloClaveOrdenVisual() ); if ($comparacionModulo !== 0) { return $comparacionModulo; } $comparacionFecha = $notificacionB->fechaOrdenTimestamp() <=> $notificacionA->fechaOrdenTimestamp(); if ($comparacionFecha !== 0) { return $comparacionFecha; } return (int) $notificacionB->id_notificacion <=> (int) $notificacionA->id_notificacion; }) ->values(); @endphp @if ($notificacionesTarjetaGlobal->isNotEmpty())
@foreach ($notificacionesTarjetaGlobal as $notificacionUsuario) @php $datosNotificacion = $notificacionUsuario->datos_notificacion; $fechaEncabezado = $datosNotificacion->fechaVisual(false); $contenidoHomologado = $datosNotificacion->contenidoVisualHomologado(); // Bancos muestra únicamente la fecha. if ($datosNotificacion->moduloNamespace() === 'bancos' && preg_match('/\b[0-9]{2}\/[0-9]{2}\/[0-9]{4}\b/', $fechaEncabezado, $fechaBanco)) { $fechaEncabezado = $fechaBanco[0]; } $actionHref = route('notificaciones.abrir', ['id' => $notificacionUsuario->id_notificacion_x_usuario]); $reviewHref = null; $reviewData = []; $esInformePdfCobranza = $datosNotificacion->esInformePdfCobranza(); $datosInformePdfCobranza = $esInformePdfCobranza && !$contenidoHomologado['homologado'] ? $datosNotificacion->datosVisualesInformePdfCobranza() : null; $esSolicitudReemplazoInformeCobranza = $datosNotificacion ->esSolicitudReemplazoInformeCobranza(); $datosSolicitudReemplazoInformeCobranza = $esSolicitudReemplazoInformeCobranza && !$contenidoHomologado['homologado'] ? $datosNotificacion->datosVisualesSolicitudReemplazoInformeCobranza() : null; $esInformeLiberadoCobranza = $datosNotificacion ->esInformeLiberadoCobranza(); $datosInformeLiberadoCobranza = $esInformeLiberadoCobranza && !$contenidoHomologado['homologado'] ? $datosNotificacion->datosVisualesInformeLiberadoCobranza() : null; $esInformePdfFacturacion = $datosNotificacion ->esInformePdfFacturacion(); $datosInformePdfFacturacion = $esInformePdfFacturacion && !$contenidoHomologado['homologado'] ? $datosNotificacion->datosVisualesInformePdfFacturacion() : null; $esBloqueNotificacionesGeneralesLineaPruebas = $datosNotificacion ->esBloqueNotificacionesGeneralesLineaPruebas(); $esNotificacionGeneralLineaPruebas = $datosNotificacion ->esNotificacionGeneralLineaPruebas(); $datosNotificacionGeneralLineaPruebas = $esBloqueNotificacionesGeneralesLineaPruebas && !$contenidoHomologado['homologado'] ? $datosNotificacion->datosVisualesNotificacionGeneralLineaPruebas() : null; $esNotificacionManualAlmacen = $datosNotificacion ->esNotificacionManualAlmacen(); $datosNotificacionManualAlmacen = $esNotificacionManualAlmacen && !$contenidoHomologado['homologado'] ? $datosNotificacion->datosVisualesNotificacionManualAlmacen() : null; $esNotificacionBancos = $datosNotificacion->moduloNamespace() === 'bancos'; if ($datosNotificacion->muestraBotonMarcarRevisado()) { $reviewHref = url()->current(); $reviewData = [ 'data-global-notification-id' => $notificacionUsuario->id_notificacion_x_usuario, 'data-no-redirect' => '1', ]; } $detallesAdicionales = $datosNotificacion->detallesAdicionales(); $detalleRows = []; if ($contenidoHomologado['homologado']) { // La matriz define una sola fuente y orden para las tres superficies. $detalleRows = $contenidoHomologado['filas']; } elseif ($esNotificacionBancos) { $ordenBancos = [ 'Programación', 'Tipo de movimiento', 'Cuenta', 'Movimiento bancario', 'Solicitud/autorización', 'Generado por', 'Fecha y hora', ]; foreach ($ordenBancos as $etiquetaBanco) { if (!isset($detallesAdicionales[$etiquetaBanco]) || trim((string) $detallesAdicionales[$etiquetaBanco]) === '') { continue; } $detalleRows[] = [ 'label' => $etiquetaBanco, 'value' => $detallesAdicionales[$etiquetaBanco], ]; } } elseif ($esInformePdfCobranza && $datosInformePdfCobranza) { $detalleRows[] = [ 'label' => 'No. de informe', 'value' => $datosInformePdfCobranza['numero_informe'], 'href' => $datosInformePdfCobranza['url_pdf'], 'target' => $datosInformePdfCobranza['url_pdf'] ? '_blank' : null, ]; $detalleRows[] = [ 'label' => 'Generado por', 'value' => $datosNotificacion->generadoPorNombre(), ]; $detalleRows[] = [ 'label' => 'Fecha y hora', 'value' => $datosInformePdfCobranza['fecha_hora'], ]; } elseif ($esSolicitudReemplazoInformeCobranza && $datosSolicitudReemplazoInformeCobranza) { $detalleRows[] = [ 'label' => 'Mensaje', 'value' => $datosNotificacion->mensajeVisual(), ]; $detalleRows[] = [ 'label' => 'No. de informe', 'value' => $datosSolicitudReemplazoInformeCobranza['numero_informe'], ]; $detalleRows[] = [ 'label' => 'Generado por', 'value' => $datosNotificacion->generadoPorNombre(), ]; $detalleRows[] = [ 'label' => 'Fecha y hora', 'value' => $datosSolicitudReemplazoInformeCobranza['fecha_hora'], ]; } elseif ($esInformeLiberadoCobranza && $datosInformeLiberadoCobranza) { $detalleRows[] = [ 'label' => 'Mensaje', 'value' => $datosNotificacion->mensajeVisual(), ]; $detalleRows[] = [ 'label' => 'Generado por', 'value' => $datosNotificacion->generadoPorNombre(), ]; $detalleRows[] = [ 'label' => 'Fecha y hora', 'value' => $datosInformeLiberadoCobranza['fecha_hora'], ]; } elseif ($esInformePdfFacturacion && $datosInformePdfFacturacion) { $detalleRows[] = [ 'label' => 'No. de informe', 'value' => $datosInformePdfFacturacion['numero_informe'], 'href' => $datosInformePdfFacturacion['url_pdf'], 'target' => $datosInformePdfFacturacion['url_pdf'] ? '_blank' : null, ]; $detalleRows[] = [ 'label' => 'Generado por', 'value' => $datosNotificacion->generadoPorNombre(), ]; $detalleRows[] = [ 'label' => 'Fecha y hora', 'value' => $datosInformePdfFacturacion['fecha_hora'], ]; } elseif ($esNotificacionManualAlmacen && $datosNotificacionManualAlmacen) { $detalleRows[] = [ 'label' => 'Mensaje', 'value' => $datosNotificacionManualAlmacen['mensaje'], ]; $detalleRows[] = [ 'label' => 'No. de informe', 'value' => $datosNotificacionManualAlmacen['numero_informe'], ]; $detalleRows[] = [ 'label' => 'Generado por', 'value' => $datosNotificacion->generadoPorNombre(), ]; $detalleRows[] = [ 'label' => 'Fecha y hora', 'value' => $datosNotificacionManualAlmacen['fecha_hora'], ]; } elseif ($esBloqueNotificacionesGeneralesLineaPruebas && $datosNotificacionGeneralLineaPruebas) { if ($datosNotificacion->esNotificacionGeneralLineaPruebas() && trim((string) $datosNotificacionGeneralLineaPruebas['mensaje']) !== '') { $detalleRows[] = [ 'label' => 'Mensaje', 'value' => $datosNotificacionGeneralLineaPruebas['mensaje'], ]; } $detalleRows[] = [ 'label' => 'No. de informe', 'value' => $datosNotificacionGeneralLineaPruebas['numero_informe'], ]; $detalleRows[] = [ 'label' => 'Generado por', 'value' => $datosNotificacion->generadoPorNombre(), ]; $detalleRows[] = [ 'label' => 'Fecha y hora', 'value' => $datosNotificacionGeneralLineaPruebas['fecha_hora'], ]; } else { if (isset($detallesAdicionales['Mensaje'])) { $detalleRows[] = ['label' => 'Mensaje', 'value' => $detallesAdicionales['Mensaje']]; } elseif (count($detallesAdicionales) === 0) { $detalleRows[] = ['label' => 'Mensaje', 'value' => $datosNotificacion->mensajeVisual()]; } $detalleRows[] = ['label' => 'Generado por', 'value' => $datosNotificacion->generadoPorNombre()]; foreach ($detallesAdicionales as $label => $value) { if (trim((string) $label) === '' || trim((string) $value) === '') { continue; } if ($label === 'Mensaje') { continue; } if (strpos((string) $label, '__texto_') === 0) { // Muestra notas limpias sin etiquetas tecnicas. $detalleRows[] = [ 'label' => '', 'value' => $value, ]; continue; } $detalleRows[] = [ 'label' => $label, 'value' => $value, ]; } } @endphp @include('Notificaciones.partials.module_card', [ 'config' => $datosNotificacion->moduloConfig(), 'moduleLabel' => $datosNotificacion->moduloLabel(), 'dateText' => $fechaEncabezado, 'title' => $contenidoHomologado['titulo'], 'summary' => ($contenidoHomologado['homologado'] || $esNotificacionBancos || $esInformePdfCobranza || $esSolicitudReemplazoInformeCobranza || $esInformeLiberadoCobranza || $esInformePdfFacturacion || $esNotificacionManualAlmacen || $esBloqueNotificacionesGeneralesLineaPruebas) ? '' : $datosNotificacion->textoPrincipal(), 'detailRows' => $detalleRows, 'actionHref' => $actionHref, 'actionText' => ($esInformePdfCobranza || $esSolicitudReemplazoInformeCobranza || $esInformeLiberadoCobranza || $esInformePdfFacturacion || $esNotificacionManualAlmacen || $esBloqueNotificacionesGeneralesLineaPruebas) ? 'Ver detalles' : 'Ver detalle', 'actionClass' => 'show-loader-before-leave', 'actionData' => [], 'reviewHref' => $reviewHref, 'reviewText' => 'Marcar como revisado', 'reviewClass' => $reviewHref ? 'module-notification-action--mark-redirect' : '', 'reviewData' => $reviewData, 'orderGroup' => $datosNotificacion->moduloClaveOrdenVisual(), 'orderDate' => $datosNotificacion->fechaOrdenTimestamp(), 'orderSequence' => $datosNotificacion->id_notificacion, 'expanded' => false, ]) @endforeach
@endif