@extends('layouts.app-layout') @section('title', 'Detalle de funcionario') @section('content') @php $isOwnProfile = auth()->check() && auth()->user()->funcionario?->id === $funcionario->id; $backUrl = $isOwnProfile ? route('funcionario.dashboard') : route('funcionarios.index'); $estadoRaw = $funcionario->estado->value ?? $funcionario->estado; $estadoLabel = 'Inactivo'; $estadoClass = 'bg-warning-subtle text-warning-emphasis'; if ($funcionario->trashed()) { $estadoLabel = 'Eliminado'; $estadoClass = 'bg-danger-subtle text-danger-emphasis'; } elseif ($estadoRaw === 'activo') { $estadoLabel = 'Activo'; $estadoClass = 'bg-success-subtle text-success-emphasis'; } $puedeDesactivar = !$funcionario->trashed() && $estadoRaw === 'activo'; $puedeRestaurar = $funcionario->trashed() || $estadoRaw === 'inactivo'; $puedeEditar = !$funcionario->trashed(); $nombre = trim(($funcionario->user->nombre ?? '') . ' ' . ($funcionario->user->apellido ?? '')); $iniciales = mb_strtoupper( mb_substr($funcionario->user->nombre ?? '', 0, 1) . mb_substr($funcionario->user->apellido ?? '', 0, 1), ); $rolLabel = $funcionario->rol?->label() ?? '—'; $horarioEntrada = $funcionario->horario_entrada ? substr((string) $funcionario->horario_entrada, 0, 5) : null; $horarioSalida = $funcionario->horario_salida ? substr((string) $funcionario->horario_salida, 0, 5) : null; $horarioAtencion = match (true) { $horarioEntrada && $horarioSalida => $horarioEntrada . ' - ' . $horarioSalida, $horarioEntrada => $horarioEntrada, $horarioSalida => $horarioSalida, default => '—', }; @endphp