X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCsvImport%2FContact.pm;h=b707ae8f8d0e90805c6590afdf02d0a6d07d994e;hb=a4f1494fd428b5388c92a0ad065ad807f32c2090;hp=5d0a1bea7fe2dc13c465291f439341a52626f934;hpb=969e749ceb3bcf8c40dac0e84094de03f4ded9d7;p=kivitendo-erp.git diff --git a/SL/Controller/CsvImport/Contact.pm b/SL/Controller/CsvImport/Contact.pm index 5d0a1bea7..b707ae8f8 100644 --- a/SL/Controller/CsvImport/Contact.pm +++ b/SL/Controller/CsvImport/Contact.pm @@ -54,33 +54,24 @@ sub check_gender { push @{ $entry->{errors} }, $::locale->text('Error: Gender (cp_gender) missing or invalid') if ($entry->{object}->cp_gender ne 'm') && ($entry->{object}->cp_gender ne 'f'); } -sub check_duplicates { - my ($self, %params) = @_; - - my $normalizer = sub { my $name = $_[0]; $name =~ s/[\s,\.\-]//g; return $name; }; - - my %by_id_and_name; - if ('check_db' eq $self->controller->profile->get('duplicates')) { - foreach my $type (qw(customers vendors)) { - foreach my $vc (@{ $self->all_vc->{$type} }) { - $by_id_and_name{ $vc->id } = { map { ( $normalizer->($_->cp_name) => 'db' ) } @{ $vc->contacts } }; +sub get_duplicate_check_fields { + return { + cp_name => { + label => $::locale->text('Name'), + default => 1, + maker => sub { + my $o = shift; + return join( + '--', + $o->cp_cv_id, + map( + { s/[\s,\.\-]//g; $_ } + $o->cp_name + ) + ); } - } - } - - foreach my $entry (@{ $self->controller->data }) { - next if @{ $entry->{errors} }; - - my $name = $normalizer->($entry->{object}->cp_name); - - $by_id_and_name{ $entry->{vc}->id } ||= { }; - if (!$by_id_and_name{ $entry->{vc}->id }->{ $name }) { - $by_id_and_name{ $entry->{vc}->id }->{ $name } = 'csv'; - - } else { - push @{ $entry->{errors} }, $by_id_and_name{ $entry->{vc}->id }->{ $name } eq 'db' ? $::locale->text('Duplicate in database') : $::locale->text('Duplicate in CSV file'); - } - } + }, + }; } sub field_lengths { @@ -125,4 +116,4 @@ sub setup_displayable_columns { ); } -1; +1; \ No newline at end of file