-% while (my $Transaction = $Transactions->Next) {
-% my $skip = 0;
-% $m->comp('/Elements/Callback', _CallbackName => 'SkipTransaction', Transaction => $Transaction, skip => \$skip, %ARGS);
-% next if $skip;
-% $i++;
-% if ($Transactions->IsLast) {
- <a name="lasttrans"></a>
-% }
- <& ShowTransaction, Ticket => $Ticket, Transaction => $Transaction, ShowHeaders => $ShowHeaders, Collapsed => $Collapsed, RowNum => $i, ShowTitleBarCommands => $ShowTitleBarCommands, %ARGS &>
-% }
+<%perl>
+my @attachments = @{$Attachments->ItemsArrayRef()};
+my @attachment_content = @{$AttachmentContent->ItemsArrayRef()};
+
+
+
+
+
+while ( my $Transaction = $Transactions->Next ) {
+ my $skip = 0;
+ $m->comp( '/Elements/Callback',
+ _CallbackName => 'SkipTransaction',
+ Transaction => $Transaction,
+ skip => \$skip,
+ %ARGS );
+ next if $skip;
+ $i++;
+
+ $m->out('<a name="lasttrans"></a>') if ( $Transactions->IsLast );
+
+ my @trans_attachments = grep { $_->TransactionId == $Transaction->Id } @attachments;
+
+ my $trans_content = {};
+ grep { ($_->TransactionId == $Transaction->Id ) && ($trans_content->{$_->Id} = $_) } @attachment_content;
+
+
+ #Args is first because we're clobbering the "Attachments" parameter
+ $m->comp( 'ShowTransaction',
+ %ARGS,
+
+ AttachPath => $AttachPath,
+ UpdatePath => $UpdatePath,
+ Ticket => $Ticket,
+ Transaction => $Transaction,
+ ShowHeaders => $ShowHeaders,
+ Collapsed => $Collapsed,
+ RowNum => $i,
+ ShowTitleBarCommands => $ShowTitleBarCommands,
+ Attachments => \@trans_attachments,
+ AttachmentContent => $trans_content
+ );
+}
+
+</%perl>