Fixed - showing old service alerts when calling the future alerts function
--- a/include/db/servicealert-dao.inc.php
+++ b/include/db/servicealert-dao.inc.php
@@ -106,7 +106,19 @@
function getFutureAlerts() {
global $conn;
- $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from \"end\") as \"end\",cause,effect,header,description,url from servicealerts_alerts where NOW() > start or NOW() < \"end\"";
+ $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from \"end\") as \"end\",cause,effect,header,description,url from servicealerts_alerts where NOW() < \"end\"";
+ // debug($query, "database");
+ $query = $conn->prepare($query);
+ $query->execute();
+ if (!$query) {
+ databaseError($conn->errorInfo());
+ return Array();
+ }
+ return $query->fetchAll();
+}
+function getAllAlerts() {
+ global $conn;
+ $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from \"end\") as \"end\",cause,effect,header,description,url from servicealerts_alerts";
// debug($query, "database");
$query = $conn->prepare($query);
$query->execute();
--- a/rtpis/servicealert_editor.php
+++ b/rtpis/servicealert_editor.php
@@ -82,7 +82,7 @@
<table>
<?php
foreach (getFutureAlerts() as $alert) {
- echo "<tr><td>" . date("c", $alert['start']) . "</td><td>" . date("c", $alert['end']) . "</td><td>" . substr($alert['description'], 0, 999) . '</td><td><a href="?edit=' . $alert['id'] . '">edit</a></td></tr>';
+ echo "<tr><td>" . date("c", $alert['start']) . "<br>to<br>" . date("c", $alert['end']) . "</td><td><b>" .$alert['header']."</b><br>". $alert['description'] . '</td><td><a href="?edit=' . $alert['id'] . '">edit</a></td></tr>';
}
?>
</table>