1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
# --
# Copyright (C) 2001-2021 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::Layout::CustomerUser;
use strict;
use warnings;
use Kernel::System::VariableCheck qw(:all);
our $ObjectManagerDisabled = 1;
=head1 NAME
Kernel::Output::HTML::Layout::CustomerUser - all CustomerUser related HTML functions
=head1 PUBLIC INTERFACE
=head2 CustomerUserAddressBookListShow()
Returns a list of customer user as sort-able list with pagination.
This function is similar to L<Kernel::Output::HTML::Layout::CustomerUser::CustomerUserAddressBookListShow()>
in F<Kernel/Output/HTML/Layout/CustomerUser.pm>.
my $Output = $LayoutObject->CustomerUserAddressBookListShow(
CustomerUserIDs => $CustomerUserIDsRef, # total list of customer user ids, that can be listed
Total => scalar @{ $CustomerUserIDsRef }, # total number of customer user ids
View => $Self->{View}, # optional, the default value is 'AddressBook'
Filter => 'All',
Filters => \%NavBarFilter,
LinkFilter => $LinkFilter,
TitleName => 'Overview: CustomerUsers',
TitleValue => $Self->{Filter},
Env => $Self,
LinkPage => $LinkPage,
LinkSort => $LinkSort,
Frontend => 'Agent', # optional (Agent|Customer), default: Agent, indicates from which frontend this function was called
);
=cut
sub CustomerUserAddressBookListShow {
my ( $Self, %Param ) = @_;
# Take object ref to local, remove it from %Param (prevent memory leak).
my $Env = delete $Param{Env};
my $Frontend = $Param{Frontend} || 'Agent';
# Set defaut view mode to 'AddressBook'.
my $View = $Param{View} || 'AddressBook';
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
# get backend from config
my $Backends = $ConfigObject->Get('CustomerUser::Frontend::Overview');
if ( !$Backends ) {
return $Self->FatalError(
Message => 'Need config option CustomerUser::Frontend::Overview',
);
}
# check for hash-ref
if ( ref $Backends ne 'HASH' ) {
return $Self->FatalError(
Message => 'Config option CustomerUser::Frontend::Overview needs to be a HASH ref!',
);
}
# check for config key
if ( !$Backends->{$View} ) {
return $Self->FatalError(
Message => "No config option found for the view '$View'!",
);
}
# nav bar
my $StartHit = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam(
Param => 'StartHit',
) || 1;
# get personal page shown count
my $PageShown = $ConfigObject->Get("CustomerUser::Frontend::$Self->{Action}")->{PageShown} || 100;
# check start option, if higher then elements available, set
# it to the last overview page (Thanks to Stefan Schmidt!)
if ( $StartHit > $Param{Total} ) {
my $Pages = int( ( $Param{Total} / $PageShown ) + 0.99999 );
$StartHit = ( ( $Pages - 1 ) * $PageShown ) + 1;
}
# set page limit and build page nav
my $Limit = $Param{Limit} || 20_000;
my %PageNav = $Self->PageNavBar(
Limit => $Limit,
StartHit => $StartHit,
PageShown => $PageShown,
AllHits => $Param{Total} || 0,
Action => 'Action=' . $Self->{Action},
Link => $Param{LinkPage},
);
# build navbar content
$Self->Block(
Name => 'OverviewNavBar',
Data => \%Param,
);
# back link
if ( $Param{LinkBack} ) {
$Self->Block(
Name => 'OverviewNavBarPageBack',
Data => \%Param,
);
}
# check if page nav is available
if (%PageNav) {
$Self->Block(
Name => 'OverviewNavBarPageNavBar',
Data => \%PageNav,
);
# don't show context settings in AJAX case (e. g. in customer ticket history),
# because the submit with page reload will not work there
if ( !$Param{AJAX} ) {
$Self->Block(
Name => 'ContextSettings',
Data => {
%PageNav,
%Param,
},
);
}
}
# build html content
my $OutputNavBar = $Self->Output(
TemplateFile => 'AgentCustomerUserAddressBookOverviewNavBar',
Data => {%Param},
);
# create output
my $OutputRaw = '';
if ( !$Param{Output} ) {
$Self->Print(
Output => \$OutputNavBar,
);
}
else {
$OutputRaw .= $OutputNavBar;
}
# load module
if ( !$Kernel::OM->Get('Kernel::System::Main')->Require( $Backends->{$View}->{Module} ) ) {
return $Self->FatalError();
}
# check for backend object
my $Object = $Backends->{$View}->{Module}->new( %{$Env} );
return if !$Object;
# run module
my $Output = $Object->Run(
%Param,
Limit => $Limit,
StartHit => $StartHit,
PageShown => $PageShown,
AllHits => $Param{Total} || 0,
Frontend => $Frontend,
);
# create output
if ( !$Param{Output} ) {
$Self->Print(
Output => \$Output,
);
}
else {
$OutputRaw .= $Output;
}
# create overview nav bar
$Self->Block(
Name => 'OverviewNavBar',
Data => {%Param},
);
# return content if available
return $OutputRaw;
}
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
|