Export ticket history to pdf


#1

Hi Everyone

is there a way to export ticket history to pdf? or at least a text file?
I checked these links but didn’t find my answer:



#2

You can dump a history of a ticket (without attachments) for example like this. We are using this in template for AdminCcs in the new queue when moving the ticket. Sorry, the code is in “Template” syntax.

----------------------------------------------------------------
  User's original request:
----------------------------------------------------------------
Time: {$Ticket->Transactions->First->CreatedObj->AsString;}
Subject: {$Ticket->Transactions->First->Subject;}
From: {$Ticket->Transactions->First->Attachments->First->GetHeader('From')}
To: {$Ticket->Transactions->First->Attachments->First->GetHeader('To')}
Cc: {$Ticket->Transactions->First->Attachments->First->GetHeader('Cc')}

{$Ticket->Transactions->First->Content()}
---------------------------------------------------------------
 Complete ticket history (oldest messages first):
----------------------------------------------------------------
{
my $resolved_message = '';
my $last_content = '';

my $transactions = $Ticket->Transactions;
$transactions->Limit( FIELD => 'Type', VALUE => 'Correspond',
ENTRYAGGREGATOR => 'OR', OPERATOR => '=', );
$transactions->Limit( FIELD => 'Type', VALUE => 'Comment',
ENTRYAGGREGATOR => 'OR', OPERATOR => '=', );

while (my $transaction = $transactions->Next) {
  my $attachments = $transaction->Attachments;
  
  while (my $message = $attachments->Next) {
    next unless $message->ContentType =~
          m!^(text/plain|message|text$)!i;

    my $content = $message->Content;
     next unless $content;

   next if $last_content eq $content;
   $last_content = $content;

  my $subject = ($message->Subject || $Ticket->Subject);

   my $wrapper = Text::Wrapper->new(columns=>70);
   $content = $wrapper->wrap($content);

   $resolved_message .= "Subject: ";
   $resolved_message .= $subject;
   $resolved_message .= "\n";
   $resolved_message .= "From: ";
   $resolved_message .= $message->CreatorObj->RealName ||
   $message->CreatorObj->EmailAddress;
   $resolved_message .= "\n";
   $resolved_message .= "Time: ";
   $resolved_message .= $message->CreatedObj->AsString;
   $resolved_message .= "\n";
   $resolved_message .= "\n";
   $resolved_message .= "$content\n";
   $resolved_message .=
   "------------------------------------------------\n";
   }
}
  print $resolved_message;
}