Mercurial > hg > fapweb
changeset 269:46138f8478e5
Work on votekey management.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 24 Nov 2013 16:10:58 +0200 |
parents | feed47a72df4 |
children | 589b44acb74a |
files | admajax.php |
diffstat | 1 files changed, 54 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Sun Nov 24 05:18:34 2013 +0200 +++ b/admajax.php Sun Nov 24 16:10:58 2013 +0200 @@ -266,35 +266,69 @@ break; case "voters": - $sqlJoins = ""; + // List of votekeys + echo + "<div>\n". + "<a href=\"#\" onClick=\"generateVoteKeys();\">Generate votekeys</a>\n". + "<a href=\"print.php\" target=\"_blank\">Printable key list</a>\n". + "</div>\n"; + switch (stGetSetting("voteKeyMode")) { case VOTE_FREELY: - break; + case VOTE_ACTIVATE: + $sql = "SELECT * FROM votekeys ORDER BY votekeys.id ASC"; - case VOTE_ACTIVATE: + $keyLen = stGetSetting("userKeyLength"); + $index = 0; + echo "<table class=\"votekeys\">\n"; + foreach (stExecSQL($sql) as $item) + { + if ($index == 0) + echo "<tr>\n"; + + // This funny code is to ensure that the cells are of uniform width + printf("<td><span class=\"keyid\">%03d</span> : ". + "<span class=\"keycode\">%s</span></td>\n", + $item["id"], + str_repeat(" ", $keyLen - strlen($item["key"])).$item["key"]); + + if ($index++ >= 5) + { + echo "</tr>\n"; + $index = 0; + } + } + if ($index > 0) + echo "</tr>\n"; + + echo "</table>\n"; break; case VOTE_ASSIGN: - $sqlJoins = "LEFT JOIN attendees ON votekeys.voter_id=attendees.id "; + $sql = "SELECT * FROM votekeys ". + "LEFT JOIN attendees ON votekeys.voter_id=attendees.id ". + "ORDER BY votekeys.id ASC"; + + echo + "<table class=\"attendees\">\n". + " <tr>\n". + " <th class=\"name\">Name</th>\n". + " <th class=\"groups\">Groups</th>\n". +// " <th class=\"email\">E-mail</th>\n". + " <th class=\"\">Key</th>\n". + " </tr>\n"; + + $row = 0; + foreach (stExecSQL($sql) as $item) + { + print_r($item); + } + + echo + "</table>\n"; break; } - $sql = "SELECT * FROM votekeys ".$sqlJoins."ORDER BY votekeys.id ASC"; - - // List of votekeys - echo - "<p><a href=\"print.php\">Printable key list</a></p>\n". - "<table class=\"attendees\">\n". - " <tr>\n". - " <th class=\"name\">Name</th>\n". - " <th class=\"groups\">Groups</th>\n". - " <th class=\"email\">E-mail</th>\n". - " <th class=\"\">Key</th>\n". - " </tr>\n"; - $row = 0; - - echo - "</table>\n"; break; case "compos":