alert template schedule pandora_enterprise#3943
This commit is contained in:
parent
5eb719ecaa
commit
645257f9dc
|
@ -206,105 +206,15 @@ $data[0] = $condition;
|
||||||
|
|
||||||
$table_conditions->data[] = $data;
|
$table_conditions->data[] = $data;
|
||||||
|
|
||||||
// DAYS
|
$table_conditions->colspan[1][0] = 2;
|
||||||
$table_days->class = 'databox alert_days';
|
$schedule = json_decode(
|
||||||
$table_days->width = '100%';
|
io_safe_output(
|
||||||
$table_days->size = [];
|
$template['schedule']
|
||||||
$table_days->data = [];
|
),
|
||||||
$table_days->style = [];
|
true
|
||||||
$table_days->styleTable = 'padding: 1px; margin: 0px; text-align: center; height: 80px;';
|
);
|
||||||
$table_days->head[0] = __('Mon');
|
$data[0] = drawInfoSchedule($schedule, 'databox alert_days');
|
||||||
$table_days->head[1] = __('Tue');
|
$data[1] = '';
|
||||||
$table_days->head[2] = __('Wed');
|
|
||||||
$table_days->head[3] = __('Thu');
|
|
||||||
$table_days->head[4] = __('Fri');
|
|
||||||
$table_days->head[5] = __('Sat');
|
|
||||||
$table_days->head[6] = __('Sun');
|
|
||||||
$table_days->data[0] = array_fill(0, 7, html_print_image('images/blade.png', true));
|
|
||||||
|
|
||||||
$days = [];
|
|
||||||
if ($template['monday']) {
|
|
||||||
$table_days->data[0][0] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($template['tuesday']) {
|
|
||||||
$table_days->data[0][1] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($template['wednesday']) {
|
|
||||||
$table_days->data[0][2] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($template['thursday']) {
|
|
||||||
$table_days->data[0][3] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($template['friday']) {
|
|
||||||
$table_days->data[0][4] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($template['saturday']) {
|
|
||||||
$table_days->data[0][5] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($template['sunday']) {
|
|
||||||
$table_days->data[0][6] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data[0] = html_print_table($table_days, true);
|
|
||||||
unset($table_days);
|
|
||||||
|
|
||||||
// TIME
|
|
||||||
$table_time->class = 'databox alert_time';
|
|
||||||
$table_time->width = '100%';
|
|
||||||
$table_time->size = [];
|
|
||||||
$table_time->data = [];
|
|
||||||
$table_time->style = [];
|
|
||||||
$table_time->styleTable = 'padding: 1px; margin: 0px; text-align: center; height: 80px; width: 100%;';
|
|
||||||
|
|
||||||
// $data[0] = __('Time from') . ' / ' . __('Time to');
|
|
||||||
if ($template['time_from'] == $template['time_to']) {
|
|
||||||
$table_time->head[0] = '00:00:00<br>-<br>23:59:59';
|
|
||||||
$table_time->data[0][0] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
} else {
|
|
||||||
$from_array = explode(':', $template['time_from']);
|
|
||||||
$from = ($from_array[0] * SECONDS_1HOUR + $from_array[1] * SECONDS_1MINUTE + $from_array[2]);
|
|
||||||
$to_array = explode(':', $template['time_to']);
|
|
||||||
$to = ($to_array[0] * SECONDS_1HOUR + $to_array[1] * SECONDS_1MINUTE + $to_array[2]);
|
|
||||||
if ($to > $from) {
|
|
||||||
if ($template['time_from'] != '00:00:00') {
|
|
||||||
$table_time->head[0] = '00:00:00<br>-<br>'.$template['time_from'];
|
|
||||||
$table_time->data[0][0] = html_print_image('images/blade.png', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$table_time->head[1] = $template['time_from'].'<br>-<br>'.$template['time_to'];
|
|
||||||
$table_time->data[0][1] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
|
|
||||||
if ($template['time_to'] != '23:59:59') {
|
|
||||||
$table_time->head[2] = $template['time_to'].'<br>-<br>23:59:59';
|
|
||||||
$table_time->data[0][2] = html_print_image('images/blade.png', true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($template['time_to'] != '00:00:00') {
|
|
||||||
$table_time->head[0] = '00:00:00<br>-<br>'.$template['time_to'];
|
|
||||||
$table_time->data[0][0] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$table_time->head[1] = $template['time_to'].'<br>-<br>'.$template['time_from'];
|
|
||||||
$table_time->data[0][1] = html_print_image('images/blade.png', true, ['class' => 'invert_filter']);
|
|
||||||
|
|
||||||
if ($template['time_from'] != '23:59:59') {
|
|
||||||
$table_time->head[2] = $template['time_from'].'<br>-<br>23:59:59';
|
|
||||||
$table_time->data[0][2] = html_print_image('images/tick.png', true, ['class' => 'invert_filter']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data[1] = $template['time_from'].' / '.$template['time_to'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$data[1] = html_print_table($table_time, true);
|
|
||||||
unset($table_time);
|
|
||||||
|
|
||||||
$table_conditions->data[] = $data;
|
$table_conditions->data[] = $data;
|
||||||
|
|
||||||
$data[0] = __('Use special days list');
|
$data[0] = __('Use special days list');
|
||||||
|
|
|
@ -1,16 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Alerts templates.
|
||||||
|
*
|
||||||
|
* @category Alerts
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Community
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
|
||||||
// ==================================================
|
|
||||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
|
||||||
// Please see http://pandorafms.org for full contribution list
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation for version 2.
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
// Load global vars.
|
// Load global vars.
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -43,14 +58,14 @@ if (defined('LAST_STEP') === false) {
|
||||||
define('LAST_STEP', 3);
|
define('LAST_STEP', 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($duplicate_template) {
|
if ($duplicate_template === true) {
|
||||||
$source_id = (int) get_parameter('source_id');
|
$source_id = (int) get_parameter('source_id');
|
||||||
$a_template = alerts_get_alert_template($source_id);
|
$a_template = alerts_get_alert_template($source_id);
|
||||||
} else {
|
} else {
|
||||||
$a_template = alerts_get_alert_template($id);
|
$a_template = alerts_get_alert_template($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
$sec = 'advanced';
|
$sec = 'advanced';
|
||||||
} else {
|
} else {
|
||||||
$sec = 'galertas';
|
$sec = 'galertas';
|
||||||
|
@ -64,7 +79,7 @@ if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
|
||||||
if ($a_template !== false) {
|
if ($a_template !== false) {
|
||||||
// If user tries to duplicate/edit a template with group=ALL.
|
// If user tries to duplicate/edit a template with group=ALL.
|
||||||
if ($a_template['id_group'] == 0) {
|
if ($a_template['id_group'] == 0) {
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
alerts_meta_print_header();
|
alerts_meta_print_header();
|
||||||
} else {
|
} else {
|
||||||
if ($step == 1) {
|
if ($step == 1) {
|
||||||
|
@ -96,7 +111,7 @@ if ($a_template !== false) {
|
||||||
// Then template group have to be in his own groups.
|
// Then template group have to be in his own groups.
|
||||||
if ($is_in_group) {
|
if ($is_in_group) {
|
||||||
// Header.
|
// Header.
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
alerts_meta_print_header();
|
alerts_meta_print_header();
|
||||||
} else {
|
} else {
|
||||||
ui_print_page_header(
|
ui_print_page_header(
|
||||||
|
@ -120,7 +135,7 @@ if ($a_template !== false) {
|
||||||
// This prevents to duplicate the header in case duplicate/edit_template action is performed.
|
// This prevents to duplicate the header in case duplicate/edit_template action is performed.
|
||||||
} else {
|
} else {
|
||||||
// Header.
|
// Header.
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
alerts_meta_print_header();
|
alerts_meta_print_header();
|
||||||
} else {
|
} else {
|
||||||
if ($step == 1) {
|
if ($step == 1) {
|
||||||
|
@ -172,7 +187,7 @@ function print_alert_template_steps($step, $id)
|
||||||
{
|
{
|
||||||
echo '<ol class="steps">';
|
echo '<ol class="steps">';
|
||||||
|
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
$sec = 'advanced';
|
$sec = 'advanced';
|
||||||
} else {
|
} else {
|
||||||
$sec = 'galertas';
|
$sec = 'galertas';
|
||||||
|
@ -256,7 +271,7 @@ function update_template($step)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
$sec = 'advanced';
|
$sec = 'advanced';
|
||||||
} else {
|
} else {
|
||||||
$sec = 'galertas';
|
$sec = 'galertas';
|
||||||
|
@ -558,7 +573,7 @@ $table = new stdClass();
|
||||||
$table->id = 'template';
|
$table->id = 'template';
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->class = 'databox filters';
|
$table->class = 'databox filters';
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
$table->head[0] = __('Create Template');
|
$table->head[0] = __('Create Template');
|
||||||
$table->head_colspan[0] = 4;
|
$table->head_colspan[0] = 4;
|
||||||
$table->headstyle[0] = 'text-align: center';
|
$table->headstyle[0] = 'text-align: center';
|
||||||
|
@ -623,7 +638,7 @@ if ($step == 2) {
|
||||||
'',
|
'',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
$table->data[1][1] .= '<div id="calendar_map"></div>';
|
$table->data[1][1] .= '<div id="calendar_map" style="width: 90%;"></div>';
|
||||||
$table->data[1][1] .= html_print_input_hidden('schedule', $schedule, true);
|
$table->data[1][1] .= html_print_input_hidden('schedule', $schedule, true);
|
||||||
|
|
||||||
$table->colspan['threshold'][1] = 3;
|
$table->colspan['threshold'][1] = 3;
|
||||||
|
@ -716,8 +731,7 @@ if ($step == 2) {
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_query = sprintf(
|
$sql_query = sprintf(
|
||||||
'
|
'SELECT id, name
|
||||||
SELECT id, name
|
|
||||||
FROM talert_actions
|
FROM talert_actions
|
||||||
WHERE id_group IN (%s)
|
WHERE id_group IN (%s)
|
||||||
ORDER BY name',
|
ORDER BY name',
|
||||||
|
@ -1085,7 +1099,7 @@ if ($step == 2) {
|
||||||
(!$is_management_allowed | $disabled)
|
(!$is_management_allowed | $disabled)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
$table->data[3][0] = __('Wizard level');
|
$table->data[3][0] = __('Wizard level');
|
||||||
$wizard_levels = [
|
$wizard_levels = [
|
||||||
'nowizard' => __('No wizard'),
|
'nowizard' => __('No wizard'),
|
||||||
|
|
|
@ -3390,3 +3390,62 @@ function alerts_get_templates_name_array($array_ids)
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw schedule info
|
||||||
|
*
|
||||||
|
* @param array $schedule
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function drawInfoSchedule($schedule, $class='info_table')
|
||||||
|
{
|
||||||
|
$table_days = new stdClass();
|
||||||
|
$table_days->width = '100%';
|
||||||
|
$table_days->class = $class;
|
||||||
|
$table_days->data = [];
|
||||||
|
$table_days->styleTable = 'text-align: center;';
|
||||||
|
$table_days->head['monday'] = __('Mon');
|
||||||
|
$table_days->head['tuesday'] = __('Tue');
|
||||||
|
$table_days->head['wednesday'] = __('Wed');
|
||||||
|
$table_days->head['thursday'] = __('Thu');
|
||||||
|
$table_days->head['friday'] = __('Fri');
|
||||||
|
$table_days->head['saturday'] = __('Sat');
|
||||||
|
$table_days->head['sunday'] = __('Sun');
|
||||||
|
|
||||||
|
$week = [
|
||||||
|
'monday',
|
||||||
|
'tuesday',
|
||||||
|
'wednesday',
|
||||||
|
'thursday',
|
||||||
|
'friday',
|
||||||
|
'saturday',
|
||||||
|
'sunday',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($week as $day) {
|
||||||
|
$table_days->data[0][$day] = html_print_image(
|
||||||
|
'images/blade.png',
|
||||||
|
true,
|
||||||
|
['class' => 'invert_filter']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($schedule as $day => $sch) {
|
||||||
|
if (isset($sch) === true && empty($sch) === false) {
|
||||||
|
$table_days->data[0][$day] = '';
|
||||||
|
foreach ($sch as $value) {
|
||||||
|
$table_days->data[0][$day] .= '<p>';
|
||||||
|
$table_days->data[0][$day] .= '<span>'.__('From').': </span>';
|
||||||
|
$table_days->data[0][$day] .= '<span>'.$value['start'].'</span>';
|
||||||
|
|
||||||
|
$table_days->data[0][$day] .= '<span> '.__('To').': </span>';
|
||||||
|
$table_days->data[0][$day] .= '<span>'.$value['end'].'</span>';
|
||||||
|
$table_days->data[0][$day] .= '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return \html_print_table($table_days, true);
|
||||||
|
}
|
||||||
|
|
|
@ -248,14 +248,11 @@ div#rules.show {
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-item {
|
.info-item {
|
||||||
width: 25%;
|
width: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.info-days {
|
|
||||||
width: 65%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-item table.info_table thead tr th {
|
.info-item table.info_table thead tr th {
|
||||||
|
min-width: 150px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue