Upgrade to 4.0.13
[usit-rt.git] / share / html / m / ticket / show
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
403d7b0b 5%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
84fb5b46
MKG
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<%args>
49$id => undef
50</%args>
51<%init>
52my $Ticket;
53my @Actions;
54
55unless ($id) {
56 Abort('No ticket specified');
57}
58
59if ($ARGS{'id'} eq 'new') {
60 # {{{ Create a new ticket
61
62 my $Queue = RT::Queue->new( $session{'CurrentUser'} );
63 $Queue->Load($ARGS{'Queue'});
64 unless ( $Queue->id ) {
65 Abort('Queue not found');
66 }
67
68 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
69 Abort('You have no permission to create tickets in that queue.');
70 }
71
72 ($Ticket, @Actions) = CreateTicket(
73 Attachments => delete $session{'Attachments'},
74 %ARGS,
75 );
76 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
77 Abort("No permission to view newly created ticket #".$Ticket->id.".");
78 }
79} else {
80 $Ticket ||= LoadTicket($ARGS{'id'});
81
82 $m->callback( CallbackName => 'BeforeProcessArguments',
83 TicketObj => $Ticket,
84 ActionsRef => \@Actions, ARGSRef => \%ARGS );
85 if ( defined $ARGS{'Action'} ) {
86 if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) {
87 my $action = $1;
88 my ($res, $msg) = $Ticket->$action();
89 push(@Actions, $msg);
90 }
91 }
92
93 $m->callback(CallbackName => 'ProcessArguments',
94 Ticket => $Ticket,
95 ARGSRef => \%ARGS,
96 Actions => \@Actions);
97
98 $ARGS{UpdateAttachments} = $session{'Attachments'};
99 push @Actions,
100 ProcessUpdateMessage(
101 ARGSRef => \%ARGS,
102 Actions => \@Actions,
103 TicketObj => $Ticket,
104 );
105 delete $session{'Attachments'};
106
107 #Process status updates
108 push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket );
109 push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $Ticket );
110 push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $Ticket );
111 push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $Ticket );
112 push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket );
113 push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $Ticket );
114
84fb5b46 115 unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
403d7b0b
MKG
116 if (@Actions) {
117 Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions);
118 } else {
119 Abort("No permission to view ticket");
120 }
84fb5b46
MKG
121 }
122 if ( $ARGS{'MarkAsSeen'} ) {
123 $Ticket->SetAttribute(
124 Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
125 Content => $Ticket->LastUpdated,
126 );
127 push @Actions, loc('Marked all messages as seen');
128 }
129}
130
131$m->callback(
132 CallbackName => 'BeforeDisplay',
133 TicketObj => \$Ticket,
134 Actions => \@Actions,
135 ARGSRef => \%ARGS,
136);
137
138# This code does automatic redirection if any updates happen.
139
140if (@Actions) {
141
142 # We've done something, so we need to clear the decks to avoid
143 # resubmission on refresh.
144 # But we need to store Actions somewhere too, so we don't lose them.
145 my $key = Digest::MD5::md5_hex( rand(1024) );
146 push @{ $session{"Actions"}->{$key} ||= [] }, @Actions;
147 $session{'i'}++;
148 my $url = RT->Config->Get('WebURL') . "m/ticket/show?id=" . $Ticket->id . "&results=" . $key;
149 $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor};
150 RT::Interface::Web::Redirect($url);
151}
152
153# If we haven't been passed in an Attachments object (through the precaching mechanism)
154# then we need to find one
155my $Attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
156
157my %documents;
158while ( my $attach = $Attachments->Next() ) {
159 next unless ($attach->Filename());
160 unshift( @{ $documents{ $attach->Filename } }, $attach );
161}
162
163my $CustomFields = $Ticket->CustomFields;
164$m->callback(
165 CallbackName => 'MassageCustomFields',
166 Object => $Ticket,
167 CustomFields => $CustomFields,
168);
169
170my $print_value = sub {
171 my ($cf, $value) = @_;
172 my $linked = $value->LinkValueTo;
173 if ( defined $linked && length $linked ) {
174 my $linked = $m->interp->apply_escapes( $linked, 'h' );
175 $m->out('<a href="'. $linked .'" target="_new">');
176 }
177 my $comp = "ShowCustomField". $cf->Type;
178 $m->callback(
179 CallbackName => 'ShowComponentName',
180 Name => \$comp,
181 CustomField => $cf,
182 Object => $Ticket,
183 );
184 if ( $m->comp_exists( $comp ) ) {
185 $m->comp( $comp, Object => $value );
186 } else {
187 $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
188 }
189 $m->out('</a>') if defined $linked && length $linked;
190
191 # This section automatically populates a div with the "IncludeContentForValue" for this custom
192 # field if it's been defined
193 if ( $cf->IncludeContentForValue ) {
194 my $vid = $value->id;
195 $m->out( '<div class="object_cf_value_include" id="object_cf_value_'. $vid .'">' );
196 $m->print( loc("See also:") );
197 $m->out( '<a href="'. $m->interp->apply_escapes($value->IncludeContentForValue, 'h') .'">' );
198 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') );
199 $m->out( qq{</a></div>\n} );
200 $m->out( qq{<script><!--\njQuery('#object_cf_value_$vid').load(} );
201 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'j') );
202 $m->out( qq{);\n--></script>\n} );
203 }
204};
205
206</%init>
207<&| /m/_elements/wrapper, title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject || '') &>
208<div id="ticket-show">
209<& /m/_elements/ticket_menu, ticket => $Ticket &>
210
211 <&| /Widgets/TitleBox, title => loc('The Basics'),
212 class => 'ticket-info-basics',
213 &>
214
215
216 <div class="entry">
217 <div class="label id"><&|/l&>Id</&>:</div>
218 <div class="value id"><%$Ticket->Id %></div>
219 </div>
220 <div class="entry">
221 <div class="label status"><&|/l&>Status</&>:</div>
222 <div class="value status"><% loc($Ticket->Status) %></div>
223 </div>
224% if ($Ticket->TimeEstimated) {
225 <div class="entry">
226 <div class="label time estimated"><&|/l&>Estimated</&>:</div>
227 <div class="value time estimated"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &></div>
228 </div>
229% }
230% if ($Ticket->TimeWorked) {
231 <div class="entry">
232 <div class="label time worked"><&|/l&>Worked</&>:</div>
233 <div class="value time worked"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeWorked &></div>
234 </div>
235% }
236% if ($Ticket->TimeLeft) {
237 <div class="entry">
238 <div class="label time left"><&|/l&>Left</&>:</div>
239 <div class="value time left"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeLeft &></div>
240 </div>
241% }
242 <div class="entry">
243 <div class="label priority"><&|/l&>Priority</&>:</div>
244 <div class="value priority"><& /Ticket/Elements/ShowPriority, Ticket => $Ticket &></div>
245 </div>
246 <div class="entry">
247 <div class="label queue"><&|/l&>Queue</&>:</div>
248 <div class="value queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &></div>
249 </div>
403d7b0b
MKG
250 <div class="entry">
251 <div class="label bookmark"><&|/l&>Bookmark</&>:</div>
252 <div class="value bookmark"><& /Ticket/Elements/Bookmark, id => $Ticket->id &></div>
253 </div>
84fb5b46
MKG
254 </&>
255
256% if ($Ticket->CustomFields->First) {
257 <&| /Widgets/TitleBox, title => loc('Custom Fields'),
258 class => 'ticket-info-cfs',
259 &>
260
261% while ( my $CustomField = $CustomFields->Next ) {
262% my $Values = $Ticket->CustomFieldValues( $CustomField->Id );
263% my $count = $Values->Count;
264 <div class="entry" id="CF-<%$CustomField->id%>-ShowRow">
265 <div class="label"><% $CustomField->Name %>:</div>
266 <div class="value">
267% unless ( $count ) {
268<i><&|/l&>(no value)</&></i>
269% } elsif ( $count == 1 ) {
270% $print_value->( $CustomField, $Values->First );
271% } else {
272<ul>
273% while ( my $Value = $Values->Next ) {
274<li>
275% $print_value->( $CustomField, $Value );
276</li>
277% }
278</ul>
279% }
280 </div>
281 </div>
282% }
283
284</&>
285% }
286
287 <&| /Widgets/TitleBox, title => loc('People'), class => 'ticket-info-people' &>
288
289
290 <div class="entry">
291 <div class="label"><&|/l&>Owner</&>:</div>
292 <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket &>
293 </div>
294 </div>
295 <div class="entry">
296 <div class="label"><&|/l&>Requestors</&>:</div>
297 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket &></div>
298 </div>
299 <div class="entry">
300 <div class="label"><&|/l&>Cc</&>:</div>
301 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket &></div>
302 </div>
303 <div class="entry">
304 <div class="label"><&|/l&>AdminCc</&>:</div>
305 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket &></div>
306 </div>
307
308 </&>
309
310% if (keys %documents) {
311<&| /Widgets/TitleBox, title => loc('Attachments'),
312 title_class=> 'inverse',
313 class => 'ticket-info-attachments',
314 color => "#336699" &>
315
316% foreach my $key (keys %documents) {
317
318<%$key%><br />
319<ul>
320% foreach my $rev (@{$documents{$key}}) {
321
322<%PERL>
323my $size = $rev->ContentLength;
324
325if ($size) {
326 my $kb = int($size/102.4) / 10;
327 my $units = RT->Config->Get('AttachmentUnits');
328
329 if (!defined($units)) {
330 if ($size > 1024) {
331 $size = $kb . "k";
332 }
333 else {
334 $size = $size . "b";
335 }
336 }
337 elsif ($units eq 'k') {
338 $size = $kb . "k";
339 }
340 else {
341 $size = $size . "b";
342 }
343
344</%PERL>
345
346<li><font size="-2">
5b0d0914 347<a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | un%>">
84fb5b46
MKG
348<&|/l, $rev->CreatedAsString, $size, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&>
349</a>
350</font></li>
351% }
352% }
353</ul>
354
355% }
356</&>
357
358% }
359% # too painful to deal with reminders
360% if ( 0 && RT->Config->Get('EnableReminders') ) {
361 <&|/Widgets/TitleBox, title => loc("Reminders"),
362 class => 'ticket-info-reminders',
363 &>
364 <div class="entry"><div
365 <form action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
366 <& /Ticket/Elements/Reminders, Ticket => $Ticket, ShowCompleted => 0 &>
367 <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
368 </form>
369 </div></div>
370 </&>
371% }
372
373 <&| /Widgets/TitleBox, title => loc("Dates"),
374 class => 'ticket-info-dates',
375 &>
376
377
378 <div class="entry">
379 <div class="label date created"><&|/l&>Created</&>:</div>
380 <div class="value date created"><% $Ticket->CreatedObj->AsString %></div>
381 </div>
382 <div class="entry">
383 <div class="label date starts"><&|/l&>Starts</&>:</div>
384 <div class="value date starts"><% $Ticket->StartsObj->AsString %></div>
385 </div>
386 <div class="entry">
387 <div class="label date started"><&|/l&>Started</&>:</div>
388 <div class="value date started"><% $Ticket->StartedObj->AsString %></div>
389 </div>
390 <div class="entry">
391 <div class="label date told"><&|/l&>Last Contact</&>:</div>
392 <div class="value date told"><% $Ticket->ToldObj->AsString %></div>
393 </div>
394 <div class="entry">
395 <div class="label date due"><&|/l&>Due</&>:</div>
396% my $due = $Ticket->DueObj;
397% if ( $due && $due->Unix > 0 && $due->Diff < 0 ) {
398 <div class="value date due"><span class="overdue"><% $due->AsString %></span></div>
399% } else {
400 <div class="value date due"><% $due->AsString %></div>
401% }
402 </div>
403 <div class="entry">
404 <div class="label date resolved"><&|/l&>Closed</&>:</div>
405 <div class="value date resolved"><% $Ticket->ResolvedObj->AsString %></div>
406 </div>
407 <div class="entry">
408 <div class="label date updated"><&|/l&>Updated</&>:</div>
409% my $UpdatedString = $Ticket->LastUpdated ? loc("[_1] by [_2]", $Ticket->LastUpdatedAsString, $Ticket->LastUpdatedByObj->Name) : loc("Never");
410 <div class="value date updated"><% $UpdatedString | h %></div>
411 </div>
412
413 </&>
414
415 <&| /Widgets/TitleBox, title => loc('Links'), class => 'ticket-info-links' &>
416
417 <div class="entry">
418 <div class="label"><% loc('Depends on')%>:</div>
419 <div class="value">
420
421<%PERL>
422my ( @active, @inactive, @not_tickets );
423for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
424 my $target = $link->TargetObj;
425 if ( $target && $target->isa('RT::Ticket') ) {
426 if ( $target->QueueObj->IsInactiveStatus( $target->Status ) ) {
427 push( @inactive, $link->TargetURI );
428 }
429 else {
430 push( @active, $link->TargetURI );
431 }
432 }
433 else {
434 push( @not_tickets, $link->TargetURI );
435 }
436}
437</%PERL>
438
439
440<ul>
441% for my $Link (@not_tickets, @active, @inactive) {
442<li><& /Elements/ShowLink, URI => $Link &></li>
443% }
444</ul>
445 </div>
446 </div>
447 <div class="entry">
448 <div class="label"><% loc('Depended on by')%>:</div>
449 <div class="value">
450<ul>
451% while (my $Link = $Ticket->DependedOnBy->Next) {
452<li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
453% }
454</ul>
455 </div>
456 </div>
457 <div class="entry">
458 <div class="label"><% loc('Parents') %>:</div>
459 <div class="value"><& /Ticket/Elements/ShowParents, Ticket => $Ticket &></div>
460 </div>
461 <div class="entry">
462 <div class="label"><% loc('Children')%>:</div>
463 <div class="value"><& /Ticket/Elements/ShowMembers, Ticket => $Ticket &></div>
464 </div>
465 <div class="entry">
466 <div class="label"><% loc('Refers to')%>:</div>
467 <div class="value">
468<ul>
469% while (my $Link = $Ticket->RefersTo->Next) {
470<li><& /Elements/ShowLink, URI => $Link->TargetURI &></li>
471% }
472</ul>
473 </div>
474 </div>
475 <div class="entry">
476 <div class="label"><% loc('Referred to by')%>:</div>
477 <div class="value">
478 <ul>
479% while (my $Link = $Ticket->ReferredToBy->Next) {
480% next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket') && $Link->BaseObj->Type eq 'reminder');
481<li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
482% }
483</ul>
484 </div>
485 </div>
486 </&>
487</div>
488</&>