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

View File

@ -318,3 +318,28 @@ div#rules.show {
align-items: center;
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;
}
.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 {
text-align: right;
}

View File

@ -27,23 +27,47 @@
*/
// 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.
\ui_print_page_header(
// Title.
__('Calendars Edit'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title.
__('Calendars Edit'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$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) {
echo $message;
@ -88,15 +112,17 @@ $inputs[] = [
];
// Submit.
$inputs[] = [
'arguments' => [
'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
];
if ($is_management_allowed === true) {
// Submit.
$inputs[] = [
'arguments' => [
'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
];
}
// Print form.
HTML::printForm(
@ -110,3 +136,5 @@ HTML::printForm(
false,
true
);
\enterprise_hook('close_meta_frame');

View File

@ -26,21 +26,47 @@
* ============================================================================
*/
// Header.
\ui_print_page_header(
// Title.
__('Calendars'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
\ui_require_css_file('wizard');
\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.
__('Calendars'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$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) {
echo $message;
@ -124,3 +150,5 @@ if ((bool) check_acl($config['id_user'], 0, 'LM') === true) {
]
);
}
\enterprise_hook('close_meta_frame');

View File

@ -28,21 +28,47 @@
global $config;
// Header.
\ui_print_page_header(
// Title.
__('Special days'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
\ui_require_css_file('wizard');
\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.
__('Special days'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$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) {
echo $message;
@ -115,19 +141,21 @@ $inputs[] = [
],
];
// Print form.
HTML::printForm(
[
'form' => [
'action' => $url.'&op=upload_ical&id='.$id_calendar,
'method' => 'POST',
'id' => 'icalendar-special-days',
'enctype' => 'multipart/form-data',
if ($is_management_allowed === true) {
// Print form.
HTML::printForm(
[
'form' => [
'action' => $url.'&op=upload_ical&id='.$id_calendar,
'method' => 'POST',
'id' => 'icalendar-special-days',
'enctype' => 'multipart/form-data',
],
'inputs' => $inputs,
],
'inputs' => $inputs,
],
false
);
false
);
}
$this_year = date('Y');
@ -290,13 +318,15 @@ for ($month = 1; $month <= 12; $month++) {
$cal_table->cellstyle[$cal_line][$week] .= 'font-size: 18px;';
$cal_table->data[$cal_line][$week] = $day.'&nbsp;';
$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] .= '>'.html_print_image(
'images/add_mc.png',
true,
['class' => 'invert_filter']
).'</a>';
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] .= __('Create');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/add_mc.png',
true,
['class' => 'invert_filter']
).'</a>';
}
if (empty($specialDays) === false && isset($specialDays[$display_year][$display_month][$day]) === true) {
$cal_table->data[$cal_line][$week] .= '<br>';
@ -395,25 +425,28 @@ for ($month = 1; $month <= 12; $month++) {
true,
['class' => 'invert_filter']
).'</a>';
$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] .= '>'.html_print_image(
'images/config.png',
true,
['class' => 'invert_filter']
).'</a> &nbsp;';
$url_delete = $url.'&op=delete&id='.$special_day['id'];
$script_delete = 'if (!confirm(\''.__('Are you sure?').'\')) return false;';
$cal_table->data[$cal_line][$week] .= '<a href="'.$url_delete.'"';
$cal_table->data[$cal_line][$week] .= ' onClick="'.$script_delete.'"';
$cal_table->data[$cal_line][$week] .= 'title="';
$cal_table->data[$cal_line][$week] .= __('Remove');
$cal_table->data[$cal_line][$week] .= '">';
$cal_table->data[$cal_line][$week] .= html_print_image(
'images/cross.png',
true,
['class' => 'invert_filter']
).'</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] .= __('Edit');
$cal_table->data[$cal_line][$week] .= '>'.html_print_image(
'images/config.png',
true,
['class' => 'invert_filter']
).'</a> &nbsp;';
$url_delete = $url.'&op=delete&id='.$special_day['id'];
$script_delete = 'if (!confirm(\''.__('Are you sure?').'\')) return false;';
$cal_table->data[$cal_line][$week] .= '<a href="'.$url_delete.'"';
$cal_table->data[$cal_line][$week] .= ' onClick="'.$script_delete.'"';
$cal_table->data[$cal_line][$week] .= 'title="';
$cal_table->data[$cal_line][$week] .= __('Remove');
$cal_table->data[$cal_line][$week] .= '">';
$cal_table->data[$cal_line][$week] .= html_print_image(
'images/cross.png',
true,
['class' => 'invert_filter']
).'</a>';
}
}
$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>';
ui_require_javascript_file('pandora_alerts');
\enterprise_hook('close_meta_frame');
?>
<script type="text/javascript">
$(document).ready (function () {

View File

@ -27,23 +27,47 @@
*/
// 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.
\ui_print_page_header(
// Title.
__('Alerts').' &raquo; '.__('Configure special day'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$tabs
);
if (\is_metaconsole() === true) {
\alerts_meta_print_header($tabs);
} else {
// Header.
\ui_print_page_header(
// Title.
__('Alerts').' &raquo; '.__('Configure special day'),
// Icon.
'images/gm_alerts.png',
// Return.
false,
// Help.
'alert_special_days',
// Godmode.
true,
// Options.
$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) {
echo $message;
@ -131,15 +155,17 @@ $inputs[] = [
],
];
// Submit.
$inputs[] = [
'arguments' => [
'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
];
if ($is_management_allowed === true) {
// Submit.
$inputs[] = [
'arguments' => [
'name' => 'button',
'label' => (($create === true) ? __('Create') : __('Update')),
'type' => 'submit',
'attributes' => 'class="sub next"',
],
];
}
// Print form.
HTML::printForm(
@ -159,6 +185,8 @@ echo '<div id="modal-alert-templates" class="invisible"></div>';
ui_require_javascript_file('calendar');
ui_require_javascript_file('pandora_alerts');
\enterprise_hook('close_meta_frame');
?>
<script type="text/javascript">
$(document).ready (function () {