import rt 3.8.10
[freeside.git] / rt / html / SelfService / Display.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2009 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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %# 
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 <& /SelfService/Elements/Header, Title => loc('#[_1]: [_2]', $Ticket->id, $Ticket->Subject) &>
49
50 <& /Elements/ListActions, actions => \@results &>
51
52   <table width="100%" class="ticketsummary" >
53       <tr>
54         <td valign="top" width="50%" class="boxcontainer">
55           <&| /Widgets/TitleBox, title => loc('The Basics'), 
56                 title_class=> 'inverse',  
57                 color => "#993333" &>
58                 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
59                 <& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket &>
60           </&>
61 </td>
62         <td valign="top" width="50%" class="boxcontainer">
63           <&| /Widgets/TitleBox, title => loc("Dates"),
64                 title_class=> 'inverse',
65                  color => "#663366" &>
66           <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
67           </&>
68 </td>
69 </tr>
70 </table>
71
72
73
74 %#!!pape: selfservice_find_attachments.patch {{
75 <& /Ticket/Elements/ShowHistory, 
76       Ticket => $Ticket, 
77       URIFile => "Display.html", 
78       ShowHeaders => $ARGS{'ShowHeaders'},
79       AttachPath => "Attachment", 
80       Attachments => $attachments, 
81       UpdatePath => "Update.html" 
82 &>
83 %#!!pape: selfservice_find_attachments.patch }}
84
85
86
87 <%INIT>
88
89 my ( $field, @results );
90
91 # {{{ Load the ticket
92 #If we get handed two ids, mason will make them an array. bleck.
93 # We want teh first one. Just because there's no other sensible way
94 # to deal
95 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
96
97 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
98
99 # store the uploaded attachment in session
100 if ( $ARGS{'Attach'} ) {    # attachment?
101     $session{'Attachments'} = {} unless defined $session{'Attachments'};
102
103     my $subject = "$ARGS{'Attach'}";
104
105     # since CGI.pm deutf8izes the magic field, we need to add it back.
106     Encode::_utf8_on($subject);
107
108     # strip leading directories
109     $subject =~ s#^.*[\\/]##;
110
111     my $attachment = MakeMIMEEntity(
112         Subject             => $subject,
113         Body                => "",
114         AttachmentFieldName => 'Attach'
115     );
116
117     $session{'Attachments'} =
118     { %{ $session{'Attachments'} || {} },
119         $ARGS{'Attach'} => $attachment };
120 }
121
122 if ( $id[0] eq 'new' ) {
123
124     # {{{ Create a new ticket
125
126     my $Queue = new RT::Queue( $session{'CurrentUser'} );
127     unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
128         $m->comp( 'Error.html', Why => loc('Queue not found') );
129         $m->abort;
130     }
131
132     unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
133         $m->comp( 'Error.html',
134             Why =>
135               loc('You have no permission to create tickets in that queue.') );
136         $m->abort;
137     }
138
139
140     ( $Ticket, @results ) =
141     CreateTicket( Attachments => $session{'Attachments'}, %ARGS, Status => 'new' );
142
143     unless ( $Ticket->id ) {
144         $m->comp( 'Error.html', Why => join( "\n", @results ));
145               $m->abort();
146         }
147
148         # }}}
149
150         # delete temporary storage entry to make WebUI clean
151         unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
152             delete $session{'Attachments'};
153         }
154
155         # }}}
156     }
157     else {
158         unless ( $Ticket->Load( $id[0] ) ) {
159             $m->comp( 'Error.html',
160                 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
161             $m->abort();
162         }
163
164     my ( $code, $msg );
165
166     #Update the status
167     if (    ( defined $ARGS{'Status'} )
168         and $ARGS{'Status'}
169         and ( $ARGS{'Status'} ne $Ticket->Status ) )
170     {
171         ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
172         push @results, "$msg";
173     }
174
175     # }}}
176
177     if (
178         $session{'Attachments'}
179         || ( defined $ARGS{'UpdateContent'}
180             && $ARGS{'UpdateContent'} ne ''
181             && $ARGS{'UpdateContent'} ne "-- \n"
182             . $session{'CurrentUser'}->UserObj->Signature )
183       )
184     {
185         $ARGS{UpdateAttachments} = $session{'Attachments'};
186     }
187     ProcessUpdateMessage(
188         ARGSRef   => \%ARGS,
189         Actions   => \@results,
190         TicketObj => $Ticket
191     );
192             delete $session{'Attachments'};
193
194     # delete temporary storage entry to make WebUI clean
195     unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
196         delete $session{'Attachments'};
197     }
198
199     my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
200     push (@results, @cfupdates);
201
202     # }}}
203
204     }
205
206     # This code does automatic redirection if any updates happen.
207
208     unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
209         $m->comp( 'Error.html',
210             Why => loc("No permission to display that ticket") );
211         $m->abort();
212     }
213
214     if (@results) {
215         # We've done something, so we need to clear the decks to avoid
216         # resubmission on refresh.
217         # But we need to store Actions somewhere too, so we don't lose them.
218         $session{"Actions"} = \@results;
219         RT::Interface::Web::Redirect($RT::WebURL."SelfService/Display.html?id="
220                                      . $Ticket->id);
221     } else {
222         @results = @{ delete $session{"Actions"} || [] };
223     }
224
225     my $Transactions = $Ticket->Transactions;
226
227     my $attachments =
228       $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );
229
230 </%INIT>
231
232
233 <%ARGS>
234 $id => undef
235 </%ARGS>