Merge branch 'ent-13392-17354-errata-hora-de-alerta-de-evento-en-module-graph' into 'develop'

Ent 13392 17354 errata hora de alerta de evento en module graph

See merge request artica/pandorafms!7162
This commit is contained in:
Matias Didier 2024-04-10 13:08:53 +00:00
commit 0a6c05a686
2 changed files with 42 additions and 0 deletions

View File

@ -1126,3 +1126,29 @@ function user_print_header(int $pure=0, string $tab='user', ?string $title=null)
]
);
}
/**
* Returns the timezone of the user given or the actual one.
*
* @param mixed $id_user Id usuario (No give notingh return current user).
*
* @return string Return timezone of the user.
*/
function user_get_timezone($id_user=null)
{
global $config;
if (empty($id_user)) {
$id_user = $config['id_user'];
}
$timezone = db_get_value(
'timezone',
'tusuario',
'id_user',
$id_user
);
return $timezone;
}

View File

@ -344,6 +344,22 @@ function flot_area_graph(
// Trick to get translated string from javascript.
$return .= html_print_input_hidden('unknown_text', __('Unknown'), true);
if (isset($array_events_alerts)) {
$user_timezone = user_get_timezone();
if (isset($user_timezone) && $user_timezone !== '') {
foreach ($array_events_alerts as $key_event_alert => $event_alert) {
foreach ($event_alert as $key => $row) {
if (isset($row['timestamp']) === true) {
$timezone = new DateTimeZone($user_timezone);
$date = new DateTime();
$date->setTimestamp($row['utimestamp']);
$date->setTimezone($timezone);
$array_events_alerts[$key_event_alert][$key]['timestamp'] = $date->format('Y-m-d H:i:s');
}
}
}
}
}
$values = json_encode($array_data);