MaintenanceAdvisor.pm
2.02 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
# --
# Kernel/Output/HTML/MaintenanceAdvisor.pm - show maintenances in progress
#
# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
# Version 01/08/2015 - Adjustments for OTRS 4
#
# --
# 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", # OLD Layout object
"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 $TEMPLATE = '<span style="font-weight: bold">%s</span> <span style="margin-right: 50px;">(desde %s)</span>';
my %maintenances = $Kernel::OM->Get("Kernel::System::Maintenance")->ListCurrentMaintenances();
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 $TEMPLATE = '<span style="float: left; margin-bottom: 10px; margin-right: 50px;">%s<br/>(desde %s)</span> ';
my @maintenances = $Kernel::OM->Get("Kernel::System::Maintenance")->ListCurrentMaintenances();
my $msg = "";
for my $maintenance ( @maintenances ) {
$msg .= sprintf( $TEMPLATE, $maintenance->{"Description"}, $DateUtilsObject->BrazilianDate(Timestamp => $DateUtilsObject->FromSQL(StringDate => $maintenance->{"StartDate"})) );
}
if ( !$msg eq "" ) {
$msg = "<b>" . $Kernel::OM->Get("Kernel::Output::HTML::Layout")->{LanguageObject}->Translate("Maintenances in progress:") . "</b> <br><br>" . $msg;
}
return $msg;
}
1;