Revision cc6d7fec
Von Bernd Bleßmann vor mehr als 4 Jahren hinzugefügt
SL/Controller/CustomerVendor.pm | ||
---|---|---|
17 | 17 |
use SL::DB::Customer; |
18 | 18 |
use SL::DB::Vendor; |
19 | 19 |
use SL::DB::Business; |
20 |
use SL::DB::ContactDepartment; |
|
20 | 21 |
use SL::DB::ContactTitle; |
21 | 22 |
use SL::DB::Employee; |
22 | 23 |
use SL::DB::Greeting; |
... | ... | |
165 | 166 |
} |
166 | 167 |
|
167 | 168 |
$self->{cv}->greeting(trim $self->{cv}->greeting); |
168 |
my $save_greeting = $self->{cv}->greeting |
|
169 |
my $save_greeting = $self->{cv}->greeting
|
|
169 | 170 |
&& $::instance_conf->get_vc_greetings_use_textfield |
170 | 171 |
&& SL::DB::Manager::Greeting->get_all_count(where => [description => $self->{cv}->greeting]) == 0; |
171 | 172 |
|
172 | 173 |
$self->{contact}->cp_title(trim($self->{contact}->cp_title)); |
173 |
my $save_contact_title = $self->{contact}->cp_title |
|
174 |
my $save_contact_title = $self->{contact}->cp_title
|
|
174 | 175 |
&& $::instance_conf->get_contact_titles_use_textfield |
175 | 176 |
&& SL::DB::Manager::ContactTitle->get_all_count(where => [description => $self->{contact}->cp_title]) == 0; |
176 | 177 |
|
178 |
$self->{contact}->cp_abteilung(trim($self->{contact}->cp_abteilung)); |
|
179 |
my $save_contact_department = $self->{contact}->cp_abteilung |
|
180 |
&& $::instance_conf->get_contact_departments_use_textfield |
|
181 |
&& SL::DB::Manager::ContactDepartment->get_all_count(where => [description => $self->{contact}->cp_abteilung]) == 0; |
|
182 |
|
|
177 | 183 |
my $db = $self->{cv}->db; |
178 | 184 |
|
179 | 185 |
$db->with_transaction(sub { |
... | ... | |
203 | 209 |
|
204 | 210 |
$self->{contact}->cp_cv_id($self->{cv}->id); |
205 | 211 |
if( $self->{contact}->cp_name ne '' || $self->{contact}->cp_givenname ne '' ) { |
206 |
SL::DB::ContactTitle->new(description => $self->{contact}->cp_title)->save if $save_contact_title; |
|
212 |
SL::DB::ContactTitle ->new(description => $self->{contact}->cp_title) ->save if $save_contact_title; |
|
213 |
SL::DB::ContactDepartment->new(description => $self->{contact}->cp_abteilung)->save if $save_contact_department; |
|
207 | 214 |
|
208 | 215 |
$self->{contact}->save(cascade => 1); |
209 | 216 |
} |
... | ... | |
951 | 958 |
} |
952 | 959 |
} |
953 | 960 |
|
961 |
$self->{all_contact_departments} = SL::DB::Manager::ContactDepartment->get_all_sorted(); |
|
962 |
foreach my $contact (@{ $self->{cv}->contacts }) { |
|
963 |
if ($contact->cp_abteilung && !grep {$contact->cp_abteilung eq $_->description} @{$self->{all_contact_departments}}) { |
|
964 |
unshift @{$self->{all_contact_departments}}, (SL::DB::ContactDepartment->new(description => $contact->cp_abteilung)); |
|
965 |
} |
|
966 |
} |
|
967 |
|
|
954 | 968 |
$self->{all_currencies} = SL::DB::Manager::Currency->get_all(); |
955 | 969 |
|
956 | 970 |
$self->{all_languages} = SL::DB::Manager::Language->get_all(); |
... | ... | |
987 | 1001 |
$self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all_sorted(query => [ or => [ id => $self->{cv}->pricegroup_id, obsolete => 0 ] ]); |
988 | 1002 |
} |
989 | 1003 |
|
990 |
$query = |
|
991 |
'SELECT DISTINCT(cp_abteilung) AS department |
|
992 |
FROM contacts |
|
993 |
WHERE cp_abteilung IS NOT NULL AND cp_abteilung != \'\' |
|
994 |
ORDER BY cp_abteilung'; |
|
995 |
$self->{all_departments} = [ |
|
996 |
map( |
|
997 |
{ $_->{department}; } |
|
998 |
selectall_hashref_query($::form, $dbh, $query) |
|
999 |
) |
|
1000 |
]; |
|
1001 |
|
|
1002 | 1004 |
$self->{contacts} = $self->{cv}->contacts; |
1003 | 1005 |
$self->{contacts} ||= []; |
1004 | 1006 |
|
Auch abrufbar als: Unified diff
Abteilungen bei Ansprechpersonen: Freitext-Feld und/oder Auswahlliste
Die Abteilung wird entweder nur mit einer Auswahlliste angezeigt oder mit
Freitext-Feld und Auswahlliste. Das ist annähernd das alte Verhalten - im
Freitext-Feld eingegebener Text wird auch in contact_departments gespeichert.
In der Mandantenkonfiguration ist das Freitext-Feld (altes Verhalten)
abschaltbar.
Todo: Fremdschlüsselbeziehung zwischen contacts und contact_departments