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