1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => $title &>
49 <& /Ticket/Elements/Tabs,
53 % $m->callback(CallbackName => 'BeforeActionList', ARGSRef => \%ARGS, Ticket => $TicketObj);
54 <& /Elements/ListActions, actions => \@results &>
56 <form action="Update.html" name="TicketUpdate"
57 method="post" enctype="multipart/form-data">
58 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS, Ticket => $TicketObj, CanRespond => $CanRespond, CanComment => $CanComment, ResponseDefault => $ResponseDefault, CommentDefault => $CommentDefault );
59 <input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction}||'' %>" />
60 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
61 <input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
63 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
65 <table width="100%" border="0">
66 % $m->callback(CallbackName => 'AfterTableOpens', ARGSRef => \%ARGS, Ticket => $TicketObj);
68 <tr><td valign="baseline" class="label"><&|/l&>Status</&>:</td>
69 <td valign="baseline">
70 <script type="text/javascript">
71 function changeStatus() {
72 var Status_select = document.getElementById('Status');
73 var x = Status_select.options[Status_select.selectedIndex].value;
74 var text = document.getElementById('WillResolve_Date');
75 var button = document.getElementById('WillResolve_Date_date_button');
76 if (x == 'resolved' || x == 'rejected' || x == 'deleted') {
78 button.style.display = 'none';
81 text.disabled = false;
82 button.style.display = 'inline';
86 <& /Elements/SelectStatus,
88 DefaultLabel => loc("[_1] (Unchanged)", loc($TicketObj->Status)),
89 Default => $ARGS{'Status'}
90 || ($TicketObj->Status eq $DefaultStatus ? undef : $DefaultStatus,
91 onchange => 'changeStatus()'
93 <span class="label"><&|/l&>Resolve this Ticket on</&>:</span>
94 <& /Elements/SelectDate,
95 menu_prefix => 'WillResolve',
99 % if ( $TicketObj->WillResolve ) {
100 <span class="label"> (<% $TicketObj->WillResolveObj->AsString %>)</span>
102 <script type="text/javascript">
106 <td rowspan=4 valign="top">
107 <table style="float:right;">
109 <td class="label"><&|/l&>Worked</&>:</td>
110 <td><& /Elements/EditTimeValue,
111 Name => 'UpdateTimeWorked',
112 Default => $ARGS{UpdateTimeWorked}||'',
113 InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
116 <& /Ticket/Elements/EditTransactionCustomFields,
118 TicketObj => $TicketObj,
119 UILocation => 'TimeWorked',
123 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
125 <input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
127 <tr><td class="label"><&|/l&>Owner</&>:</td>
128 <td><& /Elements/SelectOwner,
130 TicketObj => $TicketObj,
131 QueueObj => $TicketObj->QueueObj,
132 DefaultLabel => loc("[_1] (Unchanged)", $m->scomp('/Elements/ShowUser', User => $TicketObj->OwnerObj)),
133 Default => $ARGS{'Owner'}
136 <tr><td class="label"><&|/l&>Update Type</&>:</td>
137 <td><select name="UpdateType">
139 <option value="private" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
142 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
145 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
147 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size="60" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject()%>" />
148 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
151 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
153 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj &>
155 % if (exists $session{'Attachments'}) {
156 <tr><td><&|/l&>Attached file</&>:</td>
158 <&|/l&>Check box to delete</&><br />
159 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
160 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
166 <tr><td class="label"><&|/l&>Attach</&>:</td><td><input name="Attach" type="file" /><input type="submit" class="button" name="AddMoreAttach" value="<&|/l&>Add More Files</&>" /><input type="hidden" class="hidden" name="UpdateAttach" value="1" />
169 % if ( $gnupg_widget ) {
170 <tr><td> </td><td>
171 <& /Elements/GnuPG/SignEncryptWidget,
172 self => $gnupg_widget,
173 TicketObj => $TicketObj,
177 % $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
179 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td><td colspan=2>
180 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
181 % if (exists $ARGS{UpdateContent}) {
182 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
183 % my $temp = $ARGS{'QuoteTransaction'};
184 % delete $ARGS{'QuoteTransaction'};
185 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
186 % $ARGS{'QuoteTransaction'} = $temp;
188 % my $IncludeSignature = 1;
189 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
190 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
198 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
199 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
200 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &>
201 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
209 my $checks_failure = 0;
212 my $TicketObj = LoadTicket($id);
216 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure, results => \@results, CallbackName => 'Initial' );
218 unless($DefaultStatus){
219 $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
222 unless (RT->Config->Get('SuppressAutoOpenOnUpdate', $session{'CurrentUser'})) {
223 if ($DefaultStatus eq 'new') {
224 $DefaultStatus = 'open';
228 if ($DefaultStatus eq 'resolved') {
229 $title = loc("Resolve ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
231 $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
234 # Things needed in the template - we'll do the processing here, just
235 # for the convenience:
237 my ($CommentDefault, $ResponseDefault);
238 if ($Action ne 'Respond') {
239 $CommentDefault = qq[ selected="selected"];
240 $ResponseDefault = "";
242 $CommentDefault = "";
243 $ResponseDefault = qq[ selected="selected"];
248 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
249 $TicketObj->CurrentUserHasRight('ModifyTicket') );
251 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
252 $TicketObj->CurrentUserHasRight('ModifyTicket') );
255 # {{{ deal with deleting uploaded attachments
256 foreach my $key (keys %ARGS) {
257 if ($key =~ m/^DeleteAttach-(.+)$/) {
258 delete $session{'Attachments'}{$1};
260 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
264 # {{{ store the uploaded attachment in session
265 if ($ARGS{'Attach'}) { # attachment?
266 my $attachment = MakeMIMEEntity(
267 AttachmentFieldName => 'Attach'
270 my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
271 $session{'Attachments'} = {
272 %{$session{'Attachments'} || {}},
273 $file_path => $attachment,
278 # delete temporary storage entry to make WebUI clean
279 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
280 delete $session{'Attachments'};
284 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
285 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
286 self => $gnupg_widget,
287 TicketObj => $TicketObj,
290 if ( $ARGS{'SubmitTicket'} ) {
291 my $CFs = $TicketObj->TransactionCustomFields;
292 my $ValidCFs = $m->comp(
293 '/Elements/ValidateCustomFields',
294 CustomFields => $CFs,
295 NamePrefix => "Object-RT::Transaction--CustomField-",
298 unless ( $ValidCFs ) {
300 while (my $CF = $CFs->Next) {
301 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
302 push @results, loc($CF->Name) . ': ' . $msg;
305 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
306 self => $gnupg_widget,
307 TicketObj => $TicketObj,
309 $checks_failure = 1 unless $status;
312 # check email addresses for RT's
314 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
315 my $value = $ARGS{ $field };
316 next unless defined $value && length $value;
318 my @emails = Email::Address->parse( $value );
319 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
320 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)) );
324 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
328 $m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
329 checks_failure => $checks_failure, results => \@results, TicketObj => $TicketObj );
331 if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
332 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
333 return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
340 $DefaultStatus => undef