@extends('layouts.app-super-user') @php use Carbon\Carbon; @endphp @section('content')
{{ __('all.back_to_players') }}

{{ $user->code }}

{{ __('all.club') }}: {{ $user->association ?? 'N/A' }}

{{ __('all.group') }}: {{ $user->group ?? 'N/A' }}

{{ __('all.subgroup') }}: {{ $user->subgroup ?? 'N/A' }}

@isset($current_game)
{{ __('all.current_test') }}: {{ \Carbon\Carbon::parse($current_game->date_time_start)->format('d/m/Y H:i') }}
@endisset
@php $year = $current_date->year; $month = $current_date->month; $firstDay = \Carbon\Carbon::create($year,$month,1); $startWeekday = $firstDay->dayOfWeek; // Convertir el día de la semana para que lunes sea 0 y domingo sea 6 $startWeekday = $startWeekday === 0 ? 6 : $startWeekday - 1; $daysInMonth = $firstDay->daysInMonth; // Obtener el primer y último día del mes actual $firstDayOfMonth = Carbon::create($year, $month, 1)->startOfDay(); $lastDayOfMonth = Carbon::create($year, $month, 1)->endOfMonth()->endOfDay(); // Asegurarnos de que test_dates sea una colección $test_dates_collection = collect($test_dates ?? []); // Calcular meses con tests $months_with_tests = []; $years_with_tests = []; foreach($test_dates_collection as $test_date) { $date = Carbon::parse($test_date); if (!isset($months_with_tests[$date->year])) { $months_with_tests[$date->year] = []; } $months_with_tests[$date->year][$date->month] = true; $years_with_tests[$date->year] = true; } // Verificar si hay tests en el mes anterior $firstDayPrevMonth = $firstDayOfMonth->copy()->subMonth()->startOfMonth(); $lastDayPrevMonth = $firstDayOfMonth->copy()->subMonth()->endOfMonth(); $hasTestsPrevMonth = $test_dates_collection->filter(function($date) use ($firstDayPrevMonth, $lastDayPrevMonth) { $d = Carbon::parse($date); return $d->between($firstDayPrevMonth, $lastDayPrevMonth); })->isNotEmpty(); // Verificar si hay tests en el mes siguiente $firstDayNextMonth = $lastDayOfMonth->copy()->addDay()->startOfDay(); $lastDayNextMonth = $lastDayOfMonth->copy()->addMonth()->endOfDay(); $hasTestsNextMonth = $test_dates_collection->filter(function($date) use ($firstDayNextMonth, $lastDayNextMonth) { $d = Carbon::parse($date); return $d->between($firstDayNextMonth, $lastDayNextMonth); })->isNotEmpty(); @endphp
{{ __('all.months.' . $current_date->month) }}
@foreach(range(1, 12) as $num)
{{ __('all.months.' . $num) }}
@endforeach
{{ $current_date->year }}
@for($y = $current_date->year - 5; $y <= $current_date->year + 5; $y++)
{{ $y }}
@endfor
@php $cell=0; @endphp @for($i=0;$i<$startWeekday;$i++) @php $cell++; @endphp @endfor @for($day=1;$day<=$daysInMonth;$day++) @php $d = \Carbon\Carbon::create($year,$month,$day)->format('Y-m-d'); $hasTest = $test_dates_collection->contains($d); $classes = $hasTest ? ' has-test ' : ''; if($d == $current_date->format('Y-m-d')) $classes .= ' selected-day '; @endphp @php $cell++; if($cell%7==0) echo ''; @endphp @endfor @while($cell%7!=0) @php $cell++; @endphp @endwhile
{{ __('all.calendar_days.L') }} {{ __('all.calendar_days.M') }} {{ __('all.calendar_days.X') }} {{ __('all.calendar_days.J') }} {{ __('all.calendar_days.V') }} {{ __('all.calendar_days.S') }} {{ __('all.calendar_days.D') }}
{{ $day }} @if($hasTest) @php $dayTests = $tests_by_date[$d] ?? collect(); @endphp @if($dayTests->isNotEmpty()) @endif @endif
@if($last_period=='anterior')
@endif
{{ __('all.metrics') }}
{{ __('all.current') }}
{{ __('all.last') }}
{{ __('all.global') }}
{{ __('all.performance') }}
@foreach($metrics_current as $key => $val) @if(!in_array($key, ['CR_total_correct','CR_total_incorrect','CR_average_time']))
@if($key === 'SIN_VALOR') {{ __('all.SIN_VALOR') }} @else {{ strtoupper($key) }} @endif
@if(isset($metrics_current[$key])) {{ number_format($metrics_current[$key],2) }}% @else N/A @endif
@if(isset($metrics_last[$key])) {{ number_format($metrics_last[$key],2) }}% @else N/A @endif
@if(isset($metrics_global[$key])) {{ number_format($metrics_global[$key],2) }}% @else N/A @endif
@php $perf = $metrics_performance[$key] ?? null; @endphp @if(!is_null($perf))
{{ number_format($perf,2) }}%
@else
N/A
@endif
@endif @endforeach
CR
@if(isset($metrics_current['CR_total_correct'])) {{ number_format($metrics_current['CR_total_correct'],2) }} / {{ number_format($metrics_current['CR_total_incorrect'],2) }} {{ __('all.in_time') }} @if(isset($metrics_current['CR_average_time'])) {{ number_format($metrics_current['CR_average_time']/1000,3,',','.') }}{{ __('all.seconds_short') }} @else {{ __('all.not_available') }} @endif @else {{ __('all.not_available') }} @endif
@if(isset($metrics_last['CR_total_correct'])) {{ number_format($metrics_last['CR_total_correct'],2) }} / {{ number_format($metrics_last['CR_total_incorrect'],2) }} {{ __('all.in_time') }} @if(isset($metrics_last['CR_average_time'])) {{ number_format($metrics_last['CR_average_time']/1000,3,',','.') }}{{ __('all.seconds_short') }} @else {{ __('all.not_available') }} @endif @else {{ __('all.not_available') }} @endif
@if(isset($metrics_global['CR_total_correct'])) {{ number_format($metrics_global['CR_total_correct'],2) }} / {{ number_format($metrics_global['CR_total_incorrect'],2) }} {{ __('all.in_time') }} @if(isset($metrics_global['CR_average_time'])) {{ number_format($metrics_global['CR_average_time']/1000,3,',','.') }}{{ __('all.seconds_short') }} @else {{ __('all.not_available') }} @endif @else {{ __('all.not_available') }} @endif
@php $perfCR = $metrics_performance['CR'] ?? null; @endphp @if(!is_null($perfCR))
{{ number_format($perfCR,2) }}%
@else
N/A
@endif
@if(!empty($video_result))
@if(!empty($video_result['video']))

