tr.even td { background-color: #ffa; }
tr.total { border-top: 2px solid black; }
tr.own { border: 2px solid red; }
+td.empty { border: 0px; }
a:link, a:hover, th a:link, th a:visited, th a:hover {
color: blue;
--- /dev/null
+#! /usr/bin/perl
+
+use ccbs;
+use strict;
+use warnings;
+
+my $cgi = new CGI;
+my $id = $cgi->param('id');
+
+my $dbh = ccbs::db_connect();
+
+my $player = $dbh->selectrow_hashref('SELECT * FROM players NATURAL JOIN countries NATURAL LEFT JOIN clubs WHERE player=?', undef, $id);
+my $bestsongs = ccbs::db_fetch_all($dbh, 'SELECT song,title,score,tournament,tournamentname FROM ( SELECT DISTINCT ON (song) song,score,tournament FROM scores WHERE player=? AND score IS NOT NULL ORDER BY song,score DESC ) t1 NATURAL JOIN songs NATURAL JOIN tournaments ORDER BY score DESC LIMIT 10', $id);
+
+# Fetch all scores and count a bit
+my $columns = 0;
+my @allsongs = ();
+my $last_title = undef;
+
+my $scores = ccbs::db_fetch_all($dbh, 'SELECT title,score FROM scores NATURAL JOIN songs WHERE player=? ORDER BY title,score DESC', $id);
+for my $score (@$scores) {
+ my $title = $score->{'title'};
+ if (!defined($last_title) || $title ne $last_title) {
+ push @allsongs, { title => $title, scores => [] };
+ }
+
+ push @{$allsongs[$#allsongs]->{'scores'}}, $score->{'score'};
+
+ my $this_columns = scalar @{$allsongs[$#allsongs]->{'scores'}};
+ $columns = $this_columns if ($this_columns > $columns);
+
+ $last_title = $title;
+}
+
+ccbs::print_header();
+ccbs::process_template('player.tmpl', $player->{'title'}, {
+ player => $player,
+ bestsongs => $bestsongs,
+ allsongs => \@allsongs,
+ columns => $columns
+});
+$dbh->disconnect;
--- /dev/null
+[%# vim:set filetype=html: %]
+ <h2>Generelle fakta</h2>
+
+ <div>
+ <ul>
+ <li>Nick: [% player.nick %]</li>
+ <li>Land: [% player.countryname %]</li>
+[% IF player.clubname != '' %]
+ <li>Klubb: [% player.clubname %]</li>
+[% END %]
+ </ul>
+ </div>
+
+ <h2>Beste sanger</h2>
+
+ <div>
+ <table>
+ <tr>
+ <th></th>
+ <th>Sang</th>
+ <th>Poengsum</th>
+ <th>Arrangement</th>
+ </tr>
+
+[% SET rowno = 1 %]
+[% FOR s = bestsongs %]
+ <tr>
+ <th>[% rowno %]</th>
+[% SET rowno = rowno + 1 %]
+ <td><a href="song.pl?id=[% s.song %]">[% s.title %]</a></td>
+ <td>[% s.score %]</td>
+ <td><a href="show-tournament.pl?id=[% s.tournament %]">[% s.tournamentname %]</a></td>
+ </tr>
+[% END %]
+ </table>
+ </div>
+
+ <div>
+ <h2>Alle sanger</h2>
+
+ <table>
+[% FOR s = allsongs %]
+ <tr>
+ <th>[% s.title %]</th>
+[% SET col = 0 %]
+[% FOR score = s.scores %]
+ <td>[% score %]</td>
+[% SET col = col + 1 %]
+[% END %]
+[% WHILE col != columns %]
+ <td class="empty"></td>
+[% SET col = col + 1 %]
+[% WEND %]
+[% END %]
+ </tr>
+[% END %]
+ </table>
+ </div>