issue: header counting open and closed rows
[minimedit.git] / issue / index.php
index a4b131483522ea0f395a896fada6693b4f96e424..547547a5cd984a15d69e3a7439d2339a529e2eec 100644 (file)
@@ -59,14 +59,11 @@ if ($_POST and isset($_POST['subject'])) {
                if (!$row->id) {
                        throw new Exception('Issue niet goed opgeslagen.');
                }
-               $query = $Db->set('comments', [
-                       'page'    => "{$Page->handler}/{$row->id}",
-                       'raw'     => $_POST['body'],
-                       'message' => messagehtml($_POST['body']),
-                       'author'  => $User->login,
-               ]);
-               if (!$query->rowCount()) {
-                       throw new Exception('Issueinhoud niet opgeslagen.');
+               try {
+                       createcomment($_POST, $row);
+               }
+               catch (Exception $e) {
+                       throw new Exception("Issueinhoud niet opgeslagen: {$e->getMessage()}.");
                }
                $_POST = [];
 }
@@ -78,7 +75,7 @@ $sql = "SELECT $cols FROM issues i WHERE page = ?";
 if (isset($_GET['open'])) {
        $sql .= ' AND closed IS NULL';
 }
-$sql .= ' ORDER BY closed IS NOT NULL, updated DESC';
+$sql .= ' ORDER BY updated DESC';
 $query = $Db->query($sql, [$Page->handler]);
 
 if ($id == 'feed') {
@@ -86,6 +83,12 @@ if ($id == 'feed') {
 }
 
 ob_start();
+$stats = $Db->query(
+       "SELECT count(*) AS total, count(closed) AS closed FROM issues"
+)->fetch();
+printf("<h4>%d lopende zaken, %s opgelost</h4>\n",
+       $stats->total - $stats->closed, $stats->closed
+);
 print '<ul>';
 while ($row = $query->fetch()) {
        printf('<li%s><div><a href="%s">',