Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3706: Checked customer company name for uniqueness in frontend module. #3834

Open
wants to merge 1 commit into
base: rel-10_0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 51 additions & 8 deletions Kernel/Modules/AdminCustomerCompany.pm
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,31 @@ sub Run {
);

# check duplicate field
if ( %List && $List{ $GetParam{CustomerID} } ) {
$Errors{Duplicate} = 'ServerError';
if (%List) {
SEARCHRESULT:
for my $SearchResultID ( keys %List ) {
my %CustomerCompany = $CustomerCompanyObject->CustomerCompanyGet(
CustomerID => $SearchResultID,
);

# check CustomerID and Name as both are unique
if ( $CustomerCompany{CustomerID} eq $GetParam{CustomerID} ) {
$Errors{Duplicate} = 'ServerError';
$Errors{DuplicateMessage} = $LayoutObject->{LanguageObject}->Translate(
'Customer Company %s already exists!',
$GetParam{CustomerID},
);
last SEARCHRESULT;
}
elsif ( $CustomerCompany{CustomerCompanyName} eq $GetParam{CustomerCompanyName} ) {
$Errors{Duplicate} = 'ServerError';
$Errors{DuplicateMessage} = $LayoutObject->{LanguageObject}->Translate(
'Customer Company name %s already exists!',
$GetParam{CustomerCompanyName},
);
last SEARCHRESULT;
}
}
}
}

Expand Down Expand Up @@ -394,8 +417,31 @@ sub Run {
);

# check duplicate field
if ( %List && $List{$CustomerCompanyID} ) {
$Errors{Duplicate} = 'ServerError';
if (%List) {
SEARCHRESULT:
for my $SearchResultID ( keys %List ) {
my %CustomerCompany = $CustomerCompanyObject->CustomerCompanyGet(
CustomerID => $SearchResultID,
);

# check CustomerID and Name as both are unique
if ( $CustomerCompany{CustomerID} eq $CustomerCompanyID ) {
$Errors{Duplicate} = 'ServerError';
$Errors{DuplicateMessage} = $LayoutObject->{LanguageObject}->Translate(
'Customer Company %s already exists!',
$CustomerCompanyID,
);
last SEARCHRESULT;
}
elsif ( $CustomerCompany{CustomerCompanyName} eq $GetParam{CustomerCompanyName} ) {
$Errors{Duplicate} = 'ServerError';
$Errors{DuplicateMessage} = $LayoutObject->{LanguageObject}->Translate(
'Customer Company name %s already exists!',
$GetParam{CustomerCompanyName},
);
last SEARCHRESULT;
}
}
}

# if no errors occurred
Expand Down Expand Up @@ -482,10 +528,7 @@ sub Run {
if ( $Errors{Duplicate} ) {
$Output .= $LayoutObject->Notify(
Priority => 'Error',
Info => $LayoutObject->{LanguageObject}->Translate(
'Customer Company %s already exists!',
$CustomerCompanyID,
),
Info => $Errors{DuplicateMessage},
);
}

Expand Down