changeset 270:589b44acb74a

More work on votekey admin.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 24 Nov 2013 16:53:48 +0200
parents 46138f8478e5
children becf97e747d2
files admajax.php
diffstat 1 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Sun Nov 24 16:10:58 2013 +0200
+++ b/admajax.php	Sun Nov 24 16:53:48 2013 +0200
@@ -266,14 +266,26 @@
         break;
 
       case "voters":
+        // Generate vote keys, if needed
+        $numVKeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys");
+        $numUsers = stFetchSQLColumn("SELECT COUNT(*) FROM attendees");
+        while ($numVKeys < $numUsers)
+        {
+          if (($key = stGenerateUserKey()) !== false)
+          {
+            if (stExecSQL(stPrepareSQL("INSERT INTO votekeys (key) VALUES (%s)", $key)) !== false)
+              $numVKeys++;
+          }
+        }
+
         // List of votekeys
+        $vmode = stGetSetting("voteKeyMode");
         echo
           "<div>\n".
-          "<a href=\"#\" onClick=\"generateVoteKeys();\">Generate votekeys</a>\n".
-          "<a href=\"print.php\" target=\"_blank\">Printable key list</a>\n".
+          "<a href=\"print.php?type=votekeys\" target=\"_blank\">Printable key list</a>\n".
           "</div>\n";
 
-        switch (stGetSetting("voteKeyMode"))
+        switch ($vmode)
         {
           case VOTE_FREELY:
           case VOTE_ACTIVATE:
@@ -288,11 +300,17 @@
                 echo "<tr>\n";
               
               // This funny code is to ensure that the cells are of uniform width
-              printf("<td><span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
-                "<span class=\"keycode\">%s</span></td>\n",
+              printf("<td id=\"vkey".$item["id"].
+                "\"><span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
+                "<span class=\"keycode\">%s</span>",
                 $item["id"],
                 str_repeat("&nbsp;", $keyLen - strlen($item["key"])).$item["key"]);
               
+              if ($vmode == VOTE_ACTIVATE)
+                echo stGetFormCheckBoxInput("active", $item["id"], $prefix, $item["active"], "")."\n";
+
+              echo "</td>";
+              
               if ($index++ >= 5)
               {
                 echo "</tr>\n";