import of rt 3.0.9
[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  $attachments->GotoFirstItem;
40  while (my $message=$attachments->Next) {
41
42   my ($headers, $quoted);
43       if ($ShowHeaders && ($ShowHeaders == $Ticket->Id)) {
44           $headers = $message->Headers;
45       } else {
46           $headers = $message->NiceHeaders;
47       }
48       chomp $headers;
49       if ($headers) {
50            # localize the common headers (like 'Subject:'), too.
51            eval {$headers =~ s/^([^:]+)(?=:)/loc($1)/em; } # we eval here to catch errors when 5.6 panics
52       }
53      # 13456 is a random # of about the biggest size we want to see inline text
54      # It's here to catch anyone who hasn't updated RT_Config.pm since this
55      # constant was moved out there.
56      my $MAX_INLINE_BODY = $RT::MaxInlineBody || 13456;
57      if ($message->ContentType =~ m{^(text/plain|message|text$)}i && 
58                                     $message->ContentLength < $MAX_INLINE_BODY ) {
59          eval {
60          require Text::Quoted;
61              $quoted = Text::Quoted::extract($message->Content); 
62         }; 
63         if ($@) {
64             $quoted = $message->Content;
65         }
66      }
67         
68 </%PERL>
69 <TR class="<% $RowNum%2 ? 'oddline' : 'evenline'%>" >                                
70       <TD BGCOLOR="<%$bgcolor%>">&nbsp;&nbsp;</TD>
71       <TD>&nbsp;&nbsp;</TD>
72       <TD COLSPAN=3 VALIGN=TOP>
73 <span class="message">
74         <PRE>
75 <& ShowMessageHeaders, Headers => $headers, Transaction => $Transaction &>
76 </PRE>
77 % if (!length($quoted) && $message->ContentType =~ m#^text/#) {
78 <blockquote><i><&|/l&>Message body not shown because it is too large or is not plain text.</&><br>
79 <&|/l&>You can access it with the Download button on the right.</&></i></blockquote>
80 % } else {
81 <& ShowMessageStanza, Depth => 0, Message => $quoted, Transaction => $Transaction &>
82 % }
83 </span>
84       </TD>
85       <TD VALIGN=TOP ALIGN=RIGHT>
86         
87 % if ($message->Parent == 0  ) {
88 <BR>
89 % }
90 <%PERL>
91 my $size = $message->ContentLength or next;
92
93 if ($size) {
94     if ($size > 1024) {
95         $size = loc("[_1]k", int($size/102.4)/10);
96     }
97     else {
98         $size = loc("[_1]b", $size);
99     }
100 </%PERL>
101 <font size=-1><A HREF="<%$AttachPath%>/<%$Transaction->Id%>/<%$message->Id%>/<%$message->Filename | u%>"><&|/l&>Download</&> <% $message->Filename|| loc('(untitled)') %></a> <% $size %></font>
102 % }
103 </TD>
104 </TR>
105 % }
106 % }
107
108
109
110 <%ARGS>
111 $Ticket => undef
112 $Transaction => undef
113 $ShowHeaders => 0
114 $Collapsed => undef
115 $ShowTitleBarCommands => 1
116 $RowNum => 1
117 $AttachPath => $RT::WebPath."/Ticket/Attachment"
118 </%ARGS>
119
120 <%INIT>
121
122
123 my ($TimeTaken, $TicketString, $bgcolor);
124
125 my $transdate = $Transaction->CreatedAsString();
126 $transdate =~ s/\s/&nbsp;/g;
127
128 if ($Transaction->Type =~ /^(Create|Correspond|Comment$)/) {
129         if ($Transaction->IsInbound) {
130                 $bgcolor="#336699";
131         }
132         else {
133                 $bgcolor="#339999";
134         }
135 } elsif (($Transaction->Field =~ /^Owner$/) or 
136          ($Transaction->Type =~ /^(AddWatcher|DelWatcher)$/)) {
137         $bgcolor="#333399";
138
139 } elsif ($Transaction->Type =~ /^(AddLink|DeleteLink)$/) {
140         $bgcolor="#336633";
141 } elsif ($Transaction->Type =~ /^(Status|Set|Told)$/) {
142         if ($Transaction->Field =~ /^(Told|Starts|Started|Due)$/) {
143                 $bgcolor="#663366";     
144         }
145         else {
146                 $bgcolor="#993333";
147         }
148 }
149 else {
150         $bgcolor="#cccccc";
151 }
152
153 if ($Ticket->Id != $Transaction->Ticket) {
154         $TicketString = "Ticket ".$Transaction->Ticket .": ";
155 }
156
157 if ($Transaction->TimeTaken > 0) {
158         $TimeTaken = $Transaction->TimeTaken." min"
159 }
160 my $attachments = $Transaction->Attachments;
161 $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
162
163 my $titlebar_commands='&nbsp;';
164
165 # If the transaction has anything attached to it at all
166 if ($Transaction->Attachments->First && $ShowTitleBarCommands) {
167         if ($Transaction->TicketObj->CurrentUserHasRight('ReplyToTicket')) {
168                 $titlebar_commands .= 
169                   "[<a href=\"Update.html?id=".
170                   $Transaction->Ticket . "&QuoteTransaction=".$Transaction->Id.
171                   "&Action=Respond\">". loc('Reply') ."</a>]&nbsp;";
172         }
173         if ($Transaction->TicketObj->CurrentUserHasRight('CommentOnTicket')) {
174              $titlebar_commands .= 
175              "[<a href=\"Update.html?id=".$Transaction->Ticket. 
176              "&QuoteTransaction=".$Transaction->Id.
177              "&Action=Comment\">". loc('Comment') ."</a>]";
178         }
179 }
180
181 </%INIT>