Add admin UI/Backend for adding a new Incident
This commit is contained in:
@@ -15,6 +15,21 @@ class StatusBoard_Incident extends StatusBoard_DatabaseObject {
|
|||||||
protected $current_status = null;
|
protected $current_status = null;
|
||||||
protected $statuses = 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) {
|
public static function openForSite(StatusBoard_Site $site) {
|
||||||
return static::allFor('site', $site->id, 'incident_open');
|
return static::allFor('site', $site->id, 'incident_open');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ class StatusBoard_Site extends StatusBoard_DatabaseObject {
|
|||||||
return $new_service;
|
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) {
|
public function openIncidents($ignore_cache = false) {
|
||||||
if ($this->incidents_open === null || $ignore_cache) {
|
if ($this->incidents_open === null || $ignore_cache) {
|
||||||
$this->incidents_open = StatusBoard_Incident::openForSite($this);
|
$this->incidents_open = StatusBoard_Incident::openForSite($this);
|
||||||
|
|||||||
@@ -47,9 +47,38 @@ if ($request->exists('do')) {
|
|||||||
|
|
||||||
} break;
|
} 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.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,9 +53,58 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</dl>
|
</dl>
|
||||||
{else}
|
{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}
|
{/if}
|
||||||
|
|
||||||
<form id="admin_addincident" method="post" action="{$base_uri}admin/add-incident/site/{$site->id}/">
|
<form id="admin_addsite" method="post" action="{$base_uri}admin/site/service/{$service->id}/id/{$site->id}/do/add-incident/">
|
||||||
<input type="button" class="btn success" name="addsite" value="Add Incident" />
|
<fieldset>
|
||||||
|
<legend>Add Incident</legend>
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<label for="admin_incident_add_reference">Reference</label>
|
||||||
|
<div class="text">
|
||||||
|
<input class="xlarge span5" id="admin_incident_add_reference" name="reference" type="text" value="" />
|
||||||
|
</div>
|
||||||
|
</div><!-- /clearfix -->
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<label for="admin_incident_add_description">Description</label>
|
||||||
|
<div class="text">
|
||||||
|
<textarea class="span12" id="admin_incident_add_description" name="description"></textarea>
|
||||||
|
</div>
|
||||||
|
</div><!-- /clearfix -->
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<label for="admin_incident_add_status">Initial Classification</label>
|
||||||
|
<div class="select">
|
||||||
|
<select class="xlarge span5" id="admin_incident_add_status" name="status">
|
||||||
|
{foreach from=StatusBoard_Status::available() item=status}
|
||||||
|
{if $status != StatusBoard_Status::STATUS_Resolved}
|
||||||
|
<option value="{$status}">{StatusBoard_Status::name($status)}</option>
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div><!-- /clearfix -->
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<label for="admin_incident_add_starttime">Start Time</label>
|
||||||
|
<div class="text">
|
||||||
|
<input class="xlarge span5" id="admin_incident_add_starttime" name="starttime" type="text" value="Now" />
|
||||||
|
</div>
|
||||||
|
</div><!-- /clearfix -->
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<label for="admin_incident_add_estimatedendtime">Estimated End Time</label>
|
||||||
|
<div class="text">
|
||||||
|
<input class="xlarge span5" id="admin_incident_add_estimatedendtime" name="estimatedendtime" type="text" value="+4 hours" />
|
||||||
|
</div>
|
||||||
|
</div><!-- /clearfix -->
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<div class="input">
|
||||||
|
<input type="submit" class="btn primary" name="addincident" value="Add Incident" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user