{{ __('all.camera_view') }}

@endif
@if(!empty($video_result['images']) && !empty($video_result['images']['face']))
Face
@endif
@if(isset($video_stats)) @endif
{{ __('all.analyzed_time') }} {{ __('all.total_time') }}
{{ __('all.static') }} @if(isset($video_result['length']) && isset($video_result['length_invalid_pose']) && $test_duration_seconds > 0) @php $frame_rate = $test_duration_seconds > 0 ? ($video_result['length'][0] / $test_duration_seconds) : 1.0; $staticTime = $test_duration_seconds > 0 ? ($test_duration_seconds - ($video_result['length_invalid_pose'][0]/$frame_rate)) : 0; @endphp {{ gmdate('i:s', (int)$staticTime) }} @else 00:00 @endif @if(isset($test_duration_seconds) && $test_duration_seconds > 0) {{ gmdate('i:s', (int)$test_duration_seconds) }} @else 00:00 @endif
{{ __('all.natural') }} @if(isset($video_result['length']) && isset($video_result['length_invalid_pose']) && isset($video_result['length_invalid_expression']) && $test_duration_seconds > 0) @php $frame_rate = $test_duration_seconds > 0 ? ($video_result['length'][0] / $test_duration_seconds) : 1.0; $naturalTime = $test_duration_seconds > 0 ? ($test_duration_seconds - ($video_result['length_invalid_pose'][0]/$frame_rate) - ($video_result['length_invalid_expression'][0]/$frame_rate)) : 0; @endphp {{ gmdate('i:s', (int)$naturalTime) }} @else 00:00 @endif @if(isset($test_duration_seconds) && $test_duration_seconds > 0) {{ gmdate('i:s', (int)$test_duration_seconds) }} @else 00:00 @endif
@if(!empty($video_result)) @php $rightResults = $video_result['results']['right'] ?? []; $leftResults = $video_result['results']['left'] ?? []; @endphp
@foreach($rightResults as $key => $result) @endforeach
@if(!empty($video_result['images']) && !empty($video_result['images']['right_eye'])) Right eye @endif {{ __('all.right_eye') }}
{{ __('all.type') }} {{ __('all.darkness') }} {{ __('all.color') }}
{{$key}} {{number_format($result['darkness'], 2)}}% {{ $result['color'] ? __('all.color_blue_purple') : __('all.color_brown_dark') }}
@foreach($leftResults as $key => $result) @endforeach
@if(!empty($video_result['images']) && !empty($video_result['images']['left_eye'])) Left eye @endif {{ __('all.left_eye') }}
{{ __('all.type') }} {{ __('all.darkness') }} {{ __('all.color') }}
{{$key}} {{number_format($result['darkness'], 2)}}% {{ $result['color'] ? __('all.color_blue_purple') : __('all.color_brown_dark') }}
@endif
@else

