Hide rankinglist if there is none. Count the number of qualified for next round.
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 14 Feb 2005 19:32:16 +0000 (19:32 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 14 Feb 2005 19:32:16 +0000 (19:32 +0000)
html/show-tournament.pl
html/templates/show-tournament.tmpl

index 87df626..57bd379 100755 (executable)
@@ -62,12 +62,26 @@ for my $score (@$scores) {
 }
 
 my $num_rounds = scalar @rounds;
+my $num_rankings = scalar @$rankings;
+
+# If there have been no rounds, check out the number of participants; if not, check the
+# number of qualified from the last round
+my $num_qualified;
+if ($num_rounds == 0) {
+       my $ref = $dbh->selectrow_hashref('SELECT COUNT(*) AS num_participants FROM tournamentparticipation WHERE tournament=?', undef, $id);
+       $num_qualified = $ref->{'num_participants'};
+} else {
+       my $ref = $dbh->selectrow_hashref('SELECT numqualifying FROM roundparticipation WHERE tournament=? AND round=?', undef, $id, $num_rounds);
+       $num_qualified = $ref->{'numqualifying'};
+}
 
 ccbs::print_header();
 ccbs::process_template('show-tournament.tmpl', $tournament->{'tournamentname'}, {
        tournament => $tournament,
        rankings => $rankings,
+       num_rankings => $num_rankings,
        rounds => \@rounds,
-       num_rounds => $num_rounds
+       num_rounds => $num_rounds,
+       num_qualified => $num_qualified
 });
 $dbh->disconnect;
index fac6ed0..ad3a8e9 100644 (file)
@@ -42,6 +42,7 @@
     </form>
   </div>
 
+[% IF num_rankings > 0 %]
   <h2>Rankingliste</h2>
 
   <div>
@@ -55,6 +56,7 @@
 [% END %]
     </ul>
   </div>
+[% END %]
 
 [% FOR r = rounds %]
   <h2>Runde [% r.round %]</h2>