When I started using RT, wandered around its menus playing “press and guess”, and I found the “My Day” screen under tools. I was really excited by the idea of it, but it wasn’t quite what I needed – my work flow works best ordered by staleness, and I really need a bit more context for each ticket.
I’ve created an Overlay for html/Tools/MyDay.html, which adds the last text attachment – it looks like this:
Here’s the code of the overlay:
<& /Elements/Header, Title => $title &>
<& /Elements/Tabs &>
<& /Elements/ListActions, actions => \@results &>
<h2><&|/l, $session{'CurrentUser'}->Name &>Active tickets for [_1]</&></h2>
<form method="post" action="MyDay.html">
<table width="100%" cellpadding="0" cellspacing="0" class="myday">
% while ( my $Ticket = $Tickets->Next()) {
% $i++;
% my $class = $i % 2 ? 'class="evenline"' : 'class="oddline"';
<tr <%$class|n%>><td colspan="2"><h2><a
href="<%RT->Config->Get('WebPath')%>/Ticket/Display.html?id=<%$Ticket->Id%>"><%$Ticket->Id%>:
<%$Ticket->Subject%></a></h2></td></tr>
<tr <%$class|n%>><td><span class="label"><&|/l&>Worked</&>:</span><input size="3" name="UpdateTimeWorked-<%$Ticket->Id%>" /> <&|/l&>minutes</&>
</td>
<td rowspan="2"><span class="label"><&|/l&>Comments</&>:<br /></span><textarea name="UpdateContent-<%$Ticket->Id%>" rows="5"
cols="60"></textarea><br />
% my $Attachments = $Ticket->Attachments;
% my $final_note;
% while( my $attachment = $Attachments->Next ) {
% next unless $attachment->ContentType =~ /text/;
% $final_note = $attachment->Content;
% }
<div class="messagebody">
<%$final_note%>
</div>
</td></tr>
<tr <%$class|n%>>
<td><span class="label"><&|/l&>Status</&>:</span> <& /Ticket/Elements/SelectStatus, Name=> 'UpdateStatus-'.$Ticket->Id, TicketObj => $Ticket &>
</td>
</tr>
% }
</table>
<& /Elements/Submit, Label => loc('Record all updates') , Reset => 1, ResetLabel => loc('Clear')&>
</form>
</html>
<%INIT>
my $title = loc("What I did today (Barton's local overlay)");
my $i = 0;
my @results;
foreach my $arg ( keys %ARGS ) {
next unless ( $arg =~ /^UpdateStatus-(\d*)$/ );
my $id = $1;
my $ticket = LoadTicket($id);
next unless ( $ticket->id );
if ( my $content = $ARGS{'UpdateContent-'.$id} ) {
my ( $val, $msg ) = $ticket->Comment(
Content => $content,
TimeTaken => $ARGS{ 'UpdateTimeWorked-' . $id }
);
push @results, loc( "Ticket [_1]: [_2]", $id, $msg );
} elsif ( my $worked = $ARGS{ 'UpdateTimeWorked-' . $id } ) {
my ( $val, $msg ) = $ticket->SetTimeWorked( $worked + $ticket->TimeWorked );
push @results, loc( "Ticket [_1]: [_2]", $id, $msg );
}
if ( my $status = $ARGS{ 'UpdateStatus-' . $id } ) {
if ( $status ne $ticket->Status ) {
my ( $val, $msg ) = $ticket->SetStatus($status);
push @results, loc( "Ticket [_1]: [_2]", $id, $msg );
}
}
}
my $Tickets = RT::Tickets->new($session{'CurrentUser'});
$Tickets->LimitOwner(VALUE => $session{'CurrentUser'}->Id);
$Tickets->LimitToActiveStatus;
$Tickets->OrderBy ( FIELD => 'LastUpdated', ORDER => 'ASC');
</%INIT>
Now… I’d like to use ShowTransactionAttachments
which would do all the formatting goodness used on Ticket/Display.html, but I’m not sure how to call that and only process the last attachment.
the call to ShowTransactionAttachments
in ./share/html/Elements/ShowTransaction looks like this:
$m->comp(
'ShowTransactionAttachments',
%ARGS,
Parent => 0
)
So I’m assuming that I can call $m->comp()
and pass in a hash in place of %ARGS
with … @Attachments
… somewhere.