# -- # Kernel/Output/HTML/MaintenanceAdvisor.pm - show maintenances in progress # # Copyright (C) 2014-2018 - SeTIC - UFSC - http://setic.ufsc.br/ # Version 2015-08-01 - Adjustments for OTRS 4 # Version 2018-01-05 - Adjustments for OTRS 6 # # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see # the enclosed file COPYING for license information (AGPL). If you # did not receive this file, see http://www.gnu.org/licenses/agpl.txt. # -- package Kernel::Output::HTML::MaintenanceAdvisor; use strict; use warnings; our @ObjectDependencies = ( "Kernel::System::Maintenance", "Kernel::System::DateUtils", "Kernel::System::DB", "Kernel::Output::HTML::Layout", "Kernel::System::Log", "Kernel::Config" ); sub new { my ( $Type, %Param ) = @_; # allocate new hash for object my $Self = {}; bless( $Self, $Type ); return $Self; } sub Run { my ( $Self, %Param ) = @_; my $LanguageObject = $Kernel::OM->Get("Kernel::Language"); my $TEMPLATE = '%s (' . $LanguageObject->Translate('since') . ' %s)'; my $msg = $Self->GetStatus(); return $Kernel::OM->Get("Kernel::Output::HTML::Layout")->Notify( Priority => 'Warning', Link => '', Data => "
$msg
", ); } sub GetStatus { my ( $Self, %Param ) = @_; my $DateUtilsObject = $Kernel::OM->Get("Kernel::System::DateUtils"); my $LanguageObject = $Kernel::OM->Get("Kernel::Language"); my $TEMPLATE = '%s
(' . $LanguageObject->Translate('since') . ' %s)
'; my @maintenances = $Kernel::OM->Get("Kernel::System::Maintenance")->ListMaintenances(Type => "current"); my $msg = ""; for my $maintenance ( @maintenances ) { $msg .= sprintf( $TEMPLATE, $maintenance->{"Description"}, $DateUtilsObject->BrazilianDate(Timestamp => $DateUtilsObject->FromSQL(StringDate => $maintenance->{"StartDate"})) ); } if ( !$msg eq "" ) { $msg = "" . $LanguageObject->Translate("Maintenances in progress:") . "

" . $msg; } return $msg; } 1;