-% 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 &>
-% }
+<%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++;
+
+ 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,
+ LastTransaction => $Transactions->IsLast
+ );
+
+# manually flush the content buffer after each txn, so the user sees
+# some update
+$m->flush_buffer();
+}
+
+</%perl>