changeset 1038:2e1a9b564674

Add votekey information blurb.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 20 Nov 2015 08:38:38 +0200
parents df54d73bc5a0
children 42cf6048a594
files admajax.php admin.js
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Fri Nov 20 07:54:48 2015 +0200
+++ b/admajax.php	Fri Nov 20 08:38:38 2015 +0200
@@ -392,6 +392,14 @@
 }
 
 
+function stGetVoteKeyInfo()
+{
+  $nkeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys WHERE active=1");
+  $totalKeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys");
+  return "Info: <b>".$nkeys."</b> of <b>".$totalKeys."</b> votekeys are activated.";
+}
+
+
 function stGetVoteKeyItemData($id, $item, $prefix)
 {
   global $setVoteKeyMode, $setVoteKeyLen;
@@ -1370,6 +1378,10 @@
           stError("No such attendee ID!");
         break;
 
+      case "votekeyinfo":
+        echo stGetVoteKeyInfo();
+        break;
+
       case "votekey":
       case "votekeyclass":
         switch ($setVoteKeyMode)
@@ -1426,6 +1438,7 @@
           "</div>\n".
           "<div class=\"tabHeadersSub\">\n".
           "<a href=\"print.php?type=votekeys\" target=\"_blank\">Show printable key list</a>\n".
+          "<div id=\"vkeyInfo\">".stGetVoteKeyInfo()."</div>\n".
           "</div>\n";
 
         switch ($setVoteKeyMode)
--- a/admin.js	Fri Nov 20 07:54:48 2015 +0200
+++ b/admin.js	Fri Nov 20 08:38:38 2015 +0200
@@ -536,6 +536,12 @@
 //
 // Votekey management
 //
+function voteKeyInfoRefresh()
+{
+  jsRefreshItems("vkeyInfo", "votekey", "info");
+}
+
+
 function voteKeyRefresh(id)
 {
   var msuccess2 = function(txt)
@@ -543,6 +549,7 @@
     var nitem = document.getElementById("vkey"+id);
     if (nitem)
       nitem.className = txt;
+    voteKeyInfoRefresh();
   }
 
   var msuccess1 = function(txt)
@@ -550,6 +557,7 @@
     var nitem = document.getElementById("vkey"+id);
     if (nitem)
       nitem.innerHTML = txt;
+    voteKeyInfoRefresh();
   }
 
   jsSendPOSTRequest("action=get&type=votekey&id="+id, msuccess1);
@@ -562,6 +570,7 @@
   var msuccess = function(txt)
   {
     voteKeyRefresh(id);
+    voteKeyInfoRefresh();
   }
 
   jsSendPOSTRequest("action=votekey&type="+type+"&id="+id+"&"+args, msuccess);