WIP:Planned downtime copy.
This commit is contained in:
parent
4da16bedf8
commit
a92fe64b64
|
@ -135,6 +135,7 @@ $first_create = (int) get_parameter('first_create');
|
||||||
$create_downtime = (int) get_parameter('create_downtime');
|
$create_downtime = (int) get_parameter('create_downtime');
|
||||||
$update_downtime = (int) get_parameter('update_downtime');
|
$update_downtime = (int) get_parameter('update_downtime');
|
||||||
$edit_downtime = (int) get_parameter('edit_downtime');
|
$edit_downtime = (int) get_parameter('edit_downtime');
|
||||||
|
$downtime_copy = (int) get_parameter('downtime_copy');
|
||||||
$id_downtime = (int) get_parameter('id_downtime');
|
$id_downtime = (int) get_parameter('id_downtime');
|
||||||
|
|
||||||
$id_agent = (int) get_parameter('id_agent');
|
$id_agent = (int) get_parameter('id_agent');
|
||||||
|
@ -420,6 +421,15 @@ if ($create_downtime || $update_downtime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($downtime_copy) {
|
||||||
|
$result = planned_downtimes_copy($id_downtime);
|
||||||
|
if ($result === true) {
|
||||||
|
ui_print_error_message(__('Successfully copied'));
|
||||||
|
} else {
|
||||||
|
ui_print_error_message(__('Could not be copied'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Have any data to show ?
|
// Have any data to show ?
|
||||||
if ($id_downtime > 0) {
|
if ($id_downtime > 0) {
|
||||||
// Columns of the table tplanned_downtime.
|
// Columns of the table tplanned_downtime.
|
||||||
|
|
|
@ -405,6 +405,7 @@ else {
|
||||||
|
|
||||||
if ($write_permisson || $manage_permisson) {
|
if ($write_permisson || $manage_permisson) {
|
||||||
$table->head['stop'] = __('Stop downtime');
|
$table->head['stop'] = __('Stop downtime');
|
||||||
|
$table->head['copy'] = __('Copy');
|
||||||
$table->head['edit'] = __('Edit');
|
$table->head['edit'] = __('Edit');
|
||||||
$table->head['delete'] = __('Delete');
|
$table->head['delete'] = __('Delete');
|
||||||
}
|
}
|
||||||
|
@ -492,6 +493,8 @@ else {
|
||||||
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW')
|
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW')
|
||||||
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
|
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
|
||||||
) {
|
) {
|
||||||
|
// Copy.
|
||||||
|
$data['copy'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&downtime_copy=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/copy.png', true, ['title' => __('Copy'), 'class' => 'invert_filter']).'</a>';
|
||||||
// Edit.
|
// Edit.
|
||||||
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>';
|
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>';
|
||||||
// Delete.
|
// Delete.
|
||||||
|
@ -504,6 +507,8 @@ else {
|
||||||
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW')
|
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW')
|
||||||
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
|
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
|
||||||
) {
|
) {
|
||||||
|
// Copy.
|
||||||
|
$data['copy'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&downtime_copy=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/copy.png', true, ['title' => __('Copy'), 'class' => 'invert_filter']).'</a>';
|
||||||
// Edit.
|
// Edit.
|
||||||
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>';
|
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>';
|
||||||
// Delete.
|
// Delete.
|
||||||
|
@ -513,11 +518,13 @@ else {
|
||||||
$data['delete'] = '';
|
$data['delete'] = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$data['copy'] = '';
|
||||||
$data['edit'] = '';
|
$data['edit'] = '';
|
||||||
$data['delete'] = '';
|
$data['delete'] = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$data['stop'] = '';
|
$data['stop'] = '';
|
||||||
|
$data['copy'] = '';
|
||||||
$data['edit'] = '';
|
$data['edit'] = '';
|
||||||
$data['delete'] = '';
|
$data['delete'] = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -919,3 +919,73 @@ function delete_planned_downtimes($filter)
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function planned_downtimes_copy($id_downtime)
|
||||||
|
{
|
||||||
|
$planned_downtime = db_get_row_filter(
|
||||||
|
'tplanned_downtime',
|
||||||
|
['id' => $id_downtime]
|
||||||
|
);
|
||||||
|
|
||||||
|
$planned_agents = db_get_row_filter(
|
||||||
|
'tplanned_downtime_agents',
|
||||||
|
['id_downtime' => $id_downtime]
|
||||||
|
);
|
||||||
|
|
||||||
|
$planned_modules = db_get_row_filter(
|
||||||
|
'tplanned_downtime_modules',
|
||||||
|
['id_downtime' => $id_downtime]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($planned_downtime === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unset id.
|
||||||
|
unset($planned_downtime['id']);
|
||||||
|
|
||||||
|
// Change copy name.
|
||||||
|
$planned_downtime['name'] = __('Coy of ').$planned_downtime['name'];
|
||||||
|
|
||||||
|
// Insert new downtime
|
||||||
|
$result = db_process_sql_insert(
|
||||||
|
'tplanned_downtime',
|
||||||
|
$planned_downtime
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($planned_agents !== false) {
|
||||||
|
// Unser id.
|
||||||
|
unset($planned_agents['id']);
|
||||||
|
$result = db_process_sql_insert(
|
||||||
|
'tplanned_downtime_agents',
|
||||||
|
$planned_agents
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((bool) $planned_agents['all_modules'] === false
|
||||||
|
&& $planned_modules !== false
|
||||||
|
) {
|
||||||
|
// Unser id.
|
||||||
|
unset($planned_modules['id']);
|
||||||
|
$result = db_process_sql_insert(
|
||||||
|
'tplanned_downtime_agents',
|
||||||
|
$planned_agents
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue