]> git.uio.no Git - usit-rt.git/blob - share/html/Ticket/Update.html
Upgrade to 4.2.2
[usit-rt.git] / share / html / Ticket / Update.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2014 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 % my $skip;
70 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
71 % if (!$skip) {
72 <input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
73 % }
74 <tr><td class="label"><&|/l&>Update Type</&>:</td>
75 <td><select name="UpdateType" id="UpdateType">
76 % if ($CanComment) {
77 <option value="private" <% ($ARGS{'UpdateType'} &&  $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
78 % }
79 % if ($CanRespond) {
80 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
81 % }
82 </select> 
83
84 <script type="text/javascript">
85     jQuery(function() {
86         jQuery("#UpdateType").change(function(ev) {
87             jQuery(".messagebox-container")
88                 .removeClass("action-response action-private")
89                 .addClass("action-"+ev.target.value);
90         });
91     });
92     jQuery(function() {
93         jQuery("input[name=TxnSendMailTo]").change(function(ev) {
94             jQuery("input[name=TxnSendMailTo][value="+ev.target.value+"]")
95                   .attr("checked",jQuery(ev.target).attr('checked'));
96         });
97     });
98 </script>
99
100 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
101 </td></tr>
102
103 <& /Ticket/Elements/EditBasics,
104     TicketObj => $TicketObj,
105     InTable   => 1,
106     fields    => [
107         {   name => 'Status',
108             comp => '/Ticket/Elements/SelectStatus',
109             args => {
110                 Name => 'Status',
111                 Default => $DefaultStatus,
112                 TicketObj => $TicketObj,
113             },
114         },
115         {   name => 'Owner',
116             comp => '/Elements/SelectOwner',
117             args => {
118                 Name         => "Owner",
119                 TicketObj    => $TicketObj,
120                 QueueObj     => $TicketObj->QueueObj,
121                 DefaultLabel => loc("[_1] (Unchanged)", $TicketObj->OwnerObj->Format),
122                 Default      => $ARGS{'Owner'}
123             }
124         },
125         {   name => 'Worked',
126             comp => '/Elements/EditTimeValue',
127             args => {
128                 Name => 'UpdateTimeWorked',
129                 Default => $ARGS{UpdateTimeWorked}||'',
130                 InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
131             }
132         },
133     ]
134 &>
135
136 % $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $TicketObj );
137
138 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, InTable => 1 &>
139
140   </table>
141   </&>
142 </div>
143
144 <div id="ticket-update-message">
145   <& /Ticket/Elements/ShowSimplifiedRecipients, TicketObj => $TicketObj, %ARGS &>
146
147   <&|/Widgets/TitleBox, title => loc('Message'), class => 'messagedetails' &>
148   <table width="100%" border="0">
149 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
150
151 % if ( $gnupg_widget ) {
152 <tr><td>&nbsp;</td><td>
153 <& /Elements/Crypt/SignEncryptWidget,
154     self => $gnupg_widget,
155     TicketObj => $TicketObj,
156 &>
157 </td></tr>
158 % }
159 % $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
160
161 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input type="text" name="UpdateSubject" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject || '' %>" />
162 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
163 </td></tr>
164
165 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td>
166 <td class="messagebox-container action-<% $type %>">
167 <& /Articles/Elements/BeforeMessageBox, %ARGS &>
168 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
169 % if (exists $ARGS{UpdateContent}) {
170 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
171 % my $temp = $ARGS{'QuoteTransaction'};
172 % delete $ARGS{'QuoteTransaction'};
173 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
174 % $ARGS{'QuoteTransaction'} = $temp;
175 % } else {
176 % my $IncludeSignature = 1;
177 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
178 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
179 % }
180 % $m->callback( %ARGS, CallbackName => 'AfterMessageBox' );
181 </td></tr>
182
183     <& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $TicketObj &>
184   </table>
185 </&>
186
187 % $m->callback( %ARGS, CallbackName => 'BeforeSubmit', Ticket => $TicketObj );
188
189   <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', id => 'SubmitTicket' &>
190
191 % $m->callback( %ARGS, CallbackName => 'BeforeScrips', Ticket => $TicketObj );
192
193 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
194   <&|/Widgets/TitleBox, title => loc('Scrips and Recipients'), id => 'previewscrips', rolledup => RT->Config->Get('SimplifiedRecipients', $session{'CurrentUser'}) &>
195     <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
196   </&>
197 % }
198 </div>
199
200 % $m->callback( %ARGS, CallbackName => 'AfterScrips', Ticket => $TicketObj );
201
202 % if (my $recips = $m->notes("DryRun-Recipients-".$TicketObj->Id)) {
203 <input type="hidden" name="TxnRecipients" value="<% join ",",sort keys %{$recips} %>" />
204 % }
205
206 </form>
207 <hr class="clear" />
208
209 % $m->callback( %ARGS, CallbackName => 'AfterForm', Ticket => $TicketObj );
210
211 <%INIT>
212 my $CanRespond = 0;
213 my $CanComment = 0;
214 my $checks_failure = 0;
215
216 my $TicketObj = LoadTicket($id);
217
218 my @results;
219
220 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure, results => \@results, CallbackName => 'Initial' );
221 $m->scomp( '/Articles/Elements/SubjectOverride', Ticket => $TicketObj, ARGSRef => \%ARGS, results => \@results );
222
223 unless($DefaultStatus){
224     $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
225 }
226
227 my $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject||'');
228
229 # Things needed in the template - we'll do the processing here, just
230 # for the convenience:
231
232 my ($CommentDefault, $ResponseDefault);
233 if ($Action ne 'Respond') {
234     $CommentDefault = qq[ selected="selected"]; 
235     $ResponseDefault = "";
236 } else {
237     $CommentDefault = ""; 
238     $ResponseDefault = qq[ selected="selected"];
239 }
240
241 my $type =             $ARGS{'UpdateType'} ? $ARGS{'UpdateType'} :
242            lc $Action eq 'respond' ? 'response'          :
243            lc $Action eq 'comment' ? 'private'           :
244                                              'none'              ;
245
246
247 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
248                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
249
250 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
251                      $TicketObj->CurrentUserHasRight('ModifyTicket') ); 
252
253 ProcessAttachments(ARGSRef => \%ARGS);
254
255 my $gnupg_widget = $m->comp('/Elements/Crypt/SignEncryptWidget:new', Arguments => \%ARGS );
256 $m->comp( '/Elements/Crypt/SignEncryptWidget:Process',
257     self => $gnupg_widget,
258     TicketObj => $TicketObj,
259 );
260
261 if ( $ARGS{'SubmitTicket'} ) {
262
263     my %squelched = ProcessTransactionSquelching( \%ARGS );
264     $ARGS{'SquelchMailTo'} = [keys %squelched] if keys %squelched;
265
266     my ($status, @msg) = $m->comp(
267         '/Elements/ValidateCustomFields',
268         CustomFields => $TicketObj->TransactionCustomFields,
269         Object => RT::Transaction->new( $session{'CurrentUser'} ),
270         ARGSRef => \%ARGS
271     );
272     unless ( $status ) {
273         push @results, @msg;
274         $checks_failure = 1;
275     }
276     $status = $m->comp('/Elements/Crypt/SignEncryptWidget:Check',
277         self      => $gnupg_widget,
278         TicketObj => $TicketObj,
279     );
280     $checks_failure = 1 unless $status;
281 }
282
283 # check email addresses for RT's
284 {
285     foreach my $field ( qw(UpdateCc UpdateBcc) ) {
286         my $value = $ARGS{ $field };
287         next unless defined $value && length $value;
288
289         my @emails = Email::Address->parse( $value );
290         foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
291             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)) );
292             $checks_failure = 1;
293             $email = undef;
294         }
295         $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
296     }
297 }
298 my $skip_update = 0;
299 $m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
300               checks_failure => $checks_failure, results => \@results, TicketObj => $TicketObj );
301
302 if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
303     $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
304     return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
305 }
306 </%INIT>
307
308 <%ARGS>
309 $id => undef
310 $Action => ''
311 $DefaultStatus => undef
312 </%ARGS>