Putting 4.2.0 on top of 4.0.17
[usit-rt.git] / share / html / Ticket / Create.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,
49 Title => $title,
50 onload => "function () { hide('Ticket-Create-details') }" &>
51<& /Elements/Tabs &>
52
53<& /Elements/ListActions, actions => \@results &>
54
55<form action="<% RT->Config->Get('WebPath') %>/Ticket/Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
56 <input type="hidden" class="hidden" name="id" value="new" />
af59614d 57 <input type="hidden" class="hidden" name="Token" value="<% $ARGS{'Token'} %>" />
84fb5b46
MKG
58
59% $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
60
61% if ($gnupg_widget) {
af59614d 62 <& /Elements/Crypt/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
84fb5b46
MKG
63% }
64
65<div id="Ticket-Create-basics">
66<a name="basics"></a>
67
68<div id="ticket-create-metadata">
69 <&| /Widgets/TitleBox, title => loc("Basics"), class=>'ticket-info-basics' &>
70 <input type="hidden" class="hidden" name="Queue" value="<% $QueueObj->Id %>" />
71 <table width="100%" border="0">
72 <& /Ticket/Elements/EditBasics,
73 InTable => 1,
74 fields => [
75 { name => 'Queue',
76 comp => '/Ticket/Elements/ShowQueue',
77 args => {
78 QueueObj => $QueueObj,
79 },
80 },
81 { name => 'Status',
af59614d 82 comp => '/Ticket/Elements/SelectStatus',
84fb5b46
MKG
83 args => {
84 Name => "Status",
84fb5b46
MKG
85 QueueObj => $QueueObj,
86 },
87 },
88 { name => 'Owner',
89 comp => '/Elements/SelectOwner',
90 args => {
91 Name => "Owner",
92 Default => $ARGS{Owner} || RT->Nobody->Id,
93 DefaultValue => 0,
94 QueueObj => $QueueObj,
95 },
96 }
97 ]
98 &>
99
100% $m->callback( CallbackName => 'AfterOwner', ARGSRef => \%ARGS );
101
af59614d
MKG
102 <& /Elements/EditCustomFields,
103 %ARGS,
104 Object => $ticket,
105 CustomFields => $QueueObj->TicketCustomFields,
106 Grouping => 'Basics',
107 InTable => 1,
108 &>
84fb5b46
MKG
109 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
110 </table>
111 </&>
b5747ff2 112% $m->callback( CallbackName => 'AfterBasics', QueueObj => $QueueObj, ARGSRef => \%ARGS );
af59614d
MKG
113
114<& /Elements/EditCustomFieldCustomGroupings,
115 %ARGS,
116 Object => $ticket,
117 CustomFieldGenerator => sub { $QueueObj->TicketCustomFields },
118&>
119
84fb5b46
MKG
120</div>
121
122<div id="ticket-create-message">
123 <&| /Widgets/TitleBox, title => $title, class => 'messagedetails' &>
124<table border="0" cellpadding="0" cellspacing="0">
125<tr>
126<td class="label">
127<&|/l&>Requestors</&>:
128</td>
129<td class="value" colspan="5">
af59614d 130<& /Elements/EmailInput, Name => 'Requestors', Size => undef, Default => $ARGS{Requestors} || $session{CurrentUser}->EmailAddress, AutocompleteMultiple => 1 &>
84fb5b46
MKG
131% $m->callback( CallbackName => 'AfterRequestors', QueueObj => $QueueObj, ARGSRef => \%ARGS );
132</td>
133</tr>
134<tr>
135<td class="label">
136<&|/l&>Cc</&>:
137</td>
af59614d 138<td class="value" colspan="5"><& /Elements/EmailInput, Name => 'Cc', Size => undef, Default => $ARGS{Cc}, AutocompleteMultiple => 1 &></td>
84fb5b46
MKG
139</tr>
140
141<tr>
142 <td class="label">&nbsp;</td>
143 <td class="comment" colspan="5">
144 <i><font size="-2">
145 <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of email addresses. These people <strong>will</strong> receive future updates.)</&>
146 </font></i>
147 </td>
148</tr>
149
150<tr>
151<td class="label">
152<&|/l&>Admin Cc</&>:
153</td>
af59614d 154<td class="value" colspan="5"><& /Elements/EmailInput, Name => 'AdminCc', Size => undef, Default => $ARGS{AdminCc}, AutocompleteMultiple => 1 &></td>
84fb5b46
MKG
155</tr>
156
157<tr>
158 <td class="label">&nbsp;</td>
159 <td class="comment" colspan="5">
160 <i><font size="-2">
161 <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of administrative email addresses. These people <strong>will</strong> receive future updates.)</&>
162 </font></i>
163 </td>
164</tr>
165
af59614d
MKG
166<& /Elements/EditCustomFields,
167 %ARGS,
168 Object => $ticket,
169 CustomFields => $QueueObj->TicketCustomFields,
170 Grouping => 'People',
171 InTable => 1,
172&>
173
84fb5b46
MKG
174<tr>
175<td class="label">
176<&|/l&>Subject</&>:
177</td>
178<td class="value" colspan="5">
179<input type="text" name="Subject" maxsize="200" value="<%$ARGS{Subject} || ''%>" />
180% $m->callback( %ARGS, CallbackName => 'AfterSubject' );
181</td>
182</tr>
183
184% if ( $gnupg_widget ) {
185<tr><td>&nbsp;</td><td colspan="5">
af59614d 186<& /Elements/Crypt/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
84fb5b46
MKG
187</td></tr>
188% }
189
190<tr>
191<td colspan="6">
192<&|/l&>Describe the issue below</&>:<br />
193% if ( RT->Config->Get('ArticleOnTicketCreate')) {
194<& /Articles/Elements/BeforeMessageBox, %ARGS, QueueObj => $QueueObj &>
195% }
196% $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'BeforeMessageBox' );
197% if (exists $ARGS{Content}) {
198<& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
199% } else {
200<& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &>
201%}
202% $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'AfterMessageBox' );
203
204<br />
205</td>
206</tr>
207
208 <& /Ticket/Elements/AddAttachments, %ARGS, QueueObj => $QueueObj &>
209 </table>
210 </&>
211 <& /Elements/Submit, Label => loc("Create"), id => 'SubmitTicket' &>
212 </div>
213</div>
214
215<div id="Ticket-Create-details">
216<a name="details"></a>
217<table width="100%" border="0">
218<tr>
219<td width="50%" valign="top" class="boxcontainer">
220 <div class="ticket-info-basics">
af59614d
MKG
221 <&| /Widgets/TitleBox, title => loc('The Basics'),
222 title_class=> 'inverse',
223 color => "#993333" &>
84fb5b46
MKG
224<table border="0">
225<tr><td class="label"><&|/l&>Priority</&>:</td>
226<td><& /Elements/SelectPriority,
227 Name => "InitialPriority",
228 Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority,
229&></td></tr>
230<tr><td class="label"><&|/l&>Final Priority</&>:</td>
231<td><& /Elements/SelectPriority,
232 Name => "FinalPriority",
233 Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority,
234&></td></tr>
235<tr><td class="label"><&|/l&>Time Estimated</&>:</td>
236<td>
237<& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '', InUnits => $ARGS{'TimeEstimated-TimeUnits'} &>
238
239</td></tr>
240<tr><td class="label"><&|/l&>Time Worked</&>:</td>
241<td>
242<& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '', InUnits => $ARGS{'TimeWorked-TimeUnits'} &>
243</td></tr>
244<tr>
245<td class="label"><&|/l&>Time Left</&>:</td>
246<td>
247<& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '', InUnits => $ARGS{'TimeLeft-TimeUnits'} &>
248</td></tr>
249</table>
250</&>
251<br />
252<div class="ticket-info-dates">
253<&|/Widgets/TitleBox, title => loc("Dates"),
af59614d
MKG
254 title_class=> 'inverse',
255 color => "#663366" &>
84fb5b46
MKG
256
257<table>
258<tr><td class="label"><&|/l&>Starts</&>:</td><td><& /Elements/SelectDate, Name => "Starts", Default => $ARGS{Starts} || '' &></td></tr>
259<tr><td class="label"><&|/l&>Due</&>:</td><td><& /Elements/SelectDate, Name => "Due", Default => $ARGS{Due} || '' &></td></tr>
af59614d
MKG
260<& /Elements/EditCustomFields,
261 %ARGS,
262 Object => $ticket,
263 CustomFields => $QueueObj->TicketCustomFields,
264 Grouping => 'Dates',
265 InTable => 1,
266&>
84fb5b46
MKG
267</table>
268</&>
269</div>
270</div>
271<br />
272</td>
273
274<td valign="top" class="boxcontainer">
275<div class="ticket-info-links">
276<&| /Widgets/TitleBox, title => loc('Links'), title_class=> 'inverse' &>
af59614d
MKG
277<& /Elements/AddLinks,
278 Object => $ticket,
279 CustomFields => $QueueObj->TicketCustomFields,
280 ARGSRef => \%ARGS,
281 &>
84fb5b46
MKG
282</&>
283</div>
284<br />
285
286</td>
287</tr>
288</table>
289<& /Elements/Submit, Label => loc("Create") &>
290</div>
291</form>
292
293<%INIT>
294$m->callback( CallbackName => "Init", ARGSRef => \%ARGS );
295my $Queue = $ARGS{Queue};
296$session{DefaultQueue} = $Queue;
297
298if ($CloneTicket) {
299 my $CloneTicketObj = RT::Ticket->new( $session{CurrentUser} );
300 $CloneTicketObj->Load($CloneTicket)
301 or Abort( loc("Ticket could not be loaded") );
302
303 my $clone = {
304 Requestors => join( ',', $CloneTicketObj->RequestorAddresses ),
305 Cc => join( ',', $CloneTicketObj->CcAddresses ),
306 AdminCc => join( ',', $CloneTicketObj->AdminCcAddresses ),
307 InitialPriority => $CloneTicketObj->Priority,
308 };
309
310 $clone->{$_} = $CloneTicketObj->$_()
311 for qw/Owner Subject FinalPriority TimeEstimated TimeWorked
312 Status TimeLeft/;
313
314 $clone->{$_} = $CloneTicketObj->$_->AsString
315 for grep { $CloneTicketObj->$_->Unix }
316 map { $_ . "Obj" } qw/Starts Started Due Resolved/;
317
b5747ff2
MKG
318 my $get_link_value = sub {
319 my ($link, $type) = @_;
320 my $uri_method = $type . 'URI';
321 my $local_method = 'Local' . $type;
322 my $uri = $link->$uri_method;
323 return if $uri->IsLocal and
324 $uri->Object and
325 $uri->Object->isa('RT::Ticket') and
326 $uri->Object->Type eq 'reminder';
327
328 return $link->$local_method || $uri->URI;
329 };
af59614d
MKG
330 my (@refers, @refers_by);
331 my $refers = $CloneTicketObj->RefersTo;
84fb5b46 332 while ( my $refer = $refers->Next ) {
b5747ff2
MKG
333 my $refer_value = $get_link_value->($refer, 'Target');
334 push @refers, $refer_value if defined $refer_value;
84fb5b46
MKG
335 }
336 $clone->{'new-RefersTo'} = join ' ', @refers;
337
338 my $refers_by = $CloneTicketObj->ReferredToBy;
339 while ( my $refer_by = $refers_by->Next ) {
b5747ff2
MKG
340 my $refer_by_value = $get_link_value->($refer_by, 'Base');
341 push @refers_by, $refer_by_value if defined $refer_by_value;
84fb5b46
MKG
342 }
343 $clone->{'RefersTo-new'} = join ' ', @refers_by;
84fb5b46
MKG
344
345 my $cfs = $CloneTicketObj->QueueObj->TicketCustomFields();
346 while ( my $cf = $cfs->Next ) {
347 my $cf_id = $cf->id;
348 my $cf_values = $CloneTicketObj->CustomFieldValues( $cf->id );
349 my @cf_values;
350 while ( my $cf_value = $cf_values->Next ) {
351 push @cf_values, $cf_value->Content;
352 }
353 $clone->{"Object-RT::Ticket--CustomField-$cf_id-Value"} = join "\n",
354 @cf_values;
355 }
356
357 for ( keys %$clone ) {
358 $ARGS{$_} = $clone->{$_} if not defined $ARGS{$_};
359 }
360
361}
362
363my @results;
364
365my $title = loc("Create a new ticket");
366
367my $QueueObj = RT::Queue->new($session{'CurrentUser'});
af59614d 368$QueueObj->Load($Queue) || Abort(loc("Queue [_1] could not be loaded.", $Queue||''));
84fb5b46
MKG
369
370$m->callback( QueueObj => $QueueObj, title => \$title, results => \@results, ARGSRef => \%ARGS );
371
af59614d 372$m->scomp( '/Articles/Elements/SubjectOverride', ARGSRef => \%ARGS, QueueObj => $QueueObj, results => \@results );
84fb5b46 373
af59614d 374$QueueObj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."));
84fb5b46 375
af59614d 376my $ticket = RT::Ticket->new($session{'CurrentUser'}); # empty ticket object
84fb5b46 377
5b0d0914 378ProcessAttachments(ARGSRef => \%ARGS);
84fb5b46
MKG
379
380my $checks_failure = 0;
381
af59614d
MKG
382{
383 my ($status, @msg) = $m->comp(
384 '/Elements/ValidateCustomFields',
385 CustomFields => $QueueObj->TicketCustomFields,
386 ARGSRef => \%ARGS
387 );
388 unless ($status) {
389 $checks_failure = 1;
390 push @results, @msg;
391 }
392}
393
394my $gnupg_widget = $m->comp('/Elements/Crypt/SignEncryptWidget:new', Arguments => \%ARGS );
395$m->comp( '/Elements/Crypt/SignEncryptWidget:Process',
84fb5b46
MKG
396 self => $gnupg_widget,
397 QueueObj => $QueueObj,
398);
399
400
401if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
af59614d 402 my $status = $m->comp('/Elements/Crypt/SignEncryptWidget:Check',
84fb5b46
MKG
403 self => $gnupg_widget,
404 Operation => 'Create',
405 QueueObj => $QueueObj,
406 );
407 $checks_failure = 1 unless $status;
408}
409
410# check email addresses for RT's
411{
412 foreach my $field ( qw(Requestors Cc AdminCc) ) {
413 my $value = $ARGS{ $field };
414 next unless defined $value && length $value;
415
416 my @emails = Email::Address->parse( $value );
417 foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
418 push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc($field =~ /^(.*?)s?$/) );
419 $checks_failure = 1;
420 $email = undef;
421 }
422 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
423 }
424}
425
426my $skip_create = 0;
427$m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, skip_create => \$skip_create,
428 checks_failure => $checks_failure, results => \@results );
429
430$m->comp( '/Articles/Elements/CheckSkipCreate', ARGSRef => \%ARGS, skip_create => \$skip_create,
431 checks_failure => $checks_failure, results => \@results );
432
433if ((!exists $ARGS{'AddMoreAttach'}) and (defined($ARGS{'id'}) and $ARGS{'id'} eq 'new')) { # new ticket?
af59614d 434 if ( !$checks_failure && !$skip_create ) {
84fb5b46
MKG
435 $m->comp('Display.html', %ARGS);
436 $RT::Logger->crit("After display call; error is $@");
437 $m->abort();
438 }
84fb5b46
MKG
439}
440PageMenu->child( basics => raw_html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Basics') . q[</a>]);
441PageMenu->child( details => raw_html => q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Details') . q[</a>]);
442</%INIT>
443
444<%ARGS>
445$DependsOn => undef
446$DependedOnBy => undef
447$MemberOf => undef
448$QuoteTransaction => undef
449$CloneTicket => undef
450</%ARGS>