rt 4.0.23
[freeside.git] / rt / share / html / Ticket / Elements / ShowTransaction
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2015 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 <div class="ticket-transaction">
51 % $m->callback( titlebar_cmd => \$titlebar_commands, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyCommand' );
52   <div class="metadata">
53     <span class="type">
54       <a name="txn-<% $Transaction->Id %>" href="<% $DisplayPath %>#txn-<% $Transaction->Id %>">#</a>\
55       <% $LastTransaction ? '<a id="lasttrans" name="lasttrans"></a>' : ''|n %>
56     </span>
57 % $m->callback( Transaction => $Transaction, %ARGS, CallbackName => 'AfterAnchor' );
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 % $m->callback( Transaction => $Transaction, %ARGS, CallbackName => 'AfterDescription' );
64 </span>
65 % $m->callback( TimeTaken => \$TimeTaken, Transaction => $Transaction, %ARGS, CallbackName => 'ModifyTimeTaken' );
66     <span class="time-taken"><% $TimeTaken %></span>\
67     <span class="actions<% $titlebar_commands ? '': ' hidden'%>"><% $titlebar_commands |n %></span>
68   </div>
69     <div class="content">
70 % if ( $type_class eq 'message' ) {
71       <& /Elements/ShowCustomFields, Object => $Transaction &>
72 % }
73 % $m->comp('ShowTransactionAttachments', %ARGS, Parent => 0) unless ($Collapsed ||!$ShowBody);
74     </div>
75 </div>
76 </div>
77 <%ARGS>
78 $Ticket => undef
79 $Transaction => undef
80 $ShowHeaders => 0
81 $Collapsed => undef
82 $ShowTitleBarCommands => 1
83 $RowNum => 1
84 $DisplayPath => RT->Config->Get('WebPath')."/Ticket/Display.html?id=".$Ticket->id
85 $AttachPath => RT->Config->Get('WebPath')."/Ticket/Attachment"
86 $UpdatePath => RT->Config->Get('WebPath')."/Ticket/Update.html"
87 $ForwardPath => RT->Config->Get('WebPath')."/Ticket/Forward.html"
88 $EncryptionPath => RT->Config->Get('WebPath')."/Ticket/GnuPG.html"
89 $EmailRecordPath => RT->Config->Get('WebPath')."/Ticket/ShowEmailRecord.html"
90 $Attachments => undef
91 $AttachmentContent => undef
92 $ShowBody => 1
93 $LastTransaction => 0
94 $WarnUnsigned => undef
95 </%ARGS>
96 <%ONCE>
97
98 my %class = (
99     Correspond => 'message',
100     Comment    => 'message',
101
102     AddWatcher => 'people',
103     DelWatcher => 'people',
104     Take       => 'people',
105     Untake     => 'people',
106     Force      => 'people',
107     Steal      => 'people',
108     Give       => 'people',
109
110     AddLink    => 'links',
111     DeleteLink => 'links',
112 );
113
114 </%ONCE>
115 <%INIT>
116
117 my $transdate = $Transaction->CreatedAsString();
118 $transdate =~ s/\s/&nbsp;/g;
119
120 my ($type, $field) = ($Transaction->Type, $Transaction->Field || '');
121 my $type_class = $class{ $type };
122 if ( $type eq 'Create' && $Transaction->ObjectType eq 'RT::Ticket' ) {
123     $type_class = 'message';
124 }
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 $m->callback(
144     CallbackName => 'MassageTypeClass',
145     Transaction  => $Transaction,
146     TypeClassRef => \$type_class,
147     ARGSRef      => \%ARGS,
148 );
149
150 my $TicketString = '';
151 if ( $Ticket->Id != $Transaction->Ticket ) {
152     $TicketString = loc("Ticket #[_1]:", $Transaction->Ticket) .' ';
153 }
154
155 my $TimeTaken = '';
156 $TimeTaken = $Transaction->TimeTaken . " min"
157     if $Transaction->TimeTaken;
158
159 unless ($Attachments) { 
160     my $attachments = $Transaction->Attachments;
161     $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
162     $ARGS{'Attachments'} = $Attachments = $attachments->ItemsArrayRef();
163 }
164 my $titlebar_commands = '';
165
166 $m->callback(
167     CallbackName   => 'MassageAttachments',
168     Transaction    => $Transaction,
169     AttachmentsRef => \$Attachments,
170     ARGSRef        => \%ARGS,
171 );
172
173 if ( $type =~ /EmailRecord$/ ) {
174
175     $titlebar_commands .=
176         "[<a target=\"_blank\" href=\"$EmailRecordPath?id="
177       . $Transaction->Ticket
178       . "&Transaction="
179       . $Transaction->Id
180       . "&Attachment="
181       . ( $Attachments->[0] && $Attachments->[0]->id )
182       . '">' . loc('Show') . "</a>]&nbsp;";
183     $ShowBody = 0;
184 }
185
186
187 # If the transaction has anything attached to it at all
188 else {
189
190     if ( $Attachments->[0] && $ShowTitleBarCommands ) {
191         my $ticket = $Transaction->TicketObj;
192         my $can_modify = $ticket->CurrentUserHasRight('ModifyTicket');
193         if ( $can_modify || $ticket->CurrentUserHasRight('ReplyToTicket') ) {
194             $titlebar_commands .=
195                 "[<a href=\"" . $UpdatePath
196               . "?id=" . $Transaction->Ticket
197               . "&QuoteTransaction=" . $Transaction->Id
198               . "&Action=Respond\" "
199               . "class=\"reply-link\""
200               . ">"
201               . loc('Reply')
202               . "</a>]&nbsp;";
203         }
204         if ( $can_modify || $ticket->CurrentUserHasRight('CommentOnTicket') ) {
205             $titlebar_commands .=
206                 "[<a href=\"" . $UpdatePath
207               . "?id=" . $Transaction->Ticket
208               . "&QuoteTransaction=" . $Transaction->Id
209               . "&Action=Comment\" "
210               . "class=\"comment-link\""
211               . ">"
212               . loc('Comment')
213               . "</a>]";
214         }
215         if ( $ticket->CurrentUserHasRight('ForwardMessage') ) {
216             $titlebar_commands .=
217                 "[<a href=\"" . $ForwardPath
218               . "?id=" . $Transaction->Ticket
219               . "&QuoteTransaction=" . $Transaction->Id ."\" "
220               . "class=\"forward-link\""
221               . ">"
222               . loc('Forward')
223               . "</a>]";
224         }
225         if ( $can_modify
226             && RT->Config->Get('GnuPG')->{'Enable'}
227             && RT->Config->Get('GnuPG')->{'AllowEncryptDataInDB'}
228             && $ticket->CurrentUserHasRight('ForwardMessage')
229         ) {
230             $titlebar_commands .=
231                 "[<a href=\"" . $EncryptionPath
232               . "?id=" . $Transaction->Id ."\" "
233               . "class=\"gpg-link\""
234               . ">"
235               . loc('Encrypt/Decrypt')
236               . "</a>]";
237         }
238     }
239 }
240 </%INIT>