<!-- Split.html
-->
<& /Elements/Header, Title => "Ticket #".$Ticket->Id ." ".$Ticket->Subject &>
<& /Ticket/Elements/Tabs, Ticket => $Ticket, current_tab => 'Ticket/Split.html?id='.$Ticket->id &>
<form METHOD=POST ACTION="Split.html?Action=DoSplit&id=<%$Ticket->id%>">
<table CLASS="" BGCOLOR="#DDDDDD" CELLSPACING=0 BORDER=0 CELLPADDING=0 WIDTH="100%">
<tr>
<td rowspan="20" BGColor="#993333">
<img src="https://rt2test.mococo.nl:81/rt2/NoAuth/images/spacer.gif" width="1" height="1" alt="">
</td>
<td valign="center" align="left" bgcolor="#993333">
<font size="-1" color="#ffffff"><b><a class="inverse">Original Subject</a></b></font>
</td>
<td Align="Left" BGColor="#993333" VAlign="center">
<font size="-1" color="#ffffff"><b><a class="inverse"><%$Ticket->Subject|h%></a></b></font></td>
<td rowspan="20" BGColor="#993333">
<img src="https://rt2test.mococo.nl:81/rt2/NoAuth/images/spacer.gif" width="1" height="1" alt="">
</td>
</tr>
<!--
<tr><td>new original subject:</td><td><input name="subject" value="<%$Ticket->Subject|h%>" SIZE="50"></td></tr>
-->
<tr>
<td> </td>
<td><hr></td>
</tr>
% while (my $Link = $Ticket->Members->Next) {
% my $member = $Link->BaseObj;
<tr>
<td>
<a href="<%$RT::WebPath%>/Ticket/Display.html?id=<%$member->Id%>">Ticket <%$member->Id%></a>
</td>
<td>
<b><%$member->Subject%></b>
</td>
</tr>
% my $tr = RT::Transactions->new($Ticket->CurrentUser);
% $tr->Limit( FIELD => 'Ticket', VALUE => $member->id);
% $tr->Limit( FIELD => 'Type', VALUE => 'Create');
% my $iemail = $tr->Next->Message->Next;
<tr>
<td>
</td>
<td>
<%$iemail->Content%>
</td>
</tr>
% }
<tr>
<td>
</td>
<td><hr>
</td>
</tr>
<tr>
<td bgcolor="#dddddd" valign=top align=left>
<div align="left"><span class=label>New ticket</span></div>
</td>
<td>
<i>Edit subject and text down to the single problem you want the new child Ticket to track</i>
</td>
</tr>
<tr>
<td align="right">
Subject
</td>
<td><input name="subject1" value="<%$Ticket->Subject|h%>" SIZE="50">
</td>
</tr>
<tr>
<td align="right">
Text
</td>
<td>
<textarea name="content1" wrap="virtual" cols="70" rows="15"><%$initialEmail->Content|h%></textarea>
</td>
</tr>
</table>
<& /Elements/Submit, Label => 'Split The Ticket', Caption => "Be sure to edit the subject and text for this new child, then ", color => "#993333" &>
</form>
<%ARGS>
$id => undef
$Create => undef
$ShowHeaders => undef
$Collapsed => undef
</%ARGS>
<%INIT>
use RT::Transactions;
use MIME::Entity;
my ($linkid, $message, $tid, $Ticket, $initialEmail, @Actions);
$Ticket = new RT::Ticket($session{'CurrentUser'});
unless ($id) {
Abort('No ticket specified');
}
$Ticket = LoadTicket($ARGS{'id'});
unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
Abort("No permission to view ticket");
}
unless ($Ticket->CurrentUserHasRight('CreateTicket')) {
Abort("No permission to split ticket");
}
# TODO - there probably should be other rights protections here,
# but I'm not sure what
if (defined $ARGS{'Action'} && $ARGS{'Action'} eq 'DoSplit') {
my $Queue = new RT::Queue($session{'CurrentUser'});
unless ($Queue->Load($Ticket->Queue)) {
Abort('Queue not found');
}
unless ($Queue->CurrentUserHasRight('CreateTicket')) {
Abort('You have no permission to create tickets in that queue.');
}
if (defined $ARGS{'subject1'} && $ARGS{'subject1'} ne '') {
my ($newChild, $trobjid, $msg);
# $RT::Logger->warning("DoSplit 3");
($newChild, $trobjid, $msg) = $Ticket->Split('Split', $ARGS{'subject1'}, $ARGS{'content1'});
}
# $RT::Logger->warning("DoSplit 4");
push(@Actions, "Ticket split from #$ARGS{'id'}");
# $ARGS{'id'} = $Ticket->id;
}
# Gather subject and inital message from original ticket
my $transactions = RT::Transactions->new($Ticket->CurrentUser);
$transactions->Limit( FIELD => 'Ticket', VALUE => $Ticket->id());
$transactions->Limit( FIELD => 'Type', VALUE => 'Create');
$initialEmail = $transactions->Next->Message->Next;
</%INIT>