changeset 53:71256605546b

More work on admin interface.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 05 Oct 2013 08:43:39 +0300
parents cba0b944da79
children 30385b66ca1c
files admin.inc.php ajax.php fap.css msite.inc.php
diffstat 4 files changed, 70 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/admin.inc.php	Sat Oct 05 07:29:42 2013 +0300
+++ b/admin.inc.php	Sat Oct 05 08:43:39 2013 +0300
@@ -290,7 +290,12 @@
 {
   var args = makePostArgs({"oneliner":0,"email":0,"active":3}, "at", id);
 
-  sendPOSTRequest("action=update&type=attendees&id="+id+"&"+args);
+  var msuccess = function(txt)
+  {
+    setTimeout("refreshAttendees();", 50);
+  }
+
+  sendPOSTRequest("action=update&type=attendees&id="+id+"&"+args, msuccess);
 }
 
 
--- a/ajax.php	Sat Oct 05 07:29:42 2013 +0300
+++ b/ajax.php	Sat Oct 05 08:43:39 2013 +0300
@@ -66,6 +66,9 @@
 switch ($action)
 {
   case "dump":
+    //
+    // Perform generic data dump
+    //
     if (($res = execSQLCond(
       "SELECT * FROM attendees WHERE email NOT NULL AND email != '' ORDER BY regtime DESC",
       "Dump OK.")) !== FALSE)
@@ -89,6 +92,9 @@
     break;
 
   case "get":
+    //
+    // Get specific data
+    //
     switch ($type)
     {
       case "news":
@@ -201,9 +207,7 @@
         echo
         "<table class=\"attendees\">\n".
         " <tr>\n".
-        "  <th>Name</th>\n".
-        "  <th class=\"groups\">Group(s)</th>\n".
-        "  <th class=\"regtime\">Registered</th>\n".
+        "  <th class=\"rname\">Name</th>\n".
         "  <th class=\"oneliner\">Oneliner</th>\n".
         "  <th class=\"email\">E-mail</th>\n".
         "  <th>Actions</th>\n".
@@ -238,26 +242,47 @@
     break;
 
   case "delete":
+    //
+    // Delete entry
+    //
     if (stChkRequestItem("id"))
     {
       $id = intval(stGetRequestItem("id"));
 
       if ($type == "news")
+      {
         $sql = stPrepareSQL("DELETE FROM news WHERE id=%d AND persist=0", $id);
+        execSQLCond($sql, "OK, news item ".$id." deleted.");
+      }
       else
       if ($type == "attendees")
+      {
+        // Attendees require some more work
         $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id);
+        execSQLCond($sql, "OK, attendee ".$id." deleted.");
+
+        $sql = stPrepareSQL("DELETE FROM votes WHERE voter_id=%d", $id);
+        execSQLCond($sql, "OK, attendee ".$id." votes deleted.");
+      }
       else
       if ($type == "entries")
+      {
+        // .. as do compo entries
         $sql = stPrepareSQL("DELETE FROM entries WHERE id=%d", $id);
+        execSQLCond($sql, "OK, entry ".$id." deleted.");
 
-      execSQLCond($sql, "OK, ".$type." item ".$id." deleted.");
+        $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id);
+        execSQLCond($sql, "OK, entry ".$id." votes deleted.");
+      }
     }
     else
       setStatus(901, "No ID specified.");
     break;
 
   case "add":
+    //
+    // Add new entry
+    //
     if ($type == "news" && stChkRequestItem("text") &&
       stChkRequestItem("author") && stChkRequestItem("title"))
     {
@@ -278,10 +303,24 @@
       execSQLCond($sql, "OK, compo added.");
     }
     else
+    if ($type == "attendees" && stChkRequestItem("name") &&
+      stChkRequestItem("groups") && stChkRequestItem("email") &&
+      stChkRequestItem("oneliner"))
+    {
+      $sql = stPrepareSQL(
+        "INSERT INTO attendees (regtime,name,groups,oneliner,email) VALUES (%d,%S,%S,%S,%S)",
+        time(), "name", "groups", "oneliner", "email");
+
+      execSQLCond($sql, "OK, attendee added.");
+    }
+    else
       setStatus(902, "No data.");
     break;
 
   case "update":
+    //
+    // Update existing entry
+    //
     if ($type == "attendees" && stChkRequestItem("id") &&
       stChkRequestItem("email") && stChkRequestItem("oneliner") &&
       stChkRequestItem("active"))
--- a/fap.css	Sat Oct 05 07:29:42 2013 +0300
+++ b/fap.css	Sat Oct 05 08:43:39 2013 +0300
@@ -356,8 +356,12 @@
 	width: 25%;
 }
 
-table.users tr.vactive td {
-	background: rgba(255,0,0,0.5);
+table.attendees th.rname {
+	width: 15%;
+}
+
+tr.vactive td.vkey, tr.vactive td.vactive {
+	background: rgba(0,255,0,0.7);
 }
 
 div.votectrl {
--- a/msite.inc.php	Sat Oct 05 07:29:42 2013 +0300
+++ b/msite.inc.php	Sat Oct 05 08:43:39 2013 +0300
@@ -387,10 +387,23 @@
   $id = $item["id"];
   $prefix = "at";
   echo "  ".
-    "<tr class=\"".($row % 2 == 1 ? "rodd" : "reven").$eclass."\" id=\"attendee".$id."\">".
+    " <tr class=\"".($item["active"] ? "vactive " : "").
+    ($row % 2 == 1 ? "rodd" : "reven")."\" id=\"attendee".$id."\">";
+  
+  if ($edit)
+  {
+    echo
+    stGetTDEditTextItem(FALSE, 20, 40, "name", $id, $prefix, $item["name"]." / ".$item["groups"]);
+  }
+  else
+  {
+    echo
     stGetTDEditTextItem(FALSE, 20, 40, "name", $id, $prefix, $item["name"]).
     stGetTDEditTextItem(FALSE, 20, 40, "groups", $id, $prefix, $item["groups"]).
-    "<td class=\"regtime\">".date("d M Y / H:i", $item["regtime"])."</td>".
+    "<td class=\"regtime\">".date("d M Y / H:i", $item["regtime"])."</td>";
+  }
+
+  echo
     stGetTDEditTextItem($edit, 30, 64, "oneliner", $id, $prefix, $item["oneliner"], "autocomplete=\"off\"");
 
   if ($edit)