1 package SL::Controller::CsvImport::Contact;
6 use SL::DB::CustomVariable;
7 use SL::DB::CustomVariableConfig;
9 use parent qw(SL::Controller::CsvImport::Base);
11 use Rose::Object::MakeMethods::Generic
13 scalar => [ qw(table) ],
18 $self->class('SL::DB::Contact');
21 sub init_all_cvar_configs {
24 return SL::DB::Manager::CustomVariableConfig->get_all(where => [ module => 'Contacts' ]);
30 foreach my $entry (@{ $self->controller->data }) {
31 $self->check_name($entry);
32 $self->check_vc($entry, 'cp_cv_id');
33 $self->check_gender($entry);
34 $self->handle_cvars($entry);
37 $self->add_info_columns({ header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
38 $self->add_cvar_raw_data_columns;
42 my ($self, $entry) = @_;
44 my $name = $entry->{object}->cp_name;
48 push @{ $entry->{errors} }, $::locale->text('Error: Name missing') unless $name;
52 my ($self, $entry) = @_;
54 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');
57 sub get_duplicate_check_fields {
60 label => $::locale->text('Name'),
68 { s/[\s,\.\-]//g; $_ }
78 return ( cp_title => 75,
87 sub setup_displayable_columns {
90 $self->SUPER::setup_displayable_columns;
91 $self->add_cvar_columns_to_displayable_columns;
93 $self->add_displayable_columns({ name => 'cp_abteilung', description => $::locale->text('Department') },
94 { name => 'cp_birthday', description => $::locale->text('Birthday') },
95 { name => 'cp_cv_id', description => $::locale->text('Customer/Vendor (database ID)') },
96 { name => 'cp_email', description => $::locale->text('E-mail') },
97 { name => 'cp_fax', description => $::locale->text('Fax') },
98 { name => 'cp_gender', description => $::locale->text('Gender') },
99 { name => 'cp_givenname', description => $::locale->text('Given Name') },
100 { name => 'cp_mobile1', description => $::locale->text('Mobile1') },
101 { name => 'cp_mobile2', description => $::locale->text('Mobile2') },
102 { name => 'cp_name', description => $::locale->text('Name') },
103 { name => 'cp_phone1', description => $::locale->text('Phone1') },
104 { name => 'cp_phone2', description => $::locale->text('Phone2') },
105 { name => 'cp_privatemail', description => $::locale->text('Private E-mail') },
106 { name => 'cp_privatphone', description => $::locale->text('Private Phone') },
107 { name => 'cp_project', description => $::locale->text('Project') },
108 { name => 'cp_satfax', description => $::locale->text('Sat. Fax') },
109 { name => 'cp_satphone', description => $::locale->text('Sat. Phone') },
110 { name => 'cp_title', description => $::locale->text('Title') },
112 { name => 'customer', description => $::locale->text('Customer (name)') },
113 { name => 'customernumber', description => $::locale->text('Customer Number') },
114 { name => 'vendor', description => $::locale->text('Vendor (name)') },
115 { name => 'vendornumber', description => $::locale->text('Vendor Number') },