%# BEGIN LICENSE BLOCK %# %# Copyright (c) 1996-2003 Jesse Vincent %# %# (Except where explictly superceded by other copyright notices) %# %# 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. %# %# %# Unless otherwise specified, all modifications, corrections or %# extensions to this work which alter its source code become the %# property of Best Practical Solutions, LLC when submitted for %# inclusion in the work. %# %# %# END LICENSE 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' ) { % my $default; % $default = $ChildObj->FirstCustomFieldValue('Constituency') if $ChildObj; % $default ||= RT::IR::DefaultConstituency( $QueueObj ); % $default ||= scalar RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'}; <& /RTIR/Elements/EditRTIRField, QueueObj => $QueueObj, Name => 'Constituency', Default => $default, Rows => 1, &> % } 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: <%PERL> my $include_signature = 1; 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; } } else { $include_signature = 0; } <& /Elements/MessageBox, Default => $ARGS{'Content'}, IncludeSignature => $include_signature, &>
<&| /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 }, &> <& /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[] ); <%ARGS> $Title => loc("Create a new Incident") $QuoteTransaction => undef $CreateWithInvestigation => 0 $CreateIncident => $CreateWithInvestigation $Split => undef $Child => undef