summaryrefslogtreecommitdiff
path: root/rt/share/html/m/ticket/show
blob: 4d60043e0d253ffa2343a48b2eb43887167cee4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
%# BEGIN BPS TAGGED BLOCK {{{
%#
%# COPYRIGHT:
%#
%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
%#                                          <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
%#
%#
%# LICENSE:
%#
%# This work is made available to you under the terms of Version 2 of
%# the GNU General Public License. A copy of that license should have
%# been provided with this software, but in any event can be snarfed
%# from www.gnu.org.
%#
%# This work is distributed in the hope that it will be useful, but
%# WITHOUT ANY WARRANTY; without even the implied warranty of
%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%# General Public License for more details.
%#
%# You should have received a copy of the GNU General Public License
%# along with this program; if not, write to the Free Software
%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
%# 02110-1301 or visit their web page on the internet at
%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
%#
%#
%# CONTRIBUTION SUBMISSION POLICY:
%#
%# (The following paragraph is not intended to limit the rights granted
%# to you to modify and distribute this software under the terms of
%# the GNU General Public License and is only of importance to you if
%# you choose to contribute your changes and enhancements to the
%# community by submitting them to Best Practical Solutions, LLC.)
%#
%# By intentionally submitting any modifications, corrections or
%# derivatives to this work, or any other work intended for use with
%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
%# you are the copyright holder for those contributions and you grant
%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
%# royalty-free, perpetual, license to use, copy, create derivative
%# works based on those contributions, and sublicense and distribute
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
<%args>
$id => undef
</%args>
<%init>
my $Ticket;
my @Actions; 

unless ($id) {
    Abort('No ticket specified');
}

if ($ARGS{'id'} eq 'new') {
    # {{{ Create a new ticket

    my $Queue = RT::Queue->new( $session{'CurrentUser'} );
    $Queue->Load($ARGS{'Queue'});
    unless ( $Queue->id ) {
        Abort('Queue not found');
    }

    unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
        Abort('You have no permission to create tickets in that queue.');
    }

    ($Ticket, @Actions) = CreateTicket( %ARGS );
    unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
        Abort("No permission to view newly created ticket #".$Ticket->id.".");
    }
} else { 
    $Ticket ||= LoadTicket($ARGS{'id'});

    $m->callback( CallbackName => 'BeforeProcessArguments',
        TicketObj => $Ticket,
        ActionsRef => \@Actions, ARGSRef => \%ARGS );
    if ( defined $ARGS{'Action'} ) {
        if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) {
            my $action = $1;
            my ($res, $msg) = $Ticket->$action();
            push(@Actions, $msg);
        }
    }

    $m->callback(CallbackName => 'ProcessArguments', 
            Ticket => $Ticket, 
            ARGSRef => \%ARGS, 
            Actions => \@Actions);
    
    push @Actions,
        ProcessUpdateMessage(
        ARGSRef   => \%ARGS,
        Actions   => \@Actions,
        TicketObj => $Ticket,
        );

    #Process status updates
    push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket );
    push @Actions, ProcessTicketBasics(  ARGSRef => \%ARGS, TicketObj => $Ticket );
    push @Actions, ProcessTicketLinks(   ARGSRef => \%ARGS, TicketObj => $Ticket );
    push @Actions, ProcessTicketDates(   ARGSRef => \%ARGS, TicketObj => $Ticket );
    push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket );
    push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $Ticket );

    unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
        if (@Actions) {
            Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions);
        } else {
            Abort("No permission to view ticket");
        }
    }
    if ( $ARGS{'MarkAsSeen'} ) {
        $Ticket->SetAttribute(
            Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
            Content => $Ticket->LastUpdated,
        );
        push @Actions, loc('Marked all messages as seen');
    }
}

$m->callback(
    CallbackName => 'BeforeDisplay',
    TicketObj => \$Ticket,
    Actions => \@Actions,
    ARGSRef => \%ARGS,
);

# This code does automatic redirection if any updates happen. 

if (@Actions) {

    # We've done something, so we need to clear the decks to avoid
    # resubmission on refresh.
    # But we need to store Actions somewhere too, so we don't lose them.
    my $key = Digest::MD5::md5_hex( rand(1024) );
    push @{ $session{"Actions"}->{$key} ||= [] }, @Actions;
    $session{'i'}++;
    my $url = RT->Config->Get('WebURL') . "m/ticket/show?id=" . $Ticket->id . "&results=" . $key;
    $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor};
    RT::Interface::Web::Redirect($url);
}

# If we haven't been passed in an Attachments object (through the precaching mechanism)
# then we need to find one
my $Attachments = $Ticket->Attachments;

my %documents;
while ( my $attach = $Attachments->Next() ) {
    next unless ($attach->Filename());
   unshift( @{ $documents{ $attach->Filename } }, $attach );
}

my $CustomFields = $Ticket->CustomFields;
$m->callback(
    CallbackName => 'MassageCustomFields',
    Object => $Ticket,
    CustomFields => $CustomFields,
);

