import rt 3.2.2
[freeside.git] / rt / html / SelfService / Display.html
1 %# {{{ BEGIN BPS TAGGED BLOCK
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
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
16 %# from www.gnu.org.
17 %# 
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.
22 %# 
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., 675 Mass Ave, Cambridge, MA 02139, USA.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
35 %# 
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
44 %# 
45 %# }}} END BPS TAGGED BLOCK
46 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
47
48 <& /Elements/ListActions, actions => \@results &>
49
50   <TABLE WIDTH="100%" class="ticketsummary" >
51       <TR>
52         <TD VALIGN=TOP WIDTH="50%" class="boxcontainer">
53           <& /Elements/TitleBoxStart, title => loc('The Basics'), 
54                 title_class=> 'inverse',  
55                 color => "#993333" &>
56                 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
57           <& /Elements/TitleBoxEnd &>
58 </TD>
59         <TD VALIGN=TOP WIDTH="50%" class="boxcontainer">
60           <& /Elements/TitleBoxStart, title => loc("Dates"),
61                 title_class=> 'inverse',
62                  color => "#663366" &>
63           <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
64           <& /Elements/TitleBoxEnd &>
65 </TD>
66 </TR>
67 </TABLE>
68
69
70
71 %#!!pape: selfservice_find_attachments.patch {{
72 <& /Ticket/Elements/ShowHistory, Ticket => $Ticket, AttachPath => "Attachment", Attachments => $attachments, UpdatePath => "Update.html" &>
73 %#!!pape: selfservice_find_attachments.patch }}
74
75
76
77 <%INIT>
78
79 my ( $field, @results );
80
81 # {{{ Load the ticket
82 #If we get handed two ids, mason will make them an array. bleck.
83 # We want teh first one. Just because there's no other sensible way
84 # to deal
85 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
86
87 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
88 if ( $id[0] eq 'new' ) {
89
90     # {{{ Create a new ticket
91
92     my $Queue = new RT::Queue( $session{'CurrentUser'} );
93     unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
94         $m->comp( 'Error.html', Why => loc('Queue not found') );
95         $m->abort;
96     }
97
98     unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
99         $m->comp( 'Error.html',
100              Why =>
101                loc('You have no permission to create tickets in that queue.') );
102         $m->abort;
103     }
104
105     my @Requestors = split ( /\s*,\s*/, $ARGS{'Requestors'} );
106     my @Cc         = split ( /\s*,\s*/, $ARGS{'Cc'} );
107
108     my $MIMEObj = MakeMIMEEntity( Subject             => $ARGS{'Subject'},
109                                   From                => $ARGS{'From'},
110                                   Cc                  => $ARGS{'Cc'},
111                                   Body                => $ARGS{'Content'},
112                                   AttachmentFieldName => 'Attach' );
113
114     #TODO in Create_Details.html: priorities and due-date
115     my ( $id, $Trans, $ErrMsg ) = $Ticket->Create( Queue     => $ARGS{Queue},
116                                                    Requestor => \@Requestors,
117                                                    Cc        => \@Cc,
118                                                    Subject   => $ARGS{Subject},
119                                                    MIMEObj   => $MIMEObj );
120     unless ( $id && $Trans ) {
121         $m->comp( 'Error.html', Why => $ErrMsg );
122         $m->abort();
123     }
124
125     push ( @results, $ErrMsg );
126
127     # }}}
128
129 # delete temporary storage entry to make WebUI clean
130 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
131     delete $session{'Attachments'};
132 }
133 # }}}
134 }
135 else {
136     unless ( $Ticket->Load( $id[0] ) ) {
137         $m->comp( 'Error.html',
138                   Why => loc( "Couldn't load ticket '[_1]'", $id ) );
139         $m->abort();
140     }
141 }
142
143 # }}}
144
145 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
146     $m->comp( 'Error.html',
147               Why => loc("No permission to display that ticket") );
148     $m->abort();
149 }
150
151 my ( $code, $msg );
152
153 #Update the status
154 if (     ( defined $ARGS{'Status'} ) and $ARGS{'Status'}
155      and ( $ARGS{'Status'} ne $Ticket->Status ) ) {
156     ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
157     push @results, "$msg";
158 }
159
160 # {{{ store the uploaded attachment in session
161 if ($ARGS{'Attach'}) {                  # attachment?
162     $session{'Attachments'} = {} unless defined $session{'Attachments'};
163
164     my $subject = "$ARGS{'Attach'}";
165     # since CGI.pm deutf8izes the magic field, we need to add it back.
166     Encode::_utf8_on($subject);
167     # strip leading directories
168     $subject =~ s#^.*[\\/]##;
169
170     my $attachment = MakeMIMEEntity(
171         Subject             => $subject,
172         Body                => "",
173         AttachmentFieldName => 'Attach'
174     );
175
176     $session{'Attachments'} = { %{$session{'Attachments'} || {}},
177                                 $ARGS{'Attach'} => $attachment };
178 }
179 # }}}
180
181 if ( $session{'Attachments'} || 
182      (   $ARGS{'UpdateContent'} ne ''
183          && $ARGS{'UpdateContent'} ne "-- \n"
184          . $session{'CurrentUser'}->UserObj->Signature )) {
185     $ARGS{UpdateAttachments} = $session{'Attachments'};
186 }
187 ProcessUpdateMessage( ARGSRef   => \%ARGS,
188                       Actions   => \@results,
189                       TicketObj => $Ticket );
190
191 # delete temporary storage entry to make WebUI clean
192 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
193     delete $session{'Attachments'};
194 }
195 # }}}
196
197 my $Transactions = $Ticket->Transactions;
198
199 #!!pape: selfservice_find_attachments.patch {{
200 my $attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
201 #!!pape: selfservice_find_attachments.patch }}
202
203 </%INIT>
204
205
206 <%ARGS>
207 $id => undef
208 </%ARGS>