mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Merge branch 'ent-5276-AADCM-creacion-de-paradas-planificadas' into 'develop'
Refactored downtime editor See merge request artica/pandorafms!3879
This commit is contained in:
commit
971f86601a
@ -75,6 +75,7 @@ ui_print_page_header(
|
||||
// Recursion group filter.
|
||||
$recursion = get_parameter('recursion', $_POST['recursion']);
|
||||
|
||||
|
||||
// Initialize data.
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
$name = (string) get_parameter('name');
|
||||
@ -147,144 +148,9 @@ $user_groups_ad = array_keys(
|
||||
users_get_groups($config['id_user'], $access)
|
||||
);
|
||||
|
||||
// Check AD permission on downtime.
|
||||
$downtime_group = db_get_value(
|
||||
'id_group',
|
||||
'tplanned_downtime',
|
||||
'id',
|
||||
$id_downtime
|
||||
);
|
||||
|
||||
if ($id_downtime > 0) {
|
||||
if (!check_acl_restricted_all($config['id_user'], $downtime_group, 'AW')
|
||||
&& !check_acl_restricted_all($config['id_user'], $downtime_group, 'AD')
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access downtime scheduler'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// INSERT A NEW DOWNTIME_AGENT ASSOCIATION.
|
||||
if ($insert_downtime_agent === 1) {
|
||||
if ($downtime_group === false
|
||||
|| !in_array($downtime_group, $user_groups_ad)
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access downtime scheduler'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$agents = (array) get_parameter('id_agents');
|
||||
$module_names = (array) get_parameter('module');
|
||||
|
||||
$all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (int) $modules[0] === 0));
|
||||
$all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (int) $modules[0] === 0));
|
||||
|
||||
if ($all_common_modules === true) {
|
||||
$module_names = explode(',', get_parameter('all_common_modules'));
|
||||
}
|
||||
|
||||
// 'Is running' check.
|
||||
$is_running = (bool) db_get_value(
|
||||
'executed',
|
||||
'tplanned_downtime',
|
||||
'id',
|
||||
$id_downtime
|
||||
);
|
||||
if ($is_running) {
|
||||
ui_print_error_message(
|
||||
__('This elements cannot be modified while the downtime is being executed')
|
||||
);
|
||||
} else {
|
||||
// If is selected 'Any', get all the agents.
|
||||
if (count($agents) === 1 && (int) $agents[0] === -2) {
|
||||
$all_agents = get_parameter('all_agents');
|
||||
$agents = explode(',', $all_agents);
|
||||
}
|
||||
|
||||
foreach ($agents as $agent_id) {
|
||||
// Check module belongs to the agent.
|
||||
if ($modules_selection_mode == 'all' && $all_modules === false) {
|
||||
$check = false;
|
||||
foreach ($module_names as $module_name) {
|
||||
$check_module = modules_get_agentmodule_id(
|
||||
$module_name,
|
||||
$agent_id
|
||||
);
|
||||
if (!empty($check_module)) {
|
||||
$check = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$check) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Check AD permission on agent.
|
||||
$agent_group = db_get_value(
|
||||
'id_grupo',
|
||||
'tagente',
|
||||
'id_agente',
|
||||
$agent_id
|
||||
);
|
||||
|
||||
if ($agent_group === false
|
||||
|| !in_array($agent_group, $user_groups_ad)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'id_downtime' => $id_downtime,
|
||||
'id_agent' => $agent_id,
|
||||
'all_modules' => $all_modules,
|
||||
];
|
||||
$result = db_process_sql_insert(
|
||||
'tplanned_downtime_agents',
|
||||
$values
|
||||
);
|
||||
|
||||
if ($result && !$all_modules) {
|
||||
foreach ($module_names as $module_name) {
|
||||
$module = modules_get_agentmodule_id(
|
||||
$module_name,
|
||||
$agent_id
|
||||
);
|
||||
|
||||
if (empty($module)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'id_downtime' => $id_downtime,
|
||||
'id_agent' => $agent_id,
|
||||
'id_agent_module' => $module['id_agente_modulo'],
|
||||
];
|
||||
$result = db_process_sql_insert(
|
||||
'tplanned_downtime_modules',
|
||||
$values
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
$values = ['id_user' => $config['id_user']];
|
||||
$result = db_process_sql_update(
|
||||
'tplanned_downtime',
|
||||
$values,
|
||||
['id' => $id_downtime]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
insert_downtime_agent($id_downtime, $user_groups_ad);
|
||||
}
|
||||
|
||||
// DELETE A DOWNTIME_AGENT ASSOCIATION.
|
||||
@ -490,10 +356,6 @@ if ($create_downtime || $update_downtime) {
|
||||
'date_to' => $datetime_to,
|
||||
'id_user' => $config['id_user'],
|
||||
];
|
||||
} else if ($is_running) {
|
||||
ui_print_error_message(
|
||||
__('Cannot be modified while the downtime is being executed')
|
||||
);
|
||||
} else {
|
||||
$values = [
|
||||
'name' => $name,
|
||||
@ -524,6 +386,9 @@ if ($create_downtime || $update_downtime) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_running) {
|
||||
$result = false;
|
||||
} else {
|
||||
if (!empty($values)) {
|
||||
$result = db_process_sql_update(
|
||||
'tplanned_downtime',
|
||||
@ -532,6 +397,7 @@ if ($create_downtime || $update_downtime) {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($result === false) {
|
||||
if ($create_downtime) {
|
||||
@ -542,6 +408,9 @@ if ($create_downtime || $update_downtime) {
|
||||
} else {
|
||||
if ($create_downtime && $name && !$check) {
|
||||
$id_downtime = $result;
|
||||
|
||||
insert_downtime_agent($id_downtime, $user_groups_ad);
|
||||
|
||||
ui_print_success_message(__('Successfully created'));
|
||||
} else if ($update_downtime && $name) {
|
||||
ui_print_success_message(__('Successfully updated'));
|
||||
@ -672,20 +541,11 @@ $table->data[0][1] = html_print_input_text(
|
||||
true,
|
||||
$disabled_in_execution
|
||||
);
|
||||
|
||||
$return_all_group = false;
|
||||
|
||||
if (users_can_manage_group_all('AW') === true
|
||||
|| users_can_manage_group_all('AD') === true
|
||||
) {
|
||||
$return_all_group = true;
|
||||
}
|
||||
|
||||
$table->data[1][0] = __('Group');
|
||||
$table->data[1][1] = '<div class="w250px">'.html_print_select_groups(
|
||||
false,
|
||||
$access,
|
||||
$return_all_group,
|
||||
true,
|
||||
'id_group',
|
||||
$id_group,
|
||||
'',
|
||||
@ -750,7 +610,7 @@ $days = array_combine(range(1, 31), range(1, 31));
|
||||
$table->data[5][0] = __('Configure the time').' ';
|
||||
;
|
||||
$table->data[5][1] = "
|
||||
<div id='once_time' class='invisible'>
|
||||
<div id='once_time' style='display: none;'>
|
||||
<table>
|
||||
<tr>
|
||||
<td>".__('From:').'</td>
|
||||
@ -762,7 +622,7 @@ $table->data[5][1] = "
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id='periodically_time' class='invisible'>
|
||||
<div id='periodically_time' style='display: none;'>
|
||||
<table>
|
||||
<tr><td>".ui_get_using_system_timezone_warning().'</td></tr>
|
||||
<tr>
|
||||
@ -785,7 +645,7 @@ $table->data[5][1] = "
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
<table id='weekly_item' class='invisible'>
|
||||
<table id='weekly_item' style='display: none;'>
|
||||
<tr>
|
||||
<td>".__('Mon').html_print_checkbox('monday', 1, $monday, true, $disabled_in_execution).'</td>
|
||||
<td>'.__('Tue').html_print_checkbox('tuesday', 1, $tuesday, true, $disabled_in_execution).'</td>
|
||||
@ -796,7 +656,7 @@ $table->data[5][1] = "
|
||||
<td>'.__('Sun').html_print_checkbox('sunday', 1, $sunday, true, $disabled_in_execution)."</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id='monthly_item' class='invisible'>
|
||||
<table id='monthly_item' style='display: none;'>
|
||||
<tr>
|
||||
<td>".__('From day:').'</td>
|
||||
<td>'.html_print_select(
|
||||
@ -864,42 +724,16 @@ $table->data[5][1] = "
|
||||
</table>
|
||||
</div>';
|
||||
|
||||
echo '<form method="POST" action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor">';
|
||||
|
||||
if ($id_downtime > 0) {
|
||||
echo '<table width=100% border=0 cellpadding=4 >';
|
||||
echo "<tr><td width=75% valign='top'>";
|
||||
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
|
||||
} else {
|
||||
echo '<form method="POST" action="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor">';
|
||||
}
|
||||
|
||||
// Editor form.
|
||||
html_print_table($table);
|
||||
|
||||
html_print_input_hidden('id_agent', $id_agent);
|
||||
echo '<div class="action-buttons w100p" >';
|
||||
if ($id_downtime > 0) {
|
||||
html_print_input_hidden('update_downtime', 1);
|
||||
html_print_input_hidden('id_downtime', $id_downtime);
|
||||
html_print_submit_button(
|
||||
__('Update'),
|
||||
'updbutton',
|
||||
false,
|
||||
'class="sub upd"'
|
||||
);
|
||||
} else {
|
||||
html_print_input_hidden('create_downtime', 1);
|
||||
html_print_submit_button(
|
||||
__('Add'),
|
||||
'crtbutton',
|
||||
false,
|
||||
'class="sub wand"'
|
||||
);
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
if ($id_downtime > 0) {
|
||||
echo "<td valign=top class='w300px pdd_l_20px'>";
|
||||
echo "<td valign=top style='width:300px;padding-left:20px;'>";
|
||||
|
||||
$filter_group = (int) get_parameter('filter_group', 0);
|
||||
|
||||
@ -940,28 +774,27 @@ if ($id_downtime > 0) {
|
||||
$disabled_add_button = true;
|
||||
}
|
||||
|
||||
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&id_downtime=$id_downtime'>";
|
||||
html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', false, false, true, '', false, 'min-width:180px;margin-right:15px;');
|
||||
|
||||
html_print_checkbox('recursion', 1, $recursion, false, false, '');
|
||||
echo __('Recursion').' ';
|
||||
echo '<br /><br />';
|
||||
html_print_submit_button(__('Filter by group'), '', false, 'class="sub next"', false);
|
||||
echo '</form>';
|
||||
// Show available agents to include into downtime
|
||||
echo '<h4>'.__('Available agents').':</h4>';
|
||||
echo "<form method=post action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&insert_downtime_agent=1&id_downtime=$id_downtime'>";
|
||||
html_print_input_hidden('all_agents', implode(',', array_keys($agents)));
|
||||
echo html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, false, true, true, '', false, 'width: 180px;');
|
||||
$table = new StdClass();
|
||||
$table->class = 'databox filters';
|
||||
$table->width = '100%';
|
||||
$table->data = [];
|
||||
|
||||
$table->data[0][0] = __('Group filter');
|
||||
$table->data[0][1] = html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', true, false, true, '', false, 'min-width:180px;margin-right:15px;');
|
||||
$table->data[0][2] = __('Recursion').'  '.html_print_checkbox('recursion', 1, $recursion, true, false, '');
|
||||
|
||||
$table->data[1][0] = __('Available agents');
|
||||
$table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'width: 180px;');
|
||||
|
||||
|
||||
if ($type_downtime != 'quiet') {
|
||||
echo '<div id="available_modules_selection_mode" class="invisible pdd_l_20px">';
|
||||
echo '<div id="available_modules_selection_mode" style="padding-top:20px;display: none;">';
|
||||
} else {
|
||||
echo '<div id="available_modules_selection_mode" class="pdd_l_20px">';
|
||||
echo '<div id="available_modules_selection_mode" style="padding-top:20px">';
|
||||
}
|
||||
|
||||
html_print_input_hidden('all_common_modules', '');
|
||||
echo html_print_select(
|
||||
$table->data[2][1] = html_print_select(
|
||||
[
|
||||
'common' => __('Show common modules'),
|
||||
'all' => __('Show all modules'),
|
||||
@ -978,27 +811,28 @@ if ($id_downtime > 0) {
|
||||
false,
|
||||
'min-width:180px;'
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<h4>'.__('Available modules:').ui_print_help_tip(
|
||||
$table->data[3][0] = __('Available modules:').ui_print_help_tip(
|
||||
__('Only for type Quiet for downtimes.'),
|
||||
true
|
||||
).'</h4>';
|
||||
);
|
||||
|
||||
if ($type_downtime != 'quiet') {
|
||||
echo '<div id="available_modules" class="invisible">';
|
||||
echo '<div id="available_modules" style="display: none;">';
|
||||
} else {
|
||||
echo '<div id="available_modules" >';
|
||||
echo '<div id="available_modules" style="">';
|
||||
}
|
||||
|
||||
echo html_print_select(
|
||||
$table->data[3][1] = html_print_select(
|
||||
[],
|
||||
'module[]',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
@ -1006,16 +840,37 @@ if ($id_downtime > 0) {
|
||||
'width: 180px;'
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
// Print agent table.
|
||||
html_print_table($table);
|
||||
|
||||
echo '<br /><br /><br />';
|
||||
|
||||
html_print_input_hidden('id_agent', $id_agent);
|
||||
echo '<div class="action-buttons w100p" >';
|
||||
if ($id_downtime > 0) {
|
||||
html_print_input_hidden('update_downtime', 1);
|
||||
html_print_input_hidden('id_downtime', $id_downtime);
|
||||
html_print_submit_button(
|
||||
__('Update'),
|
||||
'updbutton',
|
||||
false,
|
||||
'class="sub upd"'
|
||||
);
|
||||
} else {
|
||||
html_print_input_hidden('create_downtime', 1);
|
||||
html_print_submit_button(
|
||||
__('Add'),
|
||||
'add_item',
|
||||
$disabled_add_button,
|
||||
'class="sub next"',
|
||||
false
|
||||
'crtbutton',
|
||||
false,
|
||||
'class="sub wand"'
|
||||
);
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
html_print_input_hidden('all_agents', implode(',', array_keys($agents)));
|
||||
html_print_input_hidden('all_common_modules', '');
|
||||
echo '</form>';
|
||||
echo '</table>';
|
||||
|
||||
// Start Overview of existing planned downtime.
|
||||
echo '<h4>'.__('Agents planned for this downtime').':</h4>';
|
||||
@ -1094,25 +949,10 @@ if ($id_downtime > 0) {
|
||||
if ($type_downtime != 'disable_agents_alerts'
|
||||
&& $type_downtime != 'disable_agents'
|
||||
) {
|
||||
$data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'alt' => __('Delete'),
|
||||
]
|
||||
).'</a>';
|
||||
$data[5] = '<a href="javascript:show_editor_module('.$downtime_agent['id_agente'].');">'.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).'</a>';
|
||||
}
|
||||
|
||||
$data[5] .= '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image(
|
||||
'images/cross.png',
|
||||
true,
|
||||
[
|
||||
'border' => '0',
|
||||
'alt' => __('Delete'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>';
|
||||
$data[5] .= '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&id_agent='.$downtime_agent['id_agente'].'&delete_downtime_agent=1&id_downtime_agent='.$downtime_agent['id'].'&id_downtime='.$id_downtime.'">'.html_print_image('images/cross.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).'</a>';
|
||||
}
|
||||
|
||||
$table->data['agent_'.$downtime_agent['id_agente']] = $data;
|
||||
@ -1120,7 +960,6 @@ if ($id_downtime > 0) {
|
||||
|
||||
html_print_table($table);
|
||||
}
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
$table->id = 'loading';
|
||||
@ -1154,9 +993,9 @@ $table->data['module'][1] = "
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class='datos' id='template' class='invisible'>
|
||||
<td class='name_module'></td>
|
||||
<td class='cell_delete_button right w10p' id=''>".'<a class="link_delete"
|
||||
<tr class='datos' id='template' style='display: none;'>
|
||||
<td class='name_module' style=''></td>
|
||||
<td class='cell_delete_button' style='text-align: right; width:10%;' id=''>".'<a class="link_delete"
|
||||
onclick="if(!confirm(\''.__('Are you sure?').'\')) return false;"
|
||||
href="">'.html_print_image(
|
||||
'images/cross.png',
|
||||
@ -1169,7 +1008,7 @@ $table->data['module'][1] = "
|
||||
).'</a>'."</td>
|
||||
</tr>
|
||||
<tr class='datos2' id='add_modules_row'>
|
||||
<td class='datos2'id=''>".__('Add Module:').' '.html_print_select(
|
||||
<td class='datos2' style='' id=''>".__('Add Module:').' '.html_print_select(
|
||||
[],
|
||||
'modules',
|
||||
'',
|
||||
@ -1178,7 +1017,7 @@ $table->data['module'][1] = "
|
||||
0,
|
||||
true
|
||||
)."</td>
|
||||
<td class='datos2 button_cell right w10p' id=''>".'<div id="add_button_div">'.'<a class="add_button" href="">'.html_print_image(
|
||||
<td class='datos2 button_cell' style='text-align: right; width:10%;' id=''>".'<div id="add_button_div">'.'<a class="add_button" href="">'.html_print_image(
|
||||
'images/add.png',
|
||||
true,
|
||||
[
|
||||
@ -1186,10 +1025,7 @@ $table->data['module'][1] = "
|
||||
'alt' => __('Add'),
|
||||
'class' => 'invert_filter',
|
||||
]
|
||||
).'</a>'.'</div>'."<div id='spinner_add' class='invisible'>".html_print_image(
|
||||
'images/spinner.gif',
|
||||
true
|
||||
).'</div>'.'</td>
|
||||
).'</a></div>'."<div id='spinner_add' style='display: none;'>".html_print_image('images/spinner.gif', true).'</div></td>
|
||||
</tr>
|
||||
</tbody></table>';
|
||||
|
||||
@ -1218,10 +1054,141 @@ echo '</div>';
|
||||
ui_include_time_picker();
|
||||
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/');
|
||||
|
||||
// Auxiliary function for downtime agent creation.
|
||||
function insert_downtime_agent($id_downtime, $user_groups_ad)
|
||||
{
|
||||
// Check AD permission on downtime.
|
||||
$downtime_group = db_get_value(
|
||||
'id_group',
|
||||
'tplanned_downtime',
|
||||
'id',
|
||||
$id_downtime
|
||||
);
|
||||
|
||||
if ($downtime_group === false
|
||||
|| !in_array($downtime_group, $user_groups_ad)
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access downtime scheduler'
|
||||
);
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
$agents = (array) get_parameter('id_agents');
|
||||
$module_names = (array) get_parameter('module');
|
||||
$modules_selection_mode = (string) get_parameter('modules_selection_mode');
|
||||
|
||||
$all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (string) $module_names[0] === '0'));
|
||||
$all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (string) $module_names[0] === '0'));
|
||||
|
||||
if ($all_common_modules === true) {
|
||||
$module_names = explode(',', get_parameter('all_common_modules'));
|
||||
}
|
||||
|
||||
// 'Is running' check.
|
||||
$is_running = (bool) db_get_value(
|
||||
'executed',
|
||||
'tplanned_downtime',
|
||||
'id',
|
||||
$id_downtime
|
||||
);
|
||||
if ($is_running) {
|
||||
ui_print_error_message(
|
||||
__('This elements cannot be modified while the downtime is being executed')
|
||||
);
|
||||
} else {
|
||||
// If is selected 'Any', get all the agents.
|
||||
if (count($agents) === 1 && (int) $agents[0] === -2) {
|
||||
$all_agents = get_parameter('all_agents');
|
||||
$agents = explode(',', $all_agents);
|
||||
}
|
||||
|
||||
foreach ($agents as $agent_id) {
|
||||
// Check module belongs to the agent.
|
||||
if ($modules_selection_mode == 'all' && $all_modules === false) {
|
||||
$check = false;
|
||||
foreach ($module_names as $module_name) {
|
||||
$check_module = modules_get_agentmodule_id(
|
||||
$module_name,
|
||||
$agent_id
|
||||
);
|
||||
if (!empty($check_module)) {
|
||||
$check = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$check) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Check AD permission on agent.
|
||||
$agent_group = db_get_value(
|
||||
'id_grupo',
|
||||
'tagente',
|
||||
'id_agente',
|
||||
$agent_id
|
||||
);
|
||||
|
||||
if ($agent_group === false
|
||||
|| !in_array($agent_group, $user_groups_ad)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'id_downtime' => $id_downtime,
|
||||
'id_agent' => $agent_id,
|
||||
'all_modules' => $all_modules,
|
||||
];
|
||||
$result = db_process_sql_insert(
|
||||
'tplanned_downtime_agents',
|
||||
$values
|
||||
);
|
||||
|
||||
if ($result && !$all_modules) {
|
||||
foreach ($module_names as $module_name) {
|
||||
$module = modules_get_agentmodule_id(
|
||||
$module_name,
|
||||
$agent_id
|
||||
);
|
||||
|
||||
if (empty($module)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = [
|
||||
'id_downtime' => $id_downtime,
|
||||
'id_agent' => $agent_id,
|
||||
'id_agent_module' => $module['id_agente_modulo'],
|
||||
];
|
||||
$result = db_process_sql_insert(
|
||||
'tplanned_downtime_modules',
|
||||
$values
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
$values = ['id_user' => $config['id_user']];
|
||||
$result = db_process_sql_update(
|
||||
'tplanned_downtime',
|
||||
$values,
|
||||
['id' => $id_downtime]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
var id_downtime = <?php echo $id_downtime; ?>;
|
||||
var action_in_progress = false;
|
||||
var recursion = false;
|
||||
|
||||
function change_type_downtime() {
|
||||
switch ($("#type_downtime").val()) {
|
||||
@ -1482,6 +1449,8 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript
|
||||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
populate_agents_selector();
|
||||
|
||||
$("#id_agents").change(agent_changed_by_multiple_agents);
|
||||
$("#modules_selection_mode").change(agent_changed_by_multiple_agents);
|
||||
|
||||
@ -1534,5 +1503,47 @@ ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript
|
||||
}
|
||||
// Disable datepickers when it has readonly attribute
|
||||
$('input.hasDatepicker[readonly]').disable();
|
||||
|
||||
$("#checkbox-recursion").click(function() {
|
||||
recursion = this.checked;
|
||||
$("#filter_group").trigger("change");
|
||||
});
|
||||
|
||||
// Change agent selector based on group.
|
||||
$("#filter_group").change(function() {
|
||||
populate_agents_selector();
|
||||
});
|
||||
|
||||
function populate_agents_selector() {
|
||||
jQuery.post ("ajax.php",
|
||||
{"page": "operation/agentes/ver_agente",
|
||||
"get_agents_group_json": 1,
|
||||
"id_group": $("#filter_group").val(),
|
||||
"privilege": "AW",
|
||||
"keys_prefix": "_",
|
||||
"recursion": recursion,
|
||||
},
|
||||
function (data, status) {
|
||||
$("#id_agents").empty();
|
||||
$("#module").html('');
|
||||
|
||||
option_any = $("<option></option>")
|
||||
.attr ("value", -2)
|
||||
.html ("Any");
|
||||
$("#id_agents").append (option_any);
|
||||
|
||||
jQuery.each (data, function (id, value) {
|
||||
// Remove keys_prefix from the index
|
||||
id = id.substring(1);
|
||||
|
||||
option = $("<option></option>")
|
||||
.attr ("value", value["id_agente"])
|
||||
.html (value["alias"]);
|
||||
$("#id_agents").append (option);
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user