This commit was generated by cvs2svn to compensate for changes in r8690,
[freeside.git] / rt / share / 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 % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $Ticket );
51
52 <& /Elements/ListActions, actions => \@results &>
53
54   <table width="100%" class="ticketsummary" >
55       <tr>
56         <td valign="top" width="50%" class="boxcontainer">
57           <&| /Widgets/TitleBox, title => loc('The Basics'), 
58                 title_class=> 'inverse',  
59                 color => "#993333" &>
60                 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
61                 <& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket &>
62           </&>
63 </td>
64         <td valign="top" width="50%" class="boxcontainer">
65           <&| /Widgets/TitleBox, title => loc("Dates"),
66                 title_class=> 'inverse',
67                  color => "#663366" &>
68           <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
69           </&>
70 </td>
71 </tr>
72 </table>
73
74
75
76 %#!!pape: selfservice_find_attachments.patch {{
77 <& /Ticket/Elements/ShowHistory, 
78       Ticket => $Ticket, 
79       URIFile => "Display.html", 
80       ShowHeaders => $ARGS{'ShowHeaders'},
81       DownloadableHeaders => 0,
82       AttachPath => "Attachment", 
83       Attachments => $attachments, 
84       UpdatePath => "Update.html" 
85 &>
86 %#!!pape: selfservice_find_attachments.patch }}
87
88
89
90 <%INIT>
91
92 my ( $field, @results );
93
94 $m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
95
96 # {{{ Load the ticket
97 #If we get handed two ids, mason will make them an array. bleck.
98 # We want teh first one. Just because there's no other sensible way
99 # to deal
100 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
101
102 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
103
104 # store the uploaded attachment in session
105 if ( $ARGS{'Attach'} ) {    # attachment?
106     $session{'Attachments'} = {} unless defined $session{'Attachments'};
107
108     my $attachment = MakeMIMEEntity(
109         AttachmentFieldName => 'Attach'
110     );
111
112     my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
113     $session{'Attachments'} = {
114         %{ $session{'Attachments'} || {} },
115         $file_path => $attachment,
116     };
117 }
118
119 if ( defined ($id[0]) && $id[0] eq 'new' ) {
120
121     # {{{ Create a new ticket
122
123     my $Queue = new RT::Queue( $session{'CurrentUser'} );
124     unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
125         $m->comp( 'Error.html', Why => loc('Queue not found') );
126         $m->abort;
127     }
128
129     unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
130         $m->comp( 'Error.html',
131             Why =>
132               loc('You have no permission to create tickets in that queue.') );
133         $m->abort;
134     }
135
136
137     ( $Ticket, @results ) =
138     CreateTicket( Attachments => $session{'Attachments'}, %ARGS, Status => 'new' );
139
140     unless ( $Ticket->id ) {
141         $m->comp( 'Error.html', Why => join( "\n", @results ));
142               $m->abort();
143         }
144
145         # }}}
146
147         # delete temporary storage entry to make WebUI clean
148         unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
149             delete $session{'Attachments'};
150         }
151
152         # }}}
153     }
154     else {
155         unless ( $Ticket->Load( $id[0] ) ) {
156             $m->comp( 'Error.html',
157                 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
158             $m->abort();
159         }
160
161     my ( $code, $msg );
162
163
164     if (
165         $session{'Attachments'}
166         || ( defined $ARGS{'UpdateContent'}
167             && $ARGS{'UpdateContent'} ne ''
168             && $ARGS{'UpdateContent'} ne "-- \n"
169             . $session{'CurrentUser'}->UserObj->Signature )
170       )
171     {
172         $ARGS{UpdateAttachments} = $session{'Attachments'};
173     }
174     push @results, ProcessUpdateMessage(
175         ARGSRef   => \%ARGS,
176         TicketObj => $Ticket
177     );
178             delete $session{'Attachments'};
179
180     # delete temporary storage entry to make WebUI clean
181     unless ( keys %{ $session{'Attachments'} } and $ARGS{'UpdateAttach'} ) {
182         delete $session{'Attachments'};
183     }
184
185     my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
186     push (@results, @cfupdates);
187
188     # }}}
189
190     #Update the status
191     if (    ( defined $ARGS{'Status'} )
192         and $ARGS{'Status'}
193         and ( $ARGS{'Status'} ne $Ticket->Status ) )
194     {
195         ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
196         push @results, "$msg";
197     }
198     # }}}
199
200
201     }
202
203     # This code does automatic redirection if any updates happen.
204
205     unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
206         $m->comp( 'Error.html',
207             Why => loc("No permission to display that ticket") );
208         # XXX: Why abort? then we loose footer //ruz
209         $m->abort();
210     }
211
212     if (@results) {
213         # We've done something, so we need to clear the decks to avoid
214         # resubmission on refresh.
215         # But we need to store Actions somewhere too, so we don't lose them.
216         my $key = Digest::MD5::md5_hex(rand(1024));
217         push @{ $session{"Actions"}->{$key}  ||= [] }, @results;
218         $session{'i'}++;
219         RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."SelfService/Display.html?id=". $Ticket->id."&results=".$key);
220     }
221
222     my $Transactions = $Ticket->Transactions;
223
224     my $attachments =
225       $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );
226
227     $m->callback(CallbackName => 'BeforeDisplay', Ticket => \$Ticket, ARGSRef => \%ARGS);
228 </%INIT>
229
230
231 <%ARGS>
232 $id => undef
233 </%ARGS>