rt 4.2.13 ticket#13852
[freeside.git] / rt / share / html / SelfService / Display.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2016 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="ticket-summary" >
56       <tr>
57         <td valign="top" width="50%" class="boxcontainer">
58           <&| /Widgets/TitleBox, title => loc('The Basics'),
59                 class => 'ticket-info-basics',
60                 ($LinkBasicsTitle ? (title_href => $title_box_link) : ()),
61                 title_class=> 'inverse',
62                 color => "#993333" &>
63                 <& /Ticket/Elements/ShowBasics, Ticket => $Ticket, UngroupedCFs => 1 &>
64           </&>
65
66     <& /Elements/ShowCustomFieldCustomGroupings,
67         Object       => $Ticket,
68         title_href   => ($LinkBasicsTitle ? RT->Config->Get('WebPath')."/SelfService/Update.html" : "" ),
69         Groupings    => [ grep {$_ !~ /^(Basics|Dates)$/} RT::CustomField->Groupings( "RT::Ticket" ) ],
70         &>
71 </td>
72         <td valign="top" width="50%" class="boxcontainer">
73           <&| /Widgets/TitleBox, title => loc("Dates"),
74                  class => 'ticket-info-dates',
75                  title_class=> 'inverse',
76                  color => "#663366" &>
77           <& /Ticket/Elements/ShowDates, Ticket => $Ticket, UpdatedLink => 0 &>
78           </&>
79 </td>
80 </tr>
81 </table>
82
83 % $m->callback(CallbackName => 'BeforeShowHistory', ARGSRef=> \%ARGS, Ticket => $Ticket );
84
85 <& /Elements/ShowHistory,
86       Object => $Ticket,
87       ShowHeaders => $ARGS{'ShowHeaders'},
88       DownloadableHeaders => 0,
89 &>
90
91
92
93 <%INIT>
94
95 my ( $field, @results );
96
97 $m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
98
99 # Load the ticket
100 #If we get handed two ids, mason will make them an array. bleck.
101 # We want teh first one. Just because there's no other sensible way
102 # to deal
103 my @id = ( ref $id eq 'ARRAY' ) ? @{$id} : ($id);
104
105 my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
106
107 if ( ($id[0]||'') eq 'new' ) {
108
109     my $Queue = RT::Queue->new( $session{'CurrentUser'} );
110     Abort( loc('Queue not found') ) unless $Queue->Load( $ARGS{'Queue'} );
111
112     Abort( loc('You have no permission to create tickets in that queue.') )
113         unless $Queue->CurrentUserHasRight('CreateTicket');
114
115     ( $Ticket, @results ) = CreateTicket( %ARGS );
116
117     Abort( join("\n", @results ) ) unless $Ticket->id;
118
119 }
120 else {
121     $Ticket = LoadTicket($ARGS{'id'});
122
123     push @results, ProcessUpdateMessage(
124         ARGSRef   => \%ARGS,
125         TicketObj => $Ticket
126     );
127
128     my @cfupdates = ProcessObjectCustomFieldUpdates(Object => $Ticket, ARGSRef => \%ARGS);
129     push (@results, @cfupdates);
130
131     #Update the status
132     if (    ( defined $ARGS{'Status'} )
133         and $ARGS{'Status'}
134         and ( $ARGS{'Status'} ne $Ticket->Status ) )
135     {
136         my ($code, $msg) = $Ticket->SetStatus( $ARGS{'Status'} );
137         push @results, "$msg";
138     }
139
140 }
141
142 # This code does automatic redirection if any updates happen.
143
144 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
145     Abort( loc("No permission to display that ticket") );
146 }
147
148 if ( $ARGS{'MarkAsSeen'} ) {
149     $Ticket->SetAttribute(
150         Name    => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
151         Content => $Ticket->LastUpdated,
152     );
153     push @results, loc('Marked all messages as seen');
154 }
155
156 MaybeRedirectForResults(
157     Actions   => \@results,
158     Path      => '/SelfService/Display.html',
159     Anchor    => $ARGS{'Anchor'},
160     Arguments => { 'id' => $Ticket->id },
161 );
162
163 my $LinkBasicsTitle = $Ticket->CurrentUserHasRight('ModifyTicket')
164                       || $Ticket->CurrentUserHasRight('ReplyToTicket');
165 my $title_box_link = RT->Config->Get('WebPath')."/SelfService/Update.html?id=".$Ticket->Id;
166 $m->callback(CallbackName => 'BeforeDisplay', Ticket => \$Ticket, ARGSRef => \%ARGS, title_box_link => \$title_box_link);
167 </%INIT>
168
169
170 <%ARGS>
171 $id => undef
172 </%ARGS>