This commit is contained in:
2024-10-14 00:08:40 +02:00
parent dbfba56f66
commit 1462d52e13
4572 changed files with 2658864 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
# --
# 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::CustomerUser::Generic;
use parent 'Kernel::Output::HTML::Base';
use strict;
use warnings;
our $ObjectManagerDisabled = 1;
sub Run {
my ( $Self, %Param ) = @_;
# check required params
my @Params = split /;/, $Param{Config}->{Required};
for my $Key (@Params) {
return if !$Key;
return if !$Param{Data}->{$Key};
}
# get all attributes
@Params = split /;/, $Param{Config}->{Attributes};
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# build url
my $URL = '';
KEY:
for my $Key (@Params) {
next KEY if !$Param{Data}->{$Key};
if ($URL) {
$URL .= ', ';
}
$URL .= $LayoutObject->LinkEncode( $Param{Data}->{$Key} );
}
$URL = $Param{Config}->{URL} . $URL;
my $IconName = $Param{Config}->{IconName};
# generate block
$LayoutObject->Block(
Name => 'CustomerItemRow',
Data => {
%{ $Param{Config} },
URL => $URL,
IconName => $IconName,
},
);
return 1;
}
1;

View File

@@ -0,0 +1,320 @@
# --
# 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::CustomerUser::GenericTicket;
use parent 'Kernel::Output::HTML::Base';
use strict;
use warnings;
use Kernel::System::VariableCheck qw(IsArrayRefWithData);
our $ObjectManagerDisabled = 1;
sub Run {
my ( $Self, %Param ) = @_;
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# don't show ticket search links in the print views
if ( $LayoutObject->{Action} =~ m{Print$}smx ) {
return;
}
# lookup map
my %Lookup = (
Types => {
Object => 'Kernel::System::Type',
Return => 'TypeIDs',
Input => 'Type',
Method => 'TypeLookup',
},
Queues => {
Object => 'Kernel::System::Queue',
Return => 'QueueIDs',
Input => 'Queue',
Method => 'QueueLookup',
},
States => {
Object => 'Kernel::System::State',
Return => 'StateIDs',
Input => 'State',
Method => 'StateLookup',
},
Priorities => {
Object => 'Kernel::System::Priority',
Return => 'PriorityIDs',
Input => 'Priority',
Method => 'PriorityLookup',
},
Locks => {
Object => 'Kernel::System::Lock',
Return => 'LockIDs',
Input => 'Lock',
Method => 'LockLookup',
},
Services => {
Object => 'Kernel::System::Service',
Return => 'ServiceIDs',
Input => 'Name',
Method => 'ServiceLookup',
},
SLAs => {
Object => 'Kernel::System::SLA',
Return => 'SLAIDs',
Input => 'Name',
Method => 'SLALookup',
},
);
# get all attributes
my %TicketSearch = ();
my @Params = split /;/, $Param{Config}->{Attributes};
STRING:
for my $String (@Params) {
next STRING if !$String;
my ( $Key, $Value ) = split /=/, $String;
# do lookups
if ( $Lookup{$Key} ) {
next STRING if !$Kernel::OM->Get('Kernel::System::Main')->Require( $Lookup{$Key}->{Object} );
my $Object = $Lookup{$Key}->{Object}->new( %{$Self} );
my $Method = $Lookup{$Key}->{Method};
$Value = $Object->$Method( $Lookup{$Key}->{Input} => $Value );
$Key = $Lookup{$Key}->{Return};
}
# build link and search attributes
if ( $Key =~ /IDs$/ ) {
if ( !$TicketSearch{$Key} ) {
$TicketSearch{$Key} = [$Value];
}
else {
push @{ $TicketSearch{$Key} }, $Value;
}
}
elsif ( !defined $TicketSearch{$Key} ) {
$TicketSearch{$Key} = $Value;
}
elsif ( !ref $TicketSearch{$Key} ) {
my $ValueTmp = $TicketSearch{$Key};
$TicketSearch{$Key} = [$ValueTmp];
}
else {
push @{ $TicketSearch{$Key} }, $Value;
}
}
# build URL
# note:
# "special characters" in customer id have to be escaped, so that DB::QueryCondition works
my $CustomerIDRaw = $Param{Data}->{UserCustomerID};
my $Action = $Param{Config}->{Action};
my $Subaction = $Param{Config}->{Subaction};
my $URL = $LayoutObject->{Baselink} . "Action=$Action;Subaction=$Subaction";
$URL .= ';CustomerIDRaw=' . $LayoutObject->LinkEncode($CustomerIDRaw);
for my $Key ( sort keys %TicketSearch ) {
if ( ref $TicketSearch{$Key} eq 'ARRAY' ) {
for my $Value ( @{ $TicketSearch{$Key} } ) {
$URL .= ';' . $Key . '=' . $LayoutObject->LinkEncode($Value);
}
}
else {
$URL .= ';' . $Key . '=' . $LayoutObject->LinkEncode( $TicketSearch{$Key} );
}
}
if ( defined $Param{Config}->{CustomerUserLogin} && $Param{Config}->{CustomerUserLogin} ) {
my $CustomerUserLoginEscaped = $Kernel::OM->Get('Kernel::System::DB')->QueryStringEscape(
QueryString => $Param{Data}->{UserLogin},
);
$TicketSearch{CustomerUserLogin} = $CustomerUserLoginEscaped;
$URL .= ';CustomerUserLoginRaw='
. $LayoutObject->LinkEncode($CustomerUserLoginEscaped);
}
my $StateObject = $Kernel::OM->Get('Kernel::System::State');
# replace StateType to StateIDs for the count numbers in customer information links
if ( $TicketSearch{StateType} ) {
my @StateIDs;
if ( $TicketSearch{StateType} eq 'Open' ) {
@StateIDs = $StateObject->StateGetStatesByType(
Type => 'Viewable',
Result => 'ID',
);
}
elsif ( $TicketSearch{StateType} eq 'Closed' ) {
my %ViewableStateOpenLookup = $StateObject->StateGetStatesByType(
Type => 'Viewable',
Result => 'HASH',
);
my %StateList = $StateObject->StateList( UserID => $Self->{UserID} );
for my $Item ( sort keys %StateList ) {
if ( !$ViewableStateOpenLookup{$Item} ) {
push @StateIDs, $Item;
}
}
}
# current ticket state type
else {
@StateIDs = $StateObject->StateGetStatesByType(
StateType => $TicketSearch{StateType},
Result => 'ID',
);
}
# merge with StateIDs
if ( @StateIDs && IsArrayRefWithData( $TicketSearch{StateIDs} ) ) {
my %StateIDs = map { $_ => 1 } @StateIDs;
@StateIDs = grep { exists $StateIDs{$_} } @{ $TicketSearch{StateIDs} };
}
if (@StateIDs) {
$TicketSearch{StateIDs} = \@StateIDs;
}
}
my %TimeMap = (
ArticleCreate => 'ArticleTime',
TicketCreate => 'Time',
TicketChange => 'ChangeTime',
TicketLastChange => 'LastChangeTime',
TicketClose => 'CloseTime',
TicketEscalation => 'EscalationTime',
);
for my $TimeType ( sort keys %TimeMap ) {
# get create time settings
if ( !$TicketSearch{ $TimeMap{$TimeType} . 'SearchType' } ) {
# do nothing with time stuff
}
elsif ( $TicketSearch{ $TimeMap{$TimeType} . 'SearchType' } eq 'TimeSlot' ) {
for my $Key (qw(Month Day)) {
$TicketSearch{ $TimeType . 'TimeStart' . $Key }
= sprintf( "%02d", $TicketSearch{ $TimeType . 'TimeStart' . $Key } );
$TicketSearch{ $TimeType . 'TimeStop' . $Key }
= sprintf( "%02d", $TicketSearch{ $TimeType . 'TimeStop' . $Key } );
}
if (
$TicketSearch{ $TimeType . 'TimeStartDay' }
&& $TicketSearch{ $TimeType . 'TimeStartMonth' }
&& $TicketSearch{ $TimeType . 'TimeStartYear' }
)
{
$TicketSearch{ $TimeType . 'TimeNewerDate' } = $TicketSearch{ $TimeType . 'TimeStartYear' } . '-'
. $TicketSearch{ $TimeType . 'TimeStartMonth' } . '-'
. $TicketSearch{ $TimeType . 'TimeStartDay' }
. ' 00:00:00';
}
if (
$TicketSearch{ $TimeType . 'TimeStopDay' }
&& $TicketSearch{ $TimeType . 'TimeStopMonth' }
&& $TicketSearch{ $TimeType . 'TimeStopYear' }
)
{
$TicketSearch{ $TimeType . 'TimeOlderDate' } = $TicketSearch{ $TimeType . 'TimeStopYear' } . '-'
. $TicketSearch{ $TimeType . 'TimeStopMonth' } . '-'
. $TicketSearch{ $TimeType . 'TimeStopDay' }
. ' 23:59:59';
}
}
elsif ( $TicketSearch{ $TimeMap{$TimeType} . 'SearchType' } eq 'TimePoint' ) {
if (
$TicketSearch{ $TimeType . 'TimePoint' }
&& $TicketSearch{ $TimeType . 'TimePointStart' }
&& $TicketSearch{ $TimeType . 'TimePointFormat' }
)
{
my $Time = 0;
if ( $TicketSearch{ $TimeType . 'TimePointFormat' } eq 'minute' ) {
$Time = $TicketSearch{ $TimeType . 'TimePoint' };
}
elsif ( $TicketSearch{ $TimeType . 'TimePointFormat' } eq 'hour' ) {
$Time = $TicketSearch{ $TimeType . 'TimePoint' } * 60;
}
elsif ( $TicketSearch{ $TimeType . 'TimePointFormat' } eq 'day' ) {
$Time = $TicketSearch{ $TimeType . 'TimePoint' } * 60 * 24;
}
elsif ( $TicketSearch{ $TimeType . 'TimePointFormat' } eq 'week' ) {
$Time = $TicketSearch{ $TimeType . 'TimePoint' } * 60 * 24 * 7;
}
elsif ( $TicketSearch{ $TimeType . 'TimePointFormat' } eq 'month' ) {
$Time = $TicketSearch{ $TimeType . 'TimePoint' } * 60 * 24 * 30;
}
elsif ( $TicketSearch{ $TimeType . 'TimePointFormat' } eq 'year' ) {
$Time = $TicketSearch{ $TimeType . 'TimePoint' } * 60 * 24 * 365;
}
if ( $TicketSearch{ $TimeType . 'TimePointStart' } eq 'Before' ) {
# more than ... ago
$TicketSearch{ $TimeType . 'TimeOlderMinutes' } = $Time;
}
elsif ( $TicketSearch{ $TimeType . 'TimePointStart' } eq 'Next' ) {
# within next
$TicketSearch{ $TimeType . 'TimeNewerMinutes' } = 0;
$TicketSearch{ $TimeType . 'TimeOlderMinutes' } = -$Time;
}
else {
# within last ...
$TicketSearch{ $TimeType . 'TimeOlderMinutes' } = 0;
$TicketSearch{ $TimeType . 'TimeNewerMinutes' } = $Time;
}
}
}
}
my $Count = $Kernel::OM->Get('Kernel::System::Ticket')->TicketSearch(
# result (required)
%TicketSearch,
CustomerIDRaw => $CustomerIDRaw,
CacheTTL => 60 * 2,
Result => 'COUNT',
Permission => 'ro',
UserID => $Self->{UserID},
) || 0;
my $CSSClass = $Param{Config}->{CSSClassNoOpenTicket};
if ($Count) {
$CSSClass = $Param{Config}->{CSSClassOpenTicket};
}
my $IconName = $Param{Config}->{IconNameNoOpenTicket};
if ($Count) {
$IconName = $Param{Config}->{IconNameOpenTicket};
}
# generate block
$LayoutObject->Block(
Name => 'CustomerItemRow',
Data => {
%{ $Param{Config} },
CSSClass => $CSSClass,
Extension => " ($Count)",
URL => $URL,
IconName => $IconName,
},
);
return 1;
}
1;

View File

@@ -0,0 +1,154 @@
# --
# 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::CustomerUser::OverviewAddressBook;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::Output::HTML::Layout',
'Kernel::System::CustomerUser',
'Kernel::System::Log',
'Kernel::System::JSON',
);
sub new {
my ( $Type, %Param ) = @_;
my $Self = \%Param;
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
for my $Needed (qw(PageShown StartHit)) {
if ( !$Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Needed!",
);
return;
}
}
if ( !$Param{CustomerUserIDs} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need CustomerUserIDs!',
);
return;
}
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
my @IDs = @{ $Param{CustomerUserIDs} };
my @ShowColumns;
if ( $Param{ShowColumns} && ref $Param{ShowColumns} eq 'ARRAY' ) {
@ShowColumns = @{ $Param{ShowColumns} };
}
my $CustomerUserObject = $Kernel::OM->Get('Kernel::System::CustomerUser');
my @RecordHeaderColumns;
# Build the column header for the output in the result page.
if (@ShowColumns) {
for my $Column (@ShowColumns) {
my $CSS = 'OverviewHeader';
my $OrderBy;
# Set the correct Set CSS class and order by link.
if ( $Param{SortBy} && ( $Param{SortBy} eq $Column ) ) {
if ( $Param{OrderBy} && ( $Param{OrderBy} eq 'Up' ) ) {
$OrderBy = 'Down';
$CSS .= ' SortAscendingLarge';
}
else {
$OrderBy = 'Up';
$CSS .= ' SortDescendingLarge';
}
}
else {
$OrderBy = 'Up';
}
# Get more information from the current field for the output (e.g. label).
my %FieldConfig = $CustomerUserObject->GetFieldConfig(
FieldName => $Column,
);
push @RecordHeaderColumns, {
Name => $Column,
Label => $FieldConfig{Label},
CSS => $CSS,
OrderBy => $OrderBy,
};
}
}
my @RecordDataColumns;
my $Output = '';
my $Counter = 0;
# Show customer user if there are some given from the search result.
if (@IDs) {
ID:
for my $ID (@IDs) {
$Counter++;
if ( $Counter >= $Param{StartHit} && $Counter < ( $Param{PageShown} + $Param{StartHit} ) ) {
my %CustomerUser = $CustomerUserObject->CustomerUserDataGet(
User => $ID,
);
next ID if !%CustomerUser;
# Disable the already selected customer user in the result table.
if ( $Param{LookupExcludeUserLogins}->{$ID} || !$CustomerUser{ $Param{CustomerTicketTextField} } ) {
$CustomerUser{Disabled} = 1;
}
# Set the checkbox for the already selected customer user to 'checked'.
if ( $Param{LookupExcludeUserLogins}->{$ID} ) {
$CustomerUser{AlreadySelected} = 1;
}
push @RecordDataColumns, {
%CustomerUser,
};
}
}
}
# Create the recipient json string for the output in the input field.
$Param{RecipientsJSON} = $Kernel::OM->Get('Kernel::System::JSON')->Encode(
Data => $Param{Recipients},
);
$Output .= $LayoutObject->Output(
TemplateFile => 'AgentCustomerUserAddressBookOverview',
Data => {
%Param,
RecordHeaderColumns => \@RecordHeaderColumns,
RecordDataColumns => \@RecordDataColumns,
Type => $Self->{ViewType},
ColumnCount => scalar @ShowColumns + 1,
},
);
return $Output;
}
1;