Upgrade to 4.0.13
[usit-rt.git] / share / html / Ticket / Update.html
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
403d7b0b 5%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
84fb5b46
MKG
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>
204my $CanRespond = 0;
205my $CanComment = 0;
206my $checks_failure = 0;
207
208my $TicketObj = LoadTicket($id);
209
210my @results;
211
212$m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, checks_failure => \$checks_failure, results => \@results, CallbackName => 'Initial' );
213
214unless($DefaultStatus){
215 $DefaultStatus=($ARGS{'Status'} ||$TicketObj->Status());
216}
217
218my $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
223my ($CommentDefault, $ResponseDefault);
224if ($Action ne 'Respond') {
225 $CommentDefault = qq[ selected="selected"];
226 $ResponseDefault = "";
227} else {
228 $CommentDefault = "";
229 $ResponseDefault = qq[ selected="selected"];
230}
231
232my $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
5b0d0914 245ProcessAttachments(ARGSRef => \%ARGS);
84fb5b46
MKG
246
247my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS );
248$m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
249 self => $gnupg_widget,
250 TicketObj => $TicketObj,
251);
252
253if ( $ARGS{'SubmitTicket'} ) {
254
c36a7e1d
MKG
255 my %squelched = ProcessTransactionSquelching( \%ARGS );
256 $ARGS{'SquelchMailTo'} = [keys %squelched] if keys %squelched;
84fb5b46
MKG
257
258 my $CFs = $TicketObj->TransactionCustomFields;
259 my $ValidCFs = $m->comp(
260 '/Elements/ValidateCustomFields',
261 CustomFields => $CFs,
262 NamePrefix => "Object-RT::Transaction--CustomField-",
263 ARGSRef => \%ARGS
264 );
265 unless ( $ValidCFs ) {
266 $checks_failure = 1;
267 while (my $CF = $CFs->Next) {
268 my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
269 push @results, loc($CF->Name) . ': ' . $msg;
270 }
271 }
272 my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
273 self => $gnupg_widget,
274 TicketObj => $TicketObj,
275 );
276 $checks_failure = 1 unless $status;
277}
278
279# check email addresses for RT's
280{
281 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
282 my $value = $ARGS{ $field };
283 next unless defined $value && length $value;
284
285 my @emails = Email::Address->parse( $value );
286 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
287 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)) );
288 $checks_failure = 1;
289 $email = undef;
290 }
291 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
292 }
293}
294my $skip_update = 0;
295$m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
296 checks_failure => $checks_failure, results => \@results, TicketObj => $TicketObj );
297
298if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
299 $m->callback( Ticket => $TicketObj, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
300 return $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
301}
302</%INIT>
303
304<%ARGS>
305$id => undef
306$Action => undef
307$DefaultStatus => undef
308</%ARGS>