From 4a2f33b86e70f2270906265751131161ba114f36 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 4 Apr 2005 01:34:46 +0000 Subject: [PATCH] Add a "show player" page. --- html/ccbs.css | 1 + html/player.pl | 42 +++++++++++++++++++++++++++ html/templates/player.tmpl | 58 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 html/player.pl create mode 100644 html/templates/player.tmpl diff --git a/html/ccbs.css b/html/ccbs.css index b68d590..2d01d88 100644 --- a/html/ccbs.css +++ b/html/ccbs.css @@ -65,6 +65,7 @@ th { background-color: rgb(128,229,128); } 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; diff --git a/html/player.pl b/html/player.pl new file mode 100755 index 0000000..0fbde00 --- /dev/null +++ b/html/player.pl @@ -0,0 +1,42 @@ +#! /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; diff --git a/html/templates/player.tmpl b/html/templates/player.tmpl new file mode 100644 index 0000000..0e52434 --- /dev/null +++ b/html/templates/player.tmpl @@ -0,0 +1,58 @@ +[%# vim:set filetype=html: %] +

Generelle fakta

+ +
+ +
+ +

Beste sanger

+ +
+ + + + + + + + +[% SET rowno = 1 %] +[% FOR s = bestsongs %] + + +[% SET rowno = rowno + 1 %] + + + + +[% END %] +
SangPoengsumArrangement
[% rowno %][% s.title %][% s.score %][% s.tournamentname %]
+
+ +
+

Alle sanger

+ + +[% FOR s = allsongs %] + + +[% SET col = 0 %] +[% FOR score = s.scores %] + +[% SET col = col + 1 %] +[% END %] +[% WHILE col != columns %] + +[% SET col = col + 1 %] +[% WEND %] +[% END %] + +[% END %] +
[% s.title %][% score %]
+
-- 2.39.2