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