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 }}}
50 onload => "function () { hide('Ticket-Create-details') }" &>
53 <& /Elements/ListActions, actions => \@results &>
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" />
57 <input type="hidden" class="hidden" name="Token" value="<% $ARGS{'Token'} %>" />
59 % $m->callback( CallbackName => 'FormStart', QueueObj => $QueueObj, ARGSRef => \%ARGS );
61 % if ($gnupg_widget) {
62 <& /Elements/Crypt/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
65 <div id="Ticket-Create-basics">
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,
76 comp => '/Ticket/Elements/ShowQueue',
78 QueueObj => $QueueObj,
82 comp => '/Ticket/Elements/SelectStatus',
85 QueueObj => $QueueObj,
89 comp => '/Elements/SelectOwner',
92 Default => $ARGS{Owner} || RT->Nobody->Id,
94 QueueObj => $QueueObj,
100 % $m->callback( CallbackName => 'AfterOwner', ARGSRef => \%ARGS );
102 <& /Elements/EditCustomFields,
105 CustomFields => $QueueObj->TicketCustomFields,
106 Grouping => 'Basics',
109 <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
112 % $m->callback( CallbackName => 'AfterBasics', QueueObj => $QueueObj, ARGSRef => \%ARGS );
114 <& /Elements/EditCustomFieldCustomGroupings,
117 CustomFieldGenerator => sub { $QueueObj->TicketCustomFields },
122 <div id="ticket-create-message">
123 <&| /Widgets/TitleBox, title => $title, class => 'messagedetails' &>
124 <table border="0" cellpadding="0" cellspacing="0">
127 <&|/l&>Requestors</&>:
129 <td class="value" colspan="5">
130 <& /Elements/EmailInput, Name => 'Requestors', Size => undef, Default => $ARGS{Requestors} || $session{CurrentUser}->EmailAddress, AutocompleteMultiple => 1 &>
131 % $m->callback( CallbackName => 'AfterRequestors', QueueObj => $QueueObj, ARGSRef => \%ARGS );
138 <td class="value" colspan="5"><& /Elements/EmailInput, Name => 'Cc', Size => undef, Default => $ARGS{Cc}, AutocompleteMultiple => 1 &></td>
142 <td class="label"> </td>
143 <td class="comment" colspan="5">
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.)</&>
154 <td class="value" colspan="5"><& /Elements/EmailInput, Name => 'AdminCc', Size => undef, Default => $ARGS{AdminCc}, AutocompleteMultiple => 1 &></td>
158 <td class="label"> </td>
159 <td class="comment" colspan="5">
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.)</&>
166 <& /Elements/EditCustomFields,
169 CustomFields => $QueueObj->TicketCustomFields,
170 Grouping => 'People',
178 <td class="value" colspan="5">
179 <input type="text" name="Subject" maxsize="200" value="<%$ARGS{Subject} || ''%>" />
180 % $m->callback( %ARGS, CallbackName => 'AfterSubject' );
184 % if ( $gnupg_widget ) {
185 <tr><td> </td><td colspan="5">
186 <& /Elements/Crypt/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
192 <&|/l&>Describe the issue below</&>:<br />
193 % if ( RT->Config->Get('ArticleOnTicketCreate')) {
194 <& /Articles/Elements/BeforeMessageBox, %ARGS, QueueObj => $QueueObj &>
196 % $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'BeforeMessageBox' );
197 % if (exists $ARGS{Content}) {
198 <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
200 <& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &>
202 % $m->callback( %ARGS, QueueObj => $QueueObj, CallbackName => 'AfterMessageBox' );
208 <& /Ticket/Elements/AddAttachments, %ARGS, QueueObj => $QueueObj &>
211 <& /Elements/Submit, Label => loc("Create"), id => 'SubmitTicket' &>
215 <div id="Ticket-Create-details">
216 <a name="details"></a>
217 <table width="100%" border="0">
219 <td width="50%" valign="top" class="boxcontainer">
220 <div class="ticket-info-basics">
221 <&| /Widgets/TitleBox, title => loc('The Basics'),
222 title_class=> 'inverse',
223 color => "#993333" &>
225 <tr><td class="label"><&|/l&>Priority</&>:</td>
226 <td><& /Elements/SelectPriority,
227 Name => "InitialPriority",
228 Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->InitialPriority,
230 <tr><td class="label"><&|/l&>Final Priority</&>:</td>
231 <td><& /Elements/SelectPriority,
232 Name => "FinalPriority",
233 Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->FinalPriority,
235 <tr><td class="label"><&|/l&>Time Estimated</&>:</td>
237 <& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '', InUnits => $ARGS{'TimeEstimated-TimeUnits'} &>
240 <tr><td class="label"><&|/l&>Time Worked</&>:</td>
242 <& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '', InUnits => $ARGS{'TimeWorked-TimeUnits'} &>
245 <td class="label"><&|/l&>Time Left</&>:</td>
247 <& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '', InUnits => $ARGS{'TimeLeft-TimeUnits'} &>
252 <div class="ticket-info-dates">
253 <&|/Widgets/TitleBox, title => loc("Dates"),
254 title_class=> 'inverse',
255 color => "#663366" &>
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>
260 <& /Elements/EditCustomFields,
263 CustomFields => $QueueObj->TicketCustomFields,
274 <td valign="top" class="boxcontainer">
275 <div class="ticket-info-links">
276 <&| /Widgets/TitleBox, title => loc('Links'), title_class=> 'inverse' &>
277 <& /Elements/AddLinks,
279 CustomFields => $QueueObj->TicketCustomFields,
289 <& /Elements/Submit, Label => loc("Create") &>
294 $m->callback( CallbackName => "Init", ARGSRef => \%ARGS );
295 my $Queue = $ARGS{Queue};
296 $session{DefaultQueue} = $Queue;
299 my $CloneTicketObj = RT::Ticket->new( $session{CurrentUser} );
300 $CloneTicketObj->Load($CloneTicket)
301 or Abort( loc("Ticket could not be loaded") );
304 Requestors => join( ',', $CloneTicketObj->RequestorAddresses ),
305 Cc => join( ',', $CloneTicketObj->CcAddresses ),
306 AdminCc => join( ',', $CloneTicketObj->AdminCcAddresses ),
307 InitialPriority => $CloneTicketObj->Priority,
310 $clone->{$_} = $CloneTicketObj->$_()
311 for qw/Owner Subject FinalPriority TimeEstimated TimeWorked
314 $clone->{$_} = $CloneTicketObj->$_->AsString
315 for grep { $CloneTicketObj->$_->Unix }
316 map { $_ . "Obj" } qw/Starts Started Due Resolved/;
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
325 $uri->Object->isa('RT::Ticket') and
326 $uri->Object->Type eq 'reminder';
328 return $link->$local_method || $uri->URI;
330 my (@refers, @refers_by);
331 my $refers = $CloneTicketObj->RefersTo;
332 while ( my $refer = $refers->Next ) {
333 my $refer_value = $get_link_value->($refer, 'Target');
334 push @refers, $refer_value if defined $refer_value;
336 $clone->{'new-RefersTo'} = join ' ', @refers;
338 my $refers_by = $CloneTicketObj->ReferredToBy;
339 while ( my $refer_by = $refers_by->Next ) {
340 my $refer_by_value = $get_link_value->($refer_by, 'Base');
341 push @refers_by, $refer_by_value if defined $refer_by_value;
343 $clone->{'RefersTo-new'} = join ' ', @refers_by;
345 my $cfs = $CloneTicketObj->QueueObj->TicketCustomFields();
346 while ( my $cf = $cfs->Next ) {
348 my $cf_values = $CloneTicketObj->CustomFieldValues( $cf->id );
350 while ( my $cf_value = $cf_values->Next ) {
351 push @cf_values, $cf_value->Content;
353 $clone->{"Object-RT::Ticket--CustomField-$cf_id-Value"} = join "\n",
357 for ( keys %$clone ) {
358 $ARGS{$_} = $clone->{$_} if not defined $ARGS{$_};
365 my $title = loc("Create a new ticket");
367 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
368 $QueueObj->Load($Queue) || Abort(loc("Queue [_1] could not be loaded.", $Queue||''));
370 $m->callback( QueueObj => $QueueObj, title => \$title, results => \@results, ARGSRef => \%ARGS );
372 $m->scomp( '/Articles/Elements/SubjectOverride', ARGSRef => \%ARGS, QueueObj => $QueueObj, results => \@results );
374 $QueueObj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."));
376 my $ticket = RT::Ticket->new($session{'CurrentUser'}); # empty ticket object
378 ProcessAttachments(ARGSRef => \%ARGS);
380 my $checks_failure = 0;
383 my ($status, @msg) = $m->comp(
384 '/Elements/ValidateCustomFields',
385 CustomFields => $QueueObj->TicketCustomFields,
394 my $gnupg_widget = $m->comp('/Elements/Crypt/SignEncryptWidget:new', Arguments => \%ARGS );
395 $m->comp( '/Elements/Crypt/SignEncryptWidget:Process',
396 self => $gnupg_widget,
397 QueueObj => $QueueObj,
401 if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
402 my $status = $m->comp('/Elements/Crypt/SignEncryptWidget:Check',
403 self => $gnupg_widget,
404 Operation => 'Create',
405 QueueObj => $QueueObj,
407 $checks_failure = 1 unless $status;
410 # check email addresses for RT's
412 foreach my $field ( qw(Requestors Cc AdminCc) ) {
413 my $value = $ARGS{ $field };
414 next unless defined $value && length $value;
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?$/) );
422 $ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
427 $m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, skip_create => \$skip_create,
428 checks_failure => $checks_failure, results => \@results );
430 $m->comp( '/Articles/Elements/CheckSkipCreate', ARGSRef => \%ARGS, skip_create => \$skip_create,
431 checks_failure => $checks_failure, results => \@results );
433 if ((!exists $ARGS{'AddMoreAttach'}) and (defined($ARGS{'id'}) and $ARGS{'id'} eq 'new')) { # new ticket?
434 if ( !$checks_failure && !$skip_create ) {
435 $m->comp('Display.html', %ARGS);
436 $RT::Logger->crit("After display call; error is $@");
440 PageMenu->child( basics => raw_html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Basics') . q[</a>]);
441 PageMenu->child( details => raw_html => q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Details') . q[</a>]);
446 $DependedOnBy => undef
448 $QuoteTransaction => undef
449 $CloneTicket => undef