Why is it useful? If you're using time_units to collect your billable time, it may be of interest to show if you're on track for the billable time for the day.
How to install:
(Version 5)
1) You need Kernel/Output/HTML/ToolBar/myToolBarTicketHours.pm :
Code: Select all
# --
# Kernel/Output/HTML/myToolBarTicketHours.pm
# --
# 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::ToolBar::myToolBarTicketHours;
use strict;
use warnings;
use Kernel::Language qw(Translatable);
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::System::Ticket',
'Kernel::System::DB',
'Kernel::Output::HTML::Layout',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get needed objects
# for (qw(ConfigObject LogObject DBObject TicketObject LayoutObject UserID)) {
# $Self->{$_} = $Param{$_} || die "Got no $_!";
# }
# get UserID param
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(Config)) {
if (!$Param{$_} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $_!"
);
return;
}
}
# get ticket object
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
my $Class = $Param{Config}->{CssClass};
my $ClassNew = $Param{Config}->{CssClassNew};
my $ClassReached = $Param{Config}->{CssClassReached};
my $Icon = $Param{Config}->{Icon};
my $IconNew = $Param{Config}->{IconNew};
my $IconReached = $Param{Config}->{IconReached};
my $URL = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{Baselink};
my %Return;
my $Priority = $Param{Config}->{Priority};
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
# db query
return if !$DBObject->Prepare(
SQL => 'SELECT sum(time_unit) FROM time_accounting WHERE DATE(create_time) = CURDATE() AND create_by = ?',
Bind => [ \$Self->{UserID} ],
);
my $Hours = 0;
while ( my @Row = $DBObject->FetchrowArray() ) {
$Row[0] =~ s/,/./g;
$Hours = $Hours + $Row[0];
}
$Return{ $Priority } = {
Block => 'ToolBarItem',
Count => $Hours,
Class => $Class,
Description => Translatable('Todays billable hours'),
Icon => $Icon,
};
return %Return;
}
1;
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
<ConfigItem Name="Frontend::ToolBarModule###99-Ticket::TicketHours" Required="0" Valid="1">
<Description Translatable="1">Agent interface notification module to see the number of
hours an Agent has billed today.</Description>
<Group>Ticket</Group>
<SubGroup>Frontend::Agent::ToolBarModule</SubGroup>
<Setting>
<Hash>
<Item Key="Module">Kernel::Output::HTML::ToolBar::myToolBarTicketHours</Item>
<Item Key="CssClass">Hours</Item>
<Item Key="Icon">fa fa-dollar</Item>
<Item Key="AccessKey">q</Item>
<Item Key="Priority">1030090</Item>
</Hash>
</Setting>
</ConfigItem>
</otrs_config>