import rt 3.8.7
[freeside.git] / rt / share / 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 %> <% $RowNum % 2 ? 'odd' : 'even' %>">
49 % $m->callback( titlebar_cmd => \$titlebar_commands, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyDisplay' );
50
51 <div class="ticket-transaction">
52 % $m->callback( titlebar_cmd => \$titlebar_commands, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyCommand' );
53   <div class="metadata">
54     <span class="type">
55       <a name="txn-<% $Transaction->Id %>" href="<% $DisplayPath %>#txn-<% $Transaction->Id %>">#</a>
56       <% $LastTransaction ? '<a id="lasttrans" name="lasttrans"></a>' : ''|n %>
57     </span>
58     <span class="date"><% $transdate|n %></span>
59 % my $desc = $Transaction->BriefDescription;
60 % $m->callback( text => \$desc, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyDisplay' );
61     <span class="description">
62       <& /Elements/ShowUser, User => $Transaction->CreatorObj &> - <% $TicketString %> <% $desc %>
63     </span>
64 % $m->callback( TimeTaken => \$TimeTaken, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyTimeTaken' );
65     <span class="time-taken"><% $TimeTaken %></span>
66     <span class="actions<% $titlebar_commands ? '': ' hidden'%>"><% $titlebar_commands |n %></span>
67   </div>
68
69     <div class="content">
70 % if ( $Transaction->CustomFieldValues->Count ) {
71       <& /Elements/ShowCustomFields, Object => $Transaction &>
72 % }
73 % $m->comp('ShowTransactionAttachments', %ARGS, Parent => 0) unless ($Collapsed ||!$ShowBody);
74     </div>
75
76 </div>
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->Config->Get('WebPath')."/Ticket/Display.html?id=".$Ticket->id
87 $AttachPath => RT->Config->Get('WebPath')."/Ticket/Attachment"
88 $UpdatePath => RT->Config->Get('WebPath')."/Ticket/Update.html"
89 $ForwardPath => RT->Config->Get('WebPath')."/Ticket/Forward.html"
90 $EncryptionPath => RT->Config->Get('WebPath')."/Ticket/GnuPG.html"
91 $EmailRecordPath => RT->Config->Get('WebPath')."/Ticket/ShowEmailRecord.html"
92 $Attachments => undef
93 $AttachmentContent => undef
94 $ShowBody => 1
95 $LastTransaction => 0
96 $WarnUnsigned => undef
97 </%ARGS>
98 <%ONCE>
99
100 my %class = (
101     Create     => 'message',
102     Correspond => 'message',
103     Comment    => 'message',
104
105     AddWatcher => 'people',
106     DelWatcher => 'people',
107     Take       => 'people',
108     Untake     => 'people',
109     Force      => 'people',
110     Steal      => 'people',
111     Give       => 'people',
112
113     AddLink    => 'links',
114     DeleteLink => 'links',
115 );
116
117 </%ONCE>
118 <%INIT>
119
120 my $transdate = $Transaction->CreatedAsString();
121 $transdate =~ s/\s/&nbsp;/g;
122
123 my ($type, $field) = ($Transaction->Type, $Transaction->Field || '');
124 my $type_class = $class{ $type };
125
126 unless ( $type_class ) {
127     if ( $field eq 'Owner' ) {
128         $type_class = 'people';
129     }
130     elsif ( $type =~ /^(Status|Set|Told)$/ ) {
131         if ( $field =~ /^(Told|Starts|Started|Due)$/ ) {
132             $type_class = 'dates';
133         }
134         else {
135             $type_class = 'basics';
136         }
137     }
138     else {
139         $type_class = 'other';
140     }
141 }
142
143 my $TicketString = '';
144 if ( $Ticket->Id != $Transaction->Ticket ) {
145     $TicketString = loc("Ticket #[_1]:", $Transaction->Ticket) .' ';
146 }
147
148 my $TimeTaken = '';
149 $TimeTaken = $Transaction->TimeTaken . " min"
150     if $Transaction->TimeTaken;
151
152 unless ($Attachments) { 
153     my $attachments = $Transaction->Attachments;
154     $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
155     $ARGS{'Attachments'} = $Attachments = $attachments->ItemsArrayRef();
156 }
157 my $titlebar_commands = '';
158
159 if ( $type =~ /EmailRecord$/ ) {
160
161     $titlebar_commands .=
162         "[<a target=\"_blank\" href=\"$EmailRecordPath?id="
163       . $Transaction->Ticket
164       . "&Transaction="
165       . $Transaction->Id
166       . "&Attachment="
167       . ( $Attachments->[0] && $Attachments->[0]->id )
168       . '">' . loc('Show') . "</a>]&nbsp;";
169     $ShowBody = 0;
170 }
171
172
173 # If the transaction has anything attached to it at all
174 else {
175
176     if ( $Attachments->[0] && $ShowTitleBarCommands ) {
177         my $ticket = $Transaction->TicketObj;
178         my $can_modify = $ticket->CurrentUserHasRight('ModifyTicket');
179         if ( $can_modify || $ticket->CurrentUserHasRight('ReplyToTicket') ) {
180             $titlebar_commands .=
181                 "[<a href=\"".$UpdatePath
182               . "?id=" . $Transaction->Ticket
183               . "&QuoteTransaction=" . $Transaction->Id
184               . "&Action=Respond\">"
185               . loc('Reply')
186               . "</a>]&nbsp;";
187         }
188         if ( $can_modify || $ticket->CurrentUserHasRight('CommentOnTicket') ) {
189             $titlebar_commands .=
190                 "[<a href=\"".$UpdatePath."?id="
191               . $Transaction->Ticket
192               . "&QuoteTransaction="
193               . $Transaction->Id
194               . "&Action=Comment\">"
195               . loc('Comment') . "</a>]";
196         }
197         if ( $ticket->CurrentUserHasRight('ForwardMessage') ) {
198             $titlebar_commands .=
199                 "[<a href=\"". $ForwardPath
200               . "?id=". $Transaction->Ticket
201               . "&QuoteTransaction=". $Transaction->Id
202               . "\">". loc('Forward') . "</a>]";
203         }
204         if ( $can_modify
205             && RT->Config->Get('GnuPG')->{'Enable'}
206             && RT->Config->Get('GnuPG')->{'AllowEncryptDataInDB'}
207             && $ticket->CurrentUserHasRight('ForwardMessage')
208         ) {
209             $titlebar_commands .=
210                 "[<a href=\"". $EncryptionPath
211               . "?id=". $Transaction->Id
212               . "\">". loc('Encrypt/Decrypt') . "</a>]";
213         }
214     }
215 }
216 </%INIT>