This commit was generated by cvs2svn to compensate for changes in r2526,
[freeside.git] / rt / webrt / Ticket / Elements / ShowTransaction
1 <TR bgcolor="<%$rowbgcolor%>">
2 <TD bgcolor="<%$bgcolor%>"><A NAME="#<%$Transaction->Id%>"></A>&nbsp&nbsp;</TD>
3 <TD>&nbsp&nbsp;</TD>
4 <TD><font size=-2><% $transdate|n %></font>&nbsp;</TD>
5 <TD ALIGN="LEFT"><b><%$Transaction->CreatorObj->Name%> - <%$TicketString%> <%$Transaction->BriefDescription%>
6
7 </b></TD>
8 <TD><%$TimeTaken%>&nbsp;</TD>
9 <TD ALIGN="RIGHT"><font size=-1><%$titlebar_commands|n%></font></TD>
10 </TR>
11 <%PERL>
12
13 unless ($Collapsed) {
14  $attachments->GotoFirstItem;
15  while (my $message=$attachments->Next) {
16      #we don't want to show any empty transactions, unless they have kids
17      next unless (length $message->Content || $message->Children->Count);
18      my ($headers, $content);
19      
20     </%PERL>
21
22
23 <%PERL>
24   if ($message->Parent == 0) {
25       if ($ShowHeaders == $Ticket->Id) {
26           $headers = $message->Headers;
27       } else {
28           $headers = $message->NiceHeaders;
29       }
30       chomp $headers;
31       $headers .= "\n\n" if ($headers);
32   }
33      # 13456 is a random # of about the biggest size we want to see inline text
34      my $MAX_INLINE_BODY = 13456;
35      if ($message->ContentType =~ m{^(text/plain|message|text$)}i && 
36                                     length($message->Content)< $MAX_INLINE_BODY ) {
37
38          $content = $message->Content;
39
40          my $wrapper = new Text::Wrapper (columns=>85);
41          $content = $wrapper->wrap($content);
42          $content =~ s/&/&amp;/g;
43          $content =~ s/</&lt;/g;
44          $content =~ s/>/&gt;/g;
45          $content =~ s!((?:http|https|ftp|mailto):\S*?)([\s"']|&gt;|\.[\n])!<A HREF=\"$1\" TARGET=new>$1</A>$2!g;
46
47
48      }
49      else {
50          $content = "&nbsp;";
51      }
52         
53 </%PERL>
54 <TR BGCOLOR="<%$rowbgcolor%>">
55       <TD BGCOLOR="<%$bgcolor%>">&nbsp;&nbsp;</TD>
56       <TD>&nbsp&nbsp;</TD>
57       <TD COLSPAN=3 VALIGN=TOP>
58         <PRE>
59 <%$headers%><%$content|n%>
60 </PRE>
61       </TD>
62       <TD VALIGN=TOP ALIGN=RIGHT>
63         
64 % if ($message->Parent == 0  ) {
65 <BR>
66 % }
67 <%PERL>
68 my $size = length($message->Content());
69
70 if ($size) {
71     if ($size > 1024) {
72         $size = int($size/102.4)/10 . "k";
73     }
74     else {
75         $size = $size ."b";
76     }
77 </%PERL>
78 <font size=-1><A HREF="Attachment/<%$Transaction->Id%>/<%$message->Id%>/<%$message->Filename%>">Download <%$message->Filename|| '(untitled)'%></a> <% $size %></font>
79 % }
80 </TD>
81 </TR>
82 % }
83 % }
84
85
86
87 <%ARGS>
88 $Ticket => undef
89 $Transaction => undef
90 $ShowHeaders => undef
91 $Collapsed => undef
92 $ShowTitleBarCommands => 1
93 $RowNum => 1
94 </%ARGS>
95
96 <%INIT>
97
98
99 my ($TimeTaken, $TicketString, $bgcolor, $rowbgcolor);
100
101 my $transdate = $Transaction->CreatedAsString();
102 $transdate =~ s/\s/&nbsp;/g;
103
104 if ($RowNum % 2) {
105         $rowbgcolor="#cccccc";
106 } else {
107         $rowbgcolor="#ffffff";
108 }
109
110 if ($Transaction->Type =~ /^(Create|Correspond|Comment$)/) {
111         if ($Transaction->IsInbound) {
112                 $bgcolor="#336699";
113         }
114         else {
115                 $bgcolor="#339999";
116         }
117 } elsif (($Transaction->Field =~ /^Owner$/) or 
118          ($Transaction->Type =~ /^(AddWatcher|DelWatcher)$/)) {
119         $bgcolor="#333399";
120
121 } elsif ($Transaction->Type =~ /^(AddLink|DeleteLink)$/) {
122         $bgcolor="#336633";
123 } elsif ($Transaction->Type =~ /^(Status|Set|Keyword|Told)$/) {
124         if ($Transaction->Field =~ /^(Told|Starts|Started|Due)$/) {
125                 $bgcolor="#663366";     
126         }
127         else {
128                 $bgcolor="#993333";
129         }
130 }
131 else {
132         $bgcolor="#cccccc";
133 }
134
135 if ($Ticket->Id != $Transaction->Ticket) {
136         $TicketString = "Ticket ".$Transaction->Ticket .": ";
137 }
138
139 if ($Transaction->TimeTaken > 0) {
140         $TimeTaken = $Transaction->TimeTaken." min"
141 }
142 my $attachments = $Transaction->Attachments;
143
144 my $titlebar_commands='&nbsp;';
145
146 # If the transaction has anything attached to it at all
147 if ($Transaction->Message->First && $ShowTitleBarCommands) {
148         if ($Transaction->TicketObj->CurrentUserHasRight('ReplyToTicket')) {
149                 $titlebar_commands .= 
150                   "[<a href=\"Update.html?id=".
151                   $Transaction->Ticket . "&QuoteTransaction=".$Transaction->Id.
152                   "&Action=Respond\">Reply</a>]&nbsp;";
153         }
154         if ($Transaction->TicketObj->CurrentUserHasRight('CommentOnTicket')) {
155              $titlebar_commands .= 
156              "[<a href=\"Update.html?id=".$Transaction->Ticket. 
157              "&QuoteTransaction=".$Transaction->Id.
158              "&Action=Comment\">Comment</a>]";
159         }
160 }
161
162 </%INIT>