Add new Add Incident page
This commit is contained in:
89
source/webui/pages/admin/add-incident.php
Normal file
89
source/webui/pages/admin/add-incident.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
$main = StatusBoard_Main::instance();
|
||||
$request = $main->request();
|
||||
$auth = $main->auth();
|
||||
$session = $main->session();
|
||||
|
||||
if ( ! $auth->isAuthenticated() || ! $auth->hasPermission(StatusBoard_Permission::PERM_UpdateIncidents)) {
|
||||
throw new StatusBoard_Exception_NotAuthorised();
|
||||
}
|
||||
|
||||
if ($request->exists('do')) {
|
||||
|
||||
$service_id = StatusBoard_Main::issetelse($_POST['service'], 'Sihnon_Exception_InvalidParameters');
|
||||
$site_id = StatusBoard_Main::issetelse($_POST['site'], 'Sihnon_Exception_InvalidParameters');
|
||||
$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');
|
||||
|
||||
$incident = null;
|
||||
|
||||
try {
|
||||
$service = StatusBoard_Service::fromId($service_id);
|
||||
$site = StatusBoard_Site::fromId($site_id);
|
||||
|
||||
$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.',
|
||||
);
|
||||
} catch (StatusBoard_Exception_ResultCountMismatch $e) {
|
||||
$messages[] = array(
|
||||
'severity' => 'error',
|
||||
'content' => 'The incident was not created because the Service or Site could not be found.',
|
||||
);
|
||||
}
|
||||
|
||||
$session->set('messages', $messages);
|
||||
StatusBoard_Page::redirect("admin/incident/service/{$service->id}/site/{$site->id}/id/{$incident->id}/");
|
||||
}
|
||||
|
||||
$service_id = $request->get('service');
|
||||
$site_id = $request->get('site');
|
||||
|
||||
$service = null;
|
||||
$site = null;
|
||||
|
||||
$services = StatusBoard_Service::all();
|
||||
try {
|
||||
if ($service_id) {
|
||||
$service = StatusBoard_Service::fromId($service_id);
|
||||
}
|
||||
if ($site_id) {
|
||||
$site = StatusBoard_Site::fromId($site_id);
|
||||
}
|
||||
} catch (Sihnon_Exception_ResultCountMismatch $e) {
|
||||
throw new StatusBoard_Exception_FileNotFound();
|
||||
}
|
||||
|
||||
$all_sites = array();
|
||||
if ($service) {
|
||||
$all_sites[$service->id] = $service->sites();
|
||||
} else {
|
||||
foreach ($services as $all_service) {
|
||||
$all_sites[$all_service->id] = $all_service->sites();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->smarty->assign('services', $services);
|
||||
$this->smarty->assign('service', $service);
|
||||
$this->smarty->assign('all_sites', $all_sites);
|
||||
$this->smarty->assign('site', $site);
|
||||
$this->smarty->assign('messages', $messages);
|
||||
|
||||
?>
|
||||
106
source/webui/templates/admin/add-incident.tpl
Normal file
106
source/webui/templates/admin/add-incident.tpl
Normal file
@@ -0,0 +1,106 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span4 column">
|
||||
<h3>Add Incident</h3>
|
||||
<p>Use this form to add a new incident</p>
|
||||
</div><!--/New Service description-->
|
||||
<div class="span11 column">
|
||||
|
||||
<form id="admin_addsite" method="post" action="{$base_uri}admin/add-incident/do/">
|
||||
<fieldset>
|
||||
<div class="clearfix">
|
||||
<label for="admin_incident_add_service">Service</label>
|
||||
<div class="text">
|
||||
{if $service}
|
||||
<input type="hidden" name="service" value="{$service->id}" />
|
||||
{$service->name|escape:html}
|
||||
{else}
|
||||
<select class="xlarge span5" id="admin_incident_add_service" name="service">
|
||||
{foreach from=$services item=form_service}
|
||||
<option value="{$form_service->id}">{$form_service->name|escape:html}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!-- /clearfix -->
|
||||
|
||||
<div class="clearfix">
|
||||
<label for="admin_incident_add_site">Site</label>
|
||||
<div class="text">
|
||||
{if $service && $site}
|
||||
<input type="hidden" name="site" value="{$site->id}" />
|
||||
{$site->name|escape:html}
|
||||
{else}
|
||||
<select class="xlarge span5" id="admin_incident_add_site" name="site">
|
||||
{if $service}
|
||||
{foreach from=$all_sites[$service->id] item=form_site}
|
||||
<option value="{$form_site->id}">{$form_site->name|escape:html}</option>
|
||||
{/foreach}
|
||||
{else}
|
||||
{foreach from=$services item=all_service}
|
||||
{foreach from=$all_sites[$all_service->id] item=form_site}
|
||||
<option class="{$all_service->id}" value="{$form_site->id}">{$form_site->name|escape:html}</option>
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!-- /clearfix -->
|
||||
|
||||
<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="xlarge" 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 small primary" name="addincident" value="Add Incident" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div><!--/Row for New Service-->
|
||||
</div>
|
||||
</div><!-- /container -->
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#admin_incident_add_site').chainedTo('#admin_incident_add_service');
|
||||
</script>
|
||||
@@ -4,7 +4,7 @@
|
||||
<h2>{$site_title}</h2>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<a href="#" class="btn small">Add Incident</a>
|
||||
<a href="{$base_uri}admin/add-incident/" class="btn small">Add Incident</a>
|
||||
</div>
|
||||
</div>
|
||||
<table class="bordered-table">
|
||||
|
||||
Reference in New Issue
Block a user