import rt 3.6.6
[freeside.git] / rt / html / Ticket / Elements / ShowTransaction
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2007 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/copyleft/gpl.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 <table width="100%" cellspacing="0" cellpadding="2" border="0">
50   <tr>
51     <td rowspan="2" valign="top" class="type">
52       <a name="txn-<%$Transaction->Id%>" href="<% $DisplayPath %>#txn-<%$Transaction->Id%>">#</a>
53       <% $LastTransaction ? '<a name="lasttrans">&nbsp;</a>' : '&nbsp;' |n %>
54     </td>
55     <td class="date"><% $transdate|n %></td>
56 % my $desc = $Transaction->BriefDescription;
57 % $m->comp('/Elements/Callback', _CallbackName => 'ModifyDisplay', text => \$desc, Transaction => $Transaction, %ARGS);
58     <td class="description">
59       <%$Transaction->CreatorObj->Name%> - <%$TicketString%> <%$desc%>
60     </td>
61     <td class="time-taken"><%$TimeTaken%></td>
62     <td class="actions"><%$titlebar_commands|n%></td>
63   </tr>
64
65   <tr>
66     <td colspan="4" class="content">
67 % if ($Transaction->CustomFieldValues->Count) {
68       <& /Elements/ShowCustomFields, Object => $Transaction &>
69 % }
70 % $m->comp('ShowTransactionAttachments', %ARGS, Parent => 0) unless ($Collapsed ||!$ShowBody);
71     </td>
72   </tr>
73 </table>
74 </div>
75
76 <%ARGS>
77 $Ticket => undef
78 $Transaction => undef
79 $ShowHeaders => 0
80 $Collapsed => undef
81 $ShowTitleBarCommands => 1
82 $RowNum => 1
83 $DisplayPath => $RT::WebPath."/Ticket/Display.html?id=".$Ticket->id
84 $AttachPath => $RT::WebPath."/Ticket/Attachment"
85 $UpdatePath => $RT::WebPath."/Ticket/Update.html"
86 $EmailRecordPath => $RT::WebPath."/Ticket/ShowEmailRecord.html"
87 $Attachments => undef
88 $AttachmentContent => undef
89 $ShowBody => 1
90 $LastTransaction => 0
91 </%ARGS>
92
93 <%INIT>
94
95 my ( $TimeTaken, $TicketString, $type_class );
96
97 my $transdate = $Transaction->CreatedAsString();
98 $transdate =~ s/\s/&nbsp;/g;
99
100 if ( $Transaction->Type =~ /^(Create|Correspond|Comment$)/ ) {
101     if ( $Transaction->IsInbound ) {
102         $type_class = 'message';
103     }
104     else {
105         $type_class = 'message';
106     }
107 }
108 elsif (    ( $Transaction->Field =~ /^Owner$/ )
109         or ( $Transaction->Type =~ /^(AddWatcher|DelWatcher)$/ ) ) {
110     $type_class = 'people';
111
112 }
113 elsif ( $Transaction->Type =~ /^(AddLink|DeleteLink)$/ ) {
114     $type_class = 'links';
115 }
116 elsif ( $Transaction->Type =~ /^(Status|Set|Told)$/ ) {
117     if ( $Transaction->Field =~ /^(Told|Starts|Started|Due)$/ ) {
118         $type_class = 'dates';
119     }
120     else {
121         $type_class = 'basics';
122     }
123 }
124 else {
125     $type_class = 'other';
126 }
127
128 if ( $Ticket->Id != $Transaction->Ticket ) {
129     $TicketString = "Ticket " . $Transaction->Ticket . ": ";
130 }
131 $TicketString ||= '';
132
133 if ( $Transaction->TimeTaken != 0 ) {
134     $TimeTaken = $Transaction->TimeTaken . " min";
135 } else {
136     $TimeTaken = '';
137 }
138
139 unless ($Attachments) { 
140     my $attachments = $Transaction->Attachments;
141     $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
142     $Attachments = $attachments->ItemsArrayRef();
143 }
144 my $titlebar_commands = '&nbsp;';
145
146 my @DisplayHeaders=qw ( _all);
147
148 if ( $Transaction->Type =~ /EmailRecord$/ ) {
149     @DisplayHeaders = qw(To Cc Bcc);
150
151     $titlebar_commands .=
152         "[<a target=\"_blank\" href=\"$EmailRecordPath?id="
153       . $Transaction->Ticket
154       . "&Transaction="
155       . $Transaction->Id
156       . "&Attachment="
157       . ( $Attachments->[0] && $Attachments->[0]->id )
158       . '">' . loc('Show') . "</a>]&nbsp;";
159     $ShowBody = 0;
160 }
161
162
163 # If the transaction has anything attached to it at all
164 else {
165
166     unless ( $ShowHeaders ) {
167         @DisplayHeaders = qw(To From RT-Send-Cc Cc Bcc Date Subject);
168     }
169
170     if ( $Attachments->[0] && $ShowTitleBarCommands ) {
171         if ( $Transaction->TicketObj->CurrentUserHasRight('ReplyToTicket')
172              or $Transaction->TicketObj->CurrentUserHasRight('ModifyTicket')) {
173             $titlebar_commands .=
174                 "[<a href=\"".$UpdatePath."?id="
175               . $Transaction->Ticket
176               . "&QuoteTransaction="
177               . $Transaction->Id
178               . "&Action=Respond\">"
179               . loc('Reply')
180               . "</a>]&nbsp;";
181         }
182         if ( $Transaction->TicketObj->CurrentUserHasRight('CommentOnTicket')
183              or $Transaction->TicketObj->CurrentUserHasRight('ModifyTicket')) {
184             $titlebar_commands .=
185                 "[<a href=\"".$UpdatePath."?id="
186               . $Transaction->Ticket
187               . "&QuoteTransaction="
188               . $Transaction->Id
189               . "&Action=Comment\">"
190               . loc('Comment') . "</a>]";
191         }
192     }
193 }
194 </%INIT>