Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my $out = '';
- my $finalout = '';
- my $transactions = $Ticket->Transactions;
- my $lastrans = '';
- while (my $transaction = $transactions->Next) {
- my $type = $transaction->Type;
- if ($type eq 'Create') {
- my $attachments = $transaction->Attachments;
- while (my $message = $attachments->Next) {
- next unless $message->Creator != 1;
- next unless $message->ContentType =~ m!^(text/html|text/plain$)!i;
- my $content = $message->Content;
- next unless $lastrans != $transaction->id;
- if ($message->ContentType eq m!^(text/html)!i) {
- $out .= '<tr style="background-color: #ccffcc">';
- $out .= '<td>From:</td>';
- $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #ccffcc">';
- $out .= '<td>Time:</th>';
- $out .= '<td>'.$message->Created.'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #e6ffe6">';
- $out .= '<td style="border:1pt solid black;">Create:</th>';
- $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
- $out .= '</tr>';
- }
- else {
- $out .= '<tr style="background-color: #ccffcc">';
- $out .= '<td>From:</td>';
- $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #ccffcc">';
- $out .= '<td>Time:</th>';
- $out .= '<td>'.$message->Created.'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #e6ffe6">';
- $out .= '<td style="border:1pt solid black;">Create:</th>';
- $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
- $out .= '</tr>';
- }
- $lastrans = $transaction->id;
- }
- }
- if ($type eq 'Correspond') {
- my $attachments = $transaction->Attachments;
- while (my $message = $attachments->Next) {
- next unless $message->Creator != 1;
- next unless $message->ContentType =~ m!^(text/html|text/plain$)!i;
- my $content = $message->Content;
- next unless $lastrans != $transaction->id;
- if ($message->ContentType eq m!^(text/html)!i) {
- $out .= '<tr style="background-color: #fcc">';
- $out .= '<td>From:</td>';
- $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #fcc">';
- $out .= '<td>Time:</th>';
- $out .= '<td>'.$message->Created.'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #ffebeb">';
- $out .= '<td style="border:1pt solid black;">Reply:</th>';
- $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
- $out .= '</tr>';
- }
- else {
- $out .= '<tr style="background-color: #fcc">';
- $out .= '<td>From:</td>';
- $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #fcc">';
- $out .= '<td>Time:</th>';
- $out .= '<td>'.$message->Created.'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #ffebeb">';
- $out .= '<td style="border:1pt solid black;">Reply:</th>';
- $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
- $out .= '</tr>';
- }
- $lastrans = $transaction->id;
- }
- }
- if ($type eq 'Comment') {
- my $attachments = $transaction->Attachments;
- while (my $message = $attachments->Next) {
- next unless $message->Creator != 1;
- next unless $message->ContentType =~ m!^(text/html|text/plain$)!i;
- my $content = $message->Content;
- next unless $lastrans != $transaction->id;
- next unless $content;
- if ($message->ContentType eq m!^(text/html)!i) {
- $out .= '<tr style="background-color: #FFFFDD">';
- $out .= '<td>From:</td>';
- $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #FFFFDD">';
- $out .= '<td>Time:</th>';
- $out .= '<td>'.$message->Created.'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #ffffeb">';
- $out .= '<td style="border:1pt solid black;">Comment:</th>';
- $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
- $out .= '</tr>';
- }
- else {
- $out .= '<tr style="background-color: #FFFFDD">';
- $out .= '<td>From:</td>';
- $out .= '<td>'.($message->CreatorObj->RealName || $message->CreatorObj->EmailAddress).'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #FFFFDD">';
- $out .= '<td>Time:</th>';
- $out .= '<td>'.$message->Created.'</th>';
- $out .= '</tr>';
- $out .= '<tr style="background-color: #ffffeb">';
- $out .= '<td style="border:1pt solid black;">Comment:</th>';
- $out .= '<td style="border:1pt solid black;"><pre>'.$content.'</pre></th>';
- $out .= '</tr>';
- }
- $lastrans = $transaction->id;
- }
- }
- }
- if ($out ne '') {
- $finalout .= '<table style="text-align:left;border-collapse: collapse;border:1pt solid black;">';
- $finalout .= $out;
- $finalout;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement