%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2014 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, onload => "function () { hide('ticket-create-investigation') }", &> <& /Elements/Tabs &> % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $SplitObj); <& /Elements/ListActions, actions => \@results &> <%PERL> if ( $SplitObj && !$SplitObj->CurrentUserHasRight('ModifyTicket') ) { $m->out( loc('You are not allowed to split from #[_2].', $SplitObj->id ) ); return; } if ( $ChildObj && !$ChildObj->CurrentUserHasRight('ModifyTicket') ) { $m->out( loc('You are not allowed to link with #[_2].', $ChildObj->id ) ); return; } % if ( $Split ) {
% } else { % } % if ( $ChildObj ) { % } % if ( $Split ) { % } <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
<&| /Widgets/TitleBox, title => $Title, class => 'ticket-info-basics' &> % if ( $Split ) { % my $Type = RT::IR::TicketType( Ticket => $SplitObj ); % } % if ( $ChildObj ) { % my $Type = RT::IR::TicketType( Ticket => $ChildObj ); % } % if ( $ChildObj ) { % } else { % } % if ( my $constituency_cf = RT::IR->CustomFields( 'Constituency', Queue => $QueueObj->Name ) ) { % } <& /RTIR/Elements/EditCustomFields, %ARGS, TicketObj => undef, QueueObj => $QueueObj, DefaultsFrom => $SplitObj || $ChildObj, &>
<% loc('Split from') %>: <% loc("[_1] #[_2]: [_3]", $Type, $SplitObj->Id, $SplitObj->Subject) %>
<% loc('Link with') %>: <% loc("[_1] #[_2]: [_3]", $Type, $ChildObj->Id, $ChildObj->Subject) %>
<&|/l&>Status: <& /Elements/SelectStatus, Name => 'Status', QueueObj => $QueueObj, DefaultValue => 0, Default => $ARGS{Status} || $QueueObj->Lifecycle->DefaultOnCreate, &>
<&|/l&>Owner: <& /Elements/ShowUser, User => $ChildObj->OwnerObj &> <& /Elements/SelectOwner, Name => 'Owner', QueueObj => $QueueObj, Default => $ARGS{'Owner'} || $session{'CurrentUser'}->Id &>
<&|/l&>Constituency: % if ( !$ChildObj || RT->Config->Get('_RTIR_Constituency_Propagation') eq 'no' ) { <& /RTIR/Elements/EditRTIRField, %ARGS, QueueObj => $QueueObj, Name => 'Constituency', PropagationObject => $ChildObj, &> % } else { % #TODO: hacks, we need way to define CF value on Create, but don't allow user to change it <& /RTIR/Elements/ShowRTIRField, Ticket => $ChildObj, Name => 'Constituency' &> % }
<&| /Widgets/TitleBox, title => $Title, class => 'ticket-info-message' &> % if ( $gnupg_widget ) { % } <& /Ticket/Elements/AddAttachments, %ARGS, QueueObj => $QueueObj &>
<&|/l&>Subject:
  <& /Elements/GnuPG/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, fields => [ { name => 'Priority', comp => '/Elements/SelectPriority', args => { Name => 'InitialPriority', Default => defined $ARGS{'InitialPriority'} && length $ARGS{'InitialPriority'} ? $ARGS{'InitialPriority'} : $QueueObj->InitialPriority , }, }, { name => 'Final Priority', comp => '/Elements/SelectPriority', args => { Name => 'FinalPriority', Default => defined $ARGS{'FinalPriority'} && length $ARGS{'FinalPriority'} ? $ARGS{'FinalPriority'} : $QueueObj->InitialPriority , }, }, { 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 &>
<& /RTIR/Investigation/Elements/Create, %ARGS, NamePrefix => 'Investigation', Queue => 'Investigations', SkipField => { Owner => 1, Attachments => 1, DateFields => 1 }, IncludeSignature => (exists $ARGS{'InvestigationContent'} ? 0 : 1), &> <& /Elements/Submit, Name => 'CreateWithInvestigation', Label => loc("Create Incident and run Investigation"), &>
<%INIT> $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 ); my $QueueObj = RT::Queue->new( $session{'CurrentUser'} ); $QueueObj->Load( 'Incidents' ) || Abort( loc("Queue could not be loaded.") ); $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS ); my $checks_failure = 0; my $gnupg_widget = $m->comp( '/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS ); $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process', self => $gnupg_widget, QueueObj => $QueueObj, ); if ( $CreateIncident && $gnupg_widget ) { my $status = $m->comp('/Elements/GnuPG/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, ); if ( $CreateWithInvestigation ) { $checks_failure += RT::IR->FilterRTAddresses( ARGSRef => \%ARGS, Fields => { InvestigationRequestors => 'Requestor', InvestigationCc => 'Cc', InvestigationAdminCc => 'AdminCc', }, results => \@results, ); } if ( $CreateWithInvestigation && !$ARGS{'InvestigationRequestors'} ) { push @results, loc( "You must enter a correspondent for the investigation" ); $checks_failure = 1; } if ( $ChildObj and RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject' and my $constituency_cf = RT::IR->CustomFields( 'Constituency', Queue => 'Incidents' ) ) { my $constituency_field = 'Object-RT::Ticket--CustomField-' . $constituency_cf->id .'-Values'; unless ( lc $ARGS{ $constituency_field } eq lc $ChildObj->FirstCustomFieldValue('Constituency') ) { push @results, loc( "New incident and its child #[_1] must have the same constituency", $ChildObj->id ); $checks_failure = 1; } } } 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; my $inv_obj; if ( $inc_obj && $CreateWithInvestigation ) { my (@tmp); ($inv_obj, @tmp) = $m->comp( '/RTIR/Investigation/Elements/Create:Process', %ARGS, NamePrefix => 'Investigation', DefaultsNamePrefix => '', ); push @results, @tmp; if ( $inv_obj ) { my($id, $msg) = $inv_obj->AddLink( Type => 'MemberOf', Target => $inc_obj->id ); #XXX: correct message on success push @results, $msg if !$id || $msg; } } if( $inc_obj ) { $m->callback(CallbackName => 'BeforeDisplay', ARGSRef => \%ARGS, Child => $ChildObj); MaybeRedirectForResults( Actions => \@results, Path => "/RTIR/Incident/Display.html", Arguments => { id => $inc_obj->id }, ); } } my $SubmitLabel; if ( $Split ) { $SubmitLabel = loc('Split'); } else { $SubmitLabel = loc('Create'); } PageMenu->child( incident => raw_html => q{} . loc('Incident') . q{} ); PageMenu->child( investigation => raw_html => q[] . loc('Launch Investigation') . q[] ); 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 $CreateWithInvestigation => 0 $CreateIncident => $CreateWithInvestigation $Split => undef $Child => undef