- Proper functionality for editing groups (adding/deleting players and songs)
-- Ability to edit players (in particular, fix country/group)
- Multiple variations on short titles
- Add DP/pass in addition to score
- Auto-reset of the song selector on first elimination round?
--- /dev/null
+#! /usr/bin/perl
+
+use ccbs;
+use strict;
+use warnings;
+
+ccbs::admin_only();
+
+my $dbh = ccbs::db_connect();
+my $cgi = new CGI;
+
+my $player = $cgi->param('player');
+my $nick = $cgi->param('nick');
+my $country = $cgi->param('country');
+my $club = $cgi->param('club');
+
+$club = undef if ($club == -1);
+
+$dbh->do('UPDATE players SET nick=?, country=?, club=? WHERE player=?', undef, $nick, $country, $club, $player);
+ccbs::print_see_other('player.pl?id=' . $player);
+
+$dbh->disconnect;
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);
+my ($countries, $clubs);
+unless ($ccbs::ccbs_noadmin) {
+ $countries = ccbs::db_fetch_all($dbh, 'SELECT * FROM countries ORDER BY countrycode');
+ $clubs = ccbs::db_fetch_all($dbh, 'SELECT * FROM clubs ORDER BY clubcode');
+}
+
# Fetch all scores and count a bit
my $columns = 0;
my @allsongs = ();
player => $player,
bestsongs => $bestsongs,
allsongs => \@allsongs,
- columns => $columns
+ columns => $columns,
+ countries => $countries,
+ clubs => $clubs
});
$dbh->disconnect;
</ul>
</div>
+[% IF !public %]
+ <h2>Rediger spiller</h2>
+
+ <div>
+ <form method="post" action="do-edit-player.pl">
+ <input type="hidden" name="player" value="[% player.player %]" />
+ <table>
+ <tr>
+ <th>Nick</th>
+ <td><input name="nick" value="[% player.nick %]" /></td>
+ </tr>
+ <tr>
+ <th>Land</th>
+ <td>
+ <select name="country">
+[% FOR c = countries %]
+ [% IF c.country == player.country %]
+ <option value="[% c.country %]" selected="selected">[% c.countrycode %] - [% c.countryname %]</option>
+ [% ELSE %]
+ <option value="[% c.country %]">[% c.countrycode %] - [% c.countryname %]</option>
+ [% END %]
+[% END %]
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th>Klubb</th>
+ <td>
+ <select name="club">
+ <option value="-1"></option>
+[% FOR c = clubs %]
+ [% IF c.club == player.club %]
+ <option value="[% c.club %]" selected="selected">[% c.clubname %]</option>
+ [% ELSE %]
+ <option value="[% c.club %]">[% c.clubname %]</option>
+ [% END %]
+[% END %]
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th colspan="2">
+ <input type="submit" value="Rediger" />
+ </th>
+ </tr>
+ </table>
+ </form>
+ </div>
+[% END %]
+
<h2>Beste sanger</h2>
<div>
<table>
[% FOR r = registered %]
<tr>
- <td>[% r.nick %]</td>
+ <td><a href="player.pl?id=[% r.player %]">[% r.nick %]</a></td>
[% IF r.paid %]
<td>betalt</td>
[% ELSE %]
</p>
</form>
</td>
+ <td>
+ <form method="post" action="edit-player.pl">
+ <p class="button">
+ <input type="hidden" name="player" value="[% r.player %]" />
+ <input type="submit" value="Editer spiller" />
+ </p>
+ </form>
+ </td>
</tr>
[% END %]
</table>