alert template schedule pandora_enterprise#3943
This commit is contained in:
parent
9ad6b8abaa
commit
c02abbc508
|
@ -2,4 +2,10 @@ START TRANSACTION;
|
|||
ALTER TABLE `tpolicy_queue` MODIFY COLUMN `progress` int(10) NOT NULL default '0';
|
||||
CREATE INDEX `IDX_tservice_element` ON `tservice_element`(`id_service`,`id_agente_modulo`);
|
||||
|
||||
ALTER TABLE `talert_templates` ADD COLUMN `schedule` TEXT DEFAULT NULL;
|
||||
|
||||
SOURCE procedures/alertTemplates.sql;
|
||||
CALL `migrateRanges`();
|
||||
DROP PROCEDURE `migrateRanges`;
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
CREATE PROCEDURE migrateRanges()
|
||||
BEGIN
|
||||
DECLARE done INT DEFAULT FALSE;
|
||||
DECLARE i INT;
|
||||
DECLARE r TEXT;
|
||||
DECLARE cur1 CURSOR FOR SELECT `id` FROM `talert_templates`;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
|
||||
UPDATE `talert_templates` SET `schedule` = '{"monday":_1_,"tuesday":_2_,"wednesday":_3_,"thursday":_4_,"friday":_5_,"saturday":_6_,"sunday":_7_}';
|
||||
UPDATE `talert_templates` SET `time_from` = "00:00:00", `time_to` = "00:00:00" WHERE `time_from` = `time_to`;
|
||||
|
||||
OPEN cur1;
|
||||
read_loop: LOOP
|
||||
FETCH cur1 INTO i;
|
||||
|
||||
IF done THEN
|
||||
LEAVE read_loop;
|
||||
END IF;
|
||||
|
||||
SELECT concat('[{"start":"', `time_from`, '","end":"', `time_to`, '"}]') into r FROM `talert_templates` WHERE `id` = i;
|
||||
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_1_", r) WHERE `monday` > 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_2_", r) WHERE `tuesday` > 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_3_", r) WHERE `wednesday` > 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_4_", r) WHERE `thursday` > 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_5_", r) WHERE `friday` > 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_6_", r) WHERE `saturday` > 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_7_", r) WHERE `sunday` > 0 AND `id` = i;
|
||||
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_1_", '""') WHERE `monday` = 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_2_", '""') WHERE `tuesday` = 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_3_", '""') WHERE `wednesday` = 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_4_", '""') WHERE `thursday` = 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_5_", '""') WHERE `friday` = 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_6_", '""') WHERE `saturday` = 0 AND `id` = i;
|
||||
UPDATE `talert_templates` SET `schedule` = REPLACE(`schedule`, "_7_", '""') WHERE `sunday` = 0 AND `id` = i;
|
||||
END LOOP;
|
||||
CLOSE cur1;
|
||||
END ;
|
|
@ -62,7 +62,7 @@ if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
|
|||
}
|
||||
|
||||
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 (defined('METACONSOLE')) {
|
||||
alerts_meta_print_header();
|
||||
|
@ -84,7 +84,7 @@ if ($a_template !== false) {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
// If user tries to duplicate/edit a template of others groups
|
||||
// If user tries to duplicate/edit a template of others groups.
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
||||
$own_groups = array_keys(users_get_groups($config['id_user'], 'LM'));
|
||||
|
@ -93,9 +93,9 @@ if ($a_template !== false) {
|
|||
}
|
||||
|
||||
$is_in_group = in_array($a_template['id_group'], $own_groups);
|
||||
// Then template group have to be in his own groups
|
||||
// Then template group have to be in his own groups.
|
||||
if ($is_in_group) {
|
||||
// Header
|
||||
// Header.
|
||||
if (defined('METACONSOLE')) {
|
||||
alerts_meta_print_header();
|
||||
} else {
|
||||
|
@ -117,9 +117,9 @@ 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 {
|
||||
// Header
|
||||
// Header.
|
||||
if (defined('METACONSOLE')) {
|
||||
alerts_meta_print_header();
|
||||
} else {
|
||||
|
@ -145,8 +145,10 @@ if ($a_template !== false) {
|
|||
if ($duplicate_template) {
|
||||
$source_id = (int) get_parameter('source_id');
|
||||
|
||||
// If user doesn't have the permission to access All group and source template is All group, then group is changed to the first group of user.
|
||||
if ($can_edit_all == false && a_template['id_group'] == 0) {
|
||||
// If user doesn't have the permission to access
|
||||
// All group and source template is All group,
|
||||
// then group is changed to the first group of user.
|
||||
if ($can_edit_all == false && $a_template['id_group'] == 0) {
|
||||
$a_template['id_group'] = users_get_first_group(false, 'LM', false);
|
||||
}
|
||||
|
||||
|
@ -178,7 +180,7 @@ function print_alert_template_steps($step, $id)
|
|||
|
||||
$pure = get_parameter('pure', 0);
|
||||
|
||||
// Step 1
|
||||
// Step 1.
|
||||
if ($step == 1) {
|
||||
echo '<li class="first current">';
|
||||
} else if ($step > 1) {
|
||||
|
@ -199,7 +201,7 @@ function print_alert_template_steps($step, $id)
|
|||
|
||||
echo '</li>';
|
||||
|
||||
// Step 2
|
||||
// Step 2.
|
||||
if ($step == 2) {
|
||||
echo '<li class="current">';
|
||||
} else if ($step > 2) {
|
||||
|
@ -220,7 +222,7 @@ function print_alert_template_steps($step, $id)
|
|||
|
||||
echo '</li>';
|
||||
|
||||
// Step 3
|
||||
// Step 3.
|
||||
if ($step == 3) {
|
||||
echo '<li class="last current">';
|
||||
} else if ($step > 3) {
|
||||
|
@ -284,21 +286,7 @@ function update_template($step)
|
|||
|
||||
$result = alerts_update_alert_template($id, $values);
|
||||
} else if ($step == 2) {
|
||||
// TODO: Days.
|
||||
$monday = (bool) get_parameter('monday');
|
||||
$tuesday = (bool) get_parameter('tuesday');
|
||||
$wednesday = (bool) get_parameter('wednesday');
|
||||
$thursday = (bool) get_parameter('thursday');
|
||||
$friday = (bool) get_parameter('friday');
|
||||
$saturday = (bool) get_parameter('saturday');
|
||||
$sunday = (bool) get_parameter('sunday');
|
||||
$time_from = (string) get_parameter('time_from');
|
||||
$time_from = date('H:i:00', strtotime($time_from));
|
||||
$time_to = (string) get_parameter('time_to');
|
||||
$time_to = date('H:i:00', strtotime($time_to));
|
||||
|
||||
$schedule = get_parameter('schedule');
|
||||
|
||||
$special_day = (int) get_parameter('special_day');
|
||||
$threshold = (int) get_parameter('threshold');
|
||||
$max_alerts = (int) get_parameter('max_alerts');
|
||||
|
@ -312,22 +300,11 @@ function update_template($step)
|
|||
$matches = (bool) get_parameter('matches_value');
|
||||
|
||||
$default_action = (int) get_parameter('default_action');
|
||||
if (empty($default_action)) {
|
||||
if (empty($default_action) === true) {
|
||||
$default_action = null;
|
||||
}
|
||||
|
||||
hd($schedule);
|
||||
|
||||
$values = [
|
||||
// 'monday' => $monday,
|
||||
// 'tuesday' => $tuesday,
|
||||
// 'wednesday' => $wednesday,
|
||||
// 'thursday' => $thursday,
|
||||
// 'friday' => $friday,
|
||||
// 'saturday' => $saturday,
|
||||
// 'sunday' => $sunday,
|
||||
// 'time_from' => $time_from,
|
||||
// 'time_to' => $time_to,
|
||||
'schedule' => json_encode(
|
||||
json_decode(
|
||||
io_safe_output($schedule),
|
||||
|
@ -364,9 +341,21 @@ function update_template($step)
|
|||
}
|
||||
|
||||
if ($result) {
|
||||
db_pandora_audit('Template alert management', 'Update alert template #'.$id, false, false, json_encode($values));
|
||||
db_pandora_audit(
|
||||
'Template alert management',
|
||||
'Update alert template #'.$id,
|
||||
false,
|
||||
false,
|
||||
json_encode($values)
|
||||
);
|
||||
} else {
|
||||
db_pandora_audit('Template alert management', 'Fail try to update alert template #'.$id, false, false, json_encode($values));
|
||||
db_pandora_audit(
|
||||
'Template alert management',
|
||||
'Fail try to update alert template #'.$id,
|
||||
false,
|
||||
false,
|
||||
json_encode($values)
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -412,16 +401,6 @@ $type = '';
|
|||
$value = '';
|
||||
$max = '';
|
||||
$min = '';
|
||||
// TODO: Remove.
|
||||
$time_from = '12:00:00';
|
||||
$time_to = '12:00:00';
|
||||
$monday = true;
|
||||
$tuesday = true;
|
||||
$wednesday = true;
|
||||
$thursday = true;
|
||||
$friday = true;
|
||||
$saturday = true;
|
||||
$sunday = true;
|
||||
|
||||
$schedule = null;
|
||||
$special_day = 0;
|
||||
|
@ -458,17 +437,7 @@ if ($create_template) {
|
|||
$priority = (int) get_parameter('priority');
|
||||
$wizard_level = (string) get_parameter('wizard_level');
|
||||
$id_group = get_parameter('id_group');
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
$name_check = db_get_value('name', 'talert_templates', 'name', $name);
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$name_check = db_get_value('name', 'talert_templates', 'to_char(name)', $name);
|
||||
break;
|
||||
}
|
||||
|
||||
$name_check = db_get_value('name', 'talert_templates', 'name', $name);
|
||||
|
||||
$values = [
|
||||
'description' => $description,
|
||||
|
@ -510,8 +479,7 @@ if ($create_template) {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
// Show errors
|
||||
// Show errors.
|
||||
if (!isset($messageAction)) {
|
||||
$messageAction = __('Could not be created');
|
||||
}
|
||||
|
@ -527,9 +495,9 @@ if ($create_template) {
|
|||
);
|
||||
|
||||
|
||||
// Go to previous step in case of error
|
||||
// Go to previous step in case of error.
|
||||
if ($result === false) {
|
||||
$step = ($step - 1);
|
||||
$step--;
|
||||
} else {
|
||||
$id = $result;
|
||||
}
|
||||
|
@ -543,9 +511,9 @@ if ($update_template) {
|
|||
__('Successfully updated'),
|
||||
__('Could not be updated')
|
||||
);
|
||||
// Go to previous step in case of error
|
||||
// Go to previous step in case of error.
|
||||
if ($result === false) {
|
||||
$step = ($step - 1);
|
||||
$step--;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,17 +527,6 @@ if ($id && ! $create_template) {
|
|||
$min = $template['min_value'];
|
||||
$matches = $template['matches_value'];
|
||||
|
||||
// TODO: Remove.
|
||||
$time_from = $template['time_from'];
|
||||
$time_to = $template['time_to'];
|
||||
$monday = (bool) $template['monday'];
|
||||
$tuesday = (bool) $template['tuesday'];
|
||||
$wednesday = (bool) $template['wednesday'];
|
||||
$thursday = (bool) $template['thursday'];
|
||||
$friday = (bool) $template['friday'];
|
||||
$saturday = (bool) $template['saturday'];
|
||||
$sunday = (bool) $template['sunday'];
|
||||
|
||||
$schedule = $template['schedule'];
|
||||
$special_day = (int) $template['special_day'];
|
||||
$max_alerts = $template['max_alerts'];
|
||||
|
@ -658,7 +615,15 @@ if ($step == 2) {
|
|||
$table->colspan = [];
|
||||
$table->data[1][0] = __('Schedule');
|
||||
$table->colspan[1][1] = 3;
|
||||
$table->data[1][1] = '<div id="calendar_map"></div>';
|
||||
$table->data[1][1] = ui_print_warning_message(
|
||||
[
|
||||
'message' => __('Not selected any day'),
|
||||
'force_style' => 'display:none;',
|
||||
],
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table->data[1][1] .= '<div id="calendar_map"></div>';
|
||||
$table->data[1][1] .= html_print_input_hidden('schedule', $schedule, true);
|
||||
|
||||
$table->colspan['threshold'][1] = 3;
|
||||
|
@ -711,7 +676,7 @@ if ($step == 2) {
|
|||
(!$is_management_allowed | $disabled),
|
||||
'',
|
||||
false,
|
||||
$create_template == 1 ? 'checked=checked' : ''
|
||||
($create_template == 1) ? 'checked=checked' : ''
|
||||
);
|
||||
|
||||
$table->data[5][0] = __('Max. number of alerts');
|
||||
|
@ -793,7 +758,7 @@ if ($step == 2) {
|
|||
'',
|
||||
(!$is_management_allowed | $disabled)
|
||||
);
|
||||
$table->data[7][1] .= '<span id="matches_value" '.($show_matches ? '' : 'class="invisible"').'>';
|
||||
$table->data[7][1] .= '<span id="matches_value" '.(($show_matches) ? '' : 'class="invisible"').'>';
|
||||
$table->data[7][1] .= ' '.html_print_checkbox('matches_value', 1, $matches, true);
|
||||
$table->data[7][1] .= html_print_label(
|
||||
__('Trigger when matches the value'),
|
||||
|
@ -868,8 +833,6 @@ if ($step == 2) {
|
|||
);
|
||||
$table->colspan['example'][1] = 4;
|
||||
} else if ($step == 3) {
|
||||
hd($_POST);
|
||||
|
||||
$table->style[0] = 'font-weight: bold; vertical-align: middle';
|
||||
$table->style[1] = 'font-weight: bold; vertical-align: top';
|
||||
$table->style[2] = 'font-weight: bold; vertical-align: top';
|
||||
|
@ -1035,6 +998,10 @@ if ($step == 2) {
|
|||
case 'onchange':
|
||||
$show_matches = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Not possible.
|
||||
break;
|
||||
}
|
||||
|
||||
$table->data[0][0] = __('Name');
|
||||
|
@ -1135,7 +1102,7 @@ if ($step == 2) {
|
|||
echo ui_get_using_system_timezone_warning();
|
||||
}
|
||||
|
||||
// If it's the last step it will redirect to template lists
|
||||
// If it's the last step it will redirect to template lists.
|
||||
if ($step >= LAST_STEP) {
|
||||
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_templates&pure='.$pure.'">';
|
||||
} else {
|
||||
|
@ -1164,7 +1131,7 @@ if (!$disabled) {
|
|||
} else {
|
||||
html_print_input_hidden('step', ($step + 1));
|
||||
if ($step == 2) {
|
||||
// Javascript onsubmit to avoid min = 0 and max = 0
|
||||
// Javascript onsubmit to avoid min = 0 and max = 0.
|
||||
html_print_submit_button(
|
||||
__('Next'),
|
||||
'next',
|
||||
|
@ -1460,10 +1427,8 @@ if ($step == 2) {
|
|||
}
|
||||
});
|
||||
|
||||
//time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday
|
||||
var eventsBBDD = $("#hidden-schedule").val();
|
||||
var events = loadEventBBDD(eventsBBDD);
|
||||
|
||||
var calendarEl = document.getElementById('calendar_map');
|
||||
var settings = {
|
||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||
|
@ -1474,7 +1439,11 @@ if ($step == 2) {
|
|||
secondText: '<?php echo __('Second'); ?>',
|
||||
currentText: '<?php echo __('Now'); ?>',
|
||||
closeText: '<?php echo __('Close'); ?>',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>'
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
removeText: '<?php echo __('Remove'); ?>',
|
||||
userLanguage: '<?php echo get_user_language(); ?>',
|
||||
loadingText: '<?php echo __('Loading, this operation might take several minutes...'); ?>',
|
||||
tooltipText: '<?php echo __('Drag out to remove'); ?>',
|
||||
}
|
||||
|
||||
var calendar = fullCalendarPandora(calendarEl, settings, events);
|
||||
|
|
|
@ -576,21 +576,13 @@ if ($resize_event_week === true) {
|
|||
$table->width = '100%';
|
||||
$table->data = [];
|
||||
|
||||
$table->data[0][0] = __('Remove');
|
||||
$table->data[0][1] = html_print_checkbox_switch(
|
||||
'remove_event',
|
||||
1,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$table->data[1][0] = __('From:');
|
||||
$table->data[1][1] = html_print_input_hidden(
|
||||
$table->data[0][0] = __('From:');
|
||||
$table->data[0][1] = html_print_input_hidden(
|
||||
'day_from',
|
||||
$day_from,
|
||||
true
|
||||
);
|
||||
$table->data[1][1] .= html_print_input_text(
|
||||
$table->data[0][1] .= html_print_input_text(
|
||||
'time_from_event',
|
||||
$time_from,
|
||||
'',
|
||||
|
@ -598,13 +590,13 @@ if ($resize_event_week === true) {
|
|||
9,
|
||||
true
|
||||
);
|
||||
$table->data[2][0] = __('To:');
|
||||
$table->data[2][1] = html_print_input_hidden(
|
||||
$table->data[1][0] = __('To:');
|
||||
$table->data[1][1] = html_print_input_hidden(
|
||||
'day_to',
|
||||
$day_from,
|
||||
true
|
||||
);
|
||||
$table->data[2][1] .= html_print_input_text(
|
||||
$table->data[1][1] .= html_print_input_text(
|
||||
'time_to_event',
|
||||
($time_to === '00:00:00') ? '23:59:59' : $time_to,
|
||||
'',
|
||||
|
|
|
@ -24,7 +24,6 @@ function fullCalendarPandora(calendarEl, settings, initialEvents) {
|
|||
slotMinTime: "00:00:00",
|
||||
slotMaxTime: "24:00:00",
|
||||
scrollTime: "01:00:00",
|
||||
timeFormat: "H:mm",
|
||||
locale: "en-GB",
|
||||
//timeZone: "local",
|
||||
firstDay: 1,
|
||||
|
@ -37,6 +36,7 @@ function fullCalendarPandora(calendarEl, settings, initialEvents) {
|
|||
editable: true,
|
||||
dayMaxEvents: false,
|
||||
events: initialEvents,
|
||||
defaultAllDay: false,
|
||||
select: function(info) {
|
||||
var nextDay = info.start.getDay() === 6 ? 0 : info.start.getDay() + 1;
|
||||
if (
|
||||
|
@ -59,34 +59,40 @@ function fullCalendarPandora(calendarEl, settings, initialEvents) {
|
|||
return false;
|
||||
},
|
||||
eventAllow: function(dropInfo, draggedEvent) {
|
||||
var nextDay =
|
||||
draggedEvent.start.getDay() === 6 ? 0 : draggedEvent.start.getDay() + 1;
|
||||
if (
|
||||
(draggedEvent.start.getDay() == dropInfo.start.getDay() &&
|
||||
dropInfo.start.getDay() == dropInfo.end.getDay()) ||
|
||||
(nextDay == dropInfo.end.getDay() &&
|
||||
time_format(dropInfo.end) == "00:00:00")
|
||||
) {
|
||||
return true;
|
||||
if (dropInfo.allDay != true) {
|
||||
var nextDay =
|
||||
draggedEvent.start.getDay() === 6
|
||||
? 0
|
||||
: draggedEvent.start.getDay() + 1;
|
||||
if (
|
||||
(draggedEvent.start.getDay() == dropInfo.start.getDay() &&
|
||||
dropInfo.start.getDay() == dropInfo.end.getDay()) ||
|
||||
(nextDay == dropInfo.end.getDay() &&
|
||||
time_format(dropInfo.end) == "00:00:00")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
eventDrop: function(info) {
|
||||
var nextDay =
|
||||
info.event.start.getDay() === 6 ? 0 : info.event.start.getDay() + 1;
|
||||
if (
|
||||
info.event.start.getDay() == info.event.end.getDay() ||
|
||||
(nextDay == info.event.end.getDay() &&
|
||||
time_format(info.event.end) == "00:00:00")
|
||||
) {
|
||||
recalculate_events(
|
||||
calendar,
|
||||
info.event,
|
||||
info.event.start,
|
||||
info.event.end,
|
||||
false
|
||||
);
|
||||
save_data_input(calendar);
|
||||
if (info.event.allDay != true) {
|
||||
var nextDay =
|
||||
info.event.start.getDay() === 6 ? 0 : info.event.start.getDay() + 1;
|
||||
if (
|
||||
info.event.start.getDay() == info.event.end.getDay() ||
|
||||
(nextDay == info.event.end.getDay() &&
|
||||
time_format(info.event.end) == "00:00:00")
|
||||
) {
|
||||
recalculate_events(
|
||||
calendar,
|
||||
info.event,
|
||||
info.event.start,
|
||||
info.event.end,
|
||||
false
|
||||
);
|
||||
save_data_input(calendar);
|
||||
}
|
||||
}
|
||||
},
|
||||
eventDragStop: function(info) {
|
||||
|
@ -127,17 +133,23 @@ function fullCalendarPandora(calendarEl, settings, initialEvents) {
|
|||
save_data_input(calendar);
|
||||
}
|
||||
},
|
||||
eventMouseEnter: function(info) {
|
||||
var tooltip = '<div class="tooltipevent">';
|
||||
tooltip += settings.tooltipText;
|
||||
tooltip += "</div>";
|
||||
|
||||
$(tooltip).appendTo(info.el);
|
||||
},
|
||||
eventMouseLeave: function() {
|
||||
$(".tooltipevent").remove();
|
||||
},
|
||||
eventClick: function(info) {
|
||||
var calendar_date_from = new Date(calendar.view.activeStart);
|
||||
var calendar_date_to = new Date(calendar.view.activeEnd);
|
||||
var calendar_day_from = calendar_date_from.getDate();
|
||||
var calendar_day_to = calendar_date_to.getDate();
|
||||
|
||||
var calendar_days = [];
|
||||
var acum = 1;
|
||||
var i = 0;
|
||||
// Week date.
|
||||
for (var index = calendar_day_from; index < calendar_day_to; index++) {
|
||||
for (var index = 1; index <= 7; index++) {
|
||||
// Sunday key 0.
|
||||
if (acum === 7) {
|
||||
acum = 0;
|
||||
|
@ -154,8 +166,7 @@ function fullCalendarPandora(calendarEl, settings, initialEvents) {
|
|||
title: "Event",
|
||||
message: function() {
|
||||
var id = "div-" + uniqId();
|
||||
var loading =
|
||||
"<?php echo __('Loading, this operation might take several minutes...'); ?>";
|
||||
var loading = settings.loadingText;
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: settings.url,
|
||||
|
@ -184,7 +195,7 @@ function fullCalendarPandora(calendarEl, settings, initialEvents) {
|
|||
});
|
||||
|
||||
$.datepicker.setDefaults(
|
||||
$.datepicker.regional["<?php echo get_user_language(); ?>"]
|
||||
$.datepicker.regional[settings.userLanguage]
|
||||
);
|
||||
},
|
||||
error: function(error) {
|
||||
|
@ -195,55 +206,59 @@ function fullCalendarPandora(calendarEl, settings, initialEvents) {
|
|||
return "<div id ='" + id + "'>" + loading + "</div>";
|
||||
},
|
||||
onAccept: function() {
|
||||
var remove_event = $("#checkbox-remove_event").is(":checked");
|
||||
if (remove_event === false) {
|
||||
var replace_day_from = $("#hidden-day_from").val();
|
||||
var replace_time_from = $("#text-time_from_event").val();
|
||||
var replace_day_from = $("#hidden-day_from").val();
|
||||
var replace_time_from = $("#text-time_from_event").val();
|
||||
|
||||
var array_time_from = replace_time_from.split(":");
|
||||
var new_date_from = new Date(calendar_days[replace_day_from]);
|
||||
new_date_from.setHours(
|
||||
array_time_from[0],
|
||||
array_time_from[1],
|
||||
array_time_from[2]
|
||||
var array_time_from = replace_time_from.split(":");
|
||||
var new_date_from = new Date(calendar_days[replace_day_from]);
|
||||
new_date_from.setHours(
|
||||
array_time_from[0],
|
||||
array_time_from[1],
|
||||
array_time_from[2]
|
||||
);
|
||||
|
||||
var replace_day_to = $("#hidden-day_to").val();
|
||||
var replace_time_to = $("#text-time_to_event").val();
|
||||
if (replace_time_to === "23:59:59") {
|
||||
replace_day_to++;
|
||||
replace_time_to = "00:00:00";
|
||||
}
|
||||
|
||||
var array_time_to = replace_time_to.split(":");
|
||||
var new_date_to = new Date(calendar_days[replace_day_to]);
|
||||
new_date_to.setHours(
|
||||
array_time_to[0],
|
||||
array_time_to[1],
|
||||
array_time_to[2]
|
||||
);
|
||||
|
||||
if (new_date_from < new_date_to) {
|
||||
recalculate_events(
|
||||
calendar,
|
||||
info.event,
|
||||
new_date_from,
|
||||
new_date_to,
|
||||
false
|
||||
);
|
||||
|
||||
var replace_day_to = $("#hidden-day_to").val();
|
||||
var replace_time_to = $("#text-time_to_event").val();
|
||||
if (replace_time_to === "23:59:59") {
|
||||
replace_day_to++;
|
||||
replace_time_to = "00:00:00";
|
||||
}
|
||||
|
||||
var array_time_to = replace_time_to.split(":");
|
||||
var new_date_to = new Date(calendar_days[replace_day_to]);
|
||||
new_date_to.setHours(
|
||||
array_time_to[0],
|
||||
array_time_to[1],
|
||||
array_time_to[2]
|
||||
);
|
||||
|
||||
if (new_date_from < new_date_to) {
|
||||
recalculate_events(
|
||||
calendar,
|
||||
info.event,
|
||||
new_date_from,
|
||||
new_date_to,
|
||||
false
|
||||
);
|
||||
} else {
|
||||
console.error("You cannot add smaller events");
|
||||
}
|
||||
} else {
|
||||
// Remove event.
|
||||
info.event.remove();
|
||||
console.error("You cannot add smaller events");
|
||||
}
|
||||
save_data_input(calendar);
|
||||
},
|
||||
newButton: {
|
||||
text: settings.removeText,
|
||||
class: "",
|
||||
onFunction: function() {
|
||||
// Remove event.
|
||||
info.event.remove();
|
||||
save_data_input(calendar);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
selectOverlap: false,
|
||||
eventOverlap: false,
|
||||
selectOverlap: false
|
||||
allDaySlot: true
|
||||
});
|
||||
|
||||
return calendar;
|
||||
|
@ -338,16 +353,24 @@ function save_data_input(calendar) {
|
|||
data[day_names[event.start.getDay()]].push(obj);
|
||||
});
|
||||
|
||||
if (data && Object.keys(data).length === 0) {
|
||||
$(".warning.textodialogo").show();
|
||||
} else {
|
||||
$(".warning").hide();
|
||||
}
|
||||
|
||||
$("#hidden-schedule").val(JSON.stringify(data));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function loadEventBBDD(events) {
|
||||
console.log(events);
|
||||
if (events === null || events === "") {
|
||||
$(".warning").show();
|
||||
return {};
|
||||
}
|
||||
|
||||
$(".warning").hide();
|
||||
|
||||
var current_day = new Date();
|
||||
|
||||
var day_names = [
|
||||
|
|
|
@ -495,6 +495,53 @@ function confirmDialog(settings) {
|
|||
);
|
||||
}
|
||||
|
||||
var buttons = [
|
||||
{
|
||||
id: "cancel_btn_dialog",
|
||||
text: settings.cancelText
|
||||
? settings.cancelText
|
||||
: settings.strCancelButton,
|
||||
class:
|
||||
hideCancelButton +
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
|
||||
click: function() {
|
||||
if (typeof settings.notCloseOnDeny == "undefined") {
|
||||
$(this).dialog("close");
|
||||
$(this).remove();
|
||||
}
|
||||
if (typeof settings.onDeny == "function") settings.onDeny();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: settings.strOKButton,
|
||||
class:
|
||||
hideOkButton +
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
if (typeof settings.onAccept == "function") settings.onAccept();
|
||||
$(this).remove();
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
if (settings.newButton != undefined) {
|
||||
var newButton = {
|
||||
text: settings.newButton.text,
|
||||
class:
|
||||
settings.newButton.class +
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-warning",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
if (typeof settings.newButton.onFunction == "function")
|
||||
settings.newButton.onFunction();
|
||||
$(this).remove();
|
||||
}
|
||||
};
|
||||
|
||||
buttons.unshift(newButton);
|
||||
}
|
||||
|
||||
$("#confirm_" + randomStr);
|
||||
$("#confirm_" + randomStr)
|
||||
.dialog({
|
||||
|
@ -504,35 +551,7 @@ function confirmDialog(settings) {
|
|||
width: settings.size,
|
||||
maxHeight: settings.maxHeight,
|
||||
modal: true,
|
||||
buttons: [
|
||||
{
|
||||
id: "cancel_btn_dialog",
|
||||
text: settings.cancelText
|
||||
? settings.cancelText
|
||||
: settings.strCancelButton,
|
||||
class:
|
||||
hideCancelButton +
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
|
||||
click: function() {
|
||||
if (typeof settings.notCloseOnDeny == "undefined") {
|
||||
$(this).dialog("close");
|
||||
$(this).remove();
|
||||
}
|
||||
if (typeof settings.onDeny == "function") settings.onDeny();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: settings.strOKButton,
|
||||
class:
|
||||
hideOkButton +
|
||||
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
if (typeof settings.onAccept == "function") settings.onAccept();
|
||||
$(this).remove();
|
||||
}
|
||||
}
|
||||
]
|
||||
buttons: buttons
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
|
|
@ -8473,3 +8473,15 @@ div#err_msg_centralised {
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.tooltipevent {
|
||||
width: 70px;
|
||||
background: #fff;
|
||||
position: absolute;
|
||||
z-index: 10001;
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
border: 2px solid #82b92e;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,29 @@ input[type="button"].submit-next:hover {
|
|||
background: #82b92e;
|
||||
}
|
||||
|
||||
input[type="submit"].submit-warning,
|
||||
button.submit-warning.ui-button.ui-corner-all.ui-widget,
|
||||
input[type="button"].submit-warning {
|
||||
color: #c9d511;
|
||||
border: 1px solid #c9d511;
|
||||
background: #fff;
|
||||
padding: 5px;
|
||||
font-size: 1.3em;
|
||||
margin: 0.5em 1em 0.5em 0;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
height: 30px;
|
||||
width: auto;
|
||||
min-width: 90px;
|
||||
}
|
||||
|
||||
input[type="submit"].submit-warning:hover,
|
||||
button.submit-warning.ui-button.ui-corner-all.ui-widget:hover,
|
||||
input[type="button"].submit-warning:hover {
|
||||
color: #fff;
|
||||
background: #c9d511;
|
||||
}
|
||||
|
||||
div.submit_buttons_container {
|
||||
position: relative;
|
||||
margin: 10px auto 0px;
|
||||
|
|
|
@ -522,6 +522,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` (
|
|||
`min_alerts_reset_counter` tinyint(1) default 0,
|
||||
`disable_event` tinyint(1) default 0,
|
||||
`previous_name` text,
|
||||
`schedule` text default null,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_template_action` (`id_alert_action`),
|
||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue