Advertisement
Guest User

Untitled

a guest
Feb 11th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 5.61 KB | None | 0 0
  1. my $out = '';
  2. my $finalout = '';
  3. my $transactions = $Ticket->Transactions;
  4. my $lastrans = '';
  5.  
  6. while (my $transaction = $transactions->Next) {
  7.     my $type = $transaction->Type;
  8.     if ($type eq 'Create') {
  9.         my $attachments = $transaction->Attachments;
  10.         while (my $message = $attachments->Next) {
  11.             next unless $message->Creator != 1;
  12.             next unless $message->ContentType =~ m!^(text/html|text/plain$)!i;
  13.             my $content = $message->Content;
  14.             next unless $lastrans != $transaction->id;
  15.             if ($message->ContentType eq m!^(text/html)!i) {
  16.                 $out .= '<tr style="background-color: #ccffcc">';
  17.                 $out .= '<td>From:</td>';
  18.                 $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
  19.                 $out .= '</tr>';
  20.                 $out .= '<tr style="background-color: #ccffcc">';
  21.                 $out .= '<td>Time:</th>';
  22.                 $out .= '<td>'.$message->Created.'</th>';
  23.                 $out .= '</tr>';
  24.                 $out .= '<tr style="background-color: #e6ffe6">';
  25.                 $out .= '<td style="border:1pt solid black;">Create:</th>';
  26.                 $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
  27.                 $out .= '</tr>';
  28.             }
  29.             else {
  30.                 $out .= '<tr style="background-color: #ccffcc">';
  31.                 $out .= '<td>From:</td>';
  32.                 $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
  33.                 $out .= '</tr>';
  34.                 $out .= '<tr style="background-color: #ccffcc">';
  35.                 $out .= '<td>Time:</th>';
  36.                 $out .= '<td>'.$message->Created.'</th>';
  37.                 $out .= '</tr>';
  38.                 $out .= '<tr style="background-color: #e6ffe6">';
  39.                 $out .= '<td style="border:1pt solid black;">Create:</th>';
  40.                 $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
  41.                 $out .= '</tr>';
  42.             }
  43.             $lastrans = $transaction->id;
  44.         }
  45.     }
  46.     if ($type eq 'Correspond') {
  47.         my $attachments = $transaction->Attachments;
  48.         while (my $message = $attachments->Next) {
  49.             next unless $message->Creator != 1;
  50.             next unless $message->ContentType =~ m!^(text/html|text/plain$)!i;
  51.             my $content = $message->Content;
  52.             next unless $lastrans != $transaction->id;
  53.             if ($message->ContentType eq m!^(text/html)!i) {
  54.                 $out .= '<tr style="background-color: #fcc">';
  55.                 $out .= '<td>From:</td>';
  56.                 $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
  57.                 $out .= '</tr>';
  58.                 $out .= '<tr style="background-color: #fcc">';
  59.                 $out .= '<td>Time:</th>';
  60.                 $out .= '<td>'.$message->Created.'</th>';
  61.                 $out .= '</tr>';
  62.                 $out .= '<tr style="background-color: #ffebeb">';
  63.                 $out .= '<td style="border:1pt solid black;">Reply:</th>';
  64.                 $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
  65.                 $out .= '</tr>';
  66.             }
  67.             else {
  68.                 $out .= '<tr style="background-color: #fcc">';
  69.                 $out .= '<td>From:</td>';
  70.                 $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
  71.                 $out .= '</tr>';
  72.                 $out .= '<tr style="background-color: #fcc">';
  73.                 $out .= '<td>Time:</th>';
  74.                 $out .= '<td>'.$message->Created.'</th>';
  75.                 $out .= '</tr>';
  76.                 $out .= '<tr style="background-color: #ffebeb">';
  77.                 $out .= '<td style="border:1pt solid black;">Reply:</th>';
  78.                 $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
  79.                 $out .= '</tr>';
  80.             }
  81.             $lastrans = $transaction->id;
  82.         }
  83.     }
  84.     if ($type eq 'Comment') {
  85.         my $attachments = $transaction->Attachments;
  86.         while (my $message = $attachments->Next) {
  87.             next unless $message->Creator != 1;
  88.             next unless $message->ContentType =~ m!^(text/html|text/plain$)!i;
  89.             my $content = $message->Content;
  90.             next unless $lastrans != $transaction->id;
  91.             next unless $content;
  92.             if ($message->ContentType eq m!^(text/html)!i) {
  93.                 $out .= '<tr style="background-color: #FFFFDD">';
  94.                 $out .= '<td>From:</td>';
  95.                 $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
  96.                 $out .= '</tr>';
  97.                 $out .= '<tr style="background-color: #FFFFDD">';
  98.                 $out .= '<td>Time:</th>';
  99.                 $out .= '<td>'.$message->Created.'</th>';
  100.                 $out .= '</tr>';
  101.                 $out .= '<tr style="background-color: #ffffeb">';
  102.                 $out .= '<td style="border:1pt solid black;">Comment:</th>';
  103.                 $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
  104.                 $out .= '</tr>';
  105.             }
  106.             else {
  107.                 $out .= '<tr style="background-color: #FFFFDD">';
  108.                 $out .= '<td>From:</td>';
  109.                 $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
  110.                 $out .= '</tr>';
  111.                 $out .= '<tr style="background-color: #FFFFDD">';
  112.                 $out .= '<td>Time:</th>';
  113.                 $out .= '<td>'.$message->Created.'</th>';
  114.                 $out .= '</tr>';
  115.                 $out .= '<tr style="background-color: #ffffeb">';
  116.                 $out .= '<td style="border:1pt solid black;">Comment:</th>';
  117.                 $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
  118.                 $out .= '</tr>';
  119.             }
  120.             $lastrans = $transaction->id;
  121.         }
  122.     }
  123. }
  124.  
  125. if ($out ne '') {
  126.     $finalout .= '<table style="text-align:left;border-collapse: collapse;border:1pt solid black;">';
  127.     $finalout .= $out;
  128.     $finalout;
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement