1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
56 Abort('No ticket specified');
59 if ($ARGS{'id'} eq 'new') {
60 # {{{ Create a new ticket
62 my $Queue = RT::Queue->new( $session{'CurrentUser'} );
63 $Queue->Load($ARGS{'Queue'});
64 unless ( $Queue->id ) {
65 Abort('Queue not found');
68 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
69 Abort('You have no permission to create tickets in that queue.');
72 ($Ticket, @Actions) = CreateTicket( %ARGS );
73 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
74 Abort("No permission to view newly created ticket #".$Ticket->id.".");
77 $Ticket ||= LoadTicket($ARGS{'id'});
79 $m->callback( CallbackName => 'BeforeProcessArguments',
81 ActionsRef => \@Actions, ARGSRef => \%ARGS );
82 if ( defined $ARGS{'Action'} ) {
83 if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) {
85 my ($res, $msg) = $Ticket->$action();
90 $m->callback(CallbackName => 'ProcessArguments',
93 Actions => \@Actions);
102 #Process status updates
103 push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket );
104 push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $Ticket );
105 push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $Ticket );
106 push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $Ticket );
107 push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket );
108 push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $Ticket );
110 unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
112 Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions);
114 Abort("No permission to view ticket");
117 if ( $ARGS{'MarkAsSeen'} ) {
118 $Ticket->SetAttribute(
119 Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
120 Content => $Ticket->LastUpdated,
122 push @Actions, loc('Marked all messages as seen');
127 CallbackName => 'BeforeDisplay',
128 TicketObj => \$Ticket,
129 Actions => \@Actions,
133 # This code does automatic redirection if any updates happen.
137 # We've done something, so we need to clear the decks to avoid
138 # resubmission on refresh.
139 # But we need to store Actions somewhere too, so we don't lose them.
140 my $key = Digest::MD5::md5_hex( rand(1024) );
141 push @{ $session{"Actions"}->{$key} ||= [] }, @Actions;
143 my $url = RT->Config->Get('WebURL') . "m/ticket/show?id=" . $Ticket->id . "&results=" . $key;
144 $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor};
145 RT::Interface::Web::Redirect($url);
148 # If we haven't been passed in an Attachments object (through the precaching mechanism)
149 # then we need to find one
150 my $Attachments = $Ticket->Attachments;
153 while ( my $attach = $Attachments->Next() ) {
154 next unless ($attach->Filename());
155 unshift( @{ $documents{ $attach->Filename } }, $attach );
158 my $CustomFields = $Ticket->CustomFields;
160 CallbackName => 'MassageCustomFields',
162 CustomFields => $CustomFields,
165 my $print_value = sub {
166 my ($cf, $value) = @_;
167 my $linked = $value->LinkValueTo;
168 if ( defined $linked && length $linked ) {
169 my $linked = $m->interp->apply_escapes( $linked, 'h' );
170 $m->out('<a href="'. $linked .'" target="_blank">');
172 my $comp = "ShowCustomField". $cf->Type;
174 CallbackName => 'ShowComponentName',
179 if ( $m->comp_exists( $comp ) ) {
180 $m->comp( $comp, Object => $value );
182 $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
184 $m->out('</a>') if defined $linked && length $linked;
186 # This section automatically populates a div with the "IncludeContentForValue" for this custom
187 # field if it's been defined
188 if ( $cf->IncludeContentForValue ) {
189 my $vid = $value->id;
190 $m->out( '<div class="object_cf_value_include" id="object_cf_value_'. $vid .'">' );
191 $m->print( loc("See also:") );
192 $m->out( '<a href="'. $m->interp->apply_escapes($value->IncludeContentForValue, 'h') .'">' );
193 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') );
194 $m->out( qq{</a></div>\n} );
195 $m->out( qq{<script><!--\njQuery('#object_cf_value_$vid').load(} );
196 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'j') );
197 $m->out( qq{);\n--></script>\n} );
202 <&| /m/_elements/wrapper, title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject || '') &>
203 <div id="ticket-show">
204 <& /m/_elements/ticket_menu, ticket => $Ticket &>
206 <&| /Widgets/TitleBox, title => loc('The Basics'),
207 class => 'ticket-info-basics',
212 <div class="label id"><&|/l&>Id</&>:</div>
213 <div class="value id"><%$Ticket->Id %></div>
216 <div class="label status"><&|/l&>Status</&>:</div>
217 <div class="value status"><% loc($Ticket->Status) %></div>
219 % if ($Ticket->TimeEstimated) {
221 <div class="label time estimated"><&|/l&>Estimated</&>:</div>
222 <div class="value time estimated"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &></div>
225 % if ($Ticket->TimeWorked) {
227 <div class="label time worked"><&|/l&>Worked</&>:</div>
228 <div class="value time worked"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeWorked &></div>
231 % if ($Ticket->TimeLeft) {
233 <div class="label time left"><&|/l&>Left</&>:</div>
234 <div class="value time left"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeLeft &></div>
238 <div class="label priority"><&|/l&>Priority</&>:</div>
239 <div class="value priority"><& /Ticket/Elements/ShowPriority, Ticket => $Ticket &></div>
242 <div class="label queue"><&|/l&>Queue</&>:</div>
243 <div class="value queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &></div>
246 <div class="label bookmark"><&|/l&>Bookmark</&>:</div>
247 <div class="value bookmark"><& /Ticket/Elements/Bookmark, id => $Ticket->id &></div>
251 % if ($CustomFields->Count) {
252 <&| /Widgets/TitleBox, title => loc('Custom Fields'),
253 class => 'ticket-info-cfs',
256 % while ( my $CustomField = $CustomFields->Next ) {
257 % my $Values = $Ticket->CustomFieldValues( $CustomField->Id );
258 % my $count = $Values->Count;
259 <div class="entry" id="CF-<%$CustomField->id%>-ShowRow">
260 <div class="label"><% $CustomField->Name %>:</div>
262 % unless ( $count ) {
263 <i><&|/l&>(no value)</&></i>
264 % } elsif ( $count == 1 ) {
265 % $print_value->( $CustomField, $Values->First );
268 % while ( my $Value = $Values->Next ) {
270 % $print_value->( $CustomField, $Value );
282 <&| /Widgets/TitleBox, title => loc('People'), class => 'ticket-info-people' &>
286 <div class="label"><&|/l&>Owner</&>:</div>
287 <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket, Link => 0 &>
291 <div class="label"><&|/l&>Requestors</&>:</div>
292 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket, Link => 0 &></div>
295 <div class="label"><&|/l&>Cc</&>:</div>
296 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket, Link => 0 &></div>
299 <div class="label"><&|/l&>AdminCc</&>:</div>
300 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket, Link => 0 &></div>
305 % if (keys %documents) {
306 <&| /Widgets/TitleBox, title => loc('Attachments'),
307 title_class=> 'inverse',
308 class => 'ticket-info-attachments',
309 color => "#336699" &>
311 % foreach my $key (keys %documents) {
315 % foreach my $rev (@{$documents{$key}}) {
316 % if ($rev->ContentLength) {
318 <a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | un %>">
319 <&|/l, $rev->CreatedAsString, $rev->FriendlyContentLength, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&>
330 % # too painful to deal with reminders
331 % if ( 0 && RT->Config->Get('EnableReminders') ) {
332 <&|/Widgets/TitleBox, title => loc("Reminders"),
333 class => 'ticket-info-reminders',
335 <div class="entry"><div
336 <form action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
337 <& /Ticket/Elements/Reminders, Ticket => $Ticket, ShowCompleted => 0 &>
338 <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
344 <&| /Widgets/TitleBox, title => loc("Dates"),
345 class => 'ticket-info-dates',
350 <div class="label date created"><&|/l&>Created</&>:</div>
351 <div class="value date created"><% $Ticket->CreatedObj->AsString %></div>
354 <div class="label date starts"><&|/l&>Starts</&>:</div>
355 <div class="value date starts"><% $Ticket->StartsObj->AsString %></div>
358 <div class="label date started"><&|/l&>Started</&>:</div>
359 <div class="value date started"><% $Ticket->StartedObj->AsString %></div>
362 <div class="label date told"><&|/l&>Last Contact</&>:</div>
363 <div class="value date told"><% $Ticket->ToldObj->AsString %></div>
366 <div class="label date due"><&|/l&>Due</&>:</div>
367 % my $due = $Ticket->DueObj;
368 % if ( $due && $due->IsSet && $due->Diff < 0 && $Ticket->QueueObj->IsActiveStatus($Ticket->Status) ) {
369 <div class="value date due"><span class="overdue"><% $due->AsString %></span></div>
371 <div class="value date due"><% $due->AsString %></div>
375 <div class="label date resolved"><&|/l&>Closed</&>:</div>
376 <div class="value date resolved"><% $Ticket->ResolvedObj->AsString %></div>
379 <div class="label date updated"><&|/l&>Updated</&>:</div>
380 % my $UpdatedString = $Ticket->LastUpdated ? loc("[_1] by [_2]", $Ticket->LastUpdatedAsString, $Ticket->LastUpdatedByObj->Name) : loc("Never");
381 <div class="value date updated"><% $UpdatedString | h %></div>
386 <&| /Widgets/TitleBox, title => loc('Links'), class => 'ticket-info-links' &>
389 <div class="label"><% loc('Depends on')%>:</div>
393 my ( @active, @inactive, @not_tickets );
394 for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
395 my $target = $link->TargetObj;
396 if ( $target && $target->isa('RT::Ticket') ) {
397 if ( $target->QueueObj->IsInactiveStatus( $target->Status ) ) {
398 push( @inactive, $link->TargetURI );
401 push( @active, $link->TargetURI );
405 push( @not_tickets, $link->TargetURI );
412 % for my $Link (@not_tickets, @active, @inactive) {
413 <li><& /Elements/ShowLink, URI => $Link &></li>
419 <div class="label"><% loc('Depended on by')%>:</div>
422 % while (my $Link = $Ticket->DependedOnBy->Next) {
423 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
429 <div class="label"><% loc('Parents') %>:</div>
430 <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'MemberOf' &></div>
433 <div class="label"><% loc('Children')%>:</div>
434 <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'Members' &></div>
437 <div class="label"><% loc('Refers to')%>:</div>
440 % while (my $Link = $Ticket->RefersTo->Next) {
441 <li><& /Elements/ShowLink, URI => $Link->TargetURI &></li>
447 <div class="label"><% loc('Referred to by')%>:</div>
450 % while (my $Link = $Ticket->ReferredToBy->Next) {
451 % next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket') && $Link->BaseObj->__Value('Type') eq 'reminder');
452 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>