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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
# --
# Copyright (C) 2001-2017 OTRS AG, http://otrs.com/
# --
# 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::TicketService;
use Kernel::Language qw(Translatable);
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::Log',
'Kernel::Config',
'Kernel::System::Lock',
'Kernel::System::State',
'Kernel::System::Queue',
'Kernel::System::Service',
'Kernel::System::Ticket',
'Kernel::Output::HTML::Layout',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# get UserID param
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Config} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need Config!',
);
return;
}
# do nothing if Ticket Service feature is not enabled
return if !$Kernel::OM->Get('Kernel::Config')->Get('Ticket::Service');
# viewable locks
my @ViewableLockIDs = $Kernel::OM->Get('Kernel::System::Lock')->LockViewableLock( Type => 'ID' );
# viewable states
my @ViewableStateIDs = $Kernel::OM->Get('Kernel::System::State')->StateGetStatesByType(
Type => 'Viewable',
Result => 'ID',
);
# get all queues the agent is allowed to see
my %ViewableQueues = $Kernel::OM->Get('Kernel::System::Queue')->GetAllQueues(
UserID => $Self->{UserID},
Type => 'ro',
);
my @ViewableQueueIDs = sort keys %ViewableQueues;
# get the custom services
# set the service ids to an array of non existing service ids (0)
my @MyServiceIDs = $Kernel::OM->Get('Kernel::System::Service')->GetAllCustomServices( UserID => $Self->{UserID} );
if ( !defined $MyServiceIDs[0] ) {
@MyServiceIDs = (0);
}
# get number of tickets in MyServices (which are not locked)
my $Count = $Kernel::OM->Get('Kernel::System::Ticket')->TicketSearch(
Result => 'COUNT',
QueueIDs => \@ViewableQueueIDs,
ServiceIDs => \@MyServiceIDs,
StateIDs => \@ViewableStateIDs,
LockIDs => \@ViewableLockIDs,
UserID => $Self->{UserID},
Permission => 'ro',
);
my $Class = $Param{Config}->{CssClass};
my $Icon = $Param{Config}->{Icon};
my $URL = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{Baselink};
my %Return;
my $Priority = $Param{Config}->{Priority};
if ($Count) {
$Return{ $Priority++ } = {
Block => 'ToolBarItem',
Description => Translatable('Tickets in My Services'),
Count => $Count,
Class => $Class,
Icon => $Icon,
Link => $URL . 'Action=AgentTicketService',
AccessKey => '',
};
}
return %Return;
}
1;
|