Rename servicealerts to local terminology "Real Time Passenger Information System"
[busui.git] / rtpis / servicealert_editor.php
blob:a/rtpis/servicealert_editor.php -> blob:b/rtpis/servicealert_editor.php
--- a/rtpis/servicealert_editor.php
+++ b/rtpis/servicealert_editor.php
@@ -35,18 +35,18 @@
     echo "Saved " . $_REQUEST['saveedit'];
     die();
 }
-if ($_REQUEST['delete']) {
+if (isset($_REQUEST['delete'])) {
     $deleteParts = explode(";", $_REQUEST['delete']);
     deleteInformedAlert($deleteParts[0], $deleteParts[1], $deleteParts[2]);
     echo "Deleted network inform for {$deleteParts[0]} ({$deleteParts[1]},{$deleteParts[2]})<br>\n";
     die();
 }
-if ($_REQUEST['networkinform']) {
+if (isset($_REQUEST['networkinform'])) {
     addInformedAlert($_REQUEST['networkinform'], "agency", "0", "inform");
     echo "Added network inform for" . $_REQUEST['networkinform'];
     die();
 }
-if ($_REQUEST['stopsearch']) {
+if (isset($_REQUEST['stopsearch'])) {
     addInformedAlert($_REQUEST['stopsearch'], "stop", $_REQUEST['stopid'], "remove");
     echo "Added stop remove for" . $_REQUEST['stopsearch'] . ", stop" . $_REQUEST['stopid'] . "<br>\n";
 
@@ -59,7 +59,7 @@
     }
     die();
 }
-if ($_REQUEST['streetsearch']) {
+if (isset($_REQUEST['streetsearch'])) {
 
     echo "Informing stops of street<br>\n";
     foreach (getStopsByName($_REQUEST['street']) as $stop) {
@@ -82,12 +82,12 @@
 <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>
 <?php
-$alert = getServiceAlert($_REQUEST['edit']);
+$alert = getServiceAlert((isset($_REQUEST['edit'])?$_REQUEST['edit']:""));
 ?>
 <form action="<?php echo basename(__FILE__);
 ?>" method="get">
@@ -95,19 +95,21 @@
     <div data-role="fieldcontain">
         <label for="startdate"> Start Date</label>
         <input type="text" name="startdate" id="startdate" value="<?php
-      if ($alert['start'])
+      if ($alert['start']) {
           echo date("c", $alert['start']);
-      else
+      } else {
           echo date("c", strtotime("0:00"));
+}
 ?>"  />
     </div>
     <div data-role="fieldcontain">
         <label for="enddate"> End Date </label>
         <input type="text" name="enddate" id="enddate" value="<?php
-               if ($alert['end'])
+               if ($alert['end']) {
                    echo date("c", $alert['end']);
-               else
+               } else {
                    echo date("c", strtotime("23:59"));
+}
 ?>"  />
     </div>
     <div data-role="fieldcontain">
@@ -116,8 +118,7 @@
     </div>
     <div data-role="fieldcontain">
         <label for="description">Description</label>
-        <textarea name="description">
-            <?php echo $alert['description']; ?></textarea>
+        <textarea name="description"><?php echo $alert['description']; ?></textarea>
     </div>
     <div data-role="fieldcontain">
         <label for="url">URL</label>
@@ -142,12 +143,12 @@
             }
             ?>
         </select></div>
-    <input type="hidden" name="saveedit" value="<?php echo $_REQUEST['edit']; ?>"/>
+    <input type="hidden" name="saveedit" value="<?php if (isset($_REQUEST['edit']))echo $_REQUEST['edit']; ?>"/>
     <input type="submit" value="Save"/>
 </div></form>
 
 <?php
-if ($_REQUEST['edit']) {
+if (isset($_REQUEST['edit'])) {
     echo "Informed Entities for ID {$_REQUEST['edit']}:";
     echo '<table>';
     foreach (getInformedAlerts($_REQUEST['edit'], "", "") as $informed) {
@@ -185,3 +186,4 @@
 }
 include_footer();
 ?>
+