init III
This commit is contained in:
679
Perl OTRS/Kernel/Output/HTML/LinkObject/Appointment.pm
Normal file
679
Perl OTRS/Kernel/Output/HTML/LinkObject/Appointment.pm
Normal file
@@ -0,0 +1,679 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::Output::HTML::LinkObject::Appointment;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
use Kernel::System::VariableCheck qw(:all);
|
||||
use Kernel::Output::HTML::Layout;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Calendar',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Web::Request',
|
||||
'Kernel::System::JSON',
|
||||
'Kernel::System::User',
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::Output::HTML::LinkObject::Appointment - layout backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All layout functions of link object (appointment).
|
||||
|
||||
=head2 new()
|
||||
|
||||
create an object
|
||||
|
||||
$BackendObject = Kernel::Output::HTML::LinkObject::Appointment->new(
|
||||
UserLanguage => 'en',
|
||||
UserID => 1,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# check needed objects
|
||||
for my $Needed (qw(UserLanguage UserID)) {
|
||||
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
|
||||
}
|
||||
|
||||
# create our own LayoutObject instance to avoid block data collisions with the main page
|
||||
$Self->{LayoutObject} = Kernel::Output::HTML::Layout->new( %{$Self} );
|
||||
|
||||
# define needed variables
|
||||
$Self->{ObjectData} = {
|
||||
Object => 'Appointment',
|
||||
Realname => 'Appointment',
|
||||
ObjectName => 'SourceObjectID',
|
||||
};
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
=head2 TableCreateComplex()
|
||||
|
||||
return an array with the block data
|
||||
|
||||
Return
|
||||
|
||||
%BlockData = (
|
||||
{
|
||||
ObjectName => 'SourceObjectID',
|
||||
ObjectID => 1,
|
||||
Object => 'Appointment',
|
||||
Blockname => 'Appointment',
|
||||
Headline => [
|
||||
{
|
||||
Content => 'Title',
|
||||
},
|
||||
{
|
||||
Content => 'Description',
|
||||
Width => 200,
|
||||
},
|
||||
{
|
||||
Content => 'Start Time',
|
||||
Width => 150,
|
||||
},
|
||||
{
|
||||
Content => 'End Time',
|
||||
Width => 150,
|
||||
},
|
||||
],
|
||||
ItemList => [
|
||||
[
|
||||
{
|
||||
Type => 'Link',
|
||||
Key => $AppointmentID,
|
||||
Content => 'Appointment title',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Appointment description',
|
||||
MaxLength => 100,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2016-01-01 12:00:00',
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2016-01-01 13:00:00',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
@BlockData = $BackendObject->TableCreateComplex(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateComplex {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# create needed objects
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# convert the list
|
||||
my %LinkList;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
for my $AppointmentID ( sort keys %{$DirectionList} ) {
|
||||
|
||||
$LinkList{$AppointmentID}->{Data} = $DirectionList->{$AppointmentID};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ComplexTableData = $ConfigObject->Get("LinkObject::ComplexTable");
|
||||
my $DefaultColumns;
|
||||
if (
|
||||
$ComplexTableData
|
||||
&& IsHashRefWithData($ComplexTableData)
|
||||
&& $ComplexTableData->{Appointment}
|
||||
&& IsHashRefWithData( $ComplexTableData->{Appointment} )
|
||||
)
|
||||
{
|
||||
$DefaultColumns = $ComplexTableData->{"Appointment"}->{"DefaultColumns"};
|
||||
}
|
||||
|
||||
my @TimeLongTypes = (
|
||||
"Created",
|
||||
"Changed",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"NotificationTime",
|
||||
);
|
||||
|
||||
# define the block data
|
||||
my @Headline = (
|
||||
{
|
||||
Content => 'Title',
|
||||
},
|
||||
);
|
||||
|
||||
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
|
||||
|
||||
# load user preferences
|
||||
my %Preferences = $UserObject->GetPreferences(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
if ( !$DefaultColumns || !IsHashRefWithData($DefaultColumns) ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Missing configuration for LinkObject::ComplexTable###Appointment!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Get default column priority from SysConfig
|
||||
# Each column in table (Title, StartTime, EndTime,...) has defined Priority in SysConfig.
|
||||
# System use this priority to sort columns, if user doesn't have own settings.
|
||||
my %SortOrder;
|
||||
|
||||
if (
|
||||
$ComplexTableData->{"Appointment"}->{"Priority"}
|
||||
&& IsHashRefWithData( $ComplexTableData->{"Appointment"}->{"Priority"} )
|
||||
)
|
||||
{
|
||||
%SortOrder = %{ $ComplexTableData->{"Appointment"}->{"Priority"} };
|
||||
}
|
||||
|
||||
my %UserColumns = %{$DefaultColumns};
|
||||
|
||||
if ( $Preferences{'LinkObject::ComplexTable-Appointment'} ) {
|
||||
my $JSONObject = $Kernel::OM->Get('Kernel::System::JSON');
|
||||
|
||||
my $ColumnsEnabled = $JSONObject->Decode(
|
||||
Data => $Preferences{'LinkObject::ComplexTable-Appointment'},
|
||||
);
|
||||
|
||||
if (
|
||||
$ColumnsEnabled
|
||||
&& IsHashRefWithData($ColumnsEnabled)
|
||||
&& $ColumnsEnabled->{Order}
|
||||
&& IsArrayRefWithData( $ColumnsEnabled->{Order} )
|
||||
)
|
||||
{
|
||||
# Clear sort order
|
||||
%SortOrder = ();
|
||||
|
||||
DEFAULTCOLUMN:
|
||||
for my $DefaultColumn ( sort keys %UserColumns ) {
|
||||
my $Index = 0;
|
||||
|
||||
for my $UserSetting ( @{ $ColumnsEnabled->{Order} } ) {
|
||||
$Index++;
|
||||
if ( $DefaultColumn eq $UserSetting ) {
|
||||
$UserColumns{$DefaultColumn} = 2;
|
||||
$SortOrder{$DefaultColumn} = $Index;
|
||||
|
||||
next DEFAULTCOLUMN;
|
||||
}
|
||||
}
|
||||
|
||||
# not found, means user chose to hide this item
|
||||
if ( $UserColumns{$DefaultColumn} == 2 ) {
|
||||
$UserColumns{$DefaultColumn} = 1;
|
||||
}
|
||||
|
||||
if ( !$SortOrder{$DefaultColumn} ) {
|
||||
$SortOrder{$DefaultColumn} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
# user has no own settings
|
||||
for my $Column ( sort keys %UserColumns ) {
|
||||
if ( !$SortOrder{$Column} ) {
|
||||
$SortOrder{$Column} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Define Headline columns
|
||||
|
||||
# Sort
|
||||
my @AllColumns;
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
my $ColumnTranslate = $Column;
|
||||
if ( $Column eq 'CalendarName' ) {
|
||||
$ColumnTranslate = Translatable('Calendar name');
|
||||
}
|
||||
elsif ( $Column eq 'StartTime' ) {
|
||||
$ColumnTranslate = Translatable('Start date');
|
||||
}
|
||||
elsif ( $Column eq 'EndTime' ) {
|
||||
$ColumnTranslate = Translatable('End date');
|
||||
}
|
||||
elsif ( $Column eq 'NotificationTime' ) {
|
||||
$ColumnTranslate = Translatable('Notification');
|
||||
}
|
||||
|
||||
push @AllColumns, {
|
||||
ColumnName => $Column,
|
||||
ColumnTranslate => $ColumnTranslate,
|
||||
};
|
||||
|
||||
next COLUMN if $Column eq 'Title'; # Always present, already added.
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
|
||||
# appointment fields
|
||||
my $ColumnName = $ColumnTranslate;
|
||||
|
||||
push @Headline, {
|
||||
Content => $ColumnName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# create the item list (table content)
|
||||
my @ItemList;
|
||||
|
||||
APPOINTMENTID:
|
||||
for my $AppointmentID (
|
||||
sort { $LinkList{$a}{Data}->{AppointmentID} <=> $LinkList{$b}{Data}->{AppointmentID} }
|
||||
keys %LinkList
|
||||
)
|
||||
{
|
||||
next APPOINTMENTID if !$AppointmentID;
|
||||
|
||||
# extract appointment and calendar data
|
||||
my $Appointment = $LinkList{$AppointmentID}{Data};
|
||||
my %Calendar = $Kernel::OM->Get('Kernel::System::Calendar')->CalendarGet(
|
||||
CalendarID => $Appointment->{CalendarID},
|
||||
);
|
||||
|
||||
# Title be present (since it contains master link to the appointment)
|
||||
my @ItemColumns = (
|
||||
{
|
||||
Type => 'Link',
|
||||
Key => $AppointmentID,
|
||||
Content => $Appointment->{Title},
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentAppointmentCalendarOverview;AppointmentID='
|
||||
. $AppointmentID,
|
||||
MaxLength => 70,
|
||||
},
|
||||
);
|
||||
|
||||
# Sort
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
next COLUMN if $Column eq 'Title'; # Always present, already added.
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
|
||||
my %Hash;
|
||||
if ( grep { $_ eq $Column } @TimeLongTypes ) {
|
||||
$Hash{'Type'} = 'TimeLong';
|
||||
}
|
||||
else {
|
||||
$Hash{'Type'} = 'Text';
|
||||
}
|
||||
|
||||
if ( $Column eq 'NotificationTime' ) {
|
||||
$Hash{'Content'} = $Appointment->{NotificationDate};
|
||||
}
|
||||
elsif ( $Column eq 'Created' ) {
|
||||
$Hash{'Content'} = $Appointment->{CreateTime};
|
||||
}
|
||||
elsif ( $Column eq 'Changed' ) {
|
||||
$Hash{'Content'} = $Appointment->{ChangeTime};
|
||||
}
|
||||
elsif ( $Column eq 'CalendarName' ) {
|
||||
$Hash{'Content'} = $Calendar{CalendarName};
|
||||
}
|
||||
else {
|
||||
$Hash{'Content'} = $Appointment->{$Column};
|
||||
}
|
||||
|
||||
push @ItemColumns, \%Hash;
|
||||
}
|
||||
}
|
||||
|
||||
push @ItemList, \@ItemColumns;
|
||||
}
|
||||
|
||||
return if !@ItemList;
|
||||
|
||||
my %Block = (
|
||||
Object => $Self->{ObjectData}->{Object},
|
||||
Blockname => $Self->{ObjectData}->{Realname},
|
||||
ObjectName => $Self->{ObjectData}->{ObjectName},
|
||||
ObjectID => $Param{ObjectID},
|
||||
Headline => \@Headline,
|
||||
ItemList => \@ItemList,
|
||||
AllColumns => \@AllColumns,
|
||||
);
|
||||
|
||||
return ( \%Block );
|
||||
}
|
||||
|
||||
=head2 TableCreateSimple()
|
||||
|
||||
return a hash with the link output data
|
||||
|
||||
Return
|
||||
|
||||
%LinkOutputData = (
|
||||
Normal::Source => {
|
||||
Appointment => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'A:1',
|
||||
Title => 'Title of appointment',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
%LinkOutputData = $BackendObject->TableCreateSimple(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateSimple {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my %LinkOutputData;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
my @ItemList;
|
||||
for my $AppointmentID (
|
||||
sort {
|
||||
lc $DirectionList->{$a}->{NameShort} cmp lc $DirectionList->{$b}->{NameShort}
|
||||
} keys %{$DirectionList}
|
||||
)
|
||||
{
|
||||
|
||||
# extract appointment data
|
||||
my $Appointment = $DirectionList->{$AppointmentID};
|
||||
|
||||
# define item data
|
||||
my %Item = (
|
||||
Type => 'Link',
|
||||
Content => "A:$AppointmentID",
|
||||
Title => Translatable('Appointment'),
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentAppointmentCalendarOverview;AppointmentID='
|
||||
. $AppointmentID,
|
||||
MaxLength => 20,
|
||||
);
|
||||
|
||||
push @ItemList, \%Item;
|
||||
}
|
||||
|
||||
# add item list to link output data
|
||||
$LinkOutputData{ $LinkType . '::' . $Direction }->{Appointment} = \@ItemList;
|
||||
}
|
||||
}
|
||||
|
||||
return %LinkOutputData;
|
||||
}
|
||||
|
||||
=head2 ContentStringCreate()
|
||||
|
||||
return a output string
|
||||
|
||||
my $String = $BackendObject->ContentStringCreate(
|
||||
ContentData => $HashRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub ContentStringCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ContentData} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ContentData!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
=head2 SelectableObjectList()
|
||||
|
||||
Return an array hash with select-able objects.
|
||||
|
||||
Returns:
|
||||
|
||||
@SelectableObjectList = (
|
||||
{
|
||||
Key => 'Appointment',
|
||||
Value => 'Appointment',
|
||||
},
|
||||
);
|
||||
|
||||
@SelectableObjectList = $BackendObject->SelectableObjectList(
|
||||
Selected => $Identifier, # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SelectableObjectList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Selected;
|
||||
if ( $Param{Selected} && $Param{Selected} eq $Self->{ObjectData}->{Object} ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
|
||||
# object select list
|
||||
my @ObjectSelectList = (
|
||||
{
|
||||
Key => $Self->{ObjectData}->{Object},
|
||||
Value => $Self->{ObjectData}->{Realname},
|
||||
Selected => $Selected,
|
||||
},
|
||||
);
|
||||
|
||||
return @ObjectSelectList;
|
||||
}
|
||||
|
||||
=head2 SearchOptionList()
|
||||
|
||||
return an array hash with search options
|
||||
|
||||
Return
|
||||
|
||||
@SearchOptionList = (
|
||||
{
|
||||
Key => 'AppointmentTitle',
|
||||
Name => 'Title',
|
||||
InputStrg => $FormString,
|
||||
FormData => '1234',
|
||||
},
|
||||
{
|
||||
Key => 'AppointmentDescription',
|
||||
Name => 'Description',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'BlaBla',
|
||||
},
|
||||
{
|
||||
Key => 'AppointmentCalendarID',
|
||||
Name => 'Calendar',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'Calendar1',
|
||||
},
|
||||
);
|
||||
|
||||
@SearchOptionList = $BackendObject->SearchOptionList(
|
||||
SubObject => 'Bla', # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SearchOptionList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $ParamHook = $Kernel::OM->Get('Kernel::Config')->Get('Ticket::Hook') || 'Ticket#';
|
||||
|
||||
# search option list
|
||||
my @SearchOptionList = (
|
||||
{
|
||||
Key => 'AppointmentTitle',
|
||||
Name => Translatable('Title'),
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'AppointmentDescription',
|
||||
Name => Translatable('Description'),
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'AppointmentCalendarID',
|
||||
Name => Translatable('Calendar'),
|
||||
Type => 'List',
|
||||
},
|
||||
);
|
||||
|
||||
# add formkey
|
||||
for my $Row (@SearchOptionList) {
|
||||
$Row->{FormKey} = 'SEARCH::' . $Row->{Key};
|
||||
}
|
||||
|
||||
# add form data and input string
|
||||
ROW:
|
||||
for my $Row (@SearchOptionList) {
|
||||
|
||||
next ROW if $Row->{Type} eq 'Hidden';
|
||||
|
||||
# Prepare text input fields.
|
||||
if ( $Row->{Type} eq 'Text' ) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Row->{FormKey} );
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'InputText',
|
||||
Data => {
|
||||
Key => $Row->{FormKey},
|
||||
Value => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
}
|
||||
|
||||
# Prepare drop down lists.
|
||||
elsif ( $Row->{Type} eq 'List' ) {
|
||||
|
||||
# get form data
|
||||
my @FormData = $Kernel::OM->Get('Kernel::System::Web::Request')->GetArray( Param => $Row->{FormKey} );
|
||||
$Row->{FormData} = \@FormData;
|
||||
|
||||
if ( $Row->{Key} eq 'AppointmentCalendarID' ) {
|
||||
my @CalendarList = $Kernel::OM->Get('Kernel::System::Calendar')->CalendarList(
|
||||
UserID => $Self->{UserID},
|
||||
Permission => 'rw',
|
||||
ValidID => 1,
|
||||
);
|
||||
|
||||
my @CalendarData = map {
|
||||
{
|
||||
Key => $_->{CalendarID},
|
||||
Value => $_->{CalendarName},
|
||||
}
|
||||
} sort { $a->{CalendarName} cmp $b->{CalendarName} } @CalendarList;
|
||||
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->BuildSelection(
|
||||
Data => \@CalendarData,
|
||||
Name => $Row->{FormKey},
|
||||
SelectedID => $Row->{FormData},
|
||||
Class => 'Modernize',
|
||||
Multiple => 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return @SearchOptionList;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
698
Perl OTRS/Kernel/Output/HTML/LinkObject/FAQ.pm
Normal file
698
Perl OTRS/Kernel/Output/HTML/LinkObject/FAQ.pm
Normal file
@@ -0,0 +1,698 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::Output::HTML::LinkObject::FAQ;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
use Kernel::Output::HTML::Layout;
|
||||
use Kernel::System::VariableCheck qw(:all);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Language',
|
||||
'Kernel::System::DynamicField',
|
||||
'Kernel::System::DynamicField::Backend',
|
||||
'Kernel::System::JSON',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::User',
|
||||
'Kernel::System::Web::Request',
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::Output::HTML::LinkObject::FAQ - link object backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All link object functions of link object (FAQ)
|
||||
|
||||
=head2 new()
|
||||
|
||||
create an object
|
||||
|
||||
$BackendObject = Kernel::Output::HTML::LinkObject::FAQ->new(
|
||||
%Param,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# Allocate new hash for object.
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
for my $Needed (qw(UserLanguage UserID)) {
|
||||
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
|
||||
}
|
||||
|
||||
# TODO: check if the new instance is still needed with the OM!
|
||||
|
||||
# We need our own LayoutObject instance to avoid block data collisions with the main page.
|
||||
$Self->{LayoutObject} = Kernel::Output::HTML::Layout->new( %{$Self} );
|
||||
|
||||
$Self->{ObjectData} = {
|
||||
Object => 'FAQ',
|
||||
Realname => 'FAQ',
|
||||
ObjectName => 'SourceObjectID',
|
||||
};
|
||||
|
||||
$Self->{DynamicField} = $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldListGet(
|
||||
Valid => 0,
|
||||
ObjectType => ['FAQ'],
|
||||
);
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
=head2 TableCreateComplex()
|
||||
|
||||
return an array with the block data
|
||||
|
||||
my @BlockData = $LinkObject->TableCreateComplex(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
a result could be
|
||||
|
||||
%BlockData = (
|
||||
{
|
||||
ObjectName => 'FAQID',
|
||||
ObjectID => '14785',
|
||||
|
||||
Object => 'FAQ',
|
||||
Blockname => 'FAQ',
|
||||
Headline => [
|
||||
{
|
||||
Content => 'FAQ#',
|
||||
Width => 130,
|
||||
},
|
||||
{
|
||||
Content => 'Title',
|
||||
},
|
||||
{
|
||||
Content => 'State',
|
||||
Width => 110,
|
||||
},
|
||||
{
|
||||
Content => 'Created',
|
||||
Width => 110,
|
||||
},
|
||||
],
|
||||
ItemList => [
|
||||
[
|
||||
{
|
||||
Type => 'Link',
|
||||
Key => $ItemID,
|
||||
Content => '123123123',
|
||||
Css => 'style="text-decoration: line-through"',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'The title',
|
||||
MaxLength => 50,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'internal (agent)',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
Type => 'Link',
|
||||
Key => $ItemID,
|
||||
Content => '434234',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'The title of FAQ 2',
|
||||
MaxLength => 50,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'public (all)',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateComplex {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Convert the list.
|
||||
my %LinkList;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
for my $ItemID ( sort keys %{$DirectionList} ) {
|
||||
|
||||
$LinkList{$ItemID}->{Data} = $DirectionList->{$ItemID};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
my $ComplexTableData = $ConfigObject->Get("LinkObject::ComplexTable");
|
||||
my $DefaultColumns;
|
||||
if (
|
||||
$ComplexTableData
|
||||
&& IsHashRefWithData($ComplexTableData)
|
||||
&& $ComplexTableData->{FAQ}
|
||||
&& IsHashRefWithData( $ComplexTableData->{FAQ} )
|
||||
)
|
||||
{
|
||||
$DefaultColumns = $ComplexTableData->{"FAQ"}->{"DefaultColumns"};
|
||||
}
|
||||
|
||||
my @TimeLongTypes = (
|
||||
"Created",
|
||||
"Changed",
|
||||
);
|
||||
|
||||
# Define the block data.
|
||||
my $FAQHook = $ConfigObject->Get('FAQ::FAQHook');
|
||||
|
||||
my @Headline = (
|
||||
{
|
||||
Content => $FAQHook,
|
||||
},
|
||||
);
|
||||
|
||||
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
|
||||
|
||||
# Load user preferences.
|
||||
my %Preferences = $UserObject->GetPreferences(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
if ( !$DefaultColumns || !IsHashRefWithData($DefaultColumns) ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Missing configuration for LinkObject::ComplexTable###FAQ!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Get default column priority from SysConfig.
|
||||
# Each column in table (Title, State,...) has defined Priority in SysConfig. System use this
|
||||
# priority to sort columns, if user doesn't have own settings.
|
||||
my %SortOrder;
|
||||
if (
|
||||
$ComplexTableData->{"FAQ"}->{"Priority"}
|
||||
&& IsHashRefWithData( $ComplexTableData->{"FAQ"}->{"Priority"} )
|
||||
)
|
||||
{
|
||||
%SortOrder = %{ $ComplexTableData->{"FAQ"}->{"Priority"} };
|
||||
}
|
||||
|
||||
my %UserColumns = %{$DefaultColumns};
|
||||
|
||||
if ( $Preferences{'LinkObject::ComplexTable-FAQ'} ) {
|
||||
|
||||
my $ColumnsEnabled = $Kernel::OM->Get('Kernel::System::JSON')->Decode(
|
||||
Data => $Preferences{'LinkObject::ComplexTable-FAQ'},
|
||||
);
|
||||
|
||||
if (
|
||||
$ColumnsEnabled
|
||||
&& IsHashRefWithData($ColumnsEnabled)
|
||||
&& $ColumnsEnabled->{Order}
|
||||
&& IsArrayRefWithData( $ColumnsEnabled->{Order} )
|
||||
)
|
||||
{
|
||||
# Clear sort order.
|
||||
%SortOrder = ();
|
||||
|
||||
DEFAULTCOLUMN:
|
||||
for my $DefaultColumn ( sort keys %UserColumns ) {
|
||||
my $Index = 0;
|
||||
|
||||
for my $UserSetting ( @{ $ColumnsEnabled->{Order} } ) {
|
||||
$Index++;
|
||||
if ( $DefaultColumn eq $UserSetting ) {
|
||||
$UserColumns{$DefaultColumn} = 2;
|
||||
$SortOrder{$DefaultColumn} = $Index;
|
||||
|
||||
next DEFAULTCOLUMN;
|
||||
}
|
||||
}
|
||||
|
||||
# Not found, means user chose to hide this item.
|
||||
if ( $UserColumns{$DefaultColumn} == 2 ) {
|
||||
$UserColumns{$DefaultColumn} = 1;
|
||||
}
|
||||
|
||||
if ( !$SortOrder{$DefaultColumn} ) {
|
||||
$SortOrder{$DefaultColumn} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
# User has no own settings.
|
||||
for my $Column ( sort keys %UserColumns ) {
|
||||
if ( !$SortOrder{$Column} ) {
|
||||
$SortOrder{$Column} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Define Headline columns.
|
||||
my @AllColumns;
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
my $ColumnTranslate = $Column;
|
||||
if ( $Column eq 'CategoryName' ) {
|
||||
$ColumnTranslate = Translatable('Category');
|
||||
}
|
||||
elsif ( $Column eq 'ContentType' ) {
|
||||
$ColumnTranslate = Translatable('Content Type');
|
||||
}
|
||||
|
||||
push @AllColumns, {
|
||||
ColumnName => $Column,
|
||||
ColumnTranslate => $ColumnTranslate,
|
||||
};
|
||||
|
||||
# Always present, already added.
|
||||
next COLUMN if $Column eq 'FAQNumber';
|
||||
|
||||
# if enabled by default.
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
my $ColumnName = '';
|
||||
|
||||
# Other FAQ fields.
|
||||
if ( $Column !~ m{\A DynamicField_}xms ) {
|
||||
$ColumnName = $ColumnTranslate;
|
||||
}
|
||||
|
||||
# Dynamic fields.
|
||||
else {
|
||||
my $DynamicFieldConfig;
|
||||
my $DFColumn = $Column;
|
||||
$DFColumn =~ s{DynamicField_}{}g;
|
||||
|
||||
DYNAMICFIELD:
|
||||
for my $DFConfig ( @{ $Self->{DynamicField} } ) {
|
||||
next DYNAMICFIELD if !IsHashRefWithData($DFConfig);
|
||||
next DYNAMICFIELD if $DFConfig->{Name} ne $DFColumn;
|
||||
|
||||
$DynamicFieldConfig = $DFConfig;
|
||||
last DYNAMICFIELD;
|
||||
}
|
||||
next COLUMN if !IsHashRefWithData($DynamicFieldConfig);
|
||||
|
||||
$ColumnName = $DynamicFieldConfig->{Label};
|
||||
}
|
||||
push @Headline, {
|
||||
Content => $ColumnName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# Create the item list (table content).
|
||||
my @ItemList;
|
||||
for my $ItemID ( sort { $a <=> $b } keys %LinkList ) {
|
||||
|
||||
# Extract FAQ data.
|
||||
my $FAQ = $LinkList{$ItemID}->{Data};
|
||||
|
||||
# FAQ Number must be present (since it contains master link to the FAQ).
|
||||
my @ItemColumns = (
|
||||
{
|
||||
Type => 'Link',
|
||||
Key => $ItemID,
|
||||
Content => $FAQ->{Number},
|
||||
Link => $Self->{LayoutObject}->{Baselink} . 'Action=AgentFAQZoom;ItemID=' . $ItemID,
|
||||
},
|
||||
);
|
||||
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
next COLUMN if $Column eq 'FAQNumber'; # Always present, already added.
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
|
||||
my %Hash;
|
||||
if ( grep { $_ eq $Column } @TimeLongTypes ) {
|
||||
$Hash{'Type'} = 'TimeLong';
|
||||
}
|
||||
else {
|
||||
$Hash{'Type'} = 'Text';
|
||||
}
|
||||
|
||||
if ( $Column eq 'Title' ) {
|
||||
$Hash{MaxLength} = 50;
|
||||
}
|
||||
|
||||
# FAQ fields.
|
||||
if ( $Column !~ m{\A DynamicField_}xms ) {
|
||||
if ( $Column eq 'Approved' ) {
|
||||
my $Value = $FAQ->{$Column} ? 'Yes' : 'No';
|
||||
$Hash{'Content'} = $Kernel::OM->Get('Kernel::Language')->Translate($Value);
|
||||
}
|
||||
else {
|
||||
$Hash{'Content'} = $FAQ->{$Column};
|
||||
}
|
||||
}
|
||||
|
||||
# Dynamic fields.
|
||||
else {
|
||||
my $DynamicFieldConfig;
|
||||
my $DFColumn = $Column;
|
||||
$DFColumn =~ s{DynamicField_}{}g;
|
||||
|
||||
DYNAMICFIELD:
|
||||
for my $DFConfig ( @{ $Self->{DynamicField} } ) {
|
||||
next DYNAMICFIELD if !IsHashRefWithData($DFConfig);
|
||||
next DYNAMICFIELD if $DFConfig->{Name} ne $DFColumn;
|
||||
|
||||
$DynamicFieldConfig = $DFConfig;
|
||||
last DYNAMICFIELD;
|
||||
}
|
||||
next COLUMN if !IsHashRefWithData($DynamicFieldConfig);
|
||||
|
||||
# Get field value.
|
||||
my $Value = $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->ValueGet(
|
||||
DynamicFieldConfig => $DynamicFieldConfig,
|
||||
ObjectID => $ItemID,
|
||||
);
|
||||
|
||||
my $ValueStrg = $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->DisplayValueRender(
|
||||
DynamicFieldConfig => $DynamicFieldConfig,
|
||||
Value => $Value,
|
||||
ValueMaxChars => 20,
|
||||
LayoutObject => $Self->{LayoutObject},
|
||||
);
|
||||
|
||||
$Hash{'Content'} = $ValueStrg->{Title};
|
||||
}
|
||||
|
||||
push @ItemColumns, \%Hash;
|
||||
}
|
||||
}
|
||||
|
||||
push @ItemList, \@ItemColumns;
|
||||
}
|
||||
|
||||
return if !@ItemList;
|
||||
|
||||
# Define the block data.
|
||||
my %Block = (
|
||||
Object => $Self->{ObjectData}->{Object},
|
||||
Blockname => $Self->{ObjectData}->{Realname},
|
||||
ObjectName => $Self->{ObjectData}->{ObjectName},
|
||||
ObjectID => $Param{ObjectID},
|
||||
Headline => \@Headline,
|
||||
ItemList => \@ItemList,
|
||||
AllColumns => \@AllColumns,
|
||||
);
|
||||
|
||||
return ( \%Block );
|
||||
}
|
||||
|
||||
=head2 TableCreateSimple()
|
||||
|
||||
return a hash with the link output data
|
||||
|
||||
my %LinkOutputData = $LinkObject->TableCreateSimple(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
a result could be Return
|
||||
|
||||
%LinkOutputData = (
|
||||
Normal::Source => {
|
||||
Ticket => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'F:55555',
|
||||
Title => 'FAQ#555555: The FAQ title',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'F:22222',
|
||||
Title => 'FAQ#22222: Title of FAQ 22222',
|
||||
},
|
||||
],
|
||||
},
|
||||
ParentChild::Target => {
|
||||
Ticket => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'F:77777',
|
||||
Title => 'FAQ#77777: FAQ title',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateSimple {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my $FAQHook = $Kernel::OM->Get('Kernel::Config')->Get('FAQ::FAQHook');
|
||||
my %LinkOutputData;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
my @ItemList;
|
||||
for my $ItemID ( sort { $a <=> $b } keys %{$DirectionList} ) {
|
||||
|
||||
# extract FAQ data
|
||||
my $FAQ = $DirectionList->{$ItemID};
|
||||
|
||||
# define item data
|
||||
my %Item = (
|
||||
Type => 'Link',
|
||||
Content => 'F:' . $FAQ->{Number},
|
||||
Title => "$FAQHook$FAQ->{Number}: $FAQ->{Title}",
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentFAQZoom;ItemID='
|
||||
. $ItemID,
|
||||
);
|
||||
push @ItemList, \%Item;
|
||||
}
|
||||
|
||||
# add item list to link output data
|
||||
$LinkOutputData{ $LinkType . '::' . $Direction }->{FAQ} = \@ItemList;
|
||||
}
|
||||
}
|
||||
|
||||
return %LinkOutputData;
|
||||
}
|
||||
|
||||
=head2 ContentStringCreate()
|
||||
|
||||
return a output string
|
||||
|
||||
my $String = $LinkObject->ContentStringCreate(
|
||||
ContentData => $HashRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub ContentStringCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
if ( !$Param{ContentData} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ContentData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# TODO: Check why no return is needed!
|
||||
return;
|
||||
}
|
||||
|
||||
=head2 SelectableObjectList()
|
||||
|
||||
return an array hash with select-able objects
|
||||
|
||||
my @SelectableObjectList = $LinkObject->SelectableObjectList(
|
||||
Selected => $Identifier, # (optional)
|
||||
);
|
||||
|
||||
a result could be
|
||||
|
||||
@SelectableObjectList = (
|
||||
{
|
||||
Key => 'FAQ',
|
||||
Value => 'FAQ',
|
||||
},
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SelectableObjectList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Selected;
|
||||
if ( $Param{Selected} && $Param{Selected} eq $Self->{ObjectData}->{Object} ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
|
||||
# object select list
|
||||
my @ObjectSelectList = (
|
||||
{
|
||||
Key => $Self->{ObjectData}->{Object},
|
||||
Value => $Self->{ObjectData}->{Realname},
|
||||
Selected => $Selected,
|
||||
},
|
||||
);
|
||||
|
||||
return @ObjectSelectList;
|
||||
}
|
||||
|
||||
=head2 SearchOptionList()
|
||||
|
||||
return an array hash with search options
|
||||
|
||||
my @SearchOptionList = $LinkObject->SearchOptionList(
|
||||
SubObject => 'Bla', # (optional)
|
||||
);
|
||||
|
||||
a result could be
|
||||
|
||||
@SearchOptionList = (
|
||||
{
|
||||
Key => 'Number',
|
||||
Name => 'FAQ#',
|
||||
InputStrg => $FormString,
|
||||
FormData => '1234',
|
||||
},
|
||||
{
|
||||
Key => 'Title',
|
||||
Name => 'Title',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'BlaBla',
|
||||
},
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SearchOptionList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# search option list
|
||||
my $FAQHook = $Kernel::OM->Get('Kernel::Config')->Get('FAQ::FAQHook');
|
||||
my @SearchOptionList = (
|
||||
{
|
||||
Key => 'Number',
|
||||
Name => $FAQHook,
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'Title',
|
||||
Name => 'Title',
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'What',
|
||||
Name => 'Fulltext',
|
||||
Type => 'Text',
|
||||
},
|
||||
);
|
||||
|
||||
# add form key
|
||||
for my $Row (@SearchOptionList) {
|
||||
$Row->{FormKey} = 'SEARCH::' . $Row->{Key};
|
||||
}
|
||||
|
||||
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
|
||||
|
||||
# add form data and input string
|
||||
ROW:
|
||||
for my $Row (@SearchOptionList) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $ParamObject->GetParam( Param => $Row->{FormKey} );
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'InputText',
|
||||
Data => {
|
||||
Key => $Row->{FormKey},
|
||||
Value => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
}
|
||||
|
||||
return @SearchOptionList;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
698
Perl OTRS/Kernel/Output/HTML/LinkObject/ITSMChange.pm
Normal file
698
Perl OTRS/Kernel/Output/HTML/LinkObject/ITSMChange.pm
Normal file
@@ -0,0 +1,698 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::Output::HTML::LinkObject::ITSMChange;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
use Kernel::Output::HTML::Layout;
|
||||
use Kernel::System::VariableCheck qw(:all);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Language',
|
||||
'Kernel::System::JSON',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::User',
|
||||
'Kernel::System::Web::Request',
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::Output::HTML::LinkObject::ITSMChange - layout backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All layout functions of link object (change)
|
||||
|
||||
=head2 new()
|
||||
|
||||
create an object
|
||||
|
||||
$BackendObject = Kernel::Output::HTML::LinkObject::ITSMChange->new(
|
||||
UserLanguage => 'en',
|
||||
UserID => 1,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# check needed objects
|
||||
for my $Needed (qw(UserLanguage UserID)) {
|
||||
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
|
||||
}
|
||||
|
||||
# We need our own LayoutObject instance to avoid blockdata collisions
|
||||
# with the main page.
|
||||
$Self->{LayoutObject} = Kernel::Output::HTML::Layout->new( %{$Self} );
|
||||
|
||||
# define needed variables
|
||||
$Self->{ObjectData} = {
|
||||
Object => 'ITSMChange',
|
||||
Realname => 'Change',
|
||||
ObjectName => 'SourceObjectID',
|
||||
};
|
||||
|
||||
# get config
|
||||
$Self->{ChangeHook} = $Kernel::OM->Get('Kernel::Config')->Get('ITSMChange::Hook');
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
=head2 TableCreateComplex()
|
||||
|
||||
return an array with the block data
|
||||
|
||||
Return
|
||||
|
||||
@BlockData = (
|
||||
|
||||
ObjectName => 'ChangeID',
|
||||
ObjectID => '123',
|
||||
|
||||
Object => 'ITSMChange',
|
||||
Blockname => 'Change',
|
||||
Headline => [
|
||||
{
|
||||
Content => '',
|
||||
Width => 20,
|
||||
},
|
||||
{
|
||||
Content => 'Change#',
|
||||
Width => 200,
|
||||
},
|
||||
{
|
||||
Content => 'Change Title',
|
||||
Width => 200,
|
||||
},
|
||||
{
|
||||
Content => 'Change State',
|
||||
Width => 100,
|
||||
},
|
||||
{
|
||||
Content => 'Changed',
|
||||
Width => 150,
|
||||
},
|
||||
],
|
||||
ItemList => [
|
||||
[
|
||||
{
|
||||
Type => 'ChangeStateSignal',
|
||||
Key => 123,
|
||||
Content => 'grayled',
|
||||
ChangeState => 'requested',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => '2009100112345778',
|
||||
Link => 'Action=AgentITSMChangeZoom;ChangeID=123',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Change Title',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'requested',
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
Type => 'ChangeStateSignal',
|
||||
Key => 456,
|
||||
Content => 'greenled',
|
||||
ChangeState => 'closed',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => '2009100112345774',
|
||||
Link => 'Action=AgentITSMChangeZoom;ChangeID=456',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Change Title',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'closed',
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
@BlockData = $LinkObject->TableCreateComplex(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateComplex {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# convert the list
|
||||
my %LinkList;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
for my $ChangeID ( sort keys %{$DirectionList} ) {
|
||||
|
||||
$LinkList{$ChangeID}->{Data} = $DirectionList->{$ChangeID};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
my $ComplexTableData = $ConfigObject->Get("LinkObject::ComplexTable");
|
||||
my $DefaultColumns;
|
||||
if (
|
||||
$ComplexTableData
|
||||
&& IsHashRefWithData($ComplexTableData)
|
||||
&& $ComplexTableData->{ITSMChange}
|
||||
&& IsHashRefWithData( $ComplexTableData->{ITSMChange} )
|
||||
)
|
||||
{
|
||||
$DefaultColumns = $ComplexTableData->{"ITSMChange"}->{"DefaultColumns"};
|
||||
}
|
||||
|
||||
my @TimeLongTypes = (
|
||||
'CreateTime',
|
||||
'ChangeTime',
|
||||
'PlannedStartTime',
|
||||
'PlannedEndTime',
|
||||
'ActualStartTime',
|
||||
'ActualEndTime',
|
||||
'RequestedTime',
|
||||
);
|
||||
|
||||
my @TranslateTypes = (
|
||||
'Category',
|
||||
'Impact',
|
||||
'Priority',
|
||||
);
|
||||
|
||||
# always show the change state flag and the change number
|
||||
my @Headline = (
|
||||
{
|
||||
Content => 'ChangeState',
|
||||
},
|
||||
{
|
||||
Content => $Self->{ChangeHook},
|
||||
},
|
||||
);
|
||||
|
||||
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
|
||||
|
||||
# Load user preferences.
|
||||
my %Preferences = $UserObject->GetPreferences(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
if ( !$DefaultColumns || !IsHashRefWithData($DefaultColumns) ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Missing configuration for LinkObject::ComplexTable###ITSMChange!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Get default column priority from SysConfig.
|
||||
# Each column in table (Title, State,...) has defined Priority in SysConfig. System use this
|
||||
# priority to sort columns, if user doesn't have own settings.
|
||||
my %SortOrder;
|
||||
if (
|
||||
$ComplexTableData->{"ITSMChange"}->{"Priority"}
|
||||
&& IsHashRefWithData( $ComplexTableData->{"ITSMChange"}->{"Priority"} )
|
||||
)
|
||||
{
|
||||
%SortOrder = %{ $ComplexTableData->{"ITSMChange"}->{"Priority"} };
|
||||
}
|
||||
|
||||
my %UserColumns = %{$DefaultColumns};
|
||||
|
||||
if ( $Preferences{'LinkObject::ComplexTable-ITSMChange'} ) {
|
||||
|
||||
my $ColumnsEnabled = $Kernel::OM->Get('Kernel::System::JSON')->Decode(
|
||||
Data => $Preferences{'LinkObject::ComplexTable-ITSMChange'},
|
||||
);
|
||||
|
||||
if (
|
||||
$ColumnsEnabled
|
||||
&& IsHashRefWithData($ColumnsEnabled)
|
||||
&& $ColumnsEnabled->{Order}
|
||||
&& IsArrayRefWithData( $ColumnsEnabled->{Order} )
|
||||
)
|
||||
{
|
||||
# Clear sort order.
|
||||
%SortOrder = ();
|
||||
|
||||
DEFAULTCOLUMN:
|
||||
for my $DefaultColumn ( sort keys %UserColumns ) {
|
||||
my $Index = 0;
|
||||
|
||||
for my $UserSetting ( @{ $ColumnsEnabled->{Order} } ) {
|
||||
$Index++;
|
||||
if ( $DefaultColumn eq $UserSetting ) {
|
||||
$UserColumns{$DefaultColumn} = 2;
|
||||
$SortOrder{$DefaultColumn} = $Index;
|
||||
|
||||
next DEFAULTCOLUMN;
|
||||
}
|
||||
}
|
||||
|
||||
# Not found, means user chose to hide this item.
|
||||
if ( $UserColumns{$DefaultColumn} == 2 ) {
|
||||
$UserColumns{$DefaultColumn} = 1;
|
||||
}
|
||||
|
||||
if ( !$SortOrder{$DefaultColumn} ) {
|
||||
$SortOrder{$DefaultColumn} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
# User has no own settings.
|
||||
for my $Column ( sort keys %UserColumns ) {
|
||||
if ( !$SortOrder{$Column} ) {
|
||||
$SortOrder{$Column} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Define Headline columns.
|
||||
my @AllColumns;
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
my $ColumnTranslate = $Column;
|
||||
if ( $Column eq 'CreateTime' ) {
|
||||
$ColumnTranslate = Translatable('Created');
|
||||
}
|
||||
elsif ( $Column eq 'ChangeTime' ) {
|
||||
$ColumnTranslate = Translatable('Changed');
|
||||
}
|
||||
|
||||
push @AllColumns, {
|
||||
ColumnName => $Column,
|
||||
ColumnTranslate => $ColumnTranslate,
|
||||
};
|
||||
|
||||
# if enabled by default.
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
push @Headline, {
|
||||
Content => $ColumnTranslate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# create the item list, sort by ChangeID Down
|
||||
my @ItemList;
|
||||
for my $ChangeID (
|
||||
sort {
|
||||
$LinkList{$b}{Data}->{ChangeID} <=> $LinkList{$a}{Data}->{ChangeID}
|
||||
} keys %LinkList
|
||||
)
|
||||
{
|
||||
|
||||
# extract change data
|
||||
my $Change = $LinkList{$ChangeID}->{Data};
|
||||
|
||||
my @ItemColumns = (
|
||||
{
|
||||
Type => 'ChangeStateSignal',
|
||||
Key => $ChangeID,
|
||||
Content => $Change->{ChangeStateSignal},
|
||||
ChangeState => $Change->{ChangeState},
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => $Change->{ChangeNumber},
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMChangeZoom;ChangeID='
|
||||
. $ChangeID,
|
||||
Title => "Change# $Change->{ChangeNumber}: $Change->{ChangeTitle}",
|
||||
},
|
||||
);
|
||||
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
|
||||
my %Hash;
|
||||
if ( grep { $_ eq $Column } @TimeLongTypes ) {
|
||||
$Hash{'Type'} = 'TimeLong';
|
||||
}
|
||||
else {
|
||||
$Hash{'Type'} = 'Text';
|
||||
}
|
||||
|
||||
if ( grep { $_ eq $Column } @TranslateTypes ) {
|
||||
$Hash{'Translate'} = 1;
|
||||
}
|
||||
|
||||
$Hash{'Content'} = $Change->{$Column};
|
||||
|
||||
push @ItemColumns, \%Hash;
|
||||
}
|
||||
}
|
||||
|
||||
push @ItemList, \@ItemColumns;
|
||||
}
|
||||
|
||||
return if !@ItemList;
|
||||
|
||||
# Define the block data.
|
||||
my %Block = (
|
||||
Object => $Self->{ObjectData}->{Object},
|
||||
Blockname => $Self->{ObjectData}->{Object},
|
||||
ObjectName => $Self->{ObjectData}->{ObjectName},
|
||||
ObjectID => $Param{ObjectID},
|
||||
Headline => \@Headline,
|
||||
ItemList => \@ItemList,
|
||||
AllColumns => \@AllColumns,
|
||||
);
|
||||
|
||||
return ( \%Block );
|
||||
|
||||
}
|
||||
|
||||
=head2 TableCreateSimple()
|
||||
|
||||
return a hash with the link output data
|
||||
|
||||
Return
|
||||
|
||||
%LinkOutputData = (
|
||||
Normal::Source => {
|
||||
ITSMChange => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'CH:2009100112354321-1',
|
||||
Title => 'Change# 2009101610005402: The Change Title',
|
||||
Css => 'style="text-decoration: line-through"',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'CH:2009100112354321-6',
|
||||
Title => 'Change# 2009101610007634: The Change Title',
|
||||
},
|
||||
],
|
||||
},
|
||||
ParentChild::Target => {
|
||||
ITSMChange => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'CH:2009100112354321-3',
|
||||
Title => 'Change# 20091016100044331: The Change Title',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
%LinkOutputData = $LinkObject->TableCreateSimple(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateSimple {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my %LinkOutputData;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
# create the item list, sort by ChangeID Down
|
||||
my @ItemList;
|
||||
for my $ChangeID (
|
||||
sort {
|
||||
$DirectionList->{$b}->{ChangeID} <=> $DirectionList->{$a}->{ChangeID}
|
||||
} keys %{$DirectionList}
|
||||
)
|
||||
{
|
||||
|
||||
# extract change data
|
||||
my $Change = $DirectionList->{$ChangeID};
|
||||
|
||||
# define item data
|
||||
my %Item = (
|
||||
Type => 'Link',
|
||||
Content => 'CH:' . $Change->{ChangeNumber},
|
||||
Title =>
|
||||
"$Self->{ChangeHook} $Change->{ChangeNumber}: $Change->{ChangeTitle}",
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMChangeZoom;ChangeID='
|
||||
. $ChangeID,
|
||||
MaxLength => 20,
|
||||
);
|
||||
|
||||
push @ItemList, \%Item;
|
||||
}
|
||||
|
||||
# add item list to link output data
|
||||
$LinkOutputData{ $LinkType . '::' . $Direction }->{ITSMChange} = \@ItemList;
|
||||
}
|
||||
}
|
||||
|
||||
return %LinkOutputData;
|
||||
}
|
||||
|
||||
=head2 ContentStringCreate()
|
||||
|
||||
return a output string
|
||||
|
||||
my $String = $LayoutObject->ContentStringCreate(
|
||||
ContentData => $HashRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub ContentStringCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ContentData} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ContentData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# extract content
|
||||
my $Content = $Param{ContentData};
|
||||
|
||||
return if $Content->{Type} ne 'ChangeStateSignal';
|
||||
|
||||
# build html for signal LED
|
||||
my $String = $Self->{LayoutObject}->Output(
|
||||
Template => '<div class="Flag Small" title="[% Data.ChangeState | html %]"> '
|
||||
. '<span class="[% Data.ChangeStateSignal | html %]"></span> </div>',
|
||||
Data => {
|
||||
ChangeStateSignal => $Content->{Content},
|
||||
ChangeState => $Content->{ChangeState} || '',
|
||||
},
|
||||
);
|
||||
|
||||
return $String;
|
||||
}
|
||||
|
||||
=head2 SelectableObjectList()
|
||||
|
||||
return an array hash with C<selectable> objects
|
||||
|
||||
Return
|
||||
|
||||
@SelectableObjectList = (
|
||||
{
|
||||
Key => 'ITSMChange',
|
||||
Value => 'Change',
|
||||
},
|
||||
);
|
||||
|
||||
@SelectableObjectList = $LinkObject->SelectableObjectList(
|
||||
Selected => $Identifier, # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SelectableObjectList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Selected;
|
||||
if ( $Param{Selected} && $Param{Selected} eq $Self->{ObjectData}->{Object} ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
|
||||
# object select list
|
||||
my @ObjectSelectList = (
|
||||
{
|
||||
Key => $Self->{ObjectData}->{Object},
|
||||
|
||||
# also use the object here and not the real name, for translation issues
|
||||
Value => $Self->{ObjectData}->{Object},
|
||||
|
||||
Selected => $Selected,
|
||||
},
|
||||
);
|
||||
|
||||
return @ObjectSelectList;
|
||||
}
|
||||
|
||||
=head2 SearchOptionList()
|
||||
|
||||
return an array hash with search options
|
||||
|
||||
Return
|
||||
|
||||
@SearchOptionList = (
|
||||
{
|
||||
Key => 'ChangeNumber',
|
||||
Name => 'Change#',
|
||||
InputStrg => $FormString,
|
||||
FormData => '12',
|
||||
},
|
||||
{
|
||||
Key => 'ChangeTitle',
|
||||
Name => 'Change Title',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'MailServer needs update',
|
||||
},
|
||||
{
|
||||
Key => 'WorkOrderTitle',
|
||||
Name => 'Workorder Title',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'Shutdown old mail server',
|
||||
},
|
||||
);
|
||||
|
||||
@SearchOptionList = $LinkObject->SearchOptionList();
|
||||
|
||||
=cut
|
||||
|
||||
sub SearchOptionList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# search option list
|
||||
my @SearchOptionList = (
|
||||
{
|
||||
Key => 'ChangeNumber',
|
||||
Name => $Self->{ChangeHook},
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'ChangeTitle',
|
||||
Name => 'ChangeTitle',
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'WorkOrderTitle',
|
||||
Name => 'WorkOrderTitle',
|
||||
Type => 'Text',
|
||||
},
|
||||
);
|
||||
|
||||
# add formkey
|
||||
for my $Row (@SearchOptionList) {
|
||||
$Row->{FormKey} = 'SEARCH::' . $Row->{Key};
|
||||
}
|
||||
|
||||
# add form data and input string
|
||||
ROW:
|
||||
for my $Row (@SearchOptionList) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam(
|
||||
Param => $Row->{FormKey},
|
||||
);
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'InputText',
|
||||
Data => {
|
||||
Key => $Row->{FormKey},
|
||||
Value => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
|
||||
return @SearchOptionList;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
993
Perl OTRS/Kernel/Output/HTML/LinkObject/ITSMConfigItem.pm
Normal file
993
Perl OTRS/Kernel/Output/HTML/LinkObject/ITSMConfigItem.pm
Normal file
@@ -0,0 +1,993 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::Output::HTML::LinkObject::ITSMConfigItem;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Output::HTML::Layout;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::System::GeneralCatalog',
|
||||
'Kernel::System::HTMLUtils',
|
||||
'Kernel::System::ITSMConfigItem',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Web::Request',
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::Output::HTML::LinkObject::ITSMConfigItem - layout backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All layout functions of link object (config item)
|
||||
|
||||
=head2 new()
|
||||
|
||||
create an object
|
||||
|
||||
$BackendObject = Kernel::Output::HTML::LinkObject::ITSMConfigItem->new(
|
||||
UserLanguage => 'en',
|
||||
UserID => 1,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# check needed objects
|
||||
for my $Needed (qw(UserLanguage UserID)) {
|
||||
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
|
||||
}
|
||||
|
||||
# We need our own LayoutObject instance to avoid blockdata collisions
|
||||
# with the main page.
|
||||
$Self->{LayoutObject} = Kernel::Output::HTML::Layout->new( %{$Self} );
|
||||
|
||||
# define needed variables
|
||||
$Self->{ObjectData} = {
|
||||
Object => 'ITSMConfigItem',
|
||||
Realname => 'ConfigItem',
|
||||
ObjectName => 'SourceObjectID',
|
||||
};
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
=head2 TableCreateComplex()
|
||||
|
||||
return an array with the block data
|
||||
|
||||
Return
|
||||
|
||||
@BlockData = (
|
||||
{
|
||||
|
||||
ObjectName => 'ConfigItemID',
|
||||
ObjectID => '123',
|
||||
|
||||
Object => 'ITSMConfigItem',
|
||||
Blockname => 'ConfigItem Computer',
|
||||
Headline => [
|
||||
{
|
||||
Content => '',
|
||||
Width => 20,
|
||||
},
|
||||
{
|
||||
Content => 'ConfigItem#',
|
||||
Width => 100,
|
||||
},
|
||||
{
|
||||
Content => 'Name',
|
||||
},
|
||||
{
|
||||
Content => 'Deployment State',
|
||||
Width => 130,
|
||||
},
|
||||
{
|
||||
Content => 'Created',
|
||||
Width => 130,
|
||||
},
|
||||
],
|
||||
ItemList => [
|
||||
[
|
||||
{
|
||||
Type => 'CurInciSignal',
|
||||
Key => '123',
|
||||
Content => 'Incident',
|
||||
CurInciStateType => 'incident',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => '123',
|
||||
Link => 'Action=AgentITSMConfigItemZoom;ConfigItemID=123',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'The Name of the Config Item',
|
||||
MaxLength => 50,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'In Repair',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
Type => 'CurInciSignal',
|
||||
Key => '234',
|
||||
Content => 'Incident',
|
||||
CurInciStateType => 'incident',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => '234',
|
||||
Link => 'Action=AgentITSMConfigItemZoom;ConfigItemID=234',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'The Name of the Config Item 234',
|
||||
MaxLength => 50,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Productive',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2007-11-11 12:12:00',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
@BlockData = $LinkObject->TableCreateComplex(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateComplex {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my $GeneralCatalogObject = $Kernel::OM->Get('Kernel::System::GeneralCatalog');
|
||||
my $ConfigItemObject = $Kernel::OM->Get('Kernel::System::ITSMConfigItem');
|
||||
|
||||
# get and remember the Deployment state colors
|
||||
my $DeploymentStatesList = $GeneralCatalogObject->ItemList(
|
||||
Class => 'ITSM::ConfigItem::DeploymentState',
|
||||
);
|
||||
|
||||
ITEMID:
|
||||
for my $ItemID ( sort keys %{$DeploymentStatesList} ) {
|
||||
|
||||
# get deployment state preferences
|
||||
my %Preferences = $GeneralCatalogObject->GeneralCatalogPreferencesGet(
|
||||
ItemID => $ItemID,
|
||||
);
|
||||
|
||||
# check if a color is defined in preferences
|
||||
next ITEMID if !$Preferences{Color};
|
||||
|
||||
# add color style definition
|
||||
my $DeplState = $DeploymentStatesList->{$ItemID};
|
||||
|
||||
# remove any non ascii word characters
|
||||
$DeplState =~ s{ [^a-zA-Z0-9] }{_}msxg;
|
||||
|
||||
# covert to lower case
|
||||
$Self->{DeplStateColors}->{$DeplState} = lc $Preferences{Color};
|
||||
}
|
||||
|
||||
# Get the columns config.
|
||||
my $ColumnsConfig = $Kernel::OM->Get('Kernel::Config')->Get('LinkObject::ITSMConfigItem::ShowColumns');
|
||||
|
||||
# Get the columns by class config.
|
||||
my $ColumnsByClassConfig
|
||||
= $Kernel::OM->Get('Kernel::Config')->Get('LinkObject::ITSMConfigItem::ShowColumnsByClass');
|
||||
|
||||
# Get configured columns and reorganize them by class name.
|
||||
my %ColumnByClass;
|
||||
my %SignalColumnList;
|
||||
if ( $ColumnsByClassConfig && ref $ColumnsByClassConfig eq 'ARRAY' && @{$ColumnsByClassConfig} ) {
|
||||
|
||||
NAME:
|
||||
for my $Name ( @{$ColumnsByClassConfig} ) {
|
||||
my ( $Class, $Column ) = split /::/, $Name, 2;
|
||||
|
||||
next NAME if !$Column;
|
||||
|
||||
# If signal columns are configured just for certain classes, add them to the beginning of ItemColumns array,
|
||||
# not to the array with other columns.
|
||||
if ( $Column eq 'CurInciSignal' || $Column eq 'CurDeplSignal' ) {
|
||||
$SignalColumnList{$Class}->{$Column} = 1;
|
||||
next NAME;
|
||||
}
|
||||
|
||||
push @{ $ColumnByClass{$Class} }, $Column;
|
||||
}
|
||||
}
|
||||
|
||||
# convert the list
|
||||
my %LinkList;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
CONFIGITEMID:
|
||||
for my $ConfigItemID ( sort keys %{$DirectionList} ) {
|
||||
|
||||
# extract class
|
||||
my $Class = $DirectionList->{$ConfigItemID}->{Class} || '';
|
||||
|
||||
next CONFIGITEMID if !$Class;
|
||||
|
||||
$LinkList{$Class}->{$ConfigItemID}->{Data} = $DirectionList->{$ConfigItemID};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my @BlockData;
|
||||
for my $Class ( sort { lc $a cmp lc $b } keys %LinkList ) {
|
||||
|
||||
# extract config item data
|
||||
my $ConfigItemList = $LinkList{$Class};
|
||||
|
||||
# to store the column headline
|
||||
my @ShowColumnsHeadlines;
|
||||
|
||||
# create the item list
|
||||
my @ItemList;
|
||||
for my $ConfigItemID (
|
||||
sort { $ConfigItemList->{$a}->{Data}->{Name} cmp $ConfigItemList->{$b}->{Data}->{Name} }
|
||||
keys %{$ConfigItemList}
|
||||
)
|
||||
{
|
||||
my $ConfigItemData = $ConfigItemObject->ConfigItemGet(
|
||||
ConfigItemID => $ConfigItemID,
|
||||
);
|
||||
|
||||
# extract version data
|
||||
my $Version = $ConfigItemList->{$ConfigItemID}->{Data};
|
||||
|
||||
# make sure the column headline array is empty for each loop
|
||||
@ShowColumnsHeadlines = ();
|
||||
|
||||
# get the version data, including all the XML data
|
||||
my $VersionXMLData = $ConfigItemObject->VersionGet(
|
||||
ConfigItemID => $ConfigItemID,
|
||||
XMLDataGet => 1,
|
||||
);
|
||||
|
||||
my @ItemColumns = (
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => $Version->{Number},
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMConfigItemZoom;ConfigItemID='
|
||||
. $ConfigItemID,
|
||||
Title => "ConfigItem# $Version->{Number} ($Version->{Class}): $Version->{Name}",
|
||||
},
|
||||
);
|
||||
|
||||
# Add columns from 'LinkObject::ITSMConfigItem::ShowColumns' setting to the current CI class
|
||||
# if it does not contain them. Signal columns is saved in hash because they will be added later.
|
||||
COLUMNCONFIG:
|
||||
for my $Column ( @{$ColumnsConfig} ) {
|
||||
|
||||
if ( $Column eq 'CurInciSignal' || $Column eq 'CurDeplSignal' ) {
|
||||
$SignalColumnList{$Class}->{$Column} = 1;
|
||||
}
|
||||
elsif ( !grep { $_ eq $Column } @{ $ColumnByClass{$Class} } ) {
|
||||
push @{ $ColumnByClass{$Class} }, $Column;
|
||||
}
|
||||
}
|
||||
|
||||
# Add signal columns to the beginning of the array if needed.
|
||||
if ( $SignalColumnList{$Class}->{CurDeplSignal} ) {
|
||||
unshift @ItemColumns, {
|
||||
Type => 'CurDeplSignal',
|
||||
Key => $ConfigItemID,
|
||||
Content => $Version->{CurDeplState},
|
||||
};
|
||||
}
|
||||
if ( $SignalColumnList{$Class}->{CurInciSignal} ) {
|
||||
unshift @ItemColumns, {
|
||||
Type => 'CurInciSignal',
|
||||
Key => $ConfigItemID,
|
||||
Content => $Version->{CurInciState},
|
||||
CurInciStateType => $Version->{CurInciStateType},
|
||||
};
|
||||
}
|
||||
|
||||
# these columns will be added if no class based column config is defined
|
||||
my @AdditionalDefaultItemColumns = (
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => $Version->{Name},
|
||||
MaxLength => 50,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => $Version->{CurDeplState},
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => $ConfigItemData->{CreateTime},
|
||||
},
|
||||
);
|
||||
|
||||
# individual column config for this class exists
|
||||
if ( $ColumnByClass{$Class} ) {
|
||||
|
||||
# convert the XML data into a hash
|
||||
my $ExtendedVersionData = $Self->{LayoutObject}->XMLData2Hash(
|
||||
XMLDefinition => $VersionXMLData->{XMLDefinition},
|
||||
XMLData => $VersionXMLData->{XMLData}->[1]->{Version}->[1],
|
||||
Attributes => $ColumnByClass{$Class},
|
||||
);
|
||||
|
||||
COLUMN:
|
||||
for my $Column ( @{ $ColumnByClass{$Class} } ) {
|
||||
|
||||
# process some non-xml attributes
|
||||
if ( $Version->{$Column} ) {
|
||||
|
||||
# handle the CI name
|
||||
if ( $Column eq 'Name' ) {
|
||||
|
||||
# add the column
|
||||
push @ItemColumns, {
|
||||
Type => 'Text',
|
||||
Content => $Version->{Name},
|
||||
MaxLength => 50,
|
||||
};
|
||||
|
||||
# add the headline
|
||||
push @ShowColumnsHeadlines, {
|
||||
Content => 'Name',
|
||||
};
|
||||
}
|
||||
|
||||
# special translation handling
|
||||
elsif ( $Column eq 'CurDeplState' ) {
|
||||
|
||||
# add the column
|
||||
push @ItemColumns, {
|
||||
Type => 'Text',
|
||||
Content => $Version->{$Column},
|
||||
Translate => 1,
|
||||
};
|
||||
|
||||
# add the headline
|
||||
push @ShowColumnsHeadlines, {
|
||||
Content => 'Deployment State',
|
||||
};
|
||||
}
|
||||
|
||||
# special translation handling
|
||||
elsif ( $Column eq 'CurInciState' ) {
|
||||
|
||||
# add the column
|
||||
push @ItemColumns, {
|
||||
Type => 'Text',
|
||||
Content => $Version->{$Column},
|
||||
Translate => 1,
|
||||
};
|
||||
|
||||
# add the headline
|
||||
push @ShowColumnsHeadlines, {
|
||||
Content => 'Incident State',
|
||||
};
|
||||
}
|
||||
|
||||
# special translation handling
|
||||
elsif ( $Column eq 'Class' ) {
|
||||
|
||||
# add the column
|
||||
push @ItemColumns, {
|
||||
Type => 'Text',
|
||||
Content => $Version->{$Column},
|
||||
Translate => 1,
|
||||
};
|
||||
|
||||
# add the headline
|
||||
push @ShowColumnsHeadlines, {
|
||||
Content => 'Class',
|
||||
};
|
||||
}
|
||||
|
||||
# special date/time handling
|
||||
elsif ( $Column eq 'CreateTime' ) {
|
||||
|
||||
# add the column
|
||||
push @ItemColumns, {
|
||||
Type => 'TimeLong',
|
||||
Content => $Version->{CreateTime},
|
||||
};
|
||||
|
||||
# add the headline
|
||||
push @ShowColumnsHeadlines, {
|
||||
Content => 'Created',
|
||||
};
|
||||
}
|
||||
|
||||
next COLUMN;
|
||||
}
|
||||
|
||||
# convert to ascii text in case the value contains html
|
||||
my $Value = $Kernel::OM->Get('Kernel::System::HTMLUtils')->ToAscii(
|
||||
String => $ExtendedVersionData->{$Column}->{Value},
|
||||
) || '';
|
||||
|
||||
# convert all whitespace and newlines to single spaces
|
||||
$Value =~ s{ \s+ }{ }gxms;
|
||||
|
||||
# add the column
|
||||
push @ItemColumns, {
|
||||
Type => 'Text',
|
||||
Content => $Value,
|
||||
};
|
||||
|
||||
# add the headline
|
||||
push @ShowColumnsHeadlines, {
|
||||
Content => $ExtendedVersionData->{$Column}->{Name} || '',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# individual column config for this class does not exist,
|
||||
# so the default columns will be used
|
||||
else {
|
||||
|
||||
# add the default columns
|
||||
push @ItemColumns, @AdditionalDefaultItemColumns;
|
||||
|
||||
# add the default column headlines
|
||||
@ShowColumnsHeadlines = (
|
||||
{
|
||||
Content => 'Name',
|
||||
},
|
||||
{
|
||||
Content => 'Deployment State',
|
||||
Width => 130,
|
||||
},
|
||||
{
|
||||
Content => 'Created',
|
||||
Width => 130,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
push @ItemList, \@ItemColumns;
|
||||
}
|
||||
|
||||
return if !@ItemList;
|
||||
|
||||
# define the block data
|
||||
my %Block = (
|
||||
Object => $Self->{ObjectData}->{Object},
|
||||
Blockname => $Self->{ObjectData}->{Realname} . ' (' . $Class . ')',
|
||||
Headline => [
|
||||
{
|
||||
Content => 'ConfigItem#',
|
||||
Width => 100,
|
||||
},
|
||||
],
|
||||
ItemList => \@ItemList,
|
||||
);
|
||||
|
||||
# Add 'CurInciSignal' and 'CurDeplSignal' columns to the beginning of headline if needed.
|
||||
if ( $SignalColumnList{$Class}->{CurDeplSignal} ) {
|
||||
unshift @{ $Block{Headline} }, {
|
||||
Content => 'Deployment State',
|
||||
Width => 20,
|
||||
};
|
||||
}
|
||||
if ( $SignalColumnList{$Class}->{CurInciSignal} ) {
|
||||
unshift @{ $Block{Headline} }, {
|
||||
Content => 'Incident State',
|
||||
Width => 20,
|
||||
};
|
||||
}
|
||||
|
||||
# add the column headlines
|
||||
push @{ $Block{Headline} }, @ShowColumnsHeadlines;
|
||||
|
||||
push @BlockData, \%Block;
|
||||
}
|
||||
|
||||
return @BlockData;
|
||||
}
|
||||
|
||||
=head2 TableCreateSimple()
|
||||
|
||||
return a hash with the link output data
|
||||
|
||||
Return
|
||||
|
||||
%LinkOutputData = (
|
||||
Normal::Source => {
|
||||
ITSMConfigItem => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'CI:55555',
|
||||
Title => 'ConfigItem# 555555: The config item name',
|
||||
Css => 'style="text-decoration: line-through"',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'CI:22222',
|
||||
Title => 'ConfigItem# 22222: Title of config name 22222',
|
||||
},
|
||||
],
|
||||
},
|
||||
ParentChild::Target => {
|
||||
ITSMConfigItem => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'CI:77777',
|
||||
Title => 'ConfigItem# 77777: ConfigItem name',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
%LinkOutputData = $LinkObject->TableCreateSimple(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateSimple {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my %LinkOutputData;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
my @ItemList;
|
||||
for my $ConfigItemID ( sort { $a <=> $b } keys %{$DirectionList} ) {
|
||||
|
||||
# extract config item data
|
||||
my $Version = $DirectionList->{$ConfigItemID};
|
||||
|
||||
# define item data
|
||||
my %Item = (
|
||||
Type => 'Link',
|
||||
Content => 'CI:' . $Version->{Number},
|
||||
Title => "ConfigItem# $Version->{Number} ($Version->{Class}): $Version->{Name}",
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMConfigItemZoom;ConfigItemID='
|
||||
. $ConfigItemID,
|
||||
);
|
||||
|
||||
push @ItemList, \%Item;
|
||||
}
|
||||
|
||||
# add item list to link output data
|
||||
$LinkOutputData{ $LinkType . '::' . $Direction }->{ITSMConfigItem} = \@ItemList;
|
||||
}
|
||||
}
|
||||
|
||||
return %LinkOutputData;
|
||||
}
|
||||
|
||||
=head2 ContentStringCreate()
|
||||
|
||||
return a output string
|
||||
|
||||
my $String = $LayoutObject->ContentStringCreate(
|
||||
ContentData => $HashRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub ContentStringCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ContentData} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ContentData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# extract content
|
||||
my $Content = $Param{ContentData};
|
||||
|
||||
if ( $Content->{Type} ne 'CurInciSignal' && $Content->{Type} ne 'CurDeplSignal' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $String;
|
||||
if ( $Content->{Type} eq 'CurInciSignal' ) {
|
||||
|
||||
# set incident signal
|
||||
my %InciSignals = (
|
||||
incident => 'redled',
|
||||
operational => 'greenled',
|
||||
unknown => 'grayled',
|
||||
warning => 'yellowled',
|
||||
);
|
||||
|
||||
# investigate current incident signal
|
||||
$Content->{CurInciStateType} ||= 'unknown';
|
||||
my $CurInciSignal = $InciSignals{ $Content->{CurInciStateType} };
|
||||
$CurInciSignal ||= $InciSignals{unknown};
|
||||
|
||||
$String = $Self->{LayoutObject}->Output(
|
||||
Template => '<div class="Flag Small" title="[% Translate(Data.CurInciState) | html %]"> '
|
||||
. '<span class="[% Data.CurInciSignal | html %]"></span> </div>',
|
||||
Data => {
|
||||
CurInciSignal => $CurInciSignal,
|
||||
CurInciState => $Content->{Content} || '',
|
||||
},
|
||||
);
|
||||
}
|
||||
elsif ( $Content->{Type} eq 'CurDeplSignal' ) {
|
||||
|
||||
# convert deployment state to a web safe CSS class
|
||||
my $DeplState = $Content->{Content} || '';
|
||||
$DeplState =~ s{ [^a-zA-Z0-9] }{_}msxg;
|
||||
|
||||
# get the color of the deplyment state if defined
|
||||
my $DeplStateColor = $Self->{DeplStateColors}->{$DeplState} || '';
|
||||
|
||||
my $Template = '<div class="Flag Small" title="[% Translate(Data.CurDeplState) | html %]"> ';
|
||||
|
||||
# check if color is defined and set the style class
|
||||
if ($DeplStateColor) {
|
||||
$Template .= << "END";
|
||||
<style>
|
||||
.Flag span.$DeplState {
|
||||
background-color: #$DeplStateColor;
|
||||
}
|
||||
</style>
|
||||
END
|
||||
}
|
||||
|
||||
$Template .= "<span class=\"DeplState $DeplState\"></span> </div>";
|
||||
|
||||
$String = $Self->{LayoutObject}->Output(
|
||||
Template => $Template,
|
||||
Data => {
|
||||
CurDeplState => $Content->{Content} || '',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return $String;
|
||||
}
|
||||
|
||||
=head2 SelectableObjectList()
|
||||
|
||||
return an array hash with C<selectable> objects
|
||||
|
||||
Return
|
||||
|
||||
@SelectableObjectList = (
|
||||
{
|
||||
Key => '-',
|
||||
Value => 'ConfigItem',
|
||||
Disabled => 1,
|
||||
},
|
||||
{
|
||||
Key => 'ITSMConfigItem::25',
|
||||
Value => 'ConfigItem::Computer',
|
||||
},
|
||||
{
|
||||
Key => 'ITSMConfigItem::26',
|
||||
Value => 'ConfigItem::Software',
|
||||
},
|
||||
{
|
||||
Key => 'ITSMConfigItem::27',
|
||||
Value => 'ConfigItem::Network',
|
||||
},
|
||||
);
|
||||
|
||||
@SelectableObjectList = $LinkObject->SelectableObjectList(
|
||||
Selected => $Identifier, # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SelectableObjectList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# define headline
|
||||
my @ObjectSelectList;
|
||||
|
||||
# get class list
|
||||
my $ClassList = $Kernel::OM->Get('Kernel::System::GeneralCatalog')->ItemList(
|
||||
Class => 'ITSM::ConfigItem::Class',
|
||||
);
|
||||
|
||||
return if !$ClassList;
|
||||
return if ref $ClassList ne 'HASH';
|
||||
|
||||
# get the config with the default subobjects
|
||||
my $DefaultSubobject = $Kernel::OM->Get('Kernel::Config')->Get('LinkObject::DefaultSubObject') || {};
|
||||
|
||||
CLASSID:
|
||||
for my $ClassID ( sort { lc $ClassList->{$a} cmp lc $ClassList->{$b} } keys %{$ClassList} ) {
|
||||
|
||||
# show class only if user has access rights
|
||||
my $HasAccess = $Kernel::OM->Get('Kernel::System::ITSMConfigItem')->Permission(
|
||||
Scope => 'Class',
|
||||
ClassID => $ClassID,
|
||||
UserID => $Self->{UserID},
|
||||
Type => 'ro',
|
||||
);
|
||||
|
||||
next CLASSID if !$HasAccess;
|
||||
|
||||
my $Class = $ClassList->{$ClassID} || '';
|
||||
my $Identifier = $Self->{ObjectData}->{Object} . '::' . $ClassID;
|
||||
|
||||
# set selected flag
|
||||
my $Selected;
|
||||
if ( $Param{Selected} ) {
|
||||
|
||||
if ( $Param{Selected} eq $Identifier ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
elsif (
|
||||
$Param{Selected} eq $Self->{ObjectData}->{Object}
|
||||
&& $DefaultSubobject->{ $Self->{ObjectData}->{Object} }
|
||||
)
|
||||
{
|
||||
|
||||
# extract default class name
|
||||
my $DefaultClass = $DefaultSubobject->{ $Self->{ObjectData}->{Object} } || '';
|
||||
|
||||
# check class
|
||||
if ( $DefaultClass eq $Class ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# create row
|
||||
my %Row = (
|
||||
Key => $Identifier,
|
||||
Value => $Self->{ObjectData}->{Realname} . '::' . $Class,
|
||||
Selected => $Selected,
|
||||
);
|
||||
|
||||
push @ObjectSelectList, \%Row;
|
||||
}
|
||||
|
||||
# only add headline if there are configitem classes
|
||||
# where the user has the permission to use them
|
||||
if (@ObjectSelectList) {
|
||||
|
||||
# add headline as first array element
|
||||
unshift @ObjectSelectList, {
|
||||
Key => '-',
|
||||
Value => $Self->{ObjectData}->{Realname},
|
||||
Disabled => 1,
|
||||
};
|
||||
}
|
||||
|
||||
return @ObjectSelectList;
|
||||
}
|
||||
|
||||
=head2 SearchOptionList()
|
||||
|
||||
return an array hash with search options
|
||||
|
||||
Return
|
||||
|
||||
@SearchOptionList = (
|
||||
{
|
||||
Key => 'Number',
|
||||
Name => 'ConfigItem#',
|
||||
InputStrg => $FormString,
|
||||
FormData => '1234',
|
||||
},
|
||||
{
|
||||
Key => 'Name',
|
||||
Name => 'Name',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'BlaBla',
|
||||
},
|
||||
);
|
||||
|
||||
@SearchOptionList = $LinkObject->SearchOptionList(
|
||||
SubObject => '25', # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SearchOptionList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# search option list
|
||||
my @SearchOptionList = (
|
||||
{
|
||||
Key => 'Number',
|
||||
Name => 'ConfigItem#',
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'Name',
|
||||
Name => 'Name',
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'DeplStateIDs',
|
||||
Name => 'Deployment State',
|
||||
Type => 'List',
|
||||
},
|
||||
{
|
||||
Key => 'InciStateIDs',
|
||||
Name => 'Incident State',
|
||||
Type => 'List',
|
||||
},
|
||||
);
|
||||
|
||||
# add object dependence attributes
|
||||
#if ( $Param{SubObject} ) {
|
||||
#
|
||||
# # get class list
|
||||
# my $ClassList = $Kernel::OM->Get('Kernel::System::GeneralCatalog')->ItemList(
|
||||
# Class => 'ITSM::ConfigItem::Class',
|
||||
# );
|
||||
#
|
||||
# if ( $ClassList && $ClassList eq 'HASH' ) {
|
||||
#
|
||||
# # add here the search attributes of the subobject!
|
||||
# }
|
||||
#}
|
||||
|
||||
# add formkey
|
||||
for my $Row (@SearchOptionList) {
|
||||
$Row->{FormKey} = 'SEARCH::' . $Row->{Key};
|
||||
}
|
||||
|
||||
# add form data and input string
|
||||
ROW:
|
||||
for my $Row (@SearchOptionList) {
|
||||
|
||||
# prepare text input fields
|
||||
if ( $Row->{Type} eq 'Text' ) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Row->{FormKey} );
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'InputText',
|
||||
Data => {
|
||||
Key => $Row->{FormKey},
|
||||
Value => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
|
||||
# prepare list boxes
|
||||
if ( $Row->{Type} eq 'List' ) {
|
||||
|
||||
# get form data
|
||||
my @FormData = $Kernel::OM->Get('Kernel::System::Web::Request')->GetArray( Param => $Row->{FormKey} );
|
||||
$Row->{FormData} = \@FormData;
|
||||
|
||||
# prepare deployment state list
|
||||
my %ListData;
|
||||
if ( $Row->{Key} eq 'DeplStateIDs' ) {
|
||||
|
||||
# get deployment state list
|
||||
my $DeplStateList = $Kernel::OM->Get('Kernel::System::GeneralCatalog')->ItemList(
|
||||
Class => 'ITSM::ConfigItem::DeploymentState',
|
||||
);
|
||||
|
||||
# add list
|
||||
if ( $DeplStateList && ref $DeplStateList eq 'HASH' ) {
|
||||
%ListData = %{$DeplStateList};
|
||||
}
|
||||
}
|
||||
|
||||
# prepare incident state list
|
||||
elsif ( $Row->{Key} eq 'InciStateIDs' ) {
|
||||
|
||||
# get incident state list
|
||||
my $InciStateList = $Kernel::OM->Get('Kernel::System::GeneralCatalog')->ItemList(
|
||||
Class => 'ITSM::Core::IncidentState',
|
||||
);
|
||||
|
||||
# add list
|
||||
if ( $InciStateList && ref $InciStateList eq 'HASH' ) {
|
||||
%ListData = %{$InciStateList};
|
||||
}
|
||||
}
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->BuildSelection(
|
||||
Data => \%ListData,
|
||||
Name => $Row->{FormKey},
|
||||
SelectedID => $Row->{FormData},
|
||||
Size => 3,
|
||||
Multiple => 1,
|
||||
Class => 'Modernize',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
}
|
||||
|
||||
return @SearchOptionList;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
724
Perl OTRS/Kernel/Output/HTML/LinkObject/ITSMWorkOrder.pm
Normal file
724
Perl OTRS/Kernel/Output/HTML/LinkObject/ITSMWorkOrder.pm
Normal file
@@ -0,0 +1,724 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::Output::HTML::LinkObject::ITSMWorkOrder;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
use Kernel::Output::HTML::Layout;
|
||||
use Kernel::System::VariableCheck qw(:all);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Language',
|
||||
'Kernel::System::JSON',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::User',
|
||||
'Kernel::System::Web::Request',
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::Output::HTML::LinkObject::ITSMWorkOrder - layout backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All layout functions of link object (C<workorder>)
|
||||
|
||||
=head2 new()
|
||||
|
||||
create an object
|
||||
|
||||
$BackendObject = Kernel::Output::HTML::LinkObject::ITSMWorkOrder->new(
|
||||
UserLanguage => 'en',
|
||||
UserID => 1,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# check needed objects
|
||||
for my $Needed (qw(UserLanguage UserID)) {
|
||||
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
|
||||
}
|
||||
|
||||
# We need our own LayoutObject instance to avoid blockdata collisions
|
||||
# with the main page.
|
||||
$Self->{LayoutObject} = Kernel::Output::HTML::Layout->new( %{$Self} );
|
||||
|
||||
# define needed variables
|
||||
$Self->{ObjectData} = {
|
||||
Object => 'ITSMWorkOrder',
|
||||
Realname => 'Workorder',
|
||||
ObjectName => 'SourceObjectID',
|
||||
};
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# get config
|
||||
$Self->{ChangeHook} = $ConfigObject->Get('ITSMChange::Hook');
|
||||
$Self->{WorkOrderHook} = $ConfigObject->Get('ITSMWorkOrder::Hook');
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
=head2 TableCreateComplex()
|
||||
|
||||
return an array with the block data
|
||||
|
||||
Return
|
||||
|
||||
@BlockData = (
|
||||
Object => 'ITSMWorkOrder',
|
||||
Blockname => 'WorkOrder',
|
||||
Headline => [
|
||||
{
|
||||
Content => '',
|
||||
Width => 20,
|
||||
},
|
||||
{
|
||||
Content => 'Workorder#',
|
||||
Width => 200,
|
||||
},
|
||||
{
|
||||
Content => 'Workorder Title',
|
||||
Width => 200,
|
||||
},
|
||||
{
|
||||
Content => 'Change Title',
|
||||
Width => 200,
|
||||
},
|
||||
{
|
||||
Content => 'Workorder State',
|
||||
Width => 100,
|
||||
},
|
||||
{
|
||||
Content => 'Changed',
|
||||
Width => 150,
|
||||
},
|
||||
],
|
||||
ItemList => [
|
||||
[
|
||||
{
|
||||
Type => 'WorkOrderStateSignal',
|
||||
Key => 2,
|
||||
Content => 'greenled',
|
||||
WorkOrderState => 'ready',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => '2009100112345778-3',
|
||||
Link => 'Action=AgentITSMWorkOrderZoom;WorkOrderID=2',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Workorder Title',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Change Title',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'ready',
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2009-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
Type => 'WorkOrderStateSignal',
|
||||
Key => 4,
|
||||
Content => 'redled',
|
||||
WorkOrderState => 'canceld',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => '2009100112345778-4',
|
||||
Link => 'Action=AgentITSMWorkOrderZoom;WorkOrderID=4',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Workorder Title',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Change Title',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'accepted',
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2009-02-02 13:13:00',
|
||||
},
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
@BlockData = $LinkObject->TableCreateComplex(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateComplex {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# convert the list
|
||||
my %LinkList;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
for my $WorkOrderID ( sort keys %{$DirectionList} ) {
|
||||
|
||||
$LinkList{$WorkOrderID}->{Data} = $DirectionList->{$WorkOrderID};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
my $ComplexTableData = $ConfigObject->Get("LinkObject::ComplexTable");
|
||||
my $DefaultColumns;
|
||||
if (
|
||||
$ComplexTableData
|
||||
&& IsHashRefWithData($ComplexTableData)
|
||||
&& $ComplexTableData->{ITSMWorkOrder}
|
||||
&& IsHashRefWithData( $ComplexTableData->{ITSMWorkOrder} )
|
||||
)
|
||||
{
|
||||
$DefaultColumns = $ComplexTableData->{"ITSMWorkOrder"}->{"DefaultColumns"};
|
||||
}
|
||||
|
||||
my @TimeLongTypes = (
|
||||
'CreateTime',
|
||||
'ChangeTime',
|
||||
'PlannedStartTime',
|
||||
'PlannedEndTime',
|
||||
'ActualStartTime',
|
||||
'ActualEndTime',
|
||||
);
|
||||
|
||||
my @TranslateTypes = ();
|
||||
|
||||
# always show the change state flag and the change number
|
||||
my @Headline = (
|
||||
{
|
||||
Content => 'WorkOrderState',
|
||||
},
|
||||
{
|
||||
Content => $Self->{WorkOrderHook},
|
||||
},
|
||||
);
|
||||
|
||||
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
|
||||
|
||||
# Load user preferences.
|
||||
my %Preferences = $UserObject->GetPreferences(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
if ( !$DefaultColumns || !IsHashRefWithData($DefaultColumns) ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Missing configuration for LinkObject::ComplexTable###ITSMWorkOrder!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Get default column priority from SysConfig.
|
||||
# Each column in table (Title, State,...) has defined Priority in SysConfig. System use this
|
||||
# priority to sort columns, if user doesn't have own settings.
|
||||
my %SortOrder;
|
||||
if (
|
||||
$ComplexTableData->{"ITSMWorkOrder"}->{"Priority"}
|
||||
&& IsHashRefWithData( $ComplexTableData->{"ITSMWorkOrder"}->{"Priority"} )
|
||||
)
|
||||
{
|
||||
%SortOrder = %{ $ComplexTableData->{"ITSMWorkOrder"}->{"Priority"} };
|
||||
}
|
||||
|
||||
my %UserColumns = %{$DefaultColumns};
|
||||
|
||||
if ( $Preferences{'LinkObject::ComplexTable-ITSMWorkOrder'} ) {
|
||||
|
||||
my $ColumnsEnabled = $Kernel::OM->Get('Kernel::System::JSON')->Decode(
|
||||
Data => $Preferences{'LinkObject::ComplexTable-ITSMWorkOrder'},
|
||||
);
|
||||
|
||||
if (
|
||||
$ColumnsEnabled
|
||||
&& IsHashRefWithData($ColumnsEnabled)
|
||||
&& $ColumnsEnabled->{Order}
|
||||
&& IsArrayRefWithData( $ColumnsEnabled->{Order} )
|
||||
)
|
||||
{
|
||||
# Clear sort order.
|
||||
%SortOrder = ();
|
||||
|
||||
DEFAULTCOLUMN:
|
||||
for my $DefaultColumn ( sort keys %UserColumns ) {
|
||||
my $Index = 0;
|
||||
|
||||
for my $UserSetting ( @{ $ColumnsEnabled->{Order} } ) {
|
||||
$Index++;
|
||||
if ( $DefaultColumn eq $UserSetting ) {
|
||||
$UserColumns{$DefaultColumn} = 2;
|
||||
$SortOrder{$DefaultColumn} = $Index;
|
||||
|
||||
next DEFAULTCOLUMN;
|
||||
}
|
||||
}
|
||||
|
||||
# Not found, means user chose to hide this item.
|
||||
if ( $UserColumns{$DefaultColumn} == 2 ) {
|
||||
$UserColumns{$DefaultColumn} = 1;
|
||||
}
|
||||
|
||||
if ( !$SortOrder{$DefaultColumn} ) {
|
||||
$SortOrder{$DefaultColumn} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
# User has no own settings.
|
||||
for my $Column ( sort keys %UserColumns ) {
|
||||
if ( !$SortOrder{$Column} ) {
|
||||
$SortOrder{$Column} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Define Headline columns.
|
||||
my @AllColumns;
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
my $ColumnTranslate = $Column;
|
||||
if ( $Column eq 'CreateTime' ) {
|
||||
$ColumnTranslate = Translatable('Created');
|
||||
}
|
||||
elsif ( $Column eq 'ChangeTime' ) {
|
||||
$ColumnTranslate = Translatable('Changed');
|
||||
}
|
||||
|
||||
push @AllColumns, {
|
||||
ColumnName => $Column,
|
||||
ColumnTranslate => $ColumnTranslate,
|
||||
};
|
||||
|
||||
# if enabled by default.
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
push @Headline, {
|
||||
Content => $ColumnTranslate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# create the item list, sort by ChangeID Down, then by WorkOrderID Up
|
||||
my @ItemList;
|
||||
for my $WorkOrderID (
|
||||
sort {
|
||||
$LinkList{$b}{Data}->{ChangeID} <=> $LinkList{$a}{Data}->{ChangeID}
|
||||
|| $a <=> $b
|
||||
} keys %LinkList
|
||||
)
|
||||
{
|
||||
|
||||
# extract workorder data
|
||||
my $WorkOrder = $LinkList{$WorkOrderID}->{Data};
|
||||
|
||||
my @ItemColumns = (
|
||||
{
|
||||
Type => 'WorkOrderStateSignal',
|
||||
Key => $WorkOrderID,
|
||||
Content => $WorkOrder->{WorkOrderStateSignal},
|
||||
WorkOrderState => $WorkOrder->{WorkOrderState},
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => $WorkOrder->{ChangeData}->{ChangeNumber}
|
||||
. '-' . $WorkOrder->{WorkOrderNumber},
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMWorkOrderZoom;WorkOrderID='
|
||||
. $WorkOrderID,
|
||||
Title => $Self->{ChangeHook} . $WorkOrder->{ChangeData}->{ChangeNumber} . '-'
|
||||
. $Self->{WorkOrderHook}
|
||||
. $WorkOrder->{WorkOrderNumber} . ': '
|
||||
. $WorkOrder->{WorkOrderTitle},
|
||||
},
|
||||
);
|
||||
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
|
||||
my %Hash;
|
||||
if ( grep { $_ eq $Column } @TimeLongTypes ) {
|
||||
$Hash{'Type'} = 'TimeLong';
|
||||
}
|
||||
else {
|
||||
$Hash{'Type'} = 'Text';
|
||||
}
|
||||
|
||||
if ( grep { $_ eq $Column } @TranslateTypes ) {
|
||||
$Hash{'Translate'} = 1;
|
||||
}
|
||||
|
||||
$Hash{'Content'} = $WorkOrder->{$Column};
|
||||
|
||||
push @ItemColumns, \%Hash;
|
||||
}
|
||||
}
|
||||
|
||||
push @ItemList, \@ItemColumns;
|
||||
}
|
||||
|
||||
return if !@ItemList;
|
||||
|
||||
# Define the block data.
|
||||
my %Block = (
|
||||
Object => $Self->{ObjectData}->{Object},
|
||||
Blockname => $Self->{ObjectData}->{Object},
|
||||
ObjectName => $Self->{ObjectData}->{ObjectName},
|
||||
ObjectID => $Param{ObjectID},
|
||||
Headline => \@Headline,
|
||||
ItemList => \@ItemList,
|
||||
AllColumns => \@AllColumns,
|
||||
);
|
||||
|
||||
return ( \%Block );
|
||||
|
||||
}
|
||||
|
||||
=head2 TableCreateSimple()
|
||||
|
||||
return a hash with the link output data
|
||||
|
||||
Return
|
||||
|
||||
%LinkOutputData = (
|
||||
Normal::Source => {
|
||||
ITSMWorkOrder => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'WO:2009100112354321-1',
|
||||
Title => 'Change# 2009101610005402 - Workorder# 1: The WorkOrder Title',
|
||||
Css => 'style="text-decoration: line-through"',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'WO:2009100112354321-6',
|
||||
Title => 'Change# 2009101610007634 - Workorder# 6: The WorkOrder Title',
|
||||
},
|
||||
],
|
||||
},
|
||||
ParentChild::Target => {
|
||||
ITSMWorkOrder => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'WO:2009100112354321-3',
|
||||
Title => 'Change# 20091016100044331 - Workorder# 3: The WorkOrder Title',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
%LinkOutputData = $LinkObject->TableCreateSimple(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateSimple {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my %LinkOutputData;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
# create the item list, sort by ChangeID Down, then by WorkOrderNumber Up
|
||||
my @ItemList;
|
||||
for my $WorkOrderID (
|
||||
sort {
|
||||
$DirectionList->{$b}->{ChangeID} <=> $DirectionList->{$a}->{ChangeID}
|
||||
|| $a <=> $b
|
||||
} keys %{$DirectionList}
|
||||
)
|
||||
{
|
||||
|
||||
# extract workorder data
|
||||
my $WorkOrder = $DirectionList->{$WorkOrderID};
|
||||
|
||||
# define item data
|
||||
my %Item = (
|
||||
Type => 'Link',
|
||||
Content => 'WO:' . $WorkOrder->{ChangeData}->{ChangeNumber} . '-'
|
||||
. $WorkOrder->{WorkOrderNumber},
|
||||
Title => $Self->{ChangeHook} . $WorkOrder->{ChangeData}->{ChangeNumber} . '-'
|
||||
. $Self->{WorkOrderHook}
|
||||
. $WorkOrder->{WorkOrderNumber} . ': '
|
||||
. $WorkOrder->{WorkOrderTitle},
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMWorkOrderZoom;WorkOrderID='
|
||||
. $WorkOrderID,
|
||||
MaxLength => 20,
|
||||
);
|
||||
|
||||
push @ItemList, \%Item;
|
||||
}
|
||||
|
||||
# add item list to link output data
|
||||
$LinkOutputData{ $LinkType . '::' . $Direction }->{ITSMWorkOrder} = \@ItemList;
|
||||
}
|
||||
}
|
||||
|
||||
return %LinkOutputData;
|
||||
}
|
||||
|
||||
=head2 ContentStringCreate()
|
||||
|
||||
return a output string
|
||||
|
||||
my $String = $LayoutObject->ContentStringCreate(
|
||||
ContentData => $HashRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub ContentStringCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ContentData} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ContentData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# extract content
|
||||
my $Content = $Param{ContentData};
|
||||
|
||||
return if $Content->{Type} ne 'WorkOrderStateSignal';
|
||||
|
||||
# build html for signal LED
|
||||
my $String = $Self->{LayoutObject}->Output(
|
||||
Template => '<div class="Flag Small" title="[% Data.WorkOrderState | html %]"> '
|
||||
. '<span class="[% Data.WorkOrderStateSignal | html %]"></span> </div>',
|
||||
Data => {
|
||||
WorkOrderStateSignal => $Content->{Content},
|
||||
WorkOrderState => $Content->{WorkOrderState} || '',
|
||||
},
|
||||
);
|
||||
|
||||
return $String;
|
||||
}
|
||||
|
||||
=head2 SelectableObjectList()
|
||||
|
||||
return an array hash with C<selectable> objects
|
||||
|
||||
Return
|
||||
|
||||
@SelectableObjectList = (
|
||||
{
|
||||
Key => 'ITSMWorkOrder',
|
||||
Value => 'WorkOrder',
|
||||
},
|
||||
);
|
||||
|
||||
@SelectableObjectList = $LinkObject->SelectableObjectList(
|
||||
Selected => $Identifier, # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SelectableObjectList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Selected;
|
||||
if ( $Param{Selected} && $Param{Selected} eq $Self->{ObjectData}->{Object} ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
|
||||
# object select list
|
||||
my @ObjectSelectList = (
|
||||
{
|
||||
Key => $Self->{ObjectData}->{Object},
|
||||
Value => $Self->{ObjectData}->{Realname},
|
||||
Selected => $Selected,
|
||||
},
|
||||
);
|
||||
|
||||
return @ObjectSelectList;
|
||||
}
|
||||
|
||||
=head2 SearchOptionList()
|
||||
|
||||
return an array hash with search options
|
||||
|
||||
Return
|
||||
|
||||
@SearchOptionList = (
|
||||
{
|
||||
Key => 'ChangeNumber',
|
||||
Name => 'Change#',
|
||||
InputStrg => $FormString,
|
||||
FormData => '2009100112354321',
|
||||
},
|
||||
{
|
||||
Key => 'ChangeTitle',
|
||||
Name => 'Change Title',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'Mail server needs update',
|
||||
},
|
||||
{
|
||||
Key => 'WorkOrderNumber',
|
||||
Name => 'Workorder#',
|
||||
InputStrg => $FormString,
|
||||
FormData => '12',
|
||||
},
|
||||
{
|
||||
Key => 'WorkOrderTitle',
|
||||
Name => 'WorkOrder Title',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'Shutdown old mail server',
|
||||
},
|
||||
);
|
||||
|
||||
@SearchOptionList = $LinkObject->SearchOptionList();
|
||||
|
||||
=cut
|
||||
|
||||
sub SearchOptionList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# search option list
|
||||
my @SearchOptionList = (
|
||||
{
|
||||
Key => 'ChangeNumber',
|
||||
Name => $Self->{ChangeHook},
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'ChangeTitle',
|
||||
Name => 'ChangeTitle',
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'WorkOrderNumber',
|
||||
Name => $Self->{WorkOrderHook},
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'WorkOrderTitle',
|
||||
Name => 'WorkOrderTitle',
|
||||
Type => 'Text',
|
||||
},
|
||||
);
|
||||
|
||||
# add formkey
|
||||
for my $Row (@SearchOptionList) {
|
||||
$Row->{FormKey} = 'SEARCH::' . $Row->{Key};
|
||||
}
|
||||
|
||||
# add form data and input string
|
||||
ROW:
|
||||
for my $Row (@SearchOptionList) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam(
|
||||
Param => $Row->{FormKey},
|
||||
);
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'InputText',
|
||||
Data => {
|
||||
Key => $Row->{FormKey},
|
||||
Value => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
|
||||
return @SearchOptionList;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
687
Perl OTRS/Kernel/Output/HTML/LinkObject/Service.pm
Normal file
687
Perl OTRS/Kernel/Output/HTML/LinkObject/Service.pm
Normal file
@@ -0,0 +1,687 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::Output::HTML::LinkObject::Service;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
use Kernel::Output::HTML::Layout;
|
||||
use Kernel::System::VariableCheck qw(:all);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Language',
|
||||
'Kernel::System::JSON',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::User',
|
||||
'Kernel::System::Web::Request',
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::Output::HTML::LinkObject::Service - layout backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All layout functions of link object (service)
|
||||
|
||||
=cut
|
||||
|
||||
=head2 new()
|
||||
|
||||
create an object
|
||||
|
||||
$BackendObject = Kernel::Output::HTML::LinkObject::Service->new(
|
||||
UserLanguage => 'en',
|
||||
UserID => 1,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# check needed objects
|
||||
for my $Needed (qw(UserLanguage UserID)) {
|
||||
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
|
||||
}
|
||||
|
||||
# we need our own LayoutObject instance to avoid blockdata collisions
|
||||
# with the main page.
|
||||
$Self->{LayoutObject} = Kernel::Output::HTML::Layout->new( %{$Self} );
|
||||
|
||||
# define needed variables
|
||||
$Self->{ObjectData} = {
|
||||
Object => 'Service',
|
||||
Realname => 'Service',
|
||||
ObjectName => 'SourceObjectID',
|
||||
};
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
=head2 TableCreateComplex()
|
||||
|
||||
return an array with the block data
|
||||
|
||||
Return
|
||||
|
||||
@BlockData = (
|
||||
|
||||
ObjectName => 'ServiceID',
|
||||
ObjectID => '123',
|
||||
|
||||
Object => 'Service',
|
||||
Blockname => 'Service',
|
||||
Headline => [
|
||||
{
|
||||
Content => '',
|
||||
Width => 20,
|
||||
},
|
||||
{
|
||||
Content => 'Service',
|
||||
},
|
||||
{
|
||||
Content => 'Type',
|
||||
Width => 100,
|
||||
},
|
||||
{
|
||||
Content => 'Criticality',
|
||||
Width => 100,
|
||||
},
|
||||
{
|
||||
Content => 'Changed',
|
||||
Width => 150,
|
||||
},
|
||||
],
|
||||
ItemList => [
|
||||
[
|
||||
{
|
||||
Type => 'InciSignal',
|
||||
Key => 123,
|
||||
Content => 'Operational',
|
||||
CurInciStateType => 'Operational',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'Service Bla',
|
||||
Link => 'Action=AgentITSMServiceZoom;ServiceID=123',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Other',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'High',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
Type => 'InciSignal',
|
||||
Key => 321,
|
||||
Content => 'Operational',
|
||||
CurInciStateType => 'Operational',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'Service Bla',
|
||||
Link => 'Action=AgentITSMServiceZoom;ServiceID=321',
|
||||
MaxLength => 70,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Other',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'Low',
|
||||
Translate => 1,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2007-02-02 22:12:00',
|
||||
},
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
@BlockData = $LinkObject->TableCreateComplex(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateComplex {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# convert the list
|
||||
my %LinkList;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
for my $ServiceID ( sort keys %{$DirectionList} ) {
|
||||
|
||||
$LinkList{$ServiceID}->{Data} = $DirectionList->{$ServiceID};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
my $ComplexTableData = $ConfigObject->Get("LinkObject::ComplexTable");
|
||||
my $DefaultColumns;
|
||||
if (
|
||||
$ComplexTableData
|
||||
&& IsHashRefWithData($ComplexTableData)
|
||||
&& $ComplexTableData->{Service}
|
||||
&& IsHashRefWithData( $ComplexTableData->{Service} )
|
||||
)
|
||||
{
|
||||
$DefaultColumns = $ComplexTableData->{"Service"}->{"DefaultColumns"};
|
||||
}
|
||||
|
||||
my @TimeLongTypes = (
|
||||
'CreateTime',
|
||||
'ChangeTime',
|
||||
);
|
||||
|
||||
my @TranslateTypes = (
|
||||
'Type',
|
||||
'Criticality',
|
||||
);
|
||||
|
||||
# always show the incident state flag and the service name
|
||||
my @Headline = (
|
||||
{
|
||||
Content => 'Incident State',
|
||||
},
|
||||
{
|
||||
Content => 'Service',
|
||||
},
|
||||
);
|
||||
|
||||
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
|
||||
|
||||
# Load user preferences.
|
||||
my %Preferences = $UserObject->GetPreferences(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
if ( !$DefaultColumns || !IsHashRefWithData($DefaultColumns) ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Missing configuration for LinkObject::ComplexTable###Service!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Get default column priority from SysConfig.
|
||||
# Each column in table (Title, State,...) has defined Priority in SysConfig. System use this
|
||||
# priority to sort columns, if user doesn't have own settings.
|
||||
my %SortOrder;
|
||||
if (
|
||||
$ComplexTableData->{"Service"}->{"Priority"}
|
||||
&& IsHashRefWithData( $ComplexTableData->{"Service"}->{"Priority"} )
|
||||
)
|
||||
{
|
||||
%SortOrder = %{ $ComplexTableData->{"Service"}->{"Priority"} };
|
||||
}
|
||||
|
||||
my %UserColumns = %{$DefaultColumns};
|
||||
|
||||
if ( $Preferences{'LinkObject::ComplexTable-Service'} ) {
|
||||
|
||||
my $ColumnsEnabled = $Kernel::OM->Get('Kernel::System::JSON')->Decode(
|
||||
Data => $Preferences{'LinkObject::ComplexTable-Service'},
|
||||
);
|
||||
|
||||
if (
|
||||
$ColumnsEnabled
|
||||
&& IsHashRefWithData($ColumnsEnabled)
|
||||
&& $ColumnsEnabled->{Order}
|
||||
&& IsArrayRefWithData( $ColumnsEnabled->{Order} )
|
||||
)
|
||||
{
|
||||
# Clear sort order.
|
||||
%SortOrder = ();
|
||||
|
||||
DEFAULTCOLUMN:
|
||||
for my $DefaultColumn ( sort keys %UserColumns ) {
|
||||
my $Index = 0;
|
||||
|
||||
for my $UserSetting ( @{ $ColumnsEnabled->{Order} } ) {
|
||||
$Index++;
|
||||
if ( $DefaultColumn eq $UserSetting ) {
|
||||
$UserColumns{$DefaultColumn} = 2;
|
||||
$SortOrder{$DefaultColumn} = $Index;
|
||||
|
||||
next DEFAULTCOLUMN;
|
||||
}
|
||||
}
|
||||
|
||||
# Not found, means user chose to hide this item.
|
||||
if ( $UserColumns{$DefaultColumn} == 2 ) {
|
||||
$UserColumns{$DefaultColumn} = 1;
|
||||
}
|
||||
|
||||
if ( !$SortOrder{$DefaultColumn} ) {
|
||||
$SortOrder{$DefaultColumn} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
# User has no own settings.
|
||||
for my $Column ( sort keys %UserColumns ) {
|
||||
if ( !$SortOrder{$Column} ) {
|
||||
$SortOrder{$Column} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Define Headline columns.
|
||||
my @AllColumns;
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
my $ColumnTranslate = $Column;
|
||||
if ( $Column eq 'CurInciState' ) {
|
||||
$ColumnTranslate = Translatable('Incident State');
|
||||
}
|
||||
elsif ( $Column eq 'CreateTime' ) {
|
||||
$ColumnTranslate = Translatable('Created');
|
||||
}
|
||||
elsif ( $Column eq 'ChangeTime' ) {
|
||||
$ColumnTranslate = Translatable('Changed');
|
||||
}
|
||||
|
||||
push @AllColumns, {
|
||||
ColumnName => $Column,
|
||||
ColumnTranslate => $ColumnTranslate,
|
||||
};
|
||||
|
||||
# if enabled by default.
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
push @Headline, {
|
||||
Content => $ColumnTranslate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# create the item list (table content)
|
||||
my @ItemList;
|
||||
for my $ServiceID (
|
||||
sort { lc $LinkList{$a}{Data}->{Name} cmp lc $LinkList{$b}{Data}->{Name} }
|
||||
keys %LinkList
|
||||
)
|
||||
{
|
||||
|
||||
# extract service data
|
||||
my $Service = $LinkList{$ServiceID}->{Data};
|
||||
|
||||
# CurInciSignal must always be present, as well as service name
|
||||
# (because it contains the master link to the Service).
|
||||
my @ItemColumns = (
|
||||
{
|
||||
Type => 'CurInciSignal',
|
||||
Key => $ServiceID,
|
||||
Content => $Service->{CurInciState},
|
||||
CurInciStateType => $Service->{CurInciStateType},
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => $Service->{Name},
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMServiceZoom;ServiceID='
|
||||
. $ServiceID,
|
||||
Title => "Service: $Service->{Name}",
|
||||
MaxLength => 70,
|
||||
},
|
||||
);
|
||||
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
|
||||
my %Hash;
|
||||
if ( grep { $_ eq $Column } @TimeLongTypes ) {
|
||||
$Hash{'Type'} = 'TimeLong';
|
||||
}
|
||||
else {
|
||||
$Hash{'Type'} = 'Text';
|
||||
}
|
||||
|
||||
if ( $Column eq 'Comment' ) {
|
||||
$Hash{MaxLength} = 30;
|
||||
}
|
||||
|
||||
if ( grep { $_ eq $Column } @TranslateTypes ) {
|
||||
$Hash{'Translate'} = 1;
|
||||
}
|
||||
|
||||
$Hash{'Content'} = $Service->{$Column};
|
||||
|
||||
push @ItemColumns, \%Hash;
|
||||
}
|
||||
}
|
||||
|
||||
push @ItemList, \@ItemColumns;
|
||||
}
|
||||
|
||||
return if !@ItemList;
|
||||
|
||||
# Define the block data.
|
||||
my %Block = (
|
||||
Object => $Self->{ObjectData}->{Object},
|
||||
Blockname => $Self->{ObjectData}->{Object},
|
||||
ObjectName => $Self->{ObjectData}->{ObjectName},
|
||||
ObjectID => $Param{ObjectID},
|
||||
Headline => \@Headline,
|
||||
ItemList => \@ItemList,
|
||||
AllColumns => \@AllColumns,
|
||||
);
|
||||
|
||||
return ( \%Block );
|
||||
|
||||
}
|
||||
|
||||
=head2 TableCreateSimple()
|
||||
|
||||
return a hash with the link output data
|
||||
|
||||
Return
|
||||
|
||||
%LinkOutputData = (
|
||||
Normal::Source => {
|
||||
Service => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'S:The servic[..]',
|
||||
Title => 'Service: The service name',
|
||||
Css => 'style="text-decoration: line-through"',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'S:Name of servic[..]',
|
||||
Title => 'Service: Name of service 2',
|
||||
},
|
||||
],
|
||||
},
|
||||
ParentChild::Target => {
|
||||
Service => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'S:Service nam[..]',
|
||||
Title => 'Service: Service name',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
%LinkOutputData = $LinkObject->TableCreateSimple(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateSimple {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my %LinkOutputData;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
my @ItemList;
|
||||
for my $ServiceID (
|
||||
sort {
|
||||
lc $DirectionList->{$a}->{NameShort} cmp lc $DirectionList->{$b}->{NameShort}
|
||||
} keys %{$DirectionList}
|
||||
)
|
||||
{
|
||||
|
||||
# extract service data
|
||||
my $Service = $DirectionList->{$ServiceID};
|
||||
|
||||
# define item data
|
||||
my %Item = (
|
||||
Type => 'Link',
|
||||
Content => "S:$Service->{NameShort}",
|
||||
Title => "Service: $Service->{Name}",
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentITSMServiceZoom;ServiceID='
|
||||
. $ServiceID,
|
||||
MaxLength => 20,
|
||||
);
|
||||
|
||||
push @ItemList, \%Item;
|
||||
}
|
||||
|
||||
# add item list to link output data
|
||||
$LinkOutputData{ $LinkType . '::' . $Direction }->{Service} = \@ItemList;
|
||||
}
|
||||
}
|
||||
|
||||
return %LinkOutputData;
|
||||
}
|
||||
|
||||
=head2 ContentStringCreate()
|
||||
|
||||
return a output string
|
||||
|
||||
my $String = $LayoutObject->ContentStringCreate(
|
||||
ContentData => $HashRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub ContentStringCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ContentData} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ContentData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# extract content
|
||||
my $Content = $Param{ContentData};
|
||||
|
||||
return if $Content->{Type} ne 'CurInciSignal';
|
||||
|
||||
# set incident signal
|
||||
my %InciSignals = (
|
||||
incident => 'redled',
|
||||
operational => 'greenled',
|
||||
unknown => 'grayled',
|
||||
warning => 'yellowled',
|
||||
);
|
||||
|
||||
# investigate current incident signal
|
||||
$Content->{CurInciStateType} ||= 'unknown';
|
||||
my $CurInciSignal = $InciSignals{ $Content->{CurInciStateType} };
|
||||
$CurInciSignal ||= $InciSignals{unknown};
|
||||
|
||||
my $String = $Self->{LayoutObject}->Output(
|
||||
Template => '<div class="Flag Small" title="[% Data.CurInciState | html %]"> '
|
||||
. '<span class="[% Data.CurInciSignal | html %]"></span> </div>',
|
||||
|
||||
Data => {
|
||||
CurInciSignal => $CurInciSignal,
|
||||
CurInciState => $Content->{Content} || '',
|
||||
},
|
||||
);
|
||||
|
||||
return $String;
|
||||
}
|
||||
|
||||
=head2 SelectableObjectList()
|
||||
|
||||
return an array hash with select-able objects
|
||||
|
||||
Return
|
||||
|
||||
@SelectableObjectList = (
|
||||
{
|
||||
Key => 'Service',
|
||||
Value => 'Service',
|
||||
},
|
||||
);
|
||||
|
||||
@SelectableObjectList = $LinkObject->SelectableObjectList(
|
||||
Selected => $Identifier, # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SelectableObjectList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Selected;
|
||||
if ( $Param{Selected} && $Param{Selected} eq $Self->{ObjectData}->{Object} ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
|
||||
# object select list
|
||||
my @ObjectSelectList = (
|
||||
{
|
||||
Key => $Self->{ObjectData}->{Object},
|
||||
Value => $Self->{ObjectData}->{Realname},
|
||||
Selected => $Selected,
|
||||
},
|
||||
);
|
||||
|
||||
return @ObjectSelectList;
|
||||
}
|
||||
|
||||
=head2 SearchOptionList()
|
||||
|
||||
return an array hash with search options
|
||||
|
||||
Return
|
||||
|
||||
@SearchOptionList = (
|
||||
{
|
||||
Key => 'Name',
|
||||
Name => 'Service',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'Service Name',
|
||||
},
|
||||
);
|
||||
|
||||
@SearchOptionList = $LinkObject->SearchOptionList();
|
||||
|
||||
=cut
|
||||
|
||||
sub SearchOptionList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# search option list
|
||||
my @SearchOptionList = (
|
||||
{
|
||||
Key => 'Name',
|
||||
Name => 'Service',
|
||||
Type => 'Text',
|
||||
},
|
||||
);
|
||||
|
||||
# add formkey
|
||||
for my $Row (@SearchOptionList) {
|
||||
$Row->{FormKey} = 'SEARCH::' . $Row->{Key};
|
||||
}
|
||||
|
||||
# add form data and input string
|
||||
ROW:
|
||||
for my $Row (@SearchOptionList) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Row->{FormKey} );
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'InputText',
|
||||
Data => {
|
||||
Key => $Row->{FormKey},
|
||||
Value => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
|
||||
return @SearchOptionList;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
934
Perl OTRS/Kernel/Output/HTML/LinkObject/Ticket.pm
Normal file
934
Perl OTRS/Kernel/Output/HTML/LinkObject/Ticket.pm
Normal file
@@ -0,0 +1,934 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::Output::HTML::LinkObject::Ticket;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util qw(first);
|
||||
|
||||
use Kernel::Output::HTML::Layout;
|
||||
use Kernel::System::VariableCheck qw(:all);
|
||||
use Kernel::Language qw(Translatable);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Language',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::CustomerCompany',
|
||||
'Kernel::System::CustomerUser',
|
||||
'Kernel::System::DynamicField',
|
||||
'Kernel::System::DynamicField::Backend',
|
||||
'Kernel::System::JSON',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Priority',
|
||||
'Kernel::System::State',
|
||||
'Kernel::System::Type',
|
||||
'Kernel::System::User',
|
||||
'Kernel::System::Web::Request',
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::Output::HTML::LinkObject::Ticket - layout backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All layout functions of link object (ticket).
|
||||
|
||||
|
||||
=head2 new()
|
||||
|
||||
create an object
|
||||
|
||||
$BackendObject = Kernel::Output::HTML::LinkObject::Ticket->new(
|
||||
UserLanguage => 'en',
|
||||
UserID => 1,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# check needed objects
|
||||
for my $Needed (qw(UserLanguage UserID)) {
|
||||
$Self->{$Needed} = $Param{$Needed} || die "Got no $Needed!";
|
||||
}
|
||||
|
||||
# We need our own LayoutObject instance to avoid block data collisions
|
||||
# with the main page.
|
||||
$Self->{LayoutObject} = Kernel::Output::HTML::Layout->new( %{$Self} );
|
||||
|
||||
# define needed variables
|
||||
$Self->{ObjectData} = {
|
||||
Object => 'Ticket',
|
||||
Realname => 'Ticket',
|
||||
ObjectName => 'SourceObjectID',
|
||||
};
|
||||
|
||||
# get the dynamic fields for this screen
|
||||
$Self->{DynamicField} = $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldListGet(
|
||||
Valid => 0,
|
||||
ObjectType => ['Ticket'],
|
||||
);
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
=head2 TableCreateComplex()
|
||||
|
||||
return an array with the block data
|
||||
|
||||
Return
|
||||
|
||||
%BlockData = (
|
||||
{
|
||||
ObjectName => 'TicketID',
|
||||
ObjectID => '14785',
|
||||
|
||||
Object => 'Ticket',
|
||||
Blockname => 'Ticket',
|
||||
Headline => [
|
||||
{
|
||||
Content => 'Number#',
|
||||
Width => 130,
|
||||
},
|
||||
{
|
||||
Content => 'Title',
|
||||
},
|
||||
{
|
||||
Content => 'Created',
|
||||
Width => 110,
|
||||
},
|
||||
],
|
||||
ItemList => [
|
||||
[
|
||||
{
|
||||
Type => 'Link',
|
||||
Key => $TicketID,
|
||||
Content => '123123123',
|
||||
CssClass => 'StrikeThrough',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'The title',
|
||||
MaxLength => 50,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
Type => 'Link',
|
||||
Key => $TicketID,
|
||||
Content => '434234',
|
||||
},
|
||||
{
|
||||
Type => 'Text',
|
||||
Content => 'The title of ticket 2',
|
||||
MaxLength => 50,
|
||||
},
|
||||
{
|
||||
Type => 'TimeLong',
|
||||
Content => '2008-01-01 12:12:00',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
@BlockData = $BackendObject->TableCreateComplex(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateComplex {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# create needed objects
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# convert the list
|
||||
my %LinkList;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
for my $TicketID ( sort keys %{$DirectionList} ) {
|
||||
|
||||
$LinkList{$TicketID}->{Data} = $DirectionList->{$TicketID};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ComplexTableData = $ConfigObject->Get("LinkObject::ComplexTable");
|
||||
my $DefaultColumns;
|
||||
if (
|
||||
$ComplexTableData
|
||||
&& IsHashRefWithData($ComplexTableData)
|
||||
&& $ComplexTableData->{Ticket}
|
||||
&& IsHashRefWithData( $ComplexTableData->{Ticket} )
|
||||
)
|
||||
{
|
||||
$DefaultColumns = $ComplexTableData->{"Ticket"}->{"DefaultColumns"};
|
||||
}
|
||||
|
||||
my @TimeLongTypes = (
|
||||
"Created",
|
||||
"Changed",
|
||||
"EscalationDestinationDate",
|
||||
"FirstResponseTimeDestinationDate",
|
||||
"UpdateTimeDestinationDate",
|
||||
"SolutionTimeDestinationDate",
|
||||
);
|
||||
|
||||
# define the block data
|
||||
my $TicketHook = $ConfigObject->Get('Ticket::Hook');
|
||||
my $TicketHookDivider = $ConfigObject->Get('Ticket::HookDivider');
|
||||
|
||||
my @Headline;
|
||||
|
||||
# Get needed objects.
|
||||
my $UserObject = $Kernel::OM->Get('Kernel::System::User');
|
||||
my $JSONObject = $Kernel::OM->Get('Kernel::System::JSON');
|
||||
my $LanguageObject = $Kernel::OM->Get('Kernel::Language');
|
||||
|
||||
# load user preferences
|
||||
my %Preferences = $UserObject->GetPreferences(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
if ( !$DefaultColumns || !IsHashRefWithData($DefaultColumns) ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Missing configuration for LinkObject::ComplexTable###Ticket!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Get default column priority from SysConfig
|
||||
# Each column in table (Title, State, Type,...) has defined Priority in SysConfig. System use this priority to sort columns, if user doesn't have own settings.
|
||||
my %SortOrder;
|
||||
if (
|
||||
$ComplexTableData->{"Ticket"}->{"Priority"}
|
||||
&& IsHashRefWithData( $ComplexTableData->{"Ticket"}->{"Priority"} )
|
||||
)
|
||||
{
|
||||
%SortOrder = %{ $ComplexTableData->{"Ticket"}->{"Priority"} };
|
||||
}
|
||||
|
||||
my %UserColumns = %{$DefaultColumns};
|
||||
|
||||
if ( $Preferences{'LinkObject::ComplexTable-Ticket'} ) {
|
||||
|
||||
my $ColumnsEnabled = $JSONObject->Decode(
|
||||
Data => $Preferences{'LinkObject::ComplexTable-Ticket'},
|
||||
);
|
||||
|
||||
if (
|
||||
$ColumnsEnabled
|
||||
&& IsHashRefWithData($ColumnsEnabled)
|
||||
&& $ColumnsEnabled->{Order}
|
||||
&& IsArrayRefWithData( $ColumnsEnabled->{Order} )
|
||||
)
|
||||
{
|
||||
# Clear sort order
|
||||
%SortOrder = ();
|
||||
|
||||
DEFAULTCOLUMN:
|
||||
for my $DefaultColumn ( sort keys %UserColumns ) {
|
||||
my $Index = 0;
|
||||
|
||||
for my $UserSetting ( @{ $ColumnsEnabled->{Order} } ) {
|
||||
$Index++;
|
||||
if ( $DefaultColumn eq $UserSetting ) {
|
||||
$UserColumns{$DefaultColumn} = 2;
|
||||
$SortOrder{$DefaultColumn} = $Index;
|
||||
|
||||
next DEFAULTCOLUMN;
|
||||
}
|
||||
}
|
||||
|
||||
# not found, means user chose to hide this item
|
||||
if ( $UserColumns{$DefaultColumn} == 2 ) {
|
||||
$UserColumns{$DefaultColumn} = 1;
|
||||
}
|
||||
|
||||
if ( !$SortOrder{$DefaultColumn} ) {
|
||||
$SortOrder{$DefaultColumn} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
# user has no own settings
|
||||
for my $Column ( sort keys %UserColumns ) {
|
||||
if ( !$SortOrder{$Column} ) {
|
||||
$SortOrder{$Column} = 0; # Set 0, it system will hide this item anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Define Headline columns
|
||||
|
||||
# Sort
|
||||
my @AllColumns;
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
my $ColumnTranslate = $Column;
|
||||
if ( $Column eq 'EscalationTime' ) {
|
||||
$ColumnTranslate = Translatable('Service Time');
|
||||
}
|
||||
elsif ( $Column eq 'EscalationResponseTime' ) {
|
||||
$ColumnTranslate = Translatable('First Response Time');
|
||||
}
|
||||
elsif ( $Column eq 'EscalationSolutionTime' ) {
|
||||
$ColumnTranslate = Translatable('Solution Time');
|
||||
}
|
||||
elsif ( $Column eq 'EscalationUpdateTime' ) {
|
||||
$ColumnTranslate = Translatable('Update Time');
|
||||
}
|
||||
elsif ( $Column eq 'PendingTime' ) {
|
||||
$ColumnTranslate = Translatable('Pending till');
|
||||
}
|
||||
elsif ( $Column eq 'CustomerCompanyName' ) {
|
||||
$ColumnTranslate = Translatable('Customer Name');
|
||||
}
|
||||
elsif ( $Column eq 'CustomerID' ) {
|
||||
$ColumnTranslate = Translatable('Customer ID');
|
||||
}
|
||||
elsif ( $Column eq 'CustomerName' ) {
|
||||
$ColumnTranslate = Translatable('Customer User Name');
|
||||
}
|
||||
elsif ( $Column eq 'CustomerUserID' ) {
|
||||
$ColumnTranslate = Translatable('Customer User ID');
|
||||
}
|
||||
elsif ( $Column =~ m{ \A DynamicField_ }xms ) {
|
||||
my $DynamicFieldConfig;
|
||||
|
||||
DYNAMICFIELD:
|
||||
for my $DFConfig ( @{ $Self->{DynamicField} } ) {
|
||||
next DYNAMICFIELD if !IsHashRefWithData($DFConfig);
|
||||
next DYNAMICFIELD if 'DynamicField_' . $DFConfig->{Name} ne $Column;
|
||||
|
||||
$DynamicFieldConfig = $DFConfig;
|
||||
last DYNAMICFIELD;
|
||||
}
|
||||
next COLUMN if !IsHashRefWithData($DynamicFieldConfig);
|
||||
|
||||
$ColumnTranslate = $DynamicFieldConfig->{Label};
|
||||
}
|
||||
|
||||
push @AllColumns, {
|
||||
ColumnName => $Column,
|
||||
ColumnTranslate => $ColumnTranslate,
|
||||
};
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
my $ColumnName = '';
|
||||
|
||||
# Ticket fields
|
||||
if ( $Column !~ m{\A DynamicField_}xms ) {
|
||||
$ColumnName = $Column eq 'TicketNumber' ? $TicketHook : $ColumnTranslate;
|
||||
}
|
||||
|
||||
# Dynamic fields (get label from the translated column).
|
||||
else {
|
||||
$ColumnName = $ColumnTranslate;
|
||||
}
|
||||
|
||||
push @Headline, {
|
||||
Content => $ColumnName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
# create the item list (table content)
|
||||
my @ItemList;
|
||||
for my $TicketID (
|
||||
sort { $LinkList{$a}{Data}->{Age} <=> $LinkList{$b}{Data}->{Age} }
|
||||
keys %LinkList
|
||||
)
|
||||
{
|
||||
|
||||
# extract ticket data
|
||||
my $Ticket = $LinkList{$TicketID}{Data};
|
||||
|
||||
# set css
|
||||
my $CssClass;
|
||||
my @StatesToStrike = @{ $ConfigObject->Get('LinkObject::StrikeThroughLinkedTicketStateTypes') || [] };
|
||||
if ( first { $Ticket->{StateType} eq $_ } @StatesToStrike ) {
|
||||
$CssClass = 'StrikeThrough';
|
||||
}
|
||||
|
||||
my @ItemColumns;
|
||||
|
||||
# Sort
|
||||
COLUMN:
|
||||
for my $Column ( sort { $SortOrder{$a} <=> $SortOrder{$b} } keys %UserColumns ) {
|
||||
|
||||
# if enabled by default
|
||||
if ( $UserColumns{$Column} == 2 ) {
|
||||
|
||||
my %Hash;
|
||||
if ( grep { $_ eq $Column } @TimeLongTypes ) {
|
||||
$Hash{'Type'} = 'TimeLong';
|
||||
}
|
||||
else {
|
||||
$Hash{'Type'} = 'Text';
|
||||
}
|
||||
|
||||
if ( $Column eq 'Title' ) {
|
||||
$Hash{MaxLength} = $Kernel::OM->Get('Kernel::Config')->Get('Ticket::SubjectSize') || 50;
|
||||
}
|
||||
|
||||
# Ticket fields
|
||||
if ( $Column !~ m{\A DynamicField_}xms ) {
|
||||
|
||||
if ( $Column eq 'TicketNumber' ) {
|
||||
|
||||
%Hash = (
|
||||
Type => 'Link',
|
||||
Key => $TicketID,
|
||||
Content => $Ticket->{TicketNumber},
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentTicketZoom;TicketID='
|
||||
. $TicketID,
|
||||
Title => "$TicketHook$TicketHookDivider$Ticket->{TicketNumber}",
|
||||
CssClass => $CssClass,
|
||||
);
|
||||
}
|
||||
elsif ( $Column eq 'EscalationTime' ) {
|
||||
|
||||
$Hash{'Content'} = $Self->{LayoutObject}->CustomerAge(
|
||||
Age => $Ticket->{'EscalationTime'},
|
||||
Space => ' '
|
||||
);
|
||||
}
|
||||
elsif ( $Column eq 'Age' ) {
|
||||
$Hash{'Content'} = $Self->{LayoutObject}->CustomerAge(
|
||||
Age => $Ticket->{Age},
|
||||
Space => ' ',
|
||||
);
|
||||
}
|
||||
elsif ( $Column eq 'EscalationSolutionTime' ) {
|
||||
|
||||
$Hash{'Content'} = $Self->{LayoutObject}->CustomerAge(
|
||||
Age => $Ticket->{SolutionTime} || 0,
|
||||
TimeShowAlwaysLong => 1,
|
||||
Space => ' ',
|
||||
);
|
||||
}
|
||||
elsif ( $Column eq 'EscalationResponseTime' ) {
|
||||
|
||||
$Hash{'Content'} = $Self->{LayoutObject}->CustomerAge(
|
||||
Age => $Ticket->{FirstResponseTime} || 0,
|
||||
TimeShowAlwaysLong => 1,
|
||||
Space => ' ',
|
||||
);
|
||||
}
|
||||
elsif ( $Column eq 'EscalationUpdateTime' ) {
|
||||
$Hash{'Content'} = $Self->{LayoutObject}->CustomerAge(
|
||||
Age => $Ticket->{UpdateTime} || 0,
|
||||
TimeShowAlwaysLong => 1,
|
||||
Space => ' ',
|
||||
);
|
||||
}
|
||||
elsif ( $Column eq 'PendingTime' ) {
|
||||
$Hash{'Content'} = $Self->{LayoutObject}->CustomerAge(
|
||||
Age => $Ticket->{'UntilTime'},
|
||||
Space => ' '
|
||||
);
|
||||
}
|
||||
elsif ( $Column eq 'Owner' ) {
|
||||
|
||||
# get owner info
|
||||
my %OwnerInfo = $Kernel::OM->Get('Kernel::System::User')->GetUserData(
|
||||
UserID => $Ticket->{OwnerID},
|
||||
);
|
||||
$Hash{'Content'} = $OwnerInfo{'UserFullname'};
|
||||
}
|
||||
elsif ( $Column eq 'Responsible' ) {
|
||||
|
||||
# get responsible info
|
||||
my %ResponsibleInfo = $Kernel::OM->Get('Kernel::System::User')->GetUserData(
|
||||
UserID => $Ticket->{ResponsibleID},
|
||||
);
|
||||
$Hash{'Content'} = $ResponsibleInfo{'UserFullname'};
|
||||
}
|
||||
elsif ( $Column eq 'CustomerName' ) {
|
||||
|
||||
# get customer name
|
||||
my $CustomerName;
|
||||
if ( $Ticket->{CustomerUserID} ) {
|
||||
$CustomerName = $Kernel::OM->Get('Kernel::System::CustomerUser')->CustomerName(
|
||||
UserLogin => $Ticket->{CustomerUserID},
|
||||
);
|
||||
}
|
||||
$Hash{'Content'} = $CustomerName;
|
||||
}
|
||||
elsif ( $Column eq 'CustomerCompanyName' ) {
|
||||
my %CustomerCompany = $Kernel::OM->Get('Kernel::System::CustomerCompany')->CustomerCompanyGet(
|
||||
CustomerID => $Ticket->{CustomerID},
|
||||
);
|
||||
$Hash{'Content'} = $CustomerCompany{CustomerCompanyName};
|
||||
}
|
||||
elsif ( $Column eq 'State' || $Column eq 'Priority' || $Column eq 'Lock' ) {
|
||||
$Hash{'Content'} = $LanguageObject->Translate( $Ticket->{$Column} );
|
||||
}
|
||||
else {
|
||||
$Hash{'Content'} = $Ticket->{$Column};
|
||||
}
|
||||
}
|
||||
|
||||
# Dynamic fields
|
||||
else {
|
||||
my $DynamicFieldConfig;
|
||||
my $DFColumn = $Column;
|
||||
$DFColumn =~ s{DynamicField_}{}g;
|
||||
|
||||
DYNAMICFIELD:
|
||||
for my $DFConfig ( @{ $Self->{DynamicField} } ) {
|
||||
next DYNAMICFIELD if !IsHashRefWithData($DFConfig);
|
||||
next DYNAMICFIELD if $DFConfig->{Name} ne $DFColumn;
|
||||
|
||||
$DynamicFieldConfig = $DFConfig;
|
||||
last DYNAMICFIELD;
|
||||
}
|
||||
next COLUMN if !IsHashRefWithData($DynamicFieldConfig);
|
||||
|
||||
# get field value
|
||||
my $Value = $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->ValueGet(
|
||||
DynamicFieldConfig => $DynamicFieldConfig,
|
||||
ObjectID => $TicketID,
|
||||
);
|
||||
|
||||
my $ValueStrg = $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->DisplayValueRender(
|
||||
DynamicFieldConfig => $DynamicFieldConfig,
|
||||
Value => $Value,
|
||||
ValueMaxChars => 20,
|
||||
LayoutObject => $Self->{LayoutObject},
|
||||
);
|
||||
|
||||
$Hash{'Content'} = $ValueStrg->{Title};
|
||||
}
|
||||
|
||||
push @ItemColumns, \%Hash;
|
||||
}
|
||||
}
|
||||
|
||||
push @ItemList, \@ItemColumns;
|
||||
}
|
||||
|
||||
return if !@ItemList;
|
||||
|
||||
my %Block = (
|
||||
Object => $Self->{ObjectData}->{Object},
|
||||
Blockname => $Self->{ObjectData}->{Realname},
|
||||
ObjectName => $Self->{ObjectData}->{ObjectName},
|
||||
ObjectID => $Param{ObjectID},
|
||||
Headline => \@Headline,
|
||||
ItemList => \@ItemList,
|
||||
AllColumns => \@AllColumns,
|
||||
);
|
||||
|
||||
return ( \%Block );
|
||||
}
|
||||
|
||||
=head2 TableCreateSimple()
|
||||
|
||||
return a hash with the link output data
|
||||
|
||||
Return
|
||||
|
||||
%LinkOutputData = (
|
||||
Normal::Source => {
|
||||
Ticket => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'T:55555',
|
||||
Title => 'Ticket#555555: The ticket title',
|
||||
CssClass => 'StrikeThrough',
|
||||
},
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'T:22222',
|
||||
Title => 'Ticket#22222: Title of ticket 22222',
|
||||
},
|
||||
],
|
||||
},
|
||||
ParentChild::Target => {
|
||||
Ticket => [
|
||||
{
|
||||
Type => 'Link',
|
||||
Content => 'T:77777',
|
||||
Title => 'Ticket#77777: Ticket title',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
%LinkOutputData = $BackendObject->TableCreateSimple(
|
||||
ObjectLinkListWithData => $ObjectLinkListRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub TableCreateSimple {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ObjectLinkListWithData} || ref $Param{ObjectLinkListWithData} ne 'HASH' ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ObjectLinkListWithData!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
my $TicketHook = $ConfigObject->Get('Ticket::Hook');
|
||||
my $TicketHookDivider = $ConfigObject->Get('Ticket::HookDivider');
|
||||
|
||||
my %LinkOutputData;
|
||||
for my $LinkType ( sort keys %{ $Param{ObjectLinkListWithData} } ) {
|
||||
|
||||
# extract link type List
|
||||
my $LinkTypeList = $Param{ObjectLinkListWithData}->{$LinkType};
|
||||
|
||||
for my $Direction ( sort keys %{$LinkTypeList} ) {
|
||||
|
||||
# extract direction list
|
||||
my $DirectionList = $Param{ObjectLinkListWithData}->{$LinkType}->{$Direction};
|
||||
|
||||
my @ItemList;
|
||||
for my $TicketID ( sort { $a <=> $b } keys %{$DirectionList} ) {
|
||||
|
||||
# extract ticket data
|
||||
my $Ticket = $DirectionList->{$TicketID};
|
||||
|
||||
# set css
|
||||
my $CssClass;
|
||||
my @StatesToStrike = @{ $ConfigObject->Get('LinkObject::StrikeThroughLinkedTicketStateTypes') || [] };
|
||||
|
||||
if ( first { $Ticket->{StateType} eq $_ } @StatesToStrike ) {
|
||||
$CssClass = 'StrikeThrough';
|
||||
}
|
||||
|
||||
# define item data
|
||||
my %Item = (
|
||||
Type => 'Link',
|
||||
Content => 'T:' . $Ticket->{TicketNumber},
|
||||
Title => "$TicketHook$TicketHookDivider$Ticket->{TicketNumber}: $Ticket->{Title}",
|
||||
Link => $Self->{LayoutObject}->{Baselink}
|
||||
. 'Action=AgentTicketZoom;TicketID='
|
||||
. $TicketID,
|
||||
CssClass => $CssClass,
|
||||
);
|
||||
|
||||
push @ItemList, \%Item;
|
||||
}
|
||||
|
||||
# add item list to link output data
|
||||
$LinkOutputData{ $LinkType . '::' . $Direction }->{Ticket} = \@ItemList;
|
||||
}
|
||||
}
|
||||
|
||||
return %LinkOutputData;
|
||||
}
|
||||
|
||||
=head2 ContentStringCreate()
|
||||
|
||||
return a output string
|
||||
|
||||
my $String = $BackendObject->ContentStringCreate(
|
||||
ContentData => $HashRef,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub ContentStringCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ContentData} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ContentData!'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
=head2 SelectableObjectList()
|
||||
|
||||
return an array hash with select-able objects
|
||||
|
||||
Return
|
||||
|
||||
@SelectableObjectList = (
|
||||
{
|
||||
Key => 'Ticket',
|
||||
Value => 'Ticket',
|
||||
},
|
||||
);
|
||||
|
||||
@SelectableObjectList = $BackendObject->SelectableObjectList(
|
||||
Selected => $Identifier, # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SelectableObjectList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Selected;
|
||||
if ( $Param{Selected} && $Param{Selected} eq $Self->{ObjectData}->{Object} ) {
|
||||
$Selected = 1;
|
||||
}
|
||||
|
||||
# object select list
|
||||
my @ObjectSelectList = (
|
||||
{
|
||||
Key => $Self->{ObjectData}->{Object},
|
||||
Value => $Self->{ObjectData}->{Realname},
|
||||
Selected => $Selected,
|
||||
},
|
||||
);
|
||||
|
||||
return @ObjectSelectList;
|
||||
}
|
||||
|
||||
=head2 SearchOptionList()
|
||||
|
||||
return an array hash with search options
|
||||
|
||||
Return
|
||||
|
||||
@SearchOptionList = (
|
||||
{
|
||||
Key => 'TicketNumber',
|
||||
Name => 'Ticket#',
|
||||
InputStrg => $FormString,
|
||||
FormData => '1234',
|
||||
},
|
||||
{
|
||||
Key => 'Title',
|
||||
Name => 'Title',
|
||||
InputStrg => $FormString,
|
||||
FormData => 'BlaBla',
|
||||
},
|
||||
);
|
||||
|
||||
@SearchOptionList = $BackendObject->SearchOptionList(
|
||||
SubObject => 'Bla', # (optional)
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub SearchOptionList {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $ParamHook = $Kernel::OM->Get('Kernel::Config')->Get('Ticket::Hook') || 'Ticket#';
|
||||
|
||||
# search option list
|
||||
my @SearchOptionList = (
|
||||
{
|
||||
Key => 'TicketNumber',
|
||||
Name => $ParamHook,
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'TicketTitle',
|
||||
Name => Translatable('Title'),
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'TicketFulltext',
|
||||
Name => Translatable('Fulltext'),
|
||||
Type => 'Text',
|
||||
},
|
||||
{
|
||||
Key => 'StateIDs',
|
||||
Name => Translatable('State'),
|
||||
Type => 'List',
|
||||
},
|
||||
{
|
||||
Key => 'PriorityIDs',
|
||||
Name => Translatable('Priority'),
|
||||
Type => 'List',
|
||||
},
|
||||
);
|
||||
|
||||
if ( $Kernel::OM->Get('Kernel::Config')->Get('Ticket::Type') ) {
|
||||
push @SearchOptionList,
|
||||
{
|
||||
Key => 'TypeIDs',
|
||||
Name => Translatable('Type'),
|
||||
Type => 'List',
|
||||
};
|
||||
}
|
||||
|
||||
if ( $Kernel::OM->Get('Kernel::Config')->Get('Ticket::ArchiveSystem') ) {
|
||||
push @SearchOptionList,
|
||||
{
|
||||
Key => 'ArchiveID',
|
||||
Name => Translatable('Archive search'),
|
||||
Type => 'List',
|
||||
};
|
||||
}
|
||||
|
||||
# add formkey
|
||||
for my $Row (@SearchOptionList) {
|
||||
$Row->{FormKey} = 'SEARCH::' . $Row->{Key};
|
||||
}
|
||||
|
||||
# add form data and input string
|
||||
ROW:
|
||||
for my $Row (@SearchOptionList) {
|
||||
|
||||
# prepare text input fields
|
||||
if ( $Row->{Type} eq 'Text' ) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Row->{FormKey} );
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'InputText',
|
||||
Data => {
|
||||
Key => $Row->{FormKey},
|
||||
Value => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
|
||||
# prepare list boxes
|
||||
if ( $Row->{Type} eq 'List' ) {
|
||||
|
||||
# get form data
|
||||
my @FormData = $Kernel::OM->Get('Kernel::System::Web::Request')->GetArray( Param => $Row->{FormKey} );
|
||||
$Row->{FormData} = \@FormData;
|
||||
|
||||
my $Multiple = 1;
|
||||
|
||||
my %ListData;
|
||||
if ( $Row->{Key} eq 'StateIDs' ) {
|
||||
%ListData = $Kernel::OM->Get('Kernel::System::State')->StateList(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
}
|
||||
elsif ( $Row->{Key} eq 'PriorityIDs' ) {
|
||||
%ListData = $Kernel::OM->Get('Kernel::System::Priority')->PriorityList(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
}
|
||||
elsif ( $Row->{Key} eq 'TypeIDs' ) {
|
||||
%ListData = $Kernel::OM->Get('Kernel::System::Type')->TypeList(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
}
|
||||
elsif ( $Row->{Key} eq 'ArchiveID' ) {
|
||||
%ListData = (
|
||||
ArchivedTickets => Translatable('Archived tickets'),
|
||||
NotArchivedTickets => Translatable('Unarchived tickets'),
|
||||
AllTickets => Translatable('All tickets'),
|
||||
);
|
||||
if ( !scalar @{ $Row->{FormData} } ) {
|
||||
$Row->{FormData} = ['NotArchivedTickets'];
|
||||
}
|
||||
$Multiple = 0;
|
||||
}
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->BuildSelection(
|
||||
Data => \%ListData,
|
||||
Name => $Row->{FormKey},
|
||||
SelectedID => $Row->{FormData},
|
||||
Size => 3,
|
||||
Multiple => $Multiple,
|
||||
Class => 'Modernize',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
|
||||
if ( $Row->{Type} eq 'Checkbox' ) {
|
||||
|
||||
# get form data
|
||||
$Row->{FormData} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Row->{FormKey} );
|
||||
|
||||
# parse the input text block
|
||||
$Self->{LayoutObject}->Block(
|
||||
Name => 'Checkbox',
|
||||
Data => {
|
||||
Name => $Row->{FormKey},
|
||||
Title => $Row->{FormKey},
|
||||
Content => $Row->{FormKey},
|
||||
Checked => $Row->{FormData} || '',
|
||||
},
|
||||
);
|
||||
|
||||
# add the input string
|
||||
$Row->{InputStrg} = $Self->{LayoutObject}->Output(
|
||||
TemplateFile => 'LinkObject',
|
||||
);
|
||||
|
||||
next ROW;
|
||||
}
|
||||
}
|
||||
|
||||
return @SearchOptionList;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user