%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) %# %# %# LICENSE: %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: %# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) %# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that %# you are the copyright holder for those contributions and you grant %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} <& /RTIR/Elements/Header, Title => $Title, &> <& /Elements/Tabs &> % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $SplitObj); <& /Elements/ListActions, actions => \@results &> <%PERL> if ( $SplitObj && $SplitObj->id && !$SplitObj->CurrentUserHasRight('ModifyTicket') ) { $m->out( loc('You are not allowed to split from #[_1].', $SplitObj->id ) ); return; } if ( $ChildObj && $ChildObj->id && !$ChildObj->CurrentUserHasRight('ModifyTicket') ) { $m->out( loc('You are not allowed to link with #[_1].', $ChildObj->id ) ); return; } % if ( $Split ) {
% } else { % } % if ( $ChildObj ) { % } % if ( $Split ) { % } % $m->callback( CallbackName => 'AfterHidden', ARGSRef => \%ARGS ); <& /Elements/Crypt/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
<&| /Widgets/TitleBox, title => 'Basics', class => 'ticket-info-basics' &> % if ($constituency) { % } % if ( $Split ) { % } % if ( $ChildObj ) { % } % if ( $ChildObj ) { % } else { % } % if ( !$QueueObj->SLADisabled ) { % } <& /RTIR/Elements/EditCustomFields, %ARGS, TicketObj => $ticket, QueueObj => $QueueObj, DefaultsFrom => $SplitObj || $ChildObj, CFDefaults => \%CFDefaults, &>
<% loc('Constituency') %>: <% $constituency %>
<% loc('Split from') %>: <% loc("[_1] #[_2]: [_3]", RT::IR::TicketType(Lifecycle => $SplitObj->QueueObj->Lifecycle), $SplitObj->Id, $SplitObj->Subject) %>
<&|/l&>Queue: <& /Ticket/Elements/ShowQueue, QueueObj => $QueueObj &>
<&|/l&>Status: <& /Ticket/Elements/SelectStatus, Name => 'Status', Object => $QueueObj, DefaultValue => 0, Default => $ARGS{Status} || $QueueObj->LifecycleObj->DefaultOnCreate, &>
<&|/l&>Owner: <& /Elements/ShowUser, User => $ChildObj->OwnerObj &> <& /Elements/SelectOwner, Name => 'Owner', QueueObj => $QueueObj, Default => $ARGS{'Owner'} || $session{'CurrentUser'}->Id &>
<&|/l&>SLA: <& /Elements/SelectSLA, Name => 'SLA', Default => $ARGS{SLA} || RT::SLA->GetDefaultServiceLevel(Queue => $QueueObj), DefaultValue => RT::SLA->GetDefaultServiceLevel(Queue => $QueueObj) ? 0 : 1, QueueObj => $QueueObj, &>
<& /Elements/EditCustomFieldCustomGroupings, %ARGS, %CFDefaults, Object => $ticket, CustomFieldGenerator => sub { $QueueObj->TicketCustomFields }, Groupings => [ RT::CustomField->CustomGroupings('RTIR::Ticket'), '' ], &>
<&| /Widgets/TitleBox, title => $Title, class => 'ticket-info-message' &> % if ( $gnupg_widget ) { % } <& /Ticket/Elements/AddAttachments, %ARGS, QueueObj => $QueueObj &>
<&|/l&>Subject:
  <& /Elements/Crypt/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