my $print_value = sub {
    my ($cf, $value) = @_;
    my $linked = $value->LinkValueTo;
    if ( defined $linked && length $linked ) {
        my $linked = $m->interp->apply_escapes( $linked, 'h' );
        $m->out('<a href="'. $linked .'" target="_blank">');
    }
    my $comp = "ShowCustomField". $cf->Type;
    $m->callback(
        CallbackName => 'ShowComponentName',
        Name         => \$comp,
        CustomField  => $cf,
        Object       => $Ticket,
    );
    if ( $m->comp_exists( $comp ) ) {
        $m->comp( $comp, Object => $value );
    } else {
        $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
    }
    $m->out('</a>') if defined $linked && length $linked;

    # This section automatically populates a div with the "IncludeContentForValue" for this custom
    # field if it's been defined
    if ( $cf->IncludeContentForValue ) {
       my $vid = $value->id;
       $m->out(   '<div class="object_cf_value_include" id="object_cf_value_'. $vid .'">' );
       $m->print( loc("See also:") );
       $m->out(   '<a href="'. $m->interp->apply_escapes($value->IncludeContentForValue, 'h') .'">' );
       $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') );
       $m->out(   qq{</a></div>\n} );
       $m->out(   qq{<script><!--\njQuery('#object_cf_value_$vid').load(} );
       $m->out(   $m->interp->apply_escapes($value->IncludeContentForValue, 'j') );
       $m->out(   qq{);\n--></script>\n} );
    }
};

</%init>
<&| /m/_elements/wrapper, title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject || '') &>
<div id="ticket-show">
<& /m/_elements/ticket_menu, ticket => $Ticket &>

    <&| /Widgets/TitleBox, title => loc('The Basics'),
        class => 'ticket-info-basics',
    &>


 <div class="entry">
    <div class="label id"><&|/l&>Id</&>:</div>
    <div class="value id"><%$Ticket->Id %></div>
  </div>
 <div class="entry">
    <div class="label status"><&|/l&>Status</&>:</div>
    <div class="value status"><% loc($Ticket->Status) %></div>
  </div>
% if ($Ticket->TimeEstimated) {
 <div class="entry">
    <div class="label time estimated"><&|/l&>Estimated</&>:</div>
    <div class="value time estimated"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &></div>
  </div>
% }
% if ($Ticket->TimeWorked) {
 <div class="entry">
    <div class="label time worked"><&|/l&>Worked</&>:</div>
    <div class="value time worked"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeWorked &></div>
  </div>
% }
% if ($Ticket->TimeLeft) {
 <div class="entry">
    <div class="label time left"><&|/l&>Left</&>:</div>
    <div class="value time left"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeLeft &></div>
  </div>
% }
 <div class="entry">
    <div class="label priority"><&|/l&>Priority</&>:</div>
    <div class="value priority"><& /Ticket/Elements/ShowPriority, Ticket => $Ticket &></div>
  </div>
 <div class="entry">
    <div class="label queue"><&|/l&>Queue</&>:</div>
    <div class="value queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &></div>
  </div>
 <div class="entry">
    <div class="label bookmark"><&|/l&>Bookmark</&>:</div>
    <div class="value bookmark"><& /Ticket/Elements/Bookmark, id => $Ticket->id &></div>
  </div>
    </&>

% if ($CustomFields->Count) {
    <&| /Widgets/TitleBox, title => loc('Custom Fields'),
        class => 'ticket-info-cfs',
    &>

% while ( my $CustomField = $CustomFields->Next ) {
% my $Values = $Ticket->CustomFieldValues( $CustomField->Id );
% my $count = $Values->Count;
  <div class="entry" id="CF-<%$CustomField->id%>-ShowRow">
    <div class="label"><% $CustomField->Name %>:</div>
    <div class="value">
% unless ( $count ) {
<i><&|/l&>(no value)</&></i>
% } elsif ( $count == 1 ) {
%   $print_value->( $CustomField, $Values->First );
% } else {
<ul>
% while ( my $Value = $Values->Next ) {
<li>
% $print_value->( $CustomField, $Value );
</li>
% }
</ul>
% }
    </div>
  </div>
% }

</&>
% }

    <&| /Widgets/TitleBox, title => loc('People'), class => 'ticket-info-people' &>


 <div class="entry">
    <div class="label"><&|/l&>Owner</&>:</div>
    <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket, Link => 0 &>
    </div>
  </div>
 <div class="entry">
    <div class="label"><&|/l&>Requestors</&>:</div>
    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket, Link => 0 &></div>
  </div>
 <div class="entry">
    <div class="label"><&|/l&>Cc</&>:</div>
    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket, Link => 0 &></div>
  </div>
 <div class="entry">
    <div class="label"><&|/l&>AdminCc</&>:</div>
    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket, Link => 0 &></div>
  </div>

    </&>

