3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
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
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.
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.
24 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
26 <& /Elements/ListActions, actions => \@results &>
28 <TABLE WIDTH="100%" class="ticketsummary" >
30 <TD VALIGN=TOP WIDTH="50%">
31 <& /Elements/TitleBoxStart, title => loc('The Basics'),
32 title_class=> 'inverse',
34 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
35 <& /Elements/TitleBoxEnd &>
37 <TD VALIGN=TOP WIDTH="50%">
38 <& /Elements/TitleBoxStart, title => loc("Dates"),
39 title_class=> 'inverse',
41 <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
42 <& /Elements/TitleBoxEnd &>
49 <& /Ticket/Elements/ShowHistory, Ticket => $Ticket, AttachPath => "Attachment" &>
55 my ( $field, @results );
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
61 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
63 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
64 if ( $id[0] eq 'new' ) {
66 # {{{ Create a new ticket
68 my $Queue = new RT::Queue( $session{'CurrentUser'} );
69 unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
70 $m->comp( 'Error.html', Why => loc('Queue not found') );
74 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
75 $m->comp( 'Error.html',
77 loc('You have no permission to create tickets in that queue.') );
81 my @Requestors = split ( /\s*,\s*/, $ARGS{'Requestors'} );
82 my @Cc = split ( /\s*,\s*/, $ARGS{'Cc'} );
84 my $MIMEObj = MakeMIMEEntity( Subject => $ARGS{'Subject'},
85 From => $ARGS{'From'},
87 Body => $ARGS{'Content'},
88 AttachmentFieldName => 'Attach' );
90 #TODO in Create_Details.html: priorities and due-date
91 my ( $id, $Trans, $ErrMsg ) = $Ticket->Create( Queue => $ARGS{Queue},
92 Requestor => \@Requestors,
94 Subject => $ARGS{Subject},
95 MIMEObj => $MIMEObj );
96 unless ( $id && $Trans ) {
97 $m->comp( 'Error.html', Why => $ErrMsg );
101 push ( @results, $ErrMsg );
105 # delete temporary storage entry to make WebUI clean
106 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
107 delete $session{'Attachments'};
112 unless ( $Ticket->Load( $id[0] ) ) {
113 $m->comp( 'Error.html',
114 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
121 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
122 $m->comp( 'Error.html',
123 Why => loc("No permission to display that ticket") );
130 if ( ( defined $ARGS{'Status'} )
131 and ( $ARGS{'Status'} ne $Ticket->Status ) ) {
132 ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
133 push @results, "$msg";
136 # {{{ store the uploaded attachment in session
137 if ($ARGS{'Attach'}) { # attachment?
138 $session{'Attachments'} = {} unless defined $session{'Attachments'};
140 my $subject = "$ARGS{'Attach'}";
141 # since CGI.pm deutf8izes the magic field, we need to add it back.
142 Encode::_utf8_on($subject);
143 # strip leading directories
144 $subject =~ s#^.*[\\/]##;
146 my $attachment = MakeMIMEEntity(
149 AttachmentFieldName => 'Attach'
152 $session{'Attachments'} = { %{$session{'Attachments'} || {}},
153 $ARGS{'Attach'} => $attachment };
157 if ( $session{'Attachments'} ||
158 ( $ARGS{'UpdateContent'} ne ''
159 && $ARGS{'UpdateContent'} ne "-- \n"
160 . $session{'CurrentUser'}->UserObj->Signature )) {
161 $ARGS{UpdateAttachments} = $session{'Attachments'};
163 ProcessUpdateMessage( ARGSRef => \%ARGS,
164 Actions => \@results,
165 TicketObj => $Ticket );
167 # delete temporary storage entry to make WebUI clean
168 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
169 delete $session{'Attachments'};
173 my $Transactions = $Ticket->Transactions;