add metaconsole calendars special days alerts

This commit is contained in:
Daniel Barbero Martin 2021-11-08 13:07:31 +01:00
parent 900a37ad5d
commit 2d4c949113
7 changed files with 292 additions and 169 deletions

View File

@ -153,7 +153,7 @@ class CalendarManager
$buttons['list'] = [ $buttons['list'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.ui_get_full_url( 'text' => '<a href="'.ui_get_full_url(
$this->url.'&tab=list' $this->url.'&tab_calendar=list'
).'&pure='.(int) $config['pure'].'">'.html_print_image( ).'&pure='.(int) $config['pure'].'">'.html_print_image(
'images/list.png', 'images/list.png',
true, true,
@ -175,7 +175,7 @@ class CalendarManager
$buttons['list_edit'] = [ $buttons['list_edit'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.ui_get_full_url( 'text' => '<a href="'.ui_get_full_url(
$this->url.'&tab=list&op=edit&id='.$id $this->url.'&tab_calendar=list&op=edit&id='.$id
).'&pure='.(int) $config['pure'].'">'.html_print_image( ).'&pure='.(int) $config['pure'].'">'.html_print_image(
'images/pencil.png', 'images/pencil.png',
true, true,
@ -189,7 +189,7 @@ class CalendarManager
$buttons['special_days'] = [ $buttons['special_days'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.ui_get_full_url( 'text' => '<a href="'.ui_get_full_url(
$this->url.'&tab=special_days&id_calendar='.$id $this->url.'&tab_calendar=special_days&id_calendar='.$id
).'&pure='.(int) $config['pure'].'">'.html_print_image( ).'&pure='.(int) $config['pure'].'">'.html_print_image(
'images/templates.png', 'images/templates.png',
true, true,
@ -220,7 +220,7 @@ class CalendarManager
{ {
\ui_require_css_file('alert'); \ui_require_css_file('alert');
$op = get_parameter('op'); $op = get_parameter('op');
$tab = get_parameter('tab'); $tab = get_parameter('tab_calendar');
switch ($tab) { switch ($tab) {
case 'special_days': case 'special_days':
if ($op === 'edit') { if ($op === 'edit') {
@ -544,7 +544,7 @@ class CalendarManager
'calendar/edit', 'calendar/edit',
[ [
'ajax_url' => $this->ajaxUrl, 'ajax_url' => $this->ajaxUrl,
'url' => $this->url.'&op=edit&tab=list', 'url' => $this->url.'&op=edit&tab_calendar=list',
'tabs' => $this->getTabs('list'), 'tabs' => $this->getTabs('list'),
'calendar' => $calendar, 'calendar' => $calendar,
'message' => $this->message, 'message' => $this->message,
@ -601,6 +601,8 @@ class CalendarManager
true true
)['count']; )['count'];
$is_management_allowed = \is_management_allowed();
if ((bool) $data === true) { if ((bool) $data === true) {
$manage = check_acl( $manage = check_acl(
$config['id_user'], $config['id_user'],
@ -611,7 +613,7 @@ class CalendarManager
$data = array_reduce( $data = array_reduce(
$data, $data,
function ($carry, $item) use ($manage) { function ($carry, $item) use ($manage, $is_management_allowed) {
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps // phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// Transforms array of arrays $data into an array // Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields. // of objects, making a post-process of certain fields.
@ -620,7 +622,7 @@ class CalendarManager
if ((bool) $manage === true) { if ((bool) $manage === true) {
$name = '<b><a href="'; $name = '<b><a href="';
$name .= ui_get_full_url( $name .= ui_get_full_url(
$this->url.'&op=special_days&tab=special_days&id_calendar='.$tmp->id $this->url.'&op=special_days&tab_calendar=special_days&id_calendar='.$tmp->id
); );
$name .= '">'; $name .= '">';
$name .= $tmp->name; $name .= $tmp->name;
@ -636,6 +638,7 @@ class CalendarManager
// Options. View. // Options. View.
$tmp->options = ''; $tmp->options = '';
if ((bool) $manage === true) { if ((bool) $manage === true) {
if ($is_management_allowed === true) {
// Options. Edit. // Options. Edit.
$tmp->options .= '<a href="'; $tmp->options .= '<a href="';
$tmp->options .= ui_get_full_url( $tmp->options .= ui_get_full_url(
@ -651,11 +654,12 @@ class CalendarManager
] ]
); );
$tmp->options .= '</a>'; $tmp->options .= '</a>';
}
// Options. Especial days. // Options. Especial days.
$tmp->options .= '<a href="'; $tmp->options .= '<a href="';
$tmp->options .= ui_get_full_url( $tmp->options .= ui_get_full_url(
$this->url.'&op=special_days&tab=special_days&id_calendar='.$tmp->id $this->url.'&op=special_days&tab_calendar=special_days&id_calendar='.$tmp->id
); );
$tmp->options .= '">'; $tmp->options .= '">';
$tmp->options .= html_print_image( $tmp->options .= html_print_image(
@ -668,7 +672,7 @@ class CalendarManager
); );
$tmp->options .= '</a>'; $tmp->options .= '</a>';
if ($tmp->id != 1) { if ($is_management_allowed === true && $tmp->id != 1) {
// Options. Delete. // Options. Delete.
$tmp->options .= '<a href="'; $tmp->options .= '<a href="';
$tmp->options .= ui_get_full_url( $tmp->options .= ui_get_full_url(
@ -787,7 +791,7 @@ class CalendarManager
'calendar/special_days', 'calendar/special_days',
[ [
'ajax_url' => $this->ajaxUrl, 'ajax_url' => $this->ajaxUrl,
'url' => $this->url.'&tab=special_days', 'url' => $this->url.'&tab_calendar=special_days',
'tabs' => $this->getTabs('special_days'), 'tabs' => $this->getTabs('special_days'),
'message' => $this->message, 'message' => $this->message,
'specialDays' => $specialDays, 'specialDays' => $specialDays,
@ -912,7 +916,7 @@ class CalendarManager
'calendar/special_days_edit', 'calendar/special_days_edit',
[ [
'ajax_url' => $this->ajaxUrl, 'ajax_url' => $this->ajaxUrl,
'url' => $this->url.'&id_calendar='.$specialDay->id_calendar().'&op=edit&tab=special_days', 'url' => $this->url.'&id_calendar='.$specialDay->id_calendar().'&op=edit&tab_calendar=special_days',
'tabs' => $this->getTabs('special_days'), 'tabs' => $this->getTabs('special_days'),
'specialDay' => $specialDay, 'specialDay' => $specialDay,
'message' => $this->message, 'message' => $this->message,

View File

@ -318,3 +318,28 @@ div#rules.show {
align-items: center; align-items: center;
margin-right: 80px; margin-right: 80px;
} }
.note-special-day {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
align-content: center;
}
.note-special-day div {
display: flex;
flex-direction: row;
align-items: center;
align-content: center;
}
.note-special-day div a.tip {
margin: 0px;
margin-right: 2px;
}
.note-special-day div a.tip > img {
margin: 0px;
}

View File

@ -8309,31 +8309,6 @@ div.stat-win-spinner img {
min-width: 50px; min-width: 50px;
} }
.note-special-day {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
align-content: center;
}
.note-special-day div {
display: flex;
flex-direction: row;
align-items: center;
align-content: center;
}
.note-special-day div a.tip {
margin: 0px;
margin-right: 2px;
}
.note-special-day div a.tip > img {
margin: 0px;
}
.lign_right { .lign_right {
text-align: right; text-align: right;
} }

View File

@ -27,10 +27,15 @@
*/ */
// Extras required. // Extras required.
ui_require_css_file('wizard'); \ui_require_css_file('wizard');
\enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
// Header. if (\is_metaconsole() === true) {
\ui_print_page_header( \alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title. // Title.
__('Calendars Edit'), __('Calendars Edit'),
// Icon. // Icon.
@ -43,7 +48,26 @@ ui_require_css_file('wizard');
true, true,
// Options. // Options.
$tabs $tabs
); );
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) { if (empty($message) === false) {
echo $message; echo $message;
@ -88,15 +112,17 @@ $inputs[] = [
]; ];
// Submit. if ($is_management_allowed === true) {
$inputs[] = [ // Submit.
$inputs[] = [
'arguments' => [ 'arguments' => [
'name' => 'button', 'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')), 'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit', 'type' => 'submit',
'attributes' => 'class="sub next"', 'attributes' => 'class="sub next"',
], ],
]; ];
}
// Print form. // Print form.
HTML::printForm( HTML::printForm(
@ -110,3 +136,5 @@ HTML::printForm(
false, false,
true true
); );
\enterprise_hook('close_meta_frame');

View File

@ -26,8 +26,15 @@
* ============================================================================ * ============================================================================
*/ */
// Header. \ui_require_css_file('wizard');
\ui_print_page_header( \enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title. // Title.
__('Calendars'), __('Calendars'),
// Icon. // Icon.
@ -40,7 +47,26 @@
true, true,
// Options. // Options.
$tabs $tabs
); );
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) { if (empty($message) === false) {
echo $message; echo $message;
@ -124,3 +150,5 @@ if ((bool) check_acl($config['id_user'], 0, 'LM') === true) {
] ]
); );
} }
\enterprise_hook('close_meta_frame');

View File

@ -28,8 +28,15 @@
global $config; global $config;
// Header. \ui_require_css_file('wizard');
\ui_print_page_header( \enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title. // Title.
__('Special days'), __('Special days'),
// Icon. // Icon.
@ -42,7 +49,26 @@ global $config;
true, true,
// Options. // Options.
$tabs $tabs
); );
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) { if (empty($message) === false) {
echo $message; echo $message;
@ -115,8 +141,9 @@ $inputs[] = [
], ],
]; ];
// Print form. if ($is_management_allowed === true) {
HTML::printForm( // Print form.
HTML::printForm(
[ [
'form' => [ 'form' => [
'action' => $url.'&op=upload_ical&id='.$id_calendar, 'action' => $url.'&op=upload_ical&id='.$id_calendar,
@ -127,7 +154,8 @@ HTML::printForm(
'inputs' => $inputs, 'inputs' => $inputs,
], ],
false false
); );
}
$this_year = date('Y'); $this_year = date('Y');
@ -290,6 +318,7 @@ for ($month = 1; $month <= 12; $month++) {
$cal_table->cellstyle[$cal_line][$week] .= 'font-size: 18px;'; $cal_table->cellstyle[$cal_line][$week] .= 'font-size: 18px;';
$cal_table->data[$cal_line][$week] = $day.'&nbsp;'; $cal_table->data[$cal_line][$week] = $day.'&nbsp;';
if ($is_management_allowed === true) {
$cal_table->data[$cal_line][$week] .= '<a href="'.$url.'&op=edit&date='.$date.'" title='; $cal_table->data[$cal_line][$week] .= '<a href="'.$url.'&op=edit&date='.$date.'" title=';
$cal_table->data[$cal_line][$week] .= __('Create'); $cal_table->data[$cal_line][$week] .= __('Create');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image( $cal_table->data[$cal_line][$week] .= '>'.html_print_image(
@ -297,6 +326,7 @@ for ($month = 1; $month <= 12; $month++) {
true, true,
['class' => 'invert_filter'] ['class' => 'invert_filter']
).'</a>'; ).'</a>';
}
if (empty($specialDays) === false && isset($specialDays[$display_year][$display_month][$day]) === true) { if (empty($specialDays) === false && isset($specialDays[$display_year][$display_month][$day]) === true) {
$cal_table->data[$cal_line][$week] .= '<br>'; $cal_table->data[$cal_line][$week] .= '<br>';
@ -395,6 +425,8 @@ for ($month = 1; $month <= 12; $month++) {
true, true,
['class' => 'invert_filter'] ['class' => 'invert_filter']
).'</a>'; ).'</a>';
if ($is_management_allowed === true) {
$cal_table->data[$cal_line][$week] .= '<a href="'.$url.'&op=edit&id='.$special_day['id'].'" title='; $cal_table->data[$cal_line][$week] .= '<a href="'.$url.'&op=edit&id='.$special_day['id'].'" title=';
$cal_table->data[$cal_line][$week] .= __('Edit'); $cal_table->data[$cal_line][$week] .= __('Edit');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image( $cal_table->data[$cal_line][$week] .= '>'.html_print_image(
@ -415,6 +447,7 @@ for ($month = 1; $month <= 12; $month++) {
['class' => 'invert_filter'] ['class' => 'invert_filter']
).'</a>'; ).'</a>';
} }
}
$cal_table->data[$cal_line][$week] .= '</div>'; $cal_table->data[$cal_line][$week] .= '</div>';
$cal_table->data[$cal_line][$week] .= '</div>'; $cal_table->data[$cal_line][$week] .= '</div>';
@ -457,6 +490,8 @@ if ((bool) check_acl($config['id_user'], 0, 'LM') === true) {
echo '<div id="modal-alert-templates" class="invisible"></div>'; echo '<div id="modal-alert-templates" class="invisible"></div>';
ui_require_javascript_file('pandora_alerts'); ui_require_javascript_file('pandora_alerts');
\enterprise_hook('close_meta_frame');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready (function () { $(document).ready (function () {

View File

@ -27,10 +27,15 @@
*/ */
// Extras required. // Extras required.
ui_require_css_file('wizard'); \ui_require_css_file('wizard');
\enterprise_include_once('meta/include/functions_alerts_meta.php');
\enterprise_hook('open_meta_frame');
// Header. if (\is_metaconsole() === true) {
\ui_print_page_header( \alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title. // Title.
__('Alerts').' &raquo; '.__('Configure special day'), __('Alerts').' &raquo; '.__('Configure special day'),
// Icon. // Icon.
@ -43,7 +48,26 @@ ui_require_css_file('wizard');
true, true,
// Options. // Options.
$tabs $tabs
); );
}
$is_management_allowed = \is_management_allowed();
if ($is_management_allowed === false) {
if (\is_metaconsole() === false) {
$url_link = '<a target="_blank" href="'.ui_get_meta_url($url).'">';
$url_link .= __('metaconsole');
$url_link .= '</a>';
} else {
$url_link = __('any node');
}
\ui_print_warning_message(
__(
'This node is configured with centralized mode. All alert calendar information is read only. Go to %s to manage it.',
$url_link
)
);
}
if (empty($message) === false) { if (empty($message) === false) {
echo $message; echo $message;
@ -131,15 +155,17 @@ $inputs[] = [
], ],
]; ];
// Submit. if ($is_management_allowed === true) {
$inputs[] = [ // Submit.
$inputs[] = [
'arguments' => [ 'arguments' => [
'name' => 'button', 'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')), 'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit', 'type' => 'submit',
'attributes' => 'class="sub next"', 'attributes' => 'class="sub next"',
], ],
]; ];
}
// Print form. // Print form.
HTML::printForm( HTML::printForm(
@ -159,6 +185,8 @@ echo '<div id="modal-alert-templates" class="invisible"></div>';
ui_require_javascript_file('calendar'); ui_require_javascript_file('calendar');
ui_require_javascript_file('pandora_alerts'); ui_require_javascript_file('pandora_alerts');
\enterprise_hook('close_meta_frame');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready (function () { $(document).ready (function () {