Skip to content

Commit

Permalink
Merge pull request #206 from LigeroSmart/bug/CheckIfAllChildrenAreClosed
Browse files Browse the repository at this point in the history
Bug/check if all children are closed
  • Loading branch information
mfmatos committed Sep 2, 2022
2 parents 7ac438b + 7eef6e4 commit 4091f2e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ sub new {
sub Validate {
my ( $Self, %Param ) = @_;

my $LinkObject = $Kernel::OM->Get('Kernel::System::LinkObject');

for my $Needed (qw(Data)) {
if ( !defined $Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Expand All @@ -90,15 +92,15 @@ sub Validate {
return;
}

# linked tickets
my $Links = $Kernel::OM->Get('Kernel::System::LinkObject')->LinkList(
Object => 'Ticket',
Object2 => 'Ticket',
Key => $Param{Data}{TicketID},
State => 'Valid',
Type => 'ParentChild',
UserID => 1,
);
my $Links = $LinkObject->LinkList(
Object => 'Ticket',
Key => $Param{Data}{TicketID},
Object2 => 'Ticket', # (optional)
State => 'Valid',
#Type => ''ParentChild'', # (optional)
Direction => 'Target', # (optional) default Both (Source|Target|Both)
UserID => 1,
);

if ( $Links
&& $Links->{Ticket}
Expand Down
38 changes: 24 additions & 14 deletions Kernel/System/Ticket/Event/InformClosedChildToParent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,35 @@ sub Run {

# create article for the parent
my $ChildTicketNumber = $TicketHook.$TicketHookDivider.$Ticket{TicketNumber};
my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Phone' );
my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Internal' );
$ParentArticleID = $ArticleBackendObject->ArticleCreate(
TicketID => $TicketID,
SenderType => 'system',
ArticleTypeID => 11, # note-report
Subject => $LayoutObject->{LanguageObject}->Translate(
'Child ticket closed: %s',
$ChildTicketNumber
),
Body => $LayoutObject->{LanguageObject}
IsVisibleForCustomer => 0,
MimeType => 'text/plain',
From => 'root@localhost',
InReplyTo => '',
NoAgentNotify => 0,
ReplyTo => '',
Body => $LayoutObject->{LanguageObject}
->Translate('A child ticket has been closed, please check it: %s.',
$ChildTicketNumber),
From => 'root@localhost',
ContentType => 'text/plain; charset=UTF-8',
UserID => 1,
HistoryType => 'AddNote',
Charset => 'utf-8',
UserID => 1,
Subject => $LayoutObject->{LanguageObject}->Translate(
'Child ticket closed: %s',
$ChildTicketNumber,
),
Cc => '',
To => '',
ContentType => 'text/plain; charset=utf-8',
HistoryComment => "Child ticket $Ticket{TicketNumber} closed.",
SenderTypeID => '2',
References => '',
Bcc => '',
SenderType => 'system',
MessageID => '',
HistoryType => 'AddNote',
TicketID => $TicketID
);

if ( !$ParentArticleID ) {
return $LayoutObject->ErrorScreen();
}
Expand Down

0 comments on commit 4091f2e

Please sign in to comment.