Merge pull request #33 from uchida/disable-executed-planned-downtime
Disable modification of executed planned downtime Thanks to Mr. Uchida.
This commit is contained in:
commit
57e64d4a8a
|
@ -98,6 +98,11 @@ if ($insert_downtime_agent === 1) {
|
|||
$all_modules = true;
|
||||
}
|
||||
|
||||
$executed = db_get_value ('executed', 'tplanned_downtime', 'id', $id_downtime);
|
||||
if ($executed == 1) {
|
||||
ui_print_error_message(__("This elements cannot be modified while the downtime is being executed"));
|
||||
}
|
||||
else {
|
||||
$num_agents = count($agents);
|
||||
for ($a = 0; $a < $num_agents; $a++) {
|
||||
$id_agente_dt = $agents[$a];
|
||||
|
@ -128,12 +133,18 @@ if ($insert_downtime_agent === 1) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE A DOWNTIME_AGENT ASSOCIATION
|
||||
if ($delete_downtime_agent === 1) {
|
||||
|
||||
$id_da = (int) get_parameter ('id_downtime_agent');
|
||||
|
||||
$executed = db_get_value ('executed', 'tplanned_downtime', 'id', $id_downtime);
|
||||
if ($executed == 1) {
|
||||
ui_print_error_message(__("This elements cannot be modified while the downtime is being executed"));
|
||||
}
|
||||
else {
|
||||
$row_to_delete = db_get_row('tplanned_downtime_agents', 'id', $id_da);
|
||||
|
||||
$result = db_process_sql_delete('tplanned_downtime_agents', array('id' => $id_da));
|
||||
|
@ -145,6 +156,7 @@ if ($delete_downtime_agent === 1) {
|
|||
'id_agent' => $id_agent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UPDATE OR CREATE A DOWNTIME (MAIN DATA, NOT AGENT ASSOCIATION)
|
||||
if ($create_downtime || $update_downtime) {
|
||||
|
@ -218,7 +230,22 @@ if ($create_downtime || $update_downtime) {
|
|||
}
|
||||
}
|
||||
else if ($update_downtime) {
|
||||
if (trim(io_safe_output($name)) != '') {
|
||||
$has_been_executed = db_get_value ('executed', 'tplanned_downtime', 'name', $name);
|
||||
$values = array();
|
||||
if (trim(io_safe_output($name)) == '') {
|
||||
ui_print_error_message(__('Planned downtime must have a name'));
|
||||
}
|
||||
else if ($has_been_executed == 1 && $type_execution == 'once') {
|
||||
$values = array(
|
||||
'description' => $description,
|
||||
'date_to' => $datetime_to,
|
||||
'id_user' => $config['id_user']
|
||||
);
|
||||
}
|
||||
else if ($has_been_executed == 1) {
|
||||
ui_print_error_message(__('No updates. Planned Downtime has been executed'));
|
||||
}
|
||||
else {
|
||||
$values = array(
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
|
@ -246,12 +273,9 @@ if ($create_downtime || $update_downtime) {
|
|||
$values['periodically_time_from'] = '1970/01/01 ' . $values['periodically_time_from'];
|
||||
$values['periodically_time_to'] = '1970/01/01 ' . $values['periodically_time_to'];
|
||||
}
|
||||
|
||||
$result = db_process_sql_update('tplanned_downtime', $values, array('id' => $id_downtime));
|
||||
}
|
||||
else {
|
||||
ui_print_error_message(
|
||||
__('Planned downtime must have a name'));
|
||||
if (!empty($values)) {
|
||||
$result = db_process_sql_update('tplanned_downtime', $values, array('id' => $id_downtime));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -958,6 +982,9 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
|
|||
$("#spinner_add", $('#module_editor_' + id_agent))
|
||||
.toggle();
|
||||
}
|
||||
else if (data['executed']) {
|
||||
show_executing_alert();
|
||||
}
|
||||
|
||||
action_in_progress = false;
|
||||
},
|
||||
|
@ -996,6 +1023,9 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
|
|||
$("#all_modules_text").html());
|
||||
}
|
||||
}
|
||||
else if (data['executed']) {
|
||||
show_executing_alert();
|
||||
}
|
||||
else {
|
||||
$(".cell_delete_button", "#row_module_in_downtime_" + id_module)
|
||||
.html($(old_cell_content));
|
||||
|
|
|
@ -71,6 +71,13 @@ if ($delete_module_from_downtime) {
|
|||
$id_module = (int)get_parameter('id_module', 0);
|
||||
$id_downtime = (int)get_parameter('id_downtime', 0);
|
||||
|
||||
$executed = db_get_value ('executed', 'tplanned_downtime', 'id', $id_downtime);
|
||||
if ($executed) {
|
||||
$return['executed'] = 1;
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = db_get_row_filter('tplanned_downtime_modules',
|
||||
array('id_agent_module' => $id_module,
|
||||
'id_downtime' => $id_downtime));
|
||||
|
@ -111,6 +118,13 @@ if ($add_module_into_downtime) {
|
|||
$id_module = (int)get_parameter('id_module', 0);
|
||||
$id_downtime = (int)get_parameter('id_downtime', 0);
|
||||
|
||||
$executed = db_get_value ('executed', 'tplanned_downtime', 'id', $id_downtime);
|
||||
if ($executed) {
|
||||
$return['executed'] = 1;
|
||||
echo json_encode($return);
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
$values['id_agent'] = $id_agent;
|
||||
$values['id_agent_module'] = $id_module;
|
||||
|
@ -133,3 +147,4 @@ if ($add_module_into_downtime) {
|
|||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
Loading…
Reference in New Issue