{{ __('all.no_video_data_available') }}

@endif
@php /** * colorVRtoM($key,$value): * Aplica color <70 => rojo, >=90 => verde, else => blanco * SOLO si $key está en [VRC,VRP,VPS,VPA,M]. */ function colorVRtoM($key,$val){ if(is_null($val)) return ''; if(!in_array($key,['VRC','VRP','VPS','VPA','M'])) return ''; if($val<=70) return 'bg-danger text-white'; return ''; } /** * colorPerformance($perf): * < -10 => rojo * > +10 => verde * else => sin color */ function colorPerformance($perf){ if(is_null($perf)) return ''; if($perf<=-10) return 'bg-danger text-white'; return ''; } /** * Determina si una métrica es del tipo ERROR o NOT VALUE * para los cuales la lógica de colores se invierte */ function isErrorOrNotValue($key) { return in_array(strtoupper($key), ['ERROR', 'NOT_VALUE', 'SIN_VALOR']); } /** * Determina la clase CSS para la píldora de rendimiento * según el tipo de métrica y el valor de rendimiento */ function getPerformancePillClass($key, $perf) { if (isErrorOrNotValue($key)) { // Para ERROR y NOT VALUE, la lógica se invierte return $perf < 0 ? 'positive' : 'negative'; } else { // Para el resto de métricas, comportamiento normal return $perf >= 0 ? 'positive' : 'negative'; } } /** * Calcula el número de bolas negras basado en el valor de darkness Z1 y Z1/Z2 * @param float $darknessZ1 Valor de darkness Z1 * @param float $z1z2 Valor de Z1/Z2 * @return int|string Número de bolas (1-6) o 'n/a' si no aplica */ function calculateDarkCircles($darknessZ1, $z1z2) { if (is_null($darknessZ1) || is_null($z1z2) || !is_numeric($darknessZ1) || !is_numeric($z1z2)) { return 'n/a'; } if ($darknessZ1 < 0) { // Para valores negativos (origen negativo) if ($z1z2 >= 0 && $z1z2 <= 9.99) return 6; if ($z1z2 >= 10 && $z1z2 <= 19.99) return 5; if ($z1z2 >= 20 && $z1z2 <= 29.99) return 4; if ($z1z2 >= 30 && $z1z2 <= 39.99) return 3; if ($z1z2 >= 40 && $z1z2 <= 49.99) return 2; if ($z1z2 >= 50) return 1; } else { // Para valores positivos (origen positivo) if ($z1z2 >= 0 && $z1z2 <= 9.99) return 1; if ($z1z2 >= 10 && $z1z2 <= 14.99) return 2; if ($z1z2 >= 15 && $z1z2 <= 19.99) return 3; if ($z1z2 >= 20 && $z1z2 <= 29.99) return 4; if ($z1z2 >= 30 && $z1z2 <= 39.99) return 5; if ($z1z2 >= 40) return 6; } return 'n/a'; } /** * Genera el HTML para mostrar las bolas negras * @param int|string $count Número de bolas a mostrar o 'n/a' * @return string HTML con las bolas */ function renderDarkCircles($count) { if ($count === 'n/a' || !is_numeric($count)) { return 'n/a'; } $html = ''; for ($i = 0; $i < 6; $i++) { if ($i < $count) { $html .= '●'; // Bola llena (negra) } else { $html .= '○'; // Bola vacía } } return $html; } @endphp @endsection