<%- include('header.html', { pageTitle, extraStyles, extraScripts }) %> <% function formatDateLong(date){ if(!date){ date = new Date()} let sdate = date.toLocaleDateString('es-MX', { year: 'numeric', month: 'long', day: 'numeric' }); return sdate } function formatDate(date){ if(!date){ date = new Date()} let sdate = date.toLocaleDateString('es-MX', { year: 'numeric', month: 'short', day: 'numeric' }); return sdate.toUpperCase() } function formatTime(time){ let hh = time.substr(0,2) let mm = time.substr(3,2) let am = parseInt(hh) > 11 ? 'pm' : 'am' let hr = parseInt(hh) hr = hr > 12 ? hr-12 : hr return `${hr.toString().padStart(2,'0')}:${mm} ${am}` } function getAge(date){ const diff = Date.now() - new Date(date).getTime(); const ageDate = new Date(diff); return Math.abs(ageDate.getUTCFullYear() - 1970); } function onlyDate(date=null){ if(!date){ return new Date().toJSON().substr(0,10) } return date.toJSON().substr(0,10) } function getPoints(sport, pickle, padel, beach){ switch(sport){ case 'pickleball': return pickle; case 'padel': return padel; case 'beach_tennis': return beach; default: return 0; } } function getPhase(phase){ const phases = { 'group': 'Fase de Grupos', 'round_of_64': 'Ronda de 64', 'round_of_32': 'Ronda de 32', 'round_of_16': 'Ronda de 16', 'round_of_8': 'Ronda de 8', 'quarter': 'Cuartos de Final', 'semi': 'Semifinal', 'final': 'Final' } return phases[phase] || 'Eliminatorias' } %>

<%= isNew ? 'Nuevo Torneo' : 'Editar Torneo' %>

<% if (isNew) { %> <% } else { %> <% } %>
<% if (!isNew && tournament) { %>

Canchas

<% if (courts.length === 0) { %>

No hay canchas registradas

<% } else { %> <% courts.forEach(function(court) { %>
<%= court.name %>
<% }) %> <% } %>

Categorías

<% if (categories.length > 0) { %>
<% categories.forEach(function(cat) { %>
<%= cat.name %>
<%=cat.teams || 0%> <%=cat.teams == 1 ? 'Equipo' : 'Equipos' %>
<% }) %>
<% } %>

Agregar Categoría

<% if(tournament.sport=='pickleball'){ %> <% } else if(tournament.sport=='padel'){ %> <% } else if(tournament.sport=='beach_tennis'){ %> <% } %>

Jugadores del Torneo

<% if (typeof allPlayers !== 'undefined' && allPlayers && allPlayers.length > 0) { %>
<% let paytotal = 0 allPlayers.forEach(function(p) { paytotal += (p.payment1+p.payment2+p.payment3+p.payment4) %> <% }) %>
Nombre Cédula Edad Sexo Nivel Puntos Categoría Pago  
<%= p.name %> <%= p.legal_id %> <%= getAge(p.date_of_birth) %> <%= p.sex %> <%= p.category %> <%= getPoints(tournament.sport, p.points_pickle, p.points_padel, p.points_beach) %> <%= p.catname %> <%= p.exempt ? '---' : (p.payment1+p.payment2+p.payment3+p.payment4) %>
  Total Recaudado <%=paytotal%>  
<% } %>

Agregar Jugador

<% if(tournament.sport=='pickleball'){ %> <% } else if(tournament.sport=='padel'){ %> <% } else if(tournament.sport=='beach_tennis'){ %> <% } %>
No paga inscripción

Equipos

<% if (teams.length === 0) { %>

No hay equipos registrados

<% } else { %> <% teams.forEach(function(team) { %>
Grupo <%= team.group_name || '-' %> • #<%= team.seed_number %>
<%=team.catname%> <%= team.name %>
<%= team.player1 || 'N/A' %> <%= team.player2 || 'N/A' %>
<% }) %> <% } %>

Agregar Equipo

Fases

<% if (phases.length > 0) { %>
<% phases.forEach(function(phase) { %>

<%= phase.catname%>

Fase <%= phase.phase_order %>: <%= phase.name %> <%= phase.best_of_sets %> <%= phase.best_of_sets==1 ? 'set' : 'sets' %> • <%= phase.scoring_mode %> • <%= phase.points_to_win %> puntos <% if (phase.is_group_phase) { %> <%= phase.number_of_groups %> grupos, <%= phase.teams_per_group %> equipos <% } %>
<% if(phase.is_group_phase){ %> <% } %>
<% }) %>
<% } %>

Agregar Fase

<% if(tournament.sport=='pickleball'){ %>
<% } %>

Gestión de Partidos

<% if (phases.length === 0) { %>

No hay fases definidas

<% } else { %> <% phases.forEach(function(phase) { %>

<%= phase.catname %>

Fase <%= phase.phase_order %>: <%= phase.name %>

<% const phaseMatches = matches.filter(m => m.phase_id === phase.id); %> <% if (phaseMatches.length === 0) { %>

No hay partidos en esta fase

<% } else { %>
<% phaseMatches.forEach(function(match) { %> <% }) %>
Fecha Cancha Equipo 1 Equipo 2 Resultado Estado  
<%=formatDate(match.scheduled_date)%>
<%=formatTime(match.scheduled_time || '17:00')%>
<%=match.court_name%>
<%= match.team1_name || 'TBD' %>
<%=match.team1_player1%> / <%=match.team1_player2%>
<%= match.team2_name || 'TBD' %>
<%=match.team2_player1%> / <%=match.team2_player2%>
<% if (match.status === 'finalizado') { %> <%= match.team1_score %> - <%= match.team2_score %> <% } else { %> - <% } %> <%= match.status %>
<% } %>
<% }) %> <% } %>

Registro de Partido

<% if(tournament.sport=='pickleball'){ %>
<% } %>

Tabla de Posiciones

<% if (leaderboard.length === 0) { %>

No hay datos en la tabla de posiciones

<% } else { %>
<% leaderboard.forEach(function(entry) { %> <% }) %>
# Grupo Equipo Ganados Perdidos Sets-G Sets-P Puntos-G Puntos-P
<%= entry.rank %> <%= entry.group_name || '-' %> <%= entry.team_name %>
<%=entry.name1%> / <%=entry.name2%>
<%= entry.wins %> <%= entry.losses %> <%= entry.sets_won %> <%= entry.sets_lost %> <%= entry.points_for %> <%= entry.points_against %>
<% } %>
<% } %>
<%- include('footer.html', { extraScripts }) %>