changeset 308:3cfd95758377

A bit of work on vote key management backend.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 26 Nov 2013 23:25:11 +0200
parents c0d573a5de5b
children 7c9f9db89306
files admajax.php admin.php
diffstat 2 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Tue Nov 26 22:47:24 2013 +0200
+++ b/admajax.php	Tue Nov 26 23:25:11 2013 +0200
@@ -314,7 +314,8 @@
               if ($voteKeyMode == VOTE_ACTIVATE)
               {
                 echo stGetFormCheckBoxInput("active", $item["id"], "",
-                  $item["active"], "", "class=\"keyactive\" onClick=\"voteKeyActivated(".$item["id"].")\"", "xx")."\n";
+                  $item["active"], FALSE,
+                  "class=\"keyactive\" onClick=\"voteKeyToggle(".$item["id"].")\"", "xx")."\n";
               }
 
               echo "</div>";
@@ -322,23 +323,34 @@
             break;
 
           case VOTE_ASSIGN:
-            $sql = "SELECT * FROM votekeys ".
-              "LEFT JOIN attendees ON votekeys.id=attendees.key_id ".
-              "ORDER BY votekeys.id ASC";
+            $sql = "SELECT votekeys.key,attendees.* FROM attendees ".
+              "LEFT JOIN votekeys ON votekeys.id=attendees.key_id ".
+              "ORDER BY attendees.regtime DESC";
 
             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".
+              "  <th class=\"vkeynum\">Key #</th>\n".
+              "  <th class=\"vkey\">Votekey</th>\n".
               " </tr>\n";
 
             $row = 0;
+            $prefix = "vk";
             foreach (stExecSQL($sql) as $item)
             {
-              print_r($item);
+              $vid = $item["id"];
+              echo
+                " <tr>\n".
+                "  <td class=\"name\">".chentities($item["name"])."</td>\n".
+                "  <td class=\"groups\">".chentities($item["groups"])."</td>\n".
+                "  <td class=\"vkeynum\">".
+                  stGetFormTextInput(5, 5, "key_id", $vid, $prefix, $item["key_id"]).
+                  stGetFormButtonInput("assign", $vid, $prefix, "Set", "voteKeyAssign(".$vid.")").
+                  "</td>\n".
+                "  <td class=\"vkey\">".chentities($item["key"])."</td>\n".
+                " </tr>\n";
             }
 
             echo
@@ -666,6 +678,18 @@
           stExecSQLCond($sql, "OK, entry updated.");
         }
       }
+      else
+      if ($type == "votekey")
+      {
+        switch (stGetRequestItem("mode"))
+        {
+          case "assign":
+            break;
+          
+          case "active":
+            break;
+        }
+      }
     }
     break;
 
--- a/admin.php	Tue Nov 26 22:47:24 2013 +0200
+++ b/admin.php	Tue Nov 26 23:25:11 2013 +0200
@@ -386,6 +386,31 @@
 }
 
 
+function voteKeyToggle(id)
+{
+  var args = makePostArgs({"active":2}, "vk", id);
+
+  var msuccess = function(txt)
+  {
+    refreshItems("votekey"+id, "votekey", "&id="+id);
+  }
+
+  sendPOSTRequest("action=update&type=votekey&mode=active&id="+id+"&"+args, msuccess);
+}
+
+
+function voteKeyAssign(id)
+{
+  var args = makePostArgs({"key_id":2}, "vk", id);
+
+  var msuccess = function(txt)
+  {
+    refreshItems("votekey"+id, "votekey", "&id="+id);
+  }
+
+  sendPOSTRequest("action=update&type=votekey&mode=assign&id="+id+"&"+args);
+}
+
 
 function updateTabList(tabset, extra)
 {