rt 4.2.15
[freeside.git] / rt / share / html / Ticket / Update.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2018 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 <& /Elements/Header, Title  => $title &>
49 <& /Elements/Tabs &>
50
51 % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
52 <& /Elements/ListActions, actions => \@results &>
53
54 <form action="Update.html" name="TicketUpdate"
55     method="post" enctype="multipart/form-data">
56 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS, Ticket => $TicketObj, CanRespond => $CanRespond, CanComment => $CanComment, ResponseDefault => $ResponseDefault, CommentDefault => $CommentDefault );
57 <input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction}||'' %>" />
58 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
59 <input type="hidden" class="hidden" name="Action" value="<% $Action %>" />
60 <input type="hidden" class="hidden" name="Token" value="<% $ARGS{'Token'} %>" />
61
62 <& /Elements/Crypt/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
63
64 <div id="ticket-update-metadata">
65   <&|/Widgets/TitleBox, title => loc('Ticket and Transaction') &>
66 <table width="100%" border="0">
67 % $m->callback(CallbackName => 'AfterTableOpens', ARGSRef => \%ARGS, Ticket => $TicketObj);
68
69 <& /Ticket/Elements/EditTransactionCustomFields, 
70     %ARGS,
71     TicketObj   => $TicketObj,
72     UILocation  => 'TimeWorked',
73 &>
74
75 % my $skip;
76 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
77 % if (!$skip) {
78 <input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
79 % }
80 <tr><td class="label"><&|/l&>Update Type</&>:</td>
81 <td><select name="UpdateType" id="UpdateType">
82 % if ($CanComment) {
83 <option value="private" <% ($ARGS{'UpdateType'} &&  $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
84 % }
85 % if ($CanRespond) {
86 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
87 % }
88 </select> 
89
90 <script type="text/javascript">
91     jQuery(function() {
92         jQuery("input[name=TxnSendMailTo]").change(function(ev) {
93             jQuery("input[name=TxnSendMailTo]").filter( function() { return this.value == ev.target.value; } ).prop("checked",jQuery(ev.target).prop('checked'));
94         });
95     });
96 </script>
97
98 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
99 </td></tr>
100
101 <script type="text/javascript">
102 function changeStatus() {
103   var Status_select = document.getElementById('Status');
104   var x = Status_select.options[Status_select.selectedIndex].value;
105   var text = document.getElementById('WillResolve_Date');
106   var button = document.getElementById('WillResolve_Date_date_button');
107   if (x == 'resolved' || x == 'rejected' || x == 'deleted') {
108     text.disabled = true;
109     button.style.display = 'none';
110   }
111   else {
112     text.disabled = false;
113     button.style.display = 'inline';
114   }
115 }
116 </script>
117
118 <& /Ticket/Elements/EditBasics,
119     TicketObj => $TicketObj,
120     InTable   => 1,
121     fields    => [
122         {   name => 'Status',
123             comp => '/Ticket/Elements/SelectStatus',
124             args => {
125                 Name => 'Status',
126                 Default => $DefaultStatus,
127                 TicketObj => $TicketObj,
128                 onchange => 'changeStatus()'
129             },
130         },
131         {   name => 'Resolve this Ticket on',
132             comp => '/Elements/SelectDate',
133             args => {
134                 menu_prefix => 'WillResolve',
135                 current => 0,
136                 ShowTime => 0,
137             },
138         },
139         {   name => 'Owner',
140             comp => '/Elements/SelectOwner',
141             args => {
142                 Name         => "Owner",
143                 TicketObj    => $TicketObj,
144                 QueueObj     => $TicketObj->QueueObj,
145                 DefaultLabel => loc("[_1] (Unchanged)", $TicketObj->OwnerObj->Format),
146                 Default      => $ARGS{'Owner'}
147             }
148         },
149         {   name => 'Worked',
150             comp => '/Elements/EditTimeValue',
151             args => {
152                 Name => 'UpdateTimeWorked',
153                 Default => $ARGS{UpdateTimeWorked}||'',
154             }
155         },
156     ]
157 &>
158
159 <script type="text/javascript">
160 changeStatus();
161 </script>
162
163 % $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $TicketObj );
164
165 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, InTable => 1, KeepValue => 1, &>
166
167   </table>
168   </&>
169
170 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', Ticket => $TicketObj );
171
172 </div>
173
174 <div id="ticket-update-message">
175   <& /Ticket/Elements/ShowSimplifiedRecipients, TicketObj => $TicketObj, %ARGS &>
176
177   <&|/Widgets/TitleBox, title => loc('Message'), class => 'messagedetails' &>
178   <table width="100%" border="0">
179 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
180
181 % if ( $gnupg_widget ) {
182 <tr><td>&nbsp;</td><td>
183 <& /Elements/Crypt/SignEncryptWidget,
184     self => $gnupg_widget,
185     TicketObj => $TicketObj,
186 &>
187 </td></tr>
188 % }
189 % $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
190
191 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input type="text" name="UpdateSubject" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject || '' %>" />
192 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
193 </td></tr>
194
195 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td>
196 <td class="messagebox-container action-<% $type %>">
197 <& /Articles/Elements/BeforeMessageBox, %ARGS &>
198 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
199 % if (exists $ARGS{UpdateContent}) {
200 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
201 % my $temp = $ARGS{'QuoteTransaction'};
202 % delete $ARGS{'QuoteTransaction'};
203 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
204 % $ARGS{'QuoteTransaction'} = $temp;
205 % } else {
206 % my $IncludeSignature = 1;
207 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
208 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
209 % }
210 % $m->callback( %ARGS, CallbackName => 'AfterMessageBox' );
211 </td></tr>
212
213     <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $TicketObj &>
214   </table>
215 </&>
216
217 % $m->callback( %ARGS, CallbackName => 'BeforeSubmit', Ticket => $TicketObj );
218
219   <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', id => 'SubmitTicket' &>
220
221 % $m->callback( %ARGS, CallbackName => 'BeforeScrips', Ticket => $TicketObj );
222
223 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
224   <&|/Widgets/TitleBox, title => loc('Scrips and Recipients'), id => 'previewscrips', rolledup => RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) &>
225     <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
226   </&>
227 % }
228 </div>
229
230 % $m->callback( %ARGS, CallbackName => 'AfterScrips', Ticket => $TicketObj );
231
232 % if (my $recips = $m->notes("DryRun-Recipients-".$TicketObj->Id)) {
233 <input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %{$recips} %>" />
234 % }
235
236 </form>
237 <hr class="clear" />
238
239 % $m->callback( %ARGS, CallbackName => 'AfterForm', Ticket => $TicketObj );
240
241 <%INIT>
242 my $CanRespond = 0;
243 my $CanComment = 0;
244 my $checks_failure = 0;
245
246 my $TicketObj = LoadTicket($id);
247
248 my @results;
249
250 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure, results => \@results, CallbackName => 'Initial' );
251 $m->scomp( '/Articles/Elements/SubjectOverride', Ticket => $TicketObj, ARGSRef => \%ARGS, results => \@results );
252
253 unless($DefaultStatus){
254     $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
255 }
256
257 my $title = loc("Update ticket #[_1]: [_2]", $TicketObj->id, $TicketObj->Subject);
258
259 # Things needed in the template - we'll do the processing here, just
260 # for the convenience:
261
262 my ($CommentDefault, $ResponseDefault);
263 if ($Action ne 'Respond') {
264     $CommentDefault = qq[ selected="selected"]; 
265     $ResponseDefault = "";
266 } else {
267     $CommentDefault = ""; 
268     $ResponseDefault = qq[ selected="selected"];
269 }
270
271 my $type =             $ARGS{'UpdateType'} ? $ARGS{'UpdateType'} :
272            lc $Action eq 'respond' ? 'response'          :
273            lc $Action eq 'comment' ? 'private'           :
274                                              'none'              ;
275
276
277 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
278                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
279
280 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
281                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
282
283 ProcessAttachments(ARGSRef => \%ARGS);
284
285 my %squelched = ProcessTransactionSquelching( \%ARGS );
286 $ARGS{'SquelchMailTo'} = [keys %squelched] if keys %squelched;
287
288 my $gnupg_widget = $m->comp('/Elements/Crypt/SignEncryptWidget:new', Arguments => \%ARGS );
289 $m->comp( '/Elements/Crypt/SignEncryptWidget:Process',
290     self => $gnupg_widget,
291     TicketObj => $TicketObj,
292 );
293
294 if ( $ARGS{'SubmitTicket'} ) {
295
296     my ($status, @msg) = $m->comp(
297         '/Elements/ValidateCustomFields',
298         CustomFields => $TicketObj->TransactionCustomFields,
299         Object => RT::Transaction->new( $session{'CurrentUser'} ),
300         ARGSRef => \%ARGS
301     );
302     unless ( $status ) {
303         push @results, @msg;
304         $checks_failure = 1;
305     }
306     $status = $m->comp('/Elements/Crypt/SignEncryptWidget:Check',
307         self      => $gnupg_widget,
308         TicketObj => $TicketObj,
309     );
310     $checks_failure = 1 unless $status;
311 }
312
313 # check email addresses for RT's
314 {
315     foreach my $field ( qw(UpdateCc UpdateBcc) ) {
316         my $value = $ARGS{ $field };
317         next unless defined $value && length $value;
318
319         my @emails = Email::Address->parse( $value );
320         foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
321             push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc(substr($field, 6)) );
322             $checks_failure = 1;
323             $email = undef;
324         }
325         $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
326     }
327 }
328
329 # $skip_update is provided below by reference to allow a final check to stop
330 # the update and print a message for the user to fix something.
331 my $skip_update = 0;
332 $m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
333               checks_failure => $checks_failure, results => \@results, TicketObj => $TicketObj );
334
335 if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
336     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
337     return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
338 }
339 </%INIT>
340
341 <%ARGS>
342 $id => undef
343 $Action => ''
344 $DefaultStatus => undef
345 </%ARGS>