diff --git a/source/lib/StatusBoard/Incident.class.php b/source/lib/StatusBoard/Incident.class.php index 6165a02..e99c9de 100644 --- a/source/lib/StatusBoard/Incident.class.php +++ b/source/lib/StatusBoard/Incident.class.php @@ -14,6 +14,21 @@ class StatusBoard_Incident extends StatusBoard_DatabaseObject { protected $current_status = null; protected $statuses = null; + + public static function newForSite(StatusBoard_Site $site, $reference, $description, $status, $start_time, $estimated_end_time) { + $new_incident = new self(); + $new_incident->site = $site->id; + $new_incident->reference = $reference; + $new_incident->description = $description; + $new_incident->start_time = $start_time; + $new_incident->estimated_end_time = $estimated_end_time; + $new_incident->actual_end_time = null; + + $new_incident->create(); + $new_incident->changeStatus($status, 'Initial Classification'); + + return $new-incident; + } public static function openForSite(StatusBoard_Site $site) { return static::allFor('site', $site->id, 'incident_open'); diff --git a/source/lib/StatusBoard/Site.class.php b/source/lib/StatusBoard/Site.class.php index a4790fb..18aaa10 100644 --- a/source/lib/StatusBoard/Site.class.php +++ b/source/lib/StatusBoard/Site.class.php @@ -27,6 +27,10 @@ class StatusBoard_Site extends StatusBoard_DatabaseObject { return $new_service; } + public function newIncident($reference, $description, $status, $start_time, $estimated_end_time) { + return StatusBoard_Incident::newForSite($this, $reference, $description, $status, $start_time, $estimated_end_time); + } + public function openIncidents($ignore_cache = false) { if ($this->incidents_open === null || $ignore_cache) { $this->incidents_open = StatusBoard_Incident::openForSite($this); diff --git a/source/webui/pages/admin/site.php b/source/webui/pages/admin/site.php index 2d3fc72..acd73e5 100644 --- a/source/webui/pages/admin/site.php +++ b/source/webui/pages/admin/site.php @@ -47,9 +47,38 @@ if ($request->exists('do')) { } break; - default: { + case 'add-incident': { + $reference = StatusBoard_Main::issetelse($_POST['reference'], 'Sihnon_Exception_InvalidParameters'); + $description = StatusBoard_Main::issetelse($_POST['description'], 'Sihnon_Exception_InvalidParameters'); + $status = StatusBoard_Main::issetelse($_POST['status'], 'Sihnon_Exception_InvalidParameters'); + $start_time = StatusBoard_Main::issetelse($_POST['starttime'], 'Sihnon_Exception_InvalidParameters'); + $estimated_end_time = StatusBoard_Main::issetelse($_POST['estimatedendtime'], 'Sihnon_Exception_InvalidParameters'); + + $start_time = strtotime($start_time); + if ($start_time === null) { + throw new StatusBoard_Exception_InvalidParameters('starttime'); + } + $estimated_end_time = strtotime($estimated_end_time); + if ($estimated_end_time === null) { + throw new StatusBoard_Exception_InvalidParameters('estimatedendtime'); + } + $incident = $site->newIncident($reference, $description, $status, $start_time, $estimated_end_time); + + $messages[] = array( + 'severity' => 'success', + 'content' => 'The incident was created succesfully.', + ); + + } break; + + default: { + $messages[] = array( + 'severity' => 'warning', + 'content' => "The activity '{$activity}' is not supported.", + ); } + } } diff --git a/source/webui/templates/admin/site.tpl b/source/webui/templates/admin/site.tpl index bfabf2d..a264d12 100644 --- a/source/webui/templates/admin/site.tpl +++ b/source/webui/templates/admin/site.tpl @@ -53,9 +53,58 @@ {/foreach} {else} - There are no open incidents for this site . If you need to open one, use the button below. + There are no open incidents for this site . If you need to open one, use the form below. {/if} -
- -
\ No newline at end of file +
+
+ Add Incident + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+