class = 'alternate';
$table_details->width = '100%';
$table_details->size = array ();
$table_details->data = array();
$table_details->style = array();
$table_details->style[0] = 'font-weight: bold;';
$data = array();
$data[0] = __('Agent');
$data[1] = $agent_name;
$table_details->data[] = $data;
$data[0] = __('Module');
$data[1] = $module_name;
$table_details->data[] = $data;
$data[0] = __('Template');
$data[1] = $template['name'] . ui_print_help_tip($template['description'], true);
$table_details->data[] = $data;
$data[0] = __('Last fired');
$data[1] = ui_print_timestamp ($alert["last_fired"], true);
$table_details->data[] = $data;
if ($alert["times_fired"] > 0) {
$status = STATUS_ALERT_FIRED;
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
}
elseif ($alert["disabled"] > 0) {
$status = STATUS_ALERT_DISABLED;
$title = __('Alert disabled');
}
else {
$status = STATUS_ALERT_NOT_FIRED;
$title = __('Alert not fired');
}
$data[0] = __('Status');
$data[1] = '' . ui_print_status_image($status, $title, true) . '' . $title;
$table_details->data[] = $data;
$priorities = get_priorities ();
$data[0] = __('Priority');
$data[1] = ' ' . $priorities[$template['priority']];
$table_details->data[] = $data;
$data[0] = __('Stand by');
$data[1] = $alert['standby'] == 1 ? __('Yes') : __('No');
$table_details->data[] = $data;
if (enterprise_installed() && $alert['id_policy_alerts'] != 0) {
$policyInfo = policies_is_alert_in_policy2($alert['id'], false);
if ($policyInfo === false) {
$policy = __('N/A');
}
else {
$img = 'images/policies.png';
$policy = '' .
html_print_image($img, true, array('title' => $policyInfo['name'])) .
'';
}
$data[0] = __('Policy');
$data[1] = $policy;
$table_details->data[] = $data;
}
// TABLE DETAILS END
// TABLE CONDITIONS
$table_conditions->class = 'alternate';
$table_conditions->width = '100%';
$table_conditions->size = array ();
$table_conditions->data = array();
$table_conditions->style = array();
$table_conditions->style[0] = 'font-weight: bold; width: 50%;';
$data = array();
$table_conditions->colspan[0][0] = 2;
switch ($template['type']) {
case 'regex':
if ($template['matches_value']) {
$condition = __('The alert would fire when the value matches ');
}
else {
$condition = __('The alert would fire when the value doesn\'t match ');
}
$condition = str_replace('', $template['value'], $condition);
break;
case 'equal':
$condition = __('The alert would fire when the value is ');
$condition = str_replace('', $template['value'], $condition);
break;
case 'not_equal':
$condition = __('The alert would fire when the value is not ');
$condition = str_replace('', $template['value'], $condition);
break;
case 'max_min':
if ($template['matches_value']) {
$condition = __('The alert would fire when the value is between and ');
}
else {
$condition = __('The alert would fire when the value is not between and ');
}
$condition = str_replace('', $template['min_value'], $condition);
$condition = str_replace('', $template['max_value'], $condition);
break;
case 'max':
$condition = __('The alert would fire when the value is below ');
$condition = str_replace('', $template['min_value'], $condition);
break;
case 'min':
$condition = __('The alert would fire when the value is above ');
$condition = str_replace('', $template['max_value'], $condition);
break;
case 'onchange':
if ($template['matches_value']) {
$condition = __('The alert would fire when the module value changes');
}
else {
$condition = __('The alert would fire when the module value does not change');
}
break;
case 'warning':
$condition = __('The alert would fire when the module is in warning status');
break;
case 'critical':
$condition = __('The alert would fire when the module is in critical status');
break;
case 'unknown':
$condition = __('The alert would fire when the module is in unknown status');
break;
case 'always':
$condition = __('Always');
}
$data[0] = $condition;
$table_conditions->data[] = $data;
//DAYS
$table_days->class = 'databox alert_days';
$table_days->width = '100%';
$table_days->size = array ();
$table_days->data = array();
$table_days->style = array();
$table_days->styleTable = 'padding: 1px; margin: 0px; text-align: center; height: 80px;';
$table_days->head[0] = __('Mon');
$table_days->head[1] = __('Tue');
$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 = array();
if ($template['monday']) {
$table_days->data[0][0] = html_print_image('images/tick.png', true);
}
if ($template['tuesday']) {
$table_days->data[0][1] = html_print_image('images/tick.png', true);
}
if ($template['wednesday']) {
$table_days->data[0][2] = html_print_image('images/tick.png', true);
}
if ($template['thursday']) {
$table_days->data[0][3] = html_print_image('images/tick.png', true);
}
if ($template['friday']) {
$table_days->data[0][4] = html_print_image('images/tick.png', true);
}
if ($template['saturday']) {
$table_days->data[0][5] = html_print_image('images/tick.png', true);
}
if ($template['sunday']) {
$table_days->data[0][6] = html_print_image('images/tick.png', true);
}
$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 = array ();
$table_time->data = array();
$table_time->style = array();
$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
-
23:59:59';
$table_time->data[0][0] = html_print_image('images/tick.png', true);
}
else {
$from_array = explode(':', $template['time_from']);
$from = $from_array[0] * 3600 + $from_array[1] * 60 + $from_array[2];
$to_array = explode(':', $template['time_to']);
$to = $to_array[0] * 3600 + $to_array[1] * 60 + $to_array[2];
if ($to > $from) {
if ($template['time_from'] != '00:00:00') {
$table_time->head[0] = '00:00:00
-
' . $template['time_from'];
$table_time->data[0][0] = html_print_image('images/blade.png', true);
}
$table_time->head[1] = $template['time_from'] . '
-
' . $template['time_to'];
$table_time->data[0][1] = html_print_image('images/tick.png', true);
if ($template['time_to'] != '23:59:59') {
$table_time->head[2] = $template['time_to'] . '
-
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
-
' . $template['time_to'];
$table_time->data[0][0] = html_print_image('images/tick.png', true);
}
$table_time->head[1] = $template['time_to'] . '
-
' . $template['time_from'];
$table_time->data[0][1] = html_print_image('images/blade.png', true);
if ($template['time_from'] != '23:59:59') {
$table_time->head[2] = $template['time_from'] . '
-
23:59:59';
$table_time->data[0][2] = html_print_image('images/tick.png', true);
}
}
$data[1] = $template['time_from'] . ' / ' . $template['time_to'];
}
$data[1] = html_print_table($table_time, true);
unset($table_time);
$table_conditions->data[] = $data;
$data[0] = __('Use special days list');
$data[1] = (isset($alert['special_day']) && $alert['special_day'] == 1) ? __('Yes') : __('No');
$table_conditions->data[] = $data;
$data[0] = __('Time threshold');
$data[1] = human_time_description_raw ($template['time_threshold'], true);
$table_conditions->data[] = $data;
$data[0] = __('Number of alerts') . ' ('. __('Min') . '/' . __('Max') . ')';
$data[1] = $template['min_alerts'] . '/' . $template['max_alerts'];
$table_conditions->data[] = $data;
// TABLE CONDITIONS END
$table->class = 'alert_list databox';
$table->width = '98%';
$table->size = array();
$table->head = array();
$table->data = array();
$table->style = array();
$table->style[0] = 'width: 50%;';
$table->head[0] = __('Alert details');
$table->head[1] = __('Firing conditions');
$table->data[0][0] = html_print_table($table_details, true);
$table->data[0][1] = html_print_table($table_conditions, true);
html_print_table($table);
unset($table);
$actions = alerts_get_actions_escalation($actions, $default_action);
// ESCALATION
$table->class = 'alert_list databox alternate alert_escalation';
$table->width = '98%';
$table->size = array ();
$table->head = array();
$table->data = array();
$table->styleTable = 'text-align: center;';
echo '