#! /usr/bin/perl

use ccbs;
use strict;
use warnings;

my $dbh = ccbs::db_connect();
my $tournaments = ccbs::db_fetch_all($dbh, 'SELECT * FROM tournaments NATURAL JOIN seasons ORDER BY season, date, tournamentname');

# Translate the season names
my @t_trans = ();
for my $t (@$tournaments) {
	my %tt = %$t;
	$tt{'seasonname'} = Locale::gettext::gettext($t->{'seasonname'});
	push @t_trans, \%tt;
}

ccbs::print_header();
ccbs::process_template('tournaments.tmpl', _('Tournaments'), { tournaments => \@t_trans });
$dbh->disconnect;
