#! /usr/bin/perl

use ccbs;
use strict;
use warnings;

my $dbh = ccbs::db_connect();
my $cgi = new CGI;

my $tournament = $cgi->param('tournament');
my $round = $cgi->param('round');
my $num_random = $cgi->param('numrandom');
my $num_chosen = $cgi->param('numchosen');
my $num_groups = $cgi->param('numgroups');
my $num_qual = $cgi->param('numqual');

$dbh->do('INSERT INTO rounds (tournament, round, randomsongs, chosensongs, numqualifying) VALUES (?, ?, ?, ?, ?)',
	undef, $tournament, $round, $num_random, $num_chosen, $num_qual);

for my $i (1..$num_groups) {
	$dbh->do('INSERT INTO groups (tournament, round, parallel) VALUES (?, ?, ?)',
		undef, $tournament, $round, $i);
}

ccbs::print_see_other('show-tournamelt.pl?id=' . $tournament);

$dbh->disconnect;
