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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
# --
# 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::System::GenericAgent::NotifyAgentGroupWithWritePermission;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::DateTime',
'Kernel::System::Group',
'Kernel::System::Log',
'Kernel::System::Queue',
'Kernel::System::SLA',
'Kernel::System::Ticket',
'Kernel::System::User',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# 0=off; 1=on;
$Self->{Debug} = $Param{Debug} || 0;
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# get ticket object
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
# get ticket data
my %Ticket = $TicketObject->TicketGet(
%Param,
DynamicFields => 0,
);
# get used calendar
my $Calendar = $TicketObject->TicketCalendarGet(
%Ticket,
);
# get time object
my $StopDateTimeObject = $Kernel::OM->Create('Kernel::System::DateTime');
# check if it is during business hours, then send escalation info
my $StartDateTimeObject = $Kernel::OM->Create(
'Kernel::System::DateTime',
ObjectParams => {
Epoch => $StopDateTimeObject->ToEpoch() - ( 10 * 60 ),
}
);
my $CountedTime = StartDateTimeObject->Delta(
DateTimeObject => $StopDateTimeObject,
ForWorkingTime => 1,
Calendar => $Calendar,
);
if ( !$CountedTime ) {
if ( $Self->{Debug} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'debug',
Message =>
"Send no escalation for Ticket $Ticket{TicketNumber}/$Ticket{TicketID} because currently no working hours!",
);
}
return 1;
}
# check if it's a escalation or escalation notification
# check escalation times
my $EscalationType = '';
TYPE:
for my $Type (
qw(FirstResponseTimeEscalation UpdateTimeEscalation SolutionTimeEscalation
FirstResponseTimeNotification UpdateTimeNotification SolutionTimeNotification)
)
{
if ( defined $Ticket{$Type} ) {
if ( $Type =~ /TimeEscalation$/ ) {
$EscalationType = 'Escalation';
last TYPE;
}
elsif ( $Type =~ /TimeNotification$/ ) {
$EscalationType = 'EscalationNotifyBefore';
last TYPE;
}
}
}
# check
if ( !$EscalationType ) {
if ( $Self->{Debug} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'debug',
Message =>
"Can't send escalation for Ticket $Ticket{TicketNumber}/$Ticket{TicketID} because ticket is not escalated!",
);
}
return;
}
# trigger notification event
$TicketObject->EventHandler(
Event => 'Notification' . $EscalationType,
Data => {
TicketID => $Param{TicketID},
CustomerMessageParams => \%Param,
},
UserID => 1,
);
return 1;
}
1;
|