@extends('layouts.app')
@section('title','Gestão de Contests')
@section('content')
@php use App\Models\ContestDate; @endphp
{{-- Mensagens --}}
@if(session('sucesso'))
✅ {{ session('sucesso') }}
@endif
@if(session('erro'))
❌ {{ session('erro') }}
@endif
{{-- Toggle Ativação Automática --}}
⚙️ Ativação Automática por Data
Quando ligada , o sistema ativa automaticamente o contest Futuro
quando o dia de inicio_log chegar (via cron diário às 00:05).
Requer Task Scheduler do Windows configurado.
@if($autoAtivar)
Comando para o Task Scheduler (rodar a cada 1 minuto):
php C:\laragon\www\projetos\labre-contest\artisan schedule:run
@endif
{{-- Legenda de flags --}}
@foreach(ContestDate::FLAG_LABELS as $f => $info)
{{ $f }} — {{ $info['label'] }}
@endforeach
{{-- Lista de contests --}}
@forelse($contests as $c)
@php
$fi = ContestDate::FLAG_LABELS[$c->flag] ?? ['label'=>'?','cor'=>'#333','bg'=>'#f5f5f5'];
$ep = $etapasPorContest[$c->id] ?? null;
$progresso = $ep ? (int)(($ep->concluidas / max($ep->total, 1)) * 100) : 0;
$ano = $c->start_date->format('Y');
@endphp
{{-- Cabeçalho --}}
{{ $fi['label'] }}
{{ $c->name }} {{ $ano }}
#{{ $c->id }}
📅 Contest: {{ $c->start_date->format('d/m/Y H:i') }} – {{ $c->end_date->format('d/m/Y H:i') }} UTC
📤 Envio: {{ \Carbon\Carbon::parse($c->inicio_log)->format('d/m/Y') }}
até {{ \Carbon\Carbon::parse($c->limit_log)->format('d/m/Y') }}
{{-- Barra de progresso etapas --}}
@if($ep && $ep->total > 0)
Etapas concluídas: {{ $ep->concluidas }}/{{ $ep->total }}
{{ $progresso }}%
@endif
{{-- Ações --}}
{{-- ATIVAR --}}
@if(in_array($c->flag, [ContestDate::FLAG_FUTURO, ContestDate::FLAG_ENCERRADO]))
@elseif($c->flag === ContestDate::FLAG_ATIVO)
✅ Ativo
@endif
{{-- REPROCESSAR --}}
@if($c->flag === ContestDate::FLAG_ENCERRADO)
🔄 Reprocessar
@endif
{{-- ARQUIVAR --}}
@if($c->flag === ContestDate::FLAG_ENCERRADO)
📦 Arquivar
@endif
@if($c->flag === ContestDate::FLAG_ARQUIVADO)
📁 Dados em backup — storage/app/backup/
@endif
@empty
Nenhum contest cadastrado. Criar o primeiro .
@endforelse
@endsection