% if (keys %documents) {
<&| /Widgets/TitleBox, title => loc('Attachments'), 
        title_class=> 'inverse',  
        class => 'ticket-info-attachments',
        color => "#336699" &>

% foreach my $key (keys %documents) {

<%$key%><br />
<ul>
% foreach my $rev (@{$documents{$key}}) {
% if ($rev->ContentLength) {
<li><font size="-2">
<a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | un %>">
<&|/l, $rev->CreatedAsString, $rev->FriendlyContentLength, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&>
</a>
</font></li>
% }
% }
</ul>

% }
</&>

% }
% # too painful to deal with reminders
% if ( 0 &&  RT->Config->Get('EnableReminders') ) {
    <&|/Widgets/TitleBox, title => loc("Reminders"),
        class => 'ticket-info-reminders',
    &>
       <div class="entry"><div
            <form action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
                <& /Ticket/Elements/Reminders, Ticket => $Ticket, ShowCompleted => 0 &>
                <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
            </form>
        </div></div>
    </&>
% }

    <&| /Widgets/TitleBox, title => loc("Dates"),
        class => 'ticket-info-dates',
    &>


 <div class="entry">
    <div class="label date created"><&|/l&>Created</&>:</div>
    <div class="value date created"><% $Ticket->CreatedObj->AsString %></div>
  </div>
 <div class="entry">
    <div class="label date starts"><&|/l&>Starts</&>:</div>
    <div class="value date starts"><% $Ticket->StartsObj->AsString %></div>
  </div>
 <div class="entry">
    <div class="label date started"><&|/l&>Started</&>:</div>
    <div class="value date started"><% $Ticket->StartedObj->AsString %></div>
  </div>
 <div class="entry">
    <div class="label date told"><&|/l&>Last Contact</&>:</div>
    <div class="value date told"><% $Ticket->ToldObj->AsString %></div>
  </div>
 <div class="entry">
    <div class="label date due"><&|/l&>Due</&>:</div>
% my $due = $Ticket->DueObj;
% if ( $due && $due->IsSet && $due->Diff < 0 && $Ticket->QueueObj->IsActiveStatus($Ticket->Status) ) {
    <div class="value date due"><span class="overdue"><% $due->AsString  %></span></div>
% } else {
    <div class="value date due"><% $due->AsString  %></div>
% }
  </div>
 <div class="entry">
    <div class="label date resolved"><&|/l&>Closed</&>:</div>
    <div class="value date resolved"><% $Ticket->ResolvedObj->AsString  %></div>
  </div>
 <div class="entry">
    <div class="label date updated"><&|/l&>Updated</&>:</div>
% my $UpdatedString = $Ticket->LastUpdated ? loc("[_1] by [_2]", $Ticket->LastUpdatedAsString, $Ticket->LastUpdatedByObj->Name) : loc("Never");
    <div class="value date updated"><% $UpdatedString | h %></div>
  </div>

    </&>

    <&| /Widgets/TitleBox, title => loc('Links'), class => 'ticket-info-links' &>

 <div class="entry">
    <div class="label"><% loc('Depends on')%>:</div>
    <div class="value">

<%PERL>
my ( @active, @inactive, @not_tickets );
for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
    my $target = $link->TargetObj;
    if ( $target && $target->isa('RT::Ticket') ) {
        if ( $target->QueueObj->IsInactiveStatus( $target->Status ) ) {
            push( @inactive, $link->TargetURI );
        }
        else {
            push( @active, $link->TargetURI );
        }
    }
    else {
        push( @not_tickets, $link->TargetURI );
    }
}
</%PERL>


<ul>
% for my $Link (@not_tickets, @active, @inactive) {
<li><& /Elements/ShowLink, URI => $Link &></li>
% }
</ul>
    </div>
  </div>
 <div class="entry">
    <div class="label"><% loc('Depended on by')%>:</div>
    <div class="value">
<ul>
% while (my $Link = $Ticket->DependedOnBy->Next) {
<li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
% }
</ul>
    </div>
  </div>
 <div class="entry">
    <div class="label"><% loc('Parents') %>:</div>
    <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'MemberOf' &></div>
  </div>
 <div class="entry">
    <div class="label"><% loc('Children')%>:</div>
    <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'Members' &></div>
  </div>
 <div class="entry">
    <div class="label"><% loc('Refers to')%>:</div>
    <div class="value">
<ul>
% while (my $Link = $Ticket->RefersTo->Next) {
<li><& /Elements/ShowLink, URI => $Link->TargetURI &></li>
% }
</ul>
    </div>
  </div>
 <div class="entry">
    <div class="label"><% loc('Referred to by')%>:</div>
    <div class="value">
    <ul>
% while (my $Link = $Ticket->ReferredToBy->Next) {
% next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket')  && $Link->BaseObj->__Value('Type') eq 'reminder');
<li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
% }
</ul>
    </div>
  </div>
    </&>
</div>
</&>