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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
|
# --
# Kernel/Output/HTML/Customer.pm - provides generic customer HTML output
# Copyright (C) 2001-2005 Martin Edenhofer <martin+code@otrs.org>
# --
# $Id: Customer.pm,v 1.43 2005/08/06 16:19:56 martin Exp $
# --
# 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 http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::Output::HTML::Customer;
use strict;
use vars qw($VERSION);
$VERSION = '$Revision: 1.43 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# --
sub CustomerLogin {
my $Self = shift;
my %Param = @_;
my $Output = '';
$Param{TitleArea} = " :: ".$Self->{LanguageObject}->Get('Login');
# add cookies if exists
if ($Self->{SetCookies} && $Self->{ConfigObject}->Get('SessionUseCookie')) {
foreach (keys %{$Self->{SetCookies}}) {
$Output .= "Set-Cookie: $Self->{SetCookies}->{$_}\n";
}
}
# get language options
$Param{Language} = $Self->OptionStrgHashRef(
Data => $Self->{ConfigObject}->Get('DefaultUsedLanguages'),
Name => 'Lang',
SelectedID => $Self->{UserLanguage},
OnChange => 'submit()',
HTMLQuote => 0,
LanguageTranslation => 0,
);
# get lost password output
if ($Self->{ConfigObject}->Get('CustomerPanelLostPassword')
&& $Self->{ConfigObject}->Get('Customer::AuthModule') eq 'Kernel::System::CustomerAuth::DB') {
$Self->Block(
Name => 'LostPassword',
Data => \%Param,
);
}
# get lost password output
if ($Self->{ConfigObject}->Get('CustomerPanelCreateAccount')
&& $Self->{ConfigObject}->Get('Customer::AuthModule') eq 'Kernel::System::CustomerAuth::DB') {
$Self->Block(
Name => 'CreateAccount',
Data => \%Param,
);
}
# create & return output
$Output .= $Self->Output(TemplateFile => 'CustomerLogin', Data => \%Param);
return $Output;
}
# --
sub CustomerHeader {
my $Self = shift;
my %Param = @_;
my $Output = '';
my $Type = $Param{Type} || '';
# add cookies if exists
if ($Self->{SetCookies} && $Self->{ConfigObject}->Get('SessionUseCookie')) {
foreach (keys %{$Self->{SetCookies}}) {
$Output .= "Set-Cookie: $Self->{SetCookies}->{$_}\n";
}
}
# area and title
if (!$Param{Area}) {
$Param{Area} = $Self->{ConfigObject}->Get('CustomerFrontend::Module')->{$Self->{Action}}->{NavBarName} || '';
}
if (!$Param{Title}) {
$Param{Title} = $Self->{ConfigObject}->Get('CustomerFrontend::Module')->{$Self->{Action}}->{Title} || '';
}
if (!$Param{Area}) {
$Param{Area} = $Self->{ConfigObject}->Get('PublicFrontend::Module')->{$Self->{Action}}->{NavBarName} || '';
}
if (!$Param{Title}) {
$Param{Title} = $Self->{ConfigObject}->Get('PublicFrontend::Module')->{$Self->{Action}}->{Title} || '';
}
foreach (qw(Area Title Value)) {
if ($Param{$_}) {
$Param{TitleArea} .= " :: ".$Self->{LanguageObject}->Get($Param{$_});
}
}
# create & return output
$Output .= $Self->Output(TemplateFile => "CustomerHeader$Type", Data => \%Param);
return $Output;
}
# --
sub CustomerFooter {
my $Self = shift;
my %Param = @_;
my $Type = $Param{Type} || '';
# create & return output
return $Self->Output(TemplateFile => "CustomerFooter$Type", Data => \%Param);
}
# --
sub CustomerNavigationBar {
my $Self = shift;
my %Param = @_;
# create menu items
my %NavBarModule = ();
foreach my $Module (sort keys %{$Self->{ConfigObject}->Get('CustomerFrontend::Module')}) {
my %Hash = %{$Self->{ConfigObject}->Get('CustomerFrontend::Module')->{$Module}};
if ($Hash{NavBar} && ref($Hash{NavBar}) eq 'ARRAY') {
my @Items = @{$Hash{NavBar}};
foreach my $Item (@Items) {
foreach (1..51) {
if ($NavBarModule{sprintf("%07d", $Item->{Prio})}) {
$Item->{Prio}++;
}
if (!$NavBarModule{sprintf("%07d", $Item->{Prio})}) {
last;
}
}
$NavBarModule{sprintf("%07d", $Item->{Prio})} = $Item;
}
}
}
foreach (sort keys %NavBarModule) {
$Self->Block(
Name => $NavBarModule{$_}->{Block} || 'Item',
Data => $NavBarModule{$_},
);
}
# run notification modules
if (ref($Self->{ConfigObject}->Get('CustomerFrontend::NotifyModule')) eq 'HASH') {
my %Jobs = %{$Self->{ConfigObject}->Get('CustomerFrontend::NotifyModule')};
foreach my $Job (sort keys %Jobs) {
# log try of load module
if ($Self->{Debug} > 1) {
$Self->{LogObject}->Log(
Priority => 'debug',
Message => "Try to load module: $Jobs{$Job}->{Module}!",
);
}
if (eval "require $Jobs{$Job}->{Module}") {
my $Object = $Jobs{$Job}->{Module}->new(
ConfigObject => $Self->{ConfigObject},
LogObject => $Self->{LogObject},
DBObject => $Self->{DBObject},
TimeObject => $Self->{TimeObject},
LayoutObject => $Self,
UserID => $Self->{UserID},
Debug => $Self->{Debug},
);
# log loaded module
if ($Self->{Debug} > 1) {
$Self->{LogObject}->Log(
Priority => 'debug',
Message => "Module: $Jobs{$Job}->{Module} loaded!",
);
}
# run module
$Param{Notification} .= $Object->Run(%Param, Config => $Jobs{$Job});
}
else {
$Self->{LogObject}->Log(
Priority => 'error',
Message => "Can't load module $Jobs{$Job}->{Module}!",
);
}
}
}
if ($Self->{UserEmail} ne $Self->{UserCustomerID}) {
$Param{UserLoginTop} = "$Self->{UserEmail}/$Self->{UserCustomerID}";
}
else {
$Param{UserLoginTop} = $Self->{UserEmail};
}
# create & return output
return $Self->Output(TemplateFile => 'CustomerNavigationBar', Data => \%Param);
}
# --
sub CustomerError {
my $Self = shift;
my %Param = @_;
# get backend error messages
foreach (qw(Message Traceback)) {
$Param{'Backend'.$_} = $Self->{LogObject}->GetLogEntry(
Type => 'Error',
What => $_
) || '';
$Param{'Backend'.$_} = $Self->Ascii2Html(
Text => $Param{'Backend'.$_},
HTMLResultMode => 1,
);
}
if (!$Param{Message}) {
$Param{Message} = $Param{BackendMessage};
}
# create & return output
return $Self->Output(TemplateFile => 'CustomerError', Data => \%Param);
}
# --
sub CustomerWarning {
my $Self = shift;
my %Param = @_;
# get backend error messages
foreach (qw(Message)) {
$Param{'Backend'.$_} = $Self->{LogObject}->GetLogEntry(
Type => 'Notice',
What => $_
) || $Self->{LogObject}->GetLogEntry(
Type => 'Error',
What => $_
) || '';
$Param{'Backend'.$_} = $Self->Ascii2Html(
Text => $Param{'Backend'.$_},
HTMLResultMode => 1,
);
}
if (!$Param{Message}) {
$Param{Message} = $Param{BackendMessage};
}
# create & return output
return $Self->Output(TemplateFile => 'CustomerWarning', Data => \%Param);
}
# --
sub CustomerNoPermission {
my $Self = shift;
my %Param = @_;
my $WithHeader = $Param{WithHeader} || 'yes';
my $Output = '';
$Param{Message} = 'No Permission!' if (!$Param{Message});
# create output
$Output = $Self->CustomerHeader(Title => 'No Permission') if ($WithHeader eq 'yes');
$Output .= $Self->Output(TemplateFile => 'NoPermission', Data => \%Param);
$Output .= $Self->CustomerFooter() if ($WithHeader eq 'yes');
# return output
return $Output;
}
# --
sub CustomerFreeDate {
my $Self = shift;
my %Param = @_;
my %NullOption = ();
my %SelectData = ();
my %Ticket = ();
my %Config = ();
if ($Param{NullOption}) {
# $NullOption{''} = '-';
$SelectData{Size} = 3;
$SelectData{Multiple} = 1;
}
if ($Param{Ticket}) {
%Ticket = %{$Param{Ticket}};
}
if ($Param{Config}) {
%Config = %{$Param{Config}};
}
my %Data = ();
foreach my $Count (1..2) {
$Data{'TicketFreeTime'.$Count} = $Self->BuildDateSelection(
Area => 'Customer',
%Param,
%Ticket,
Prefix => 'TicketFreeTime'.$Count,
Format => 'DateInputFormatLong',
DiffTime => $Self->{ConfigObject}->Get('TicketFreeTimeDiff'.$Count) || 0,
);
}
return %Data;
}
1;
|