+my $songs = ccbs::db_fetch_all($dbh, 'SELECT song,title FROM machinesongs NATURAL JOIN songs WHERE machine=? ORDER BY LOWER(title)', $tournament->{'machine'});
+
+# Check if the last round is valid for closing (by checking if all scores
+# entered are valid)
+my $ref = $dbh->selectrow_hashref('SELECT COUNT(*) AS num_incomplete FROM scores WHERE tournament=? AND (song IS NULL OR playmode IS NULL OR difficulty IS NULL OR chosen IS NULL or score IS NULL)', undef, $tournament->{'tournament'});
+my ($closing_valid,$finishing_valid);
+$finishing_valid = 0;
+if ($ref->{'num_incomplete'} == 0) {
+ $closing_valid = 1;
+} else {
+ $closing_valid = 0;
+}
+
+# Find all rounds currently shown on the bigscreen.
+my $active_rounds = $dbh->selectall_hashref('SELECT round FROM bigscreen.active_rounds WHERE tournament=?', 'round', undef, $id);