import of rt 3.0.4
[freeside.git] / rt / html / SelfService / 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 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
25
26 <& /Elements/ListActions, actions => \@results &>
27
28   <TABLE WIDTH="100%" class="ticketsummary" >
29       <TR>
30         <TD VALIGN=TOP WIDTH="50%">
31           <& /Elements/TitleBoxStart, title => loc('The Basics'), 
32                 title_class=> 'inverse',  
33                 color => "#993333" &>
34                 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
35           <& /Elements/TitleBoxEnd &>
36 </TD>
37         <TD VALIGN=TOP WIDTH="50%">
38           <& /Elements/TitleBoxStart, title => loc("Dates"),
39                 title_class=> 'inverse',
40                  color => "#663366" &>
41           <& /Ticket/Elements/ShowDates, Ticket => $Ticket &>
42           <& /Elements/TitleBoxEnd &>
43 </TD>
44 </TR>
45 </TABLE>
46
47
48
49 <& /Ticket/Elements/ShowHistory, Ticket => $Ticket&>
50
51
52
53 <%INIT>
54
55 my ( $field, @results );
56
57 # {{{ Load the ticket
58 #If we get handed two ids, mason will make them an array. bleck.
59 # We want teh first one. Just because there's no other sensible way
60 # to deal
61 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
62
63 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
64 if ( $id[0] eq 'new' ) {
65
66     # {{{ Create a new ticket
67
68     my $Queue = new RT::Queue( $session{'CurrentUser'} );
69     unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
70         $m->comp( 'Error.html', Why => loc('Queue not found') );
71         $m->abort;
72     }
73
74     unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
75         $m->comp( 'Error.html',
76              Why =>
77                loc('You have no permission to create tickets in that queue.') );
78         $m->abort;
79     }
80
81     my @Requestors = split ( /\s*,\s*/, $ARGS{'Requestors'} );
82     my @Cc         = split ( /\s*,\s*/, $ARGS{'Cc'} );
83
84     my $MIMEObj = MakeMIMEEntity( Subject             => $ARGS{'Subject'},
85                                   From                => $ARGS{'From'},
86                                   Cc                  => $ARGS{'Cc'},
87                                   Body                => $ARGS{'Content'},
88                                   AttachmentFieldName => 'Attach' );
89
90     #TODO in Create_Details.html: priorities and due-date
91     my ( $id, $Trans, $ErrMsg ) = $Ticket->Create( Queue     => $ARGS{Queue},
92                                                    Requestor => \@Requestors,
93                                                    Cc        => \@Cc,
94                                                    Subject   => $ARGS{Subject},
95                                                    MIMEObj   => $MIMEObj );
96     unless ( $id && $Trans ) {
97         $m->comp( 'Error.html', Why => $ErrMsg );
98         $m->abort();
99     }
100
101     push ( @results, $ErrMsg );
102
103     # }}}
104 }
105 else {
106     unless ( $Ticket->Load( $id[0] ) ) {
107         $m->comp( 'Error.html',
108                   Why => loc( "Couldn't load ticket '[_1]'", $id ) );
109         $m->abort();
110     }
111 }
112
113 # }}}
114
115 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
116     $m->comp( 'Error.html',
117               Why => loc("No permission to display that ticket") );
118     $m->abort();
119 }
120
121 my ( $code, $msg );
122
123 #Update the status
124 if (     ( defined $ARGS{'Status'} )
125      and ( $ARGS{'Status'} ne $Ticket->Status ) ) {
126     ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
127     push @results, "$msg";
128 }
129
130 ProcessUpdateMessage( ARGSRef   => \%ARGS,
131                       Actions   => \@results,
132                       TicketObj => $Ticket );
133
134 my $Transactions = $Ticket->Transactions;
135
136 </%INIT>
137
138
139 <%ARGS>
140 $id => undef
141 </%ARGS>