rt 4.0.23
[freeside.git] / rt / share / html / SelfService / Display.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 %#                                          <sales@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 <& /Ticket/Elements/ShowUpdateStatus, Ticket => $Ticket &>
54
55   <table width="100%" class="ticketsummary" >
56       <tr>
57         <td valign="top" width="50%" class="boxcontainer">
58           <&| /Widgets/TitleBox, title => loc('The Basics'),
59                 ($LinkBasicsTitle ? (title_href => $title_box_link) : ()),
60                 title_class=> 'inverse',
61                 color => "#993333" &>
62                 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
63                 <& /Ticket/Elements/ShowCustomFields, Ticket => $Ticket &>
64           </&>
65 </td>
66         <td valign="top" width="50%" class="boxcontainer">
67           <&| /Widgets/TitleBox, title => loc("Dates"),
68                 title_class=> 'inverse',
69                  color => "#663366" &>
70           <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
71           </&>
72 </td>
73 </tr>
74 </table>
75
76
77
78 <& /Ticket/Elements/ShowHistory, 
79       Ticket => $Ticket, 
80       URIFile => "Display.html", 
81       ShowHeaders => $ARGS{'ShowHeaders'},
82       DownloadableHeaders => 0,
83       AttachPath => "Attachment", 
84       Attachments => $attachments, 
85       UpdatePath => "Update.html" 
86 &>
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 = RT::Ticket->new( $session{'CurrentUser'} );
103
104 if ( defined ($id[0]) && $id[0] eq 'new' ) {
105
106     # {{{ Create a new ticket
107
108     my $Queue = RT::Queue->new( $session{'CurrentUser'} );
109     unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
110         $m->comp( 'Error.html', Why => loc('Queue not found') );
111         $m->abort;
112     }
113
114     unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
115         $m->comp( 'Error.html',
116             Why =>
117               loc('You have no permission to create tickets in that queue.') );
118         $m->abort;
119     }
120
121
122     ( $Ticket, @results ) =
123     CreateTicket( Attachments => delete $session{'Attachments'}, %ARGS );
124
125     unless ( $Ticket->id ) {
126         $m->comp( 'Error.html', Why => join( "\n", @results ));
127               $m->abort();
128         }
129     }
130     else {
131         unless ( $Ticket->Load( $id[0] ) ) {
132             $m->comp( 'Error.html',
133                 Why => loc( "Couldn't load ticket '[_1]'", $id ) );
134             $m->abort();
135         }
136
137     my ( $code, $msg );
138
139
140     if (
141         $session{'Attachments'}
142         || ( defined $ARGS{'UpdateContent'}
143             && $ARGS{'UpdateContent'} ne ''
144             && $ARGS{'UpdateContent'} ne "-- \n"
145             . $session{'CurrentUser'}->UserObj->Signature )
146       )
147     {
148         $ARGS{UpdateAttachments} = $session{'Attachments'};
149     }
150     push @results, ProcessUpdateMessage(
151         ARGSRef   => \%ARGS,
152         TicketObj => $Ticket
153     );
154     delete $session{'Attachments'};
155
156     my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
157     push (@results, @cfupdates);
158
159
160     #Update the status
161     if (    ( defined $ARGS{'Status'} )
162         and $ARGS{'Status'}
163         and ( $ARGS{'Status'} ne $Ticket->Status ) )
164     {
165         ( $code, $msg ) = $Ticket->SetStatus( $ARGS{'Status'} );
166         push @results, "$msg";
167     }
168
169
170     }
171
172     # This code does automatic redirection if any updates happen.
173
174     unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
175         $m->comp( 'Error.html',
176             Why => loc("No permission to display that ticket") );
177         # XXX: Why abort? then we loose footer //ruz
178         $m->abort();
179     }
180
181     if ( $ARGS{'MarkAsSeen'} ) {
182         $Ticket->SetAttribute(
183             Name    => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
184             Content => $Ticket->LastUpdated,
185         );
186         push @results, loc('Marked all messages as seen');
187     }
188
189     # This code does automatic redirection if any updates happen.
190     MaybeRedirectForResults(
191         Actions   => \@results,
192         Path      => '/SelfService/Display.html',
193         Anchor    => $ARGS{'Anchor'},
194         Arguments => { id => $Ticket->id },
195     );
196
197     my $Transactions = $Ticket->Transactions;
198
199     my $attachments =
200       $m->comp( '/Ticket/Elements/FindAttachments', Ticket => $Ticket );
201
202     my $LinkBasicsTitle = $Ticket->CurrentUserHasRight('ModifyTicket')
203                           || $Ticket->CurrentUserHasRight('ReplyToTicket');
204     my $title_box_link = RT->Config->Get('WebPath')."/SelfService/Update.html?id=".$Ticket->Id;
205     $m->callback(CallbackName => 'BeforeDisplay', Ticket => \$Ticket, ARGSRef => \%ARGS, title_box_link => \$title_box_link);
206 </%INIT>
207
208
209 <%ARGS>
210 $id => undef
211 </%ARGS>