diff --git a/editevent.php b/editevent.php index 3809c9c..d42bf20 100644 --- a/editevent.php +++ b/editevent.php @@ -135,7 +135,15 @@ if( $_SESSION['access'] != 1 ) { Issue Description: - + + + + + + Update: + + + diff --git a/includes/update_event.php b/includes/update_event.php index add5a89..63c94d6 100644 --- a/includes/update_event.php +++ b/includes/update_event.php @@ -15,7 +15,7 @@ $timestamp = new DateTime(); $update_date_time = date_format($timestamp, 'Y/m/d H:i'); //Insert event update into event updates table -$update = "INSERT INTO event_updates (update_desc, update_date_time, update_is_ongoing, end_date_time, event_id, user) VALUES ('$description', '$update_date_time', '$is_ongoing', '$end_date_time', '$event_id', '$user')"; +$update = "INSERT INTO event_updates (update_desc, update_date_time, update_is_ongoing, end_date_time, event_id, update_user) VALUES ('$description', '$update_date_time', '$is_ongoing', '$end_date_time', '$event_id', '$user')"; //Update value of is_ongoing in main events table $is_ongoing_endtime_query = "UPDATE events SET is_ongoing='$is_ongoing', date_time_end='$end_date_time' WHERE event_id='$event_id'"; diff --git a/index.php b/index.php index b9530b5..07a2d90 100644 --- a/index.php +++ b/index.php @@ -31,28 +31,104 @@ if( $_SESSION['access'] != 1 ) { if ($conn1->connect_error) { die("Connection Failed: " . $conn1->connect_error); } - $sql1 = "SELECT * FROM events AS events INNER JOIN units AS units ON events.unit_id=units.unit_id INNER JOIN alerts as alerts ON events.alert_id=alerts.alert_id where is_ongoing=1;"; - $result1 = $conn1->query($sql1); - if ($result1->num_rows >0){ - echo ""; - while ($row1 = $result1->fetch_assoc()) { - echo " "; + $currently_ongoing_query = "SELECT * FROM events AS events INNER JOIN units AS units ON events.unit_id=units.unit_id INNER JOIN alerts as alerts ON events.alert_id=alerts.alert_id where is_ongoing=1;"; + $currently_ongoing_result = $conn1->query($currently_ongoing_query); + if ($currently_ongoing_result->num_rows >0){ + echo "
Event IDUnitAlertStart Date and TimeDescriptionEnd Date and TimeUserEdit
".$row1["event_id"]."".$row1["unit_name"]."".$row1["alert_name"]."".$row1["date_time_start"]."".$row1["description"]."".$row1["date_time_end"]."".$row1["user"]."Edit
"; + while ($currently_ongoing_row = $currently_ongoing_result->fetch_assoc()) { + echo " "; } echo "
Event IDUnitAlertStart Date and TimeDescriptionEnd Date and TimeUserUpdatesEdit
"; + echo "".$currently_ongoing_row["event_id"].""; + echo ""; + print_r($currently_ongoing_row["unit_name"]); + echo ""; + print_r($currently_ongoing_row["alert_name"]); + echo ""; + print_r($currently_ongoing_row["date_time_start"]); + echo ""; + echo nl2br($currently_ongoing_row["description"]); + echo ""; + print_r($currently_ongoing_row["date_time_end"]); + echo ""; + print_r($currently_ongoing_row["user"]); + echo ""; + $update_query = "SELECT update_desc, update_date_time, update_user FROM event_updates WHERE event_updates.event_id=".$currently_ongoing_row["event_id"].";"; + $update_result = $conn1->query($update_query); + if ($update_result->num_rows >0){ + while ($update_row = $update_result->fetch_assoc()) { + echo "
"; + echo "Info: "; + echo ""; + echo nl2br($update_row['update_desc']); + echo "
"; + echo "User: "; + echo ""; + print_r($update_row['update_user']); + echo "
"; + echo "Time: "; + echo ""; + print_r($update_row['update_date_time']); + echo "
"; + } + } else { + echo "No updates to this event"; + } + + echo "
"; + echo "Edit
"; } else { echo "
No Ongoing Events at This Time
"; } if ($conn1->connect_error) { - die("Connection Failed: " . $conn2->connect_error); + die("Connection Failed: " . $conn1->connect_error); } - $sql2 = "SELECT * FROM events AS events INNER JOIN units AS units ON events.unit_id=units.unit_id INNER JOIN alerts as alerts ON events.alert_id=alerts.alert_id where is_ongoing=0 ORDER BY date_time_end DESC LIMIT 10;"; - $result2 = $conn1->query($sql2); - if ($result2->num_rows >0){ + $past_event_query = "SELECT * FROM events AS events INNER JOIN units AS units ON events.unit_id=units.unit_id INNER JOIN alerts as alerts ON events.alert_id=alerts.alert_id where is_ongoing=0 ORDER BY date_time_end DESC LIMIT 10;"; + $past_event_result = $conn1->query($past_event_query); + if ($past_event_result->num_rows >0){ echo "

Previous 10 Events

"; echo "This does not include ongoing events."; - echo ""; - while ($row2 = $result2->fetch_assoc()) { - echo " "; + echo "
Event IDUnitAlertStart Date and TimeDescriptionEnd Date and TimeUserEdit
".$row2["event_id"]."".$row2["unit_name"]."".$row2["alert_name"]."".$row2["date_time_start"]."".$row2["description"]."".$row2["date_time_end"]."".$row2["user"]."Edit
"; + while ($past_event_row = $past_event_result->fetch_assoc()) { + echo ""; } echo "
Event IDUnitAlertStart Date and TimeDescriptionEnd Date and TimeUserUpdatesEdit
"; + echo "".$past_event_row["event_id"].""; + echo ""; + print_r($past_event_row["unit_name"]); + echo ""; + print_r($past_event_row["alert_name"]); + echo ""; + print_r($past_event_row["date_time_start"]); + echo ""; + echo nl2br($past_event_row["description"]); + echo ""; + print_r($past_event_row["date_time_end"]); + echo ""; + print_r($past_event_row["user"]); + echo ""; + $update_query = "SELECT update_desc, update_date_time, update_user FROM event_updates WHERE event_updates.event_id=".$past_event_row["event_id"].";"; + $update_result = $conn1->query($update_query); + if ($update_result->num_rows >0){ + while ($update_row = $update_result->fetch_assoc()) { + echo "
"; + echo "Info: "; + echo ""; + echo nl2br($update_row['update_desc']); + echo "
"; + echo "User: "; + echo ""; + print_r($update_row['update_user']); + echo "
"; + echo "Time: "; + echo ""; + print_r($update_row['update_date_time']); + echo "
"; + } + } else { + echo "No updates to this event"; + } + echo "
"; + echo "Edit"; + echo "
"; } else {