MaintenanceAdvisor.pm
2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# --
# 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 = '<span style="font-weight: bold">%s</span> <span style="margin-right: 50px;">(' . $LanguageObject->Translate('since') . ' %s)</span>';
my $msg = $Self->GetStatus();
return $Kernel::OM->Get("Kernel::Output::HTML::Layout")->Notify(
Priority => 'Warning',
Link => '',
Data => "<div style=\"overflow:hidden\" id=\"maintenanceList\">$msg</div>",
);
}
sub GetStatus {
my ( $Self, %Param ) = @_;
my $DateUtilsObject = $Kernel::OM->Get("Kernel::System::DateUtils");
my $LanguageObject = $Kernel::OM->Get("Kernel::Language");
my $TEMPLATE = '<span style="float: left; margin-bottom: 10px; margin-right: 50px;">%s<br/>(' . $LanguageObject->Translate('since') . ' %s)</span> ';
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 = "<b>" . $LanguageObject->Translate("Maintenances in progress:") . "</b> <br><br>" . $msg;
}
return $msg;
}
1;