238 lines
12 KiB
PHP
238 lines
12 KiB
PHP
@extends('admin.layout')
|
|
|
|
@section('title', ($torneo ? 'Editar' : 'Nuevo') . ' Torneo - Admin OnAPB')
|
|
|
|
@section('content')
|
|
<div class="page-header">
|
|
<h2><i class="bi bi-trophy-fill"></i> {{ $torneo ? 'Editar Torneo' : 'Nuevo Torneo' }}</h2>
|
|
<a href="{{ route('admin.torneos.index') }}" class="btn-admin-outline">
|
|
<i class="bi bi-arrow-left"></i> Volver
|
|
</a>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="{{ $torneo ? 'col-lg-5' : 'col-12' }}">
|
|
<div class="admin-card mb-4">
|
|
<div class="card-header bg-white py-3">
|
|
<h5 class="mb-0 fw-bold">Información General</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" action="{{ $torneo ? route('admin.torneos.update', $torneo->id) : route('admin.torneos.store') }}" class="admin-form">
|
|
@csrf
|
|
@if($torneo) @method('PUT') @endif
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Nombre del Torneo *</label>
|
|
<input type="text" name="nombre" class="form-control" value="{{ old('nombre', $torneo->nombre ?? '') }}" required placeholder="Ej: Torneo Apertura 2026">
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Fecha de Inicio</label>
|
|
<input type="date" name="fecha_inicio" class="form-control" value="{{ old('fecha_inicio', ($torneo && $torneo->fecha_inicio) ? $torneo->fecha_inicio->format('Y-m-d') : '') }}">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label class="form-label">Fecha de Fin</label>
|
|
<input type="date" name="fecha_fin" class="form-control" value="{{ old('fecha_fin', ($torneo && $torneo->fecha_fin) ? $torneo->fecha_fin->format('Y-m-d') : '') }}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn-admin w-100 py-3 mt-3">
|
|
<i class="bi bi-check-lg"></i> {{ $torneo ? 'Actualizar Torneo' : 'Crear Torneo' }}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@if($torneo)
|
|
<div class="col-lg-7">
|
|
<!-- Assign Teams -->
|
|
<div class="admin-card mb-4">
|
|
<div class="card-header bg-white py-3 d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0 fw-bold">Equipos Participantes</h5>
|
|
<span class="badge bg-primary px-3 rounded-pill">{{ $torneo->equipos->count() }}</span>
|
|
</div>
|
|
<div class="card-body">
|
|
<form action="{{ route('admin.torneos.equipos.add', $torneo->id) }}" method="POST" class="row g-2 mb-4 align-items-end">
|
|
@csrf
|
|
<div class="col-md-6">
|
|
<label class="form-label small text-muted">Asignar Equipo al Torneo</label>
|
|
<select name="id_equipo" class="form-select select2-basic" required>
|
|
<option value="">Buscar equipo por club / categoría...</option>
|
|
@foreach($clubes as $club)
|
|
<optgroup label="{{ $club->nombre }}">
|
|
@foreach($club->equipos as $eq)
|
|
<option value="{{ $eq->id_equipo }}">
|
|
{{ $eq->categoria }} {{ $eq->division ? '('.$eq->division.')' : '' }}
|
|
</option>
|
|
@endforeach
|
|
</optgroup>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label class="form-label small text-muted">Grupo / División (Opcional)</label>
|
|
<input type="text" name="grupo" class="form-control" placeholder="Ej: Zona B">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<button type="submit" class="btn-admin w-100">
|
|
<i class="bi bi-plus-lg"></i> Agregar
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="table-responsive" style="max-height: 400px; overflow-y: auto;">
|
|
<table class="table table-sm align-middle mb-0">
|
|
<thead class="bg-light sticky-top">
|
|
<tr>
|
|
<th>Club</th>
|
|
<th>Categoría Base</th>
|
|
<th>Grupo en Torneo</th>
|
|
<th class="text-end">Acciones</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse($torneo->equipos as $te)
|
|
<tr>
|
|
<td>
|
|
<strong>{{ $te->club->nombre }}</strong>
|
|
</td>
|
|
<td>
|
|
<span class="badge border text-dark">{{ $te->categoria }} {{ $te->division }}</span>
|
|
</td>
|
|
<td>
|
|
@if($te->pivot->grupo)
|
|
<span class="badge bg-info text-white">{{ $te->pivot->grupo }}</span>
|
|
@else
|
|
<span class="text-muted small italic">Usar Base</span>
|
|
@endif
|
|
</td>
|
|
<td class="text-end">
|
|
<form action="{{ route('admin.torneos.equipos.remove', [$torneo->id, $te->id_equipo]) }}" method="POST" class="d-inline">
|
|
@csrf @method('DELETE')
|
|
<button type="submit" class="btn btn-link text-danger p-0 border-0" onclick="return confirm('¿Remover este equipo del torneo?')">
|
|
<i class="bi bi-x-circle-fill fs-5"></i>
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="3" class="text-center py-4 text-muted">No hay equipos asignados a este torneo.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
@if($torneo && $torneo->equipos->count() >= 2)
|
|
<!-- Generar Fixture -->
|
|
<div class="admin-card mt-4">
|
|
<div class="card-header bg-white py-3 d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<h5 class="mb-0 fw-bold"><i class="bi bi-calendar3-range-fill text-primary me-2"></i>Generar Fixture Regular</h5>
|
|
<span class="text-muted small">Round-Robin automático para los {{ $torneo->equipos->count() }} equipos del torneo</span>
|
|
</div>
|
|
<a href="{{ route('admin.torneos.importar', $torneo->id) }}" class="btn btn-sm btn-outline-success">
|
|
<i class="bi bi-upload"></i> Importar Masivo (CSV/Texto)
|
|
</a>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" action="{{ route('admin.torneos.fixture.preview', $torneo->id) }}">
|
|
@csrf
|
|
<div class="row g-3 align-items-end">
|
|
<div class="col-md-3">
|
|
<label class="form-label small fw-bold text-muted text-uppercase">Fecha de inicio *</label>
|
|
<input type="date" name="fecha_inicio" class="form-control" required
|
|
min="{{ date('Y-m-d') }}" value="{{ date('Y-m-d', strtotime('+7 days')) }}">
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label small fw-bold text-muted text-uppercase">Días entre jornadas</label>
|
|
<input type="number" name="dias_entre_jornadas" class="form-control" value="7" min="1" max="60">
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label class="form-label small fw-bold text-muted text-uppercase">Sede por defecto</label>
|
|
<input type="text" name="sede_default" class="form-control" placeholder="Ej: Estadio Municipal">
|
|
</div>
|
|
<div class="col-md-2 d-flex align-items-center gap-2 pt-3">
|
|
<input type="checkbox" name="doble_rueda" value="1" class="form-check-input" id="doble_rueda" style="width:20px;height:20px;">
|
|
<label for="doble_rueda" class="form-check-label small fw-bold">Ida y vuelta</label>
|
|
</div>
|
|
<div class="col-md-1">
|
|
<button type="submit" class="btn-admin w-100 py-3" title="Ver preview">
|
|
<i class="bi bi-eye"></i> Preview
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Generar Playoffs -->
|
|
<div class="admin-card mt-4 border-primary">
|
|
<div class="card-header bg-light py-3">
|
|
<h5 class="mb-0 fw-bold text-primary"><i class="bi bi-diagram-3-fill me-2"></i>Fase Eliminatoria (Playoffs)</h5>
|
|
<span class="text-muted small">Generar cruces 1º vs 8º basado en la tabla actual</span>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" action="{{ route('admin.torneos.playoffs.generar', $torneo->id) }}">
|
|
@csrf
|
|
<div class="row g-3 align-items-end">
|
|
<div class="col-md-3">
|
|
<label class="form-label small fw-bold text-muted text-uppercase">Grupo / Categoría</label>
|
|
<select name="grupo" class="form-select" required>
|
|
<option value="">Seleccione grupo...</option>
|
|
@php
|
|
$grupos = \DB::table('torneo_equipo')->where('id_torneo', $torneo->id)->distinct()->pluck('grupo')->filter();
|
|
@endphp
|
|
@foreach($grupos as $g)
|
|
<option value="{{ $g }}">{{ $g }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-md-2">
|
|
<label class="form-label small fw-bold text-muted text-uppercase">Formato de Serie</label>
|
|
<select name="formato" class="form-select" required>
|
|
<option value="1">Partido Único</option>
|
|
<option value="3">Mejor de 3</option>
|
|
<option value="5">Mejor de 5</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="alert alert-info py-2 mb-0 small">
|
|
<i class="bi bi-info-circle"></i> Los 8 mejores del grupo iniciarán en Cuartos.
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<button type="submit" class="btn btn-primary w-100 py-3" onclick="return confirm('¿Generar Cuartos de Final con este formato?')">
|
|
<i class="bi bi-lightning-fill"></i> Generar Cuartos
|
|
</button>
|
|
<a href="{{ route('admin.torneos.playoffs.manage', $torneo->id) }}" class="btn btn-outline-primary w-100 mt-2">
|
|
<i class="bi bi-diagram-3"></i> Gestionar LLaves Existentes
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
@elseif($torneo)
|
|
<div class="alert alert-warning mt-4 d-flex align-items-center gap-2">
|
|
<i class="bi bi-exclamation-triangle-fill fs-5"></i>
|
|
<span>Necesitás al menos <strong>2 equipos</strong> asignados al torneo para generar el fixture.</span>
|
|
</div>
|
|
@endif
|
|
|
|
@endsection
|
|
|