import rt 3.8.11
[freeside.git] / rt / html / Ticket / Elements / ShowTransaction
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC 
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
16 %# from www.gnu.org.
17 %# 
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 %# General Public License for more details.
22 %# 
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %# 
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 <div class="ticket-transaction<% $type_class && " $type_class" %><% $RowNum % 2 ? ' odd' : ' even' %>">
49 % $m->comp('/Elements/Callback', _CallbackName => 'ModifyDisplay', titlebar_cmd => \$titlebar_commands, Transaction => $Transaction, %ARGS);
50
51 <table width="100%" cellspacing="0" cellpadding="2" border="0">
52   <tr>
53     <td rowspan="2" valign="top" class="type">
54       <a name="txn-<%$Transaction->Id%>" href="<% $DisplayPath %>#txn-<%$Transaction->Id%>">#</a>
55       <% $LastTransaction ? '<a name="lasttrans">&nbsp;</a>' : '&nbsp;' |n %>
56     </td>
57     <td class="date"><% $transdate|n %></td>
58 % my $desc = $Transaction->BriefDescription;
59 % $m->comp('/Elements/Callback', _CallbackName => 'ModifyDisplay', text => \$desc, Transaction => $Transaction, %ARGS);
60     <td class="description">
61       <%$Transaction->CreatorObj->Name%> - <%$TicketString%> <%$desc%>
62     </td>
63     <td class="time-taken"><%$TimeTaken%></td>
64     <td class="actions"><%$titlebar_commands|n%></td>
65   </tr>
66
67   <tr>
68     <td colspan="4" class="content">
69 % if ($Transaction->CustomFieldValues->Count) {
70       <& /Elements/ShowCustomFields, Object => $Transaction &>
71 % }
72 % $m->comp('ShowTransactionAttachments', %ARGS, Parent => 0) unless ($Collapsed ||!$ShowBody);
73     </td>
74   </tr>
75
76 </table>
77 </div>
78
79 <%ARGS>
80 $Ticket => undef
81 $Transaction => undef
82 $ShowHeaders => 0
83 $Collapsed => undef
84 $ShowTitleBarCommands => 1
85 $RowNum => 1
86 $DisplayPath => $RT::WebPath."/Ticket/Display.html?id=".$Ticket->id
87 $AttachPath => $RT::WebPath."/Ticket/Attachment"
88 $UpdatePath => $RT::WebPath."/Ticket/Update.html"
89 $EmailRecordPath => $RT::WebPath."/Ticket/ShowEmailRecord.html"
90 $Attachments => undef
91 $AttachmentContent => undef
92 $ShowBody => 1
93 $LastTransaction => 0
94 </%ARGS>
95
96 <%INIT>
97
98 my ( $TimeTaken, $TicketString, $type_class );
99
100 my $transdate = $Transaction->CreatedAsString();
101 $transdate =~ s/\s/&nbsp;/g;
102
103 if ( $Transaction->Type =~ /^(Create|Correspond|Comment$)/ ) {
104     if ( $Transaction->IsInbound ) {
105         $type_class = 'message';
106     }
107     else {
108         $type_class = 'message';
109     }
110 }
111 elsif (    ( $Transaction->Field =~ /^Owner$/ )
112         or ( $Transaction->Type =~ /^(AddWatcher|DelWatcher)$/ ) ) {
113     $type_class = 'people';
114
115 }
116 elsif ( $Transaction->Type =~ /^(AddLink|DeleteLink)$/ ) {
117     $type_class = 'links';
118 }
119 elsif ( $Transaction->Type =~ /^(Status|Set|Told)$/ ) {
120     if ( $Transaction->Field =~ /^(Told|Starts|Started|Due)$/ ) {
121         $type_class = 'dates';
122     }
123     else {
124         $type_class = 'basics';
125     }
126 }
127 else {
128     $type_class = 'other';
129 }
130
131 if ( $Ticket->Id != $Transaction->Ticket ) {
132     $TicketString = "Ticket " . $Transaction->Ticket . ": ";
133 }
134 $TicketString ||= '';
135
136 if ( $Transaction->TimeTaken != 0 ) {
137     $TimeTaken = $Transaction->TimeTaken . " min";
138 } else {
139     $TimeTaken = '';
140 }
141
142 unless ($Attachments) { 
143     my $attachments = $Transaction->Attachments;
144     $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
145     $Attachments = $attachments->ItemsArrayRef();
146 }
147 my $titlebar_commands = '&nbsp;';
148
149 my @DisplayHeaders=qw ( _all);
150
151 if ( $Transaction->Type =~ /EmailRecord$/ ) {
152     @DisplayHeaders = qw(To Cc Bcc);
153
154     $titlebar_commands .=
155         "[<a target=\"_blank\" href=\"$EmailRecordPath?id="
156       . $Transaction->Ticket
157       . "&Transaction="
158       . $Transaction->Id
159       . "&Attachment="
160       . ( $Attachments->[0] && $Attachments->[0]->id )
161       . '">' . loc('Show') . "</a>]&nbsp;";
162     $ShowBody = 0;
163 }
164
165
166 # If the transaction has anything attached to it at all
167 else {
168
169     unless ( $ShowHeaders ) {
170         @DisplayHeaders = qw(To From RT-Send-Cc Cc Bcc Date Subject);
171     }
172
173     if ( $Attachments->[0] && $ShowTitleBarCommands ) {
174         if ( $Transaction->TicketObj->CurrentUserHasRight('ReplyToTicket')
175              or $Transaction->TicketObj->CurrentUserHasRight('ModifyTicket')) {
176             $titlebar_commands .=
177                 "[<a href=\"".$UpdatePath."?id="
178               . $Transaction->Ticket
179               . "&QuoteTransaction="
180               . $Transaction->Id
181               . "&Action=Respond\">"
182               . loc('Reply')
183               . "</a>]&nbsp;";
184         }
185         if ( $Transaction->TicketObj->CurrentUserHasRight('CommentOnTicket')
186              or $Transaction->TicketObj->CurrentUserHasRight('ModifyTicket')) {
187             $titlebar_commands .=
188                 "[<a href=\"".$UpdatePath."?id="
189               . $Transaction->Ticket
190               . "&QuoteTransaction="
191               . $Transaction->Id
192               . "&Action=Comment\">"
193               . loc('Comment') . "</a>]";
194         }
195     }
196 }
197 </%INIT>