import of rt 3.0.4
[freeside.git] / rt / html / Ticket / Display.html
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <& /Elements/Header, 
25     Title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject) &>
26 <& /Ticket/Elements/Tabs, 
27     Ticket => $Ticket, 
28     current_tab => 'Ticket/Display.html?id='.$Ticket->id,
29     Title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject) &>
30
31 <& /Elements/ListActions, actions => \@Actions &>
32
33 <& /Ticket/Elements/ShowSummary,  Ticket => $Ticket &>
34
35
36 <BR>
37 <& /Ticket/Elements/ShowHistory , 
38       Ticket => $Ticket, 
39       Collapsed => $ARGS{'Collapsed'}, 
40       ShowHeaders => $ARGS{'ShowHeaders'} &> 
41
42   
43 <%ARGS>
44 $id => undef
45 $Create => undef
46 $ShowHeaders => undef
47 $Collapsed => undef
48 </%ARGS>
49
50 <%INIT>
51   my ($linkid, $message, $tid, $Ticket, @Actions);  
52
53 $Ticket = new RT::Ticket($session{'CurrentUser'});
54
55 unless ($id) {
56     Abort('No ticket specified');
57 }
58
59 if ($ARGS{'id'} eq 'new') {
60     # {{{ Create a new ticket
61     
62     my $Queue = new RT::Queue($session{'CurrentUser'}); 
63     unless ($Queue->Load($ARGS{'Queue'})) {
64         Abort('Queue not found');
65     }
66     
67     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
68         Abort('You have no permission to create tickets in that queue.');
69     }
70     ($Ticket, @Actions) =
71        CreateTicket(Attachments => $session{'Attachments'}, %ARGS);
72     delete $session{'Attachments'};
73     unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
74       Abort("No permission to view newly created ticket #".$Ticket->id.".");
75     }
76     # }}}
77 }
78
79 else { 
80     $Ticket = LoadTicket($ARGS{'id'});
81     unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
82         Abort("No permission to view ticket");
83     }
84
85
86 if (defined $ARGS{'Action'}) {
87   if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
88     my $action = $1;
89     my ($res, $msg)=$Ticket->$action();
90     push(@Actions, $msg);
91   }
92 }
93
94     if ( $ARGS{'UpdateContent'} ) {
95         $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
96         if (    $ARGS{'UpdateContent'} ne ''
97              && $ARGS{'UpdateContent'} ne "-- \n"
98              . $session{'CurrentUser'}->UserObj->Signature ) {
99             $ARGS{UpdateAttachments} = $session{'Attachments'};
100             ProcessUpdateMessage( ARGSRef   => \%ARGS,
101                                   Actions   => \@Actions,
102                                   TicketObj => $Ticket );
103             delete $session{'Attachments'};
104         }
105     }
106 #Process status updates
107 my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$Ticket);
108 my @results = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);                            
109
110 push (@Actions, @BasicActions, @results);
111 }
112 </%INIT>
113
114
115
116