1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2011 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&>Owner</&>:</span>
94 <& /Elements/SelectOwner,
96 TicketObj => $TicketObj,
97 QueueObj => $TicketObj->QueueObj,
98 DefaultLabel => loc("[_1] (Unchanged)", $m->scomp('/Elements/ShowUser', User => $TicketObj->OwnerObj)),
99 Default => $ARGS{'Owner'}
101 <span class="label"><&|/l&>Close this Ticket on</&>:</span>
102 <& /Elements/SelectDate,
103 menu_prefix => 'WillResolve',
107 % if ( $TicketObj->WillResolve ) {
108 <span class="label"> (<% $TicketObj->WillResolveObj->AsString %>)</span>
110 <script type="text/javascript">
114 <td rowspan=4 valign="top">
115 <table style="float:right;">
117 <td class="label"><&|/l&>Worked</&>:</td>
118 <td><& /Elements/EditTimeValue,
119 Name => 'UpdateTimeWorked',
120 Default => $ARGS{UpdateTimeWorked}||'',
121 InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
124 <& /Ticket/Elements/EditTransactionCustomFields,
126 TicketObj => $TicketObj,
127 UILocation => 'TimeWorked',
131 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );
133 <input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" /><br />
135 <tr><td class="label"><&|/l&>Update Type</&>:</td>
136 <td><select name="UpdateType">
138 <option value="private" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "private") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$CommentDefault |n %>><&|/l&>Comments (Not sent to requestors)</&></option>
141 <option value="response" <% ($ARGS{'UpdateType'} && $ARGS{'UpdateType'} eq "response") ? qq[ selected="selected"] : !$ARGS{'UpdateType'}&&$ResponseDefault |n %>><&|/l&>Reply to requestors</&></option>
144 % $m->callback( %ARGS, CallbackName => 'AfterUpdateType' );
146 <tr><td class="label"><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size="60" value="<% $ARGS{UpdateSubject} || $TicketObj->Subject()%>" />
147 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
150 <& /Ticket/Elements/UpdateCc, %ARGS, TicketObj => $TicketObj &>
152 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj &>
154 % if (exists $session{'Attachments'}) {
155 <tr><td><&|/l&>Attached file</&>:</td>
157 <&|/l&>Check box to delete</&><br />
158 % foreach my $attach_name (keys %{$session{'Attachments'}}) {
159 <input type="checkbox" class="checkbox" name="DeleteAttach-<%$attach_name%>" value="1" /><%$attach_name%><br />
165 <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" />
168 % if ( $gnupg_widget ) {
169 <tr><td> </td><td>
170 <& /Elements/GnuPG/SignEncryptWidget,
171 self => $gnupg_widget,
172 TicketObj => $TicketObj,
176 % $m->callback( %ARGS, CallbackName => 'AfterGnuPG' );
178 <tr><td class="label" valign="top"><&|/l&>Message</&>:</td><td colspan=2>
179 % $m->callback( %ARGS, CallbackName => 'BeforeMessageBox' );
180 % if (exists $ARGS{UpdateContent}) {
181 % # preserve QuoteTransaction so we can use it to set up sane references/in/reply to
182 % my $temp = $ARGS{'QuoteTransaction'};
183 % delete $ARGS{'QuoteTransaction'};
184 <& /Elements/MessageBox, Name=>"UpdateContent", Default=>$ARGS{UpdateContent}, IncludeSignature => 0, %ARGS&>
185 % $ARGS{'QuoteTransaction'} = $temp;
187 % my $IncludeSignature = 1;
188 % $IncludeSignature = 0 if $Action ne 'Respond' && !RT->Config->Get('MessageBoxIncludeSignatureOnComment');
189 <& /Elements/MessageBox, Name=>"UpdateContent", IncludeSignature => $IncludeSignature, %ARGS &>
197 <& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>
198 % if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {
199 <&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &>
200 <& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &>
208 my $checks_failure = 0;
211 my $TicketObj = LoadTicket($id);
215 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure, results => \@results, CallbackName => 'Initial' );
217 unless($DefaultStatus){
218 $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
221 unless (RT->Config->Get('SuppressAutoOpenOnUpdate', $session{'CurrentUser'})) {
222 if ($DefaultStatus eq 'new') {
223 $DefaultStatus = 'open';
227 if ($DefaultStatus eq 'resolved') {
228 $title = loc("Resolve ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
230 $title = loc("Update ticket #[_1] ([_2])", $TicketObj->id, $TicketObj->Subject);
233 # Things needed in the template - we'll do the processing here, just
234 # for the convenience:
236 my ($CommentDefault, $ResponseDefault);
237 if ($Action ne 'Respond') {
238 $CommentDefault = qq[ selected="selected"];
239 $ResponseDefault = "";
241 $CommentDefault = "";
242 $ResponseDefault = qq[ selected="selected"];
247 $CanRespond = 1 if ( $TicketObj->CurrentUserHasRight('ReplyToTicket') or
248 $TicketObj->CurrentUserHasRight('ModifyTicket') );
250 $CanComment = 1 if ( $TicketObj->CurrentUserHasRight('CommentOnTicket') or
251 $TicketObj->CurrentUserHasRight('ModifyTicket') );
254 # {{{ deal with deleting uploaded attachments
255 foreach my $key (keys %ARGS) {
256 if ($key =~ m/^DeleteAttach-(.+)$/) {
257 delete $session{'Attachments'}{$1};
259 $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
263 # {{{ store the uploaded attachment in session
264 if ($ARGS{'Attach'}) { # attachment?
265 my $attachment = MakeMIMEEntity(
266 AttachmentFieldName => 'Attach'
269 my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
270 $session{'Attachments'} = {
271 %{$session{'Attachments'} || {}},
272 $file_path => $attachment,
277 # delete temporary storage entry to make WebUI clean
278 unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
279 delete $session{'Attachments'};
283 my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
284 $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
285 self => $gnupg_widget,
286 TicketObj => $TicketObj,
289 if ( $ARGS{'SubmitTicket'} ) {
290 my $CFs = $TicketObj->TransactionCustomFields;
291 my $ValidCFs = $m->comp(
292 '/Elements/ValidateCustomFields',
293 CustomFields => $CFs,
294 NamePrefix => "Object-RT::Transaction--CustomField-",
297 unless ( $ValidCFs ) {
299 while (my $CF = $CFs->Next) {
300 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
301 push @results, loc($CF->Name) . ': ' . $msg;
304 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
305 self => $gnupg_widget,
306 TicketObj => $TicketObj,
308 $checks_failure = 1 unless $status;
311 # check email addresses for RT's
313 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
314 my $value = $ARGS{ $field };
315 next unless defined $value && length $value;
317 my @emails = Email::Address->parse( $value );
318 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
319 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)) );
323 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
327 $m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
328 checks_failure => $checks_failure, results => \@results, TicketObj => $TicketObj );
330 if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
331 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
332 return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
339 $DefaultStatus => undef