<&|/l&>Message: <& /Elements/MessageBox, Default => $ARGS{'Content'}, IncludeSignature => 0, &>
<&| /Widgets/TitleBox, title => loc('Details'), class => 'ticket-info-details' &> <& /Ticket/Elements/EditBasics, InTable => 0, QueueObj => $QueueObj, fields => [ { name => 'Priority', comp => '/Elements/SelectPriority', args => { Name => 'InitialPriority', Default => defined $ARGS{'InitialPriority'} && length $ARGS{'InitialPriority'} ? $ARGS{'InitialPriority'} : $QueueObj->DefaultValue('InitialPriority') , }, }, { name => 'Final Priority', comp => '/Elements/SelectPriority', args => { Name => 'FinalPriority', Default => defined $ARGS{'FinalPriority'} && length $ARGS{'FinalPriority'} ? $ARGS{'FinalPriority'} : $QueueObj->DefaultValue('FinalPriority') , }, }, { name => 'Time Worked', comp => '/Elements/EditTimeValue', args => { Name => "TimeWorked", Default => $ARGS{'TimeWorked'} || '', }, }, { name => 'Time Left', comp => '/Elements/EditTimeValue', args => { Name => "TimeLeft", Default => $ARGS{'TimeLeft'} || '', }, }, { name => 'Starts', comp => '/Elements/SelectDate', args => { Name => 'Starts', Default => $ARGS{'Starts'} || '', }, }, { name => 'Due', comp => '/Elements/SelectDate', args => { Name => 'Due', Default => $ARGS{'Due'} || '', }, }, ], &>
<& /Elements/Submit, Name => 'CreateIncident', Label => $SubmitLabel, SubmitId => 'create-ticket' &>
% $m->callback( CallbackName => 'FormEnd', QueueObj => $QueueObj, Constituency => $constituency, % ChildObj => $ChildObj, SplitObj => $SplitObj, ARGSRef => \%ARGS );
<%INIT> my %CFDefaults; $m->callback( CallbackName => 'Init', CallbackPage => '/Ticket/Create.html', ARGSRef => \%ARGS, ); my @results; # if there isn't a subject, but there is a child, use that one my $ChildObj; if ( $Child ) { $ChildObj = LoadTicket( $Child ); $Child = $ARGS{'Child'} = $ChildObj->id; $ARGS{'Subject'} ||= $ChildObj->Subject; } my $SplitObj; if ( $Split ) { $SplitObj = LoadTicket( $Split ); $Split = $ARGS{'Split'} = $SplitObj->id; } $m->callback( CallbackName => 'ProcessArguments', ARGSRef => \%ARGS, Ticket => $SplitObj, Child => $ChildObj, CreateIncident => \$CreateIncident ); my $constituency = $m->{'RTIR_ConstituencyFilter'} || ''; for my $related_ticket ($ChildObj, $SplitObj) { next if !$related_ticket; my $related_constituency = RT::IR->ConstituencyFor($related_ticket); if ($constituency && $constituency ne $related_constituency) { push @results, loc("[_1] constituency '[_2]' does not match current constituency '[_3]'", RT::IR::TicketType(Ticket=>$related_ticket), $related_constituency, $constituency); } elsif(!$constituency) { $constituency = $related_constituency; } last; } my $QueueObj = RT::Queue->new($session{'CurrentUser'}); $QueueObj->Load( $ARGS{Queue} ); if (!$QueueObj->Name) { Abort( loc("Queue '[_1]' could not be loaded.", $ARGS{Queue}) ); } my $ticket = RT::Ticket->new($session{'CurrentUser'}); # empty ticket object ProcessAttachments(ARGSRef => \%ARGS); my $checks_failure = 0; my $gnupg_widget = $m->comp( '/Elements/Crypt/SignEncryptWidget:new', Arguments => \%ARGS ); $m->comp( '/Elements/Crypt/SignEncryptWidget:Process', self => $gnupg_widget, QueueObj => $QueueObj, ); if ( $CreateIncident && $gnupg_widget ) { my $status = $m->comp('/Elements/Crypt/SignEncryptWidget:Check', self => $gnupg_widget, Operation => 'Create', QueueObj => $QueueObj, ); $checks_failure = 1 unless $status; } if ( $CreateIncident ) { my $TicketCFs = $QueueObj->TicketCustomFields; my ($status, @msg) = $m->comp('/Elements/ValidateCustomFields', CustomFields => $TicketCFs, ARGSRef => \%ARGS, ); unless ( $status ) { push @results, loc( "Invalid value(s) of the custom fields:" ); while (my $CF = $TicketCFs->Next) { my $msg = $m->notes('InvalidField-' . $CF->Id) or next; push @results, $CF->Name . ': ' . $msg; } $checks_failure = 1; } $checks_failure += RT::IR->FilterRTAddresses( ARGSRef => \%ARGS, Fields => { Requestors => 'Requestor', Cc => 'Cc', AdminCc => 'AdminCc' }, results => \@results, ); } $m->callback( CallbackName => 'BeforeCreateRedirect', ARGSRef => \%ARGS, Child => $ChildObj, results => \@results, checks_failure => \$checks_failure ); if ( !$checks_failure && $CreateIncident ) { my ($inc_obj, @tmp) = $m->comp( '/RTIR/Investigation/Elements/Create:Process', %ARGS, $Child? ('MemberOf-new' => $Child): (), NamePrefix => '', DefaultsNamePrefix => '', ); push @results, @tmp; if( $inc_obj ) { $m->callback(CallbackName => 'BeforeDisplay', ARGSRef => \%ARGS, Child => $ChildObj, TicketObj => $inc_obj, results => \@results ); MaybeRedirectForResults( Actions => \@results, Path => RT::IR->HREFTo("Incident/Display.html", IncludeWebPath => 0), Arguments => { id => $inc_obj->id }, ); } } my $SubmitLabel; if ( $Split ) { $SubmitLabel = loc('Split'); } else { $SubmitLabel = loc('Create'); } unless ( exists $ARGS{'Content'} ) { my $Transactions; if ( $SplitObj ) { $Transactions = $SplitObj->Transactions; } elsif ( $ChildObj ) { $Transactions = $ChildObj->Transactions; } if ( $Transactions ) { $ARGS{'Content'} = $m->scomp("/RTIR/Elements/TransactionData", Transactions => $Transactions, Type => 'messages', Include => ['Create', 'Correspond'], ) || ''; $ARGS{'Content'} =~ s/\>/>/g; } } <%ARGS> $Title => loc("Create a new Incident") $QuoteTransaction => undef $CreateIncident => 0 $Split => undef $Child => undef