import rt 3.0.12
[freeside.git] / rt / html / Ticket / Elements / ShowTransaction
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <TR class="<% $RowNum%2 ? 'oddline' : 'evenline'%>" >
25 <TD bgcolor="<%$bgcolor%>"><A NAME="txn-<%$Transaction->Id%>" href="#txn-<%$Transaction->Id%>">#</A>&nbsp;</TD>
26 <TD>&nbsp&nbsp;</TD>
27 <TD><font size=-2><% $transdate|n %></font>&nbsp;</TD>
28 % my $desc = $Transaction->BriefDescription;
29 % $m->comp('/Elements/Callback', _CallbackName => 'ModifyDisplay', text => \$desc, Transaction => $Transaction, %ARGS);
30 <TD ALIGN="LEFT"><b><%$Transaction->CreatorObj->Name%> - <%$TicketString%> <%$desc%>
31
32 </b></TD>
33 <TD><%$TimeTaken%>&nbsp;</TD>
34 <TD ALIGN="RIGHT"><font size=-1><%$titlebar_commands|n%></font></TD>
35 </TR>
36 <%PERL>
37
38 unless ($Collapsed) {
39  foreach my $message (@$Attachments) { 
40
41   my ($headers, $quoted);
42       if ($ShowHeaders && ($ShowHeaders == $Ticket->Id)) {
43           $headers = $message->Headers;
44       } else {
45           $headers = $message->NiceHeaders;
46       }
47       chomp $headers;
48       if ($headers) {
49            # localize the common headers (like 'Subject:'), too.
50            eval {$headers =~ s/^([^:]+)(?=:)/loc($1)/em; } # we eval here to catch errors when 5.6 panics
51       }
52      
53
54      my $MAX_INLINE_BODY = $RT::MaxInlineBody || 13456;
55     if (    $message->ContentType =~ m{^(text/plain|message|text$)}i
56          && $message->ContentLength < $MAX_INLINE_BODY ) {
57
58         my $content;
59         # If we've preloaded all the content, let's pull from there
60         # if we haven't, load it now
61         if ($AttachmentContent->{$message->id}) {
62             $content = $AttachmentContent->{$message->id}->Content;
63         } else {
64             $content = $message->Content;
65         } 
66
67
68
69         eval {
70             require Text::Quoted;
71             $quoted = Text::Quoted::extract( $content );
72         };
73         if ($@) {
74             $quoted = $content;
75         }
76     }
77         
78 </%PERL>
79 <TR class="<% $RowNum%2 ? 'oddline' : 'evenline'%>" >                                
80       <TD BGCOLOR="<%$bgcolor%>">&nbsp;&nbsp;</TD>
81       <TD>&nbsp;&nbsp;</TD>
82       <TD COLSPAN=3 VALIGN=TOP>
83 <span class="message">
84         <PRE>
85 <& ShowMessageHeaders, Headers => $headers, Transaction => $Transaction &>
86 </PRE>
87 % if ($message->ContentLength && !length($quoted) && $message->ContentType =~ m#^text/#) {
88 <blockquote><i><&|/l&>Message body not shown because it is too large or is not plain text.</&><br>
89 <&|/l&>You can access it with the Download button on the right.</&></i></blockquote>
90 % } else {
91 <& ShowMessageStanza, Depth => 0, Message => $quoted, Transaction => $Transaction &>
92 % }
93 </span>
94       </TD>
95       <TD VALIGN=TOP ALIGN=RIGHT>
96         
97 % if ($message->Parent == 0  ) {
98 <BR>
99 % }
100 <%PERL>
101 my $size = $message->ContentLength or next;
102
103 if ($size) {
104     if ($size > 1024) {
105         $size = loc("[_1]k", int($size/102.4)/10);
106     }
107     else {
108         $size = loc("[_1]b", $size);
109     }
110 </%PERL>
111 <font size=-1><A HREF="<%$AttachPath%>/<%$Transaction->Id%>/<%$message->Id%>/<%$message->Filename | u%>"><&|/l&>Download</&> <% $message->Filename|| loc('(untitled)') %></a> <% $size %></font>
112 % }
113 </TD>
114 </TR>
115 % }
116 % }
117
118
119
120 <%ARGS>
121 $Ticket => undef
122 $Transaction => undef
123 $ShowHeaders => 0
124 $Collapsed => undef
125 $ShowTitleBarCommands => 1
126 $RowNum => 1
127 $AttachPath => $RT::WebPath."/Ticket/Attachment"
128 $UpdatePath => $RT::WebPath."/Ticket/Update.html"
129 $Attachments => undef
130 $AttachmentContent => undef
131 </%ARGS>
132
133 <%INIT>
134
135
136 my ($TimeTaken, $TicketString, $bgcolor);
137
138 my $transdate = $Transaction->CreatedAsString();
139 $transdate =~ s/\s/&nbsp;/g;
140
141 if ($Transaction->Type =~ /^(Create|Correspond|Comment$)/) {
142                 $bgcolor="#336699";
143 } elsif (($Transaction->Field =~ /^Owner$/) or 
144          ($Transaction->Type =~ /^(AddWatcher|DelWatcher)$/)) {
145         $bgcolor="#333399";
146
147 } elsif ($Transaction->Type =~ /^(AddLink|DeleteLink)$/) {
148         $bgcolor="#336633";
149 } elsif ($Transaction->Type =~ /^(Status|Set|Told)$/) {
150         if ($Transaction->Field =~ /^(Told|Starts|Started|Due)$/) {
151                 $bgcolor="#663366";     
152         }
153         else {
154                 $bgcolor="#993333";
155         }
156 }
157 else {
158         $bgcolor="#cccccc";
159 }
160
161 if ($Ticket->Id != $Transaction->Ticket) {
162         $TicketString = "Ticket ".$Transaction->Ticket .": ";
163 }
164
165 if ($Transaction->TimeTaken != 0) {
166         $TimeTaken = $Transaction->TimeTaken." min"
167 }
168
169 unless ($Attachments) { 
170     my $attachments = $Transaction->Attachments;
171     $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
172     $Attachments = $attachments->ItemsArrayRef();
173 }
174
175
176 my $titlebar_commands='&nbsp;';
177
178 # If the transaction has anything attached to it at all
179 if ($Attachments->[0] && $ShowTitleBarCommands) {
180         if ($Ticket->CurrentUserHasRight('ReplyToTicket')) {
181                 $titlebar_commands .= 
182                   "[<a href=\"".$UpdatePath."?id=".
183                   $Transaction->Ticket . "&QuoteTransaction=".$Transaction->Id.
184                   "&Action=Respond\">". loc('Reply') ."</a>]&nbsp;";
185         }
186         if ($Ticket->CurrentUserHasRight('CommentOnTicket')) {
187              $titlebar_commands .= 
188              "[<a href=\"".$UpdatePath."?id=".$Transaction->Ticket. 
189              "&QuoteTransaction=".$Transaction->Id.
190              "&Action=Comment\">". loc('Comment') ."</a>]";
191         }
192 }
193
194 </%INIT>