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 110
|
# --
# Copyright (C) 2001-2021 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::ToolBar::TicketService;
use Kernel::Language qw(Translatable);
use parent 'Kernel::Output::HTML::Base';
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 Run {
my ( $Self, %Param ) = @_;
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.
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
return if !$ConfigObject->Get('Ticket::Service');
return if !$ConfigObject->Get('Frontend::Module')->{AgentTicketService};
# Get viewable locks.
my @ViewableLockIDs = $Kernel::OM->Get('Kernel::System::Lock')->LockViewableLock( Type => 'ID' );
# Get 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;
if ( !@ViewableQueueIDs ) {
@ViewableQueueIDs = (999_999);
}
# Get 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 config setting 'ViewAllPossibleTickets' for AgentTicketService and set permissions
# accordingly.
my $Config = $ConfigObject->Get('Ticket::Frontend::AgentTicketService');
my $Permission = 'rw';
if ( $Config->{ViewAllPossibleTickets} ) {
$Permission = 'ro';
}
# 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 => $Permission,
) || 0;
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;
|