#! /usr/bin/perl

use ccbs;
use strict;
use warnings;

my $cgi = new CGI;
my $id = $cgi->param('id');

my $dbh = ccbs::db_connect();

my $tournament = $dbh->selectrow_hashref('SELECT * FROM tournaments NATURAL JOIN seasons NATURAL JOIN countries NATURAL JOIN machines NATURAL JOIN scoringsystems WHERE tournament=?', undef, $id);
my $ref = $dbh->selectrow_hashref('SELECT count(*) AS num_registered FROM tournamentparticipation WHERE tournament=?', undef, $id);
my $num_registered = $ref->{'num_registered'};

ccbs::print_header();
ccbs::process_template('start-tournament.tmpl', $tournament->{'tournamentname'}, {
	tournament => $tournament,
	num_registered => $num_registered
});
$dbh->disconnect;
