use SL::DB::Customer;
use SL::DB::Vendor;
use SL::DB::Business;
+use SL::DB::ContactDepartment;
use SL::DB::ContactTitle;
use SL::DB::Employee;
use SL::DB::Greeting;
}
$self->{cv}->greeting(trim $self->{cv}->greeting);
- my $save_greeting = $self->{cv}->greeting
+ my $save_greeting = $self->{cv}->greeting
&& $::instance_conf->get_vc_greetings_use_textfield
&& SL::DB::Manager::Greeting->get_all_count(where => [description => $self->{cv}->greeting]) == 0;
$self->{contact}->cp_title(trim($self->{contact}->cp_title));
- my $save_contact_title = $self->{contact}->cp_title
+ my $save_contact_title = $self->{contact}->cp_title
&& $::instance_conf->get_contact_titles_use_textfield
&& SL::DB::Manager::ContactTitle->get_all_count(where => [description => $self->{contact}->cp_title]) == 0;
+ $self->{contact}->cp_abteilung(trim($self->{contact}->cp_abteilung));
+ my $save_contact_department = $self->{contact}->cp_abteilung
+ && $::instance_conf->get_contact_departments_use_textfield
+ && SL::DB::Manager::ContactDepartment->get_all_count(where => [description => $self->{contact}->cp_abteilung]) == 0;
+
my $db = $self->{cv}->db;
$db->with_transaction(sub {
$self->{contact}->cp_cv_id($self->{cv}->id);
if( $self->{contact}->cp_name ne '' || $self->{contact}->cp_givenname ne '' ) {
- SL::DB::ContactTitle->new(description => $self->{contact}->cp_title)->save if $save_contact_title;
+ SL::DB::ContactTitle ->new(description => $self->{contact}->cp_title) ->save if $save_contact_title;
+ SL::DB::ContactDepartment->new(description => $self->{contact}->cp_abteilung)->save if $save_contact_department;
$self->{contact}->save(cascade => 1);
}
}
}
+ $self->{all_contact_departments} = SL::DB::Manager::ContactDepartment->get_all_sorted();
+ foreach my $contact (@{ $self->{cv}->contacts }) {
+ if ($contact->cp_abteilung && !grep {$contact->cp_abteilung eq $_->description} @{$self->{all_contact_departments}}) {
+ unshift @{$self->{all_contact_departments}}, (SL::DB::ContactDepartment->new(description => $contact->cp_abteilung));
+ }
+ }
+
$self->{all_currencies} = SL::DB::Manager::Currency->get_all();
$self->{all_languages} = SL::DB::Manager::Language->get_all();
$self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all_sorted(query => [ or => [ id => $self->{cv}->pricegroup_id, obsolete => 0 ] ]);
}
- $query =
- 'SELECT DISTINCT(cp_abteilung) AS department
- FROM contacts
- WHERE cp_abteilung IS NOT NULL AND cp_abteilung != \'\'
- ORDER BY cp_abteilung';
- $self->{all_departments} = [
- map(
- { $_->{department}; }
- selectall_hashref_query($::form, $dbh, $query)
- )
- ];
-
$self->{contacts} = $self->{cv}->contacts;
$self->{contacts} ||= [];
co_ustid => { type => 'text' },
coa => { type => 'text' },
company => { type => 'text' },
+ contact_departments_use_textfield => { type => 'boolean' },
contact_titles_use_textfield => { type => 'boolean' },
create_part_if_not_found => { type => 'boolean', default => 'false' },
create_zugferd_invoices => { type => 'integer' },
if ( contactId ) {
$('#action_delete_contact').show();
$('#contact_cp_title_select').val(contact['cp_title']);
+ $('#contact_cp_abteilung_select').val(contact['cp_abteilung']);
} else {
$('#action_delete_contact').hide();
$('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
'Use UStVA' => 'UStVA verwenden',
'Use WebDAV Repository' => 'Verwende WebDAV',
'Use WebDAV Storage backend' => 'Verwende WebDAV-Backend',
+ 'Use a text field to enter (new) contact departments if enabled. Otherwise, only a drop down box is offered.' => 'Textfeld zusätzlich zur Eingabe (neuer) Abteilungen von Ansprechpersonen verwenden. Sonst wird nur eine Auswahlliste angezeigt.',
'Use a text field to enter (new) contact titles if enabled. Otherwise, only a drop down box is offered.' => 'Textfeld zusätzlich zur Eingabe (neuer) Titel von Ansprechpersonen verwenden. Sonst wird nur eine Auswahlliste angezeigt.',
'Use a text field to enter (new) greetings if enabled. Otherwise, only a drop down box is offered.' => 'Textfeld zusätzlich zur Eingabe (neuer) Anreden verwenden. Sonst wird nur eine Auswahlliste angezeigt.',
'Use as new' => 'Als neu verwenden',
'Use linked items' => 'Verknüpfte Positionen verwenden',
'Use master default bin for Default Transfer, if no default bin for the part is configured' => 'Standardlagerplatz für Ein- / Auslagern über Standard-Lagerplatz, falls für die Ware kein expliziter Lagerplatz konfiguriert ist',
'Use settings from client configuration' => 'Einstellungen aus Mandantenkonfiguration folgen',
+ 'Use text field for department of contacts' => 'Textfeld für Abteilungen von Ansprechpersonen verwenden',
'Use text field for greetings' => 'Textfeld für Anreden verwenden',
'Use text field for title of contacts' => 'Textfeld für Titel von Ansprechpersonen verwenden',
'Use this storage backend for all generated PDF-Files' => 'Verwende dieses Backend für generierte PDF-Dateien',
'Use UStVA' => '',
'Use WebDAV Repository' => '',
'Use WebDAV Storage backend' => '',
+ 'Use a text field to enter (new) contact departments if enabled. Otherwise, only a drop down box is offered.' => '',
'Use a text field to enter (new) contact titles if enabled. Otherwise, only a drop down box is offered.' => '',
'Use a text field to enter (new) greetings if enabled. Otherwise, only a drop down box is offered.' => '',
'Use as new' => '',
'Use linked items' => '',
'Use master default bin for Default Transfer, if no default bin for the part is configured' => '',
'Use settings from client configuration' => '',
+ 'Use text field for department of contacts' => '',
'Use text field for greetings' => '',
'Use text field for title of contacts' => '',
'Use this storage backend for all generated PDF-Files' => '',
--- /dev/null
+-- @tag: defaults_contact_departments_use_textfield
+-- @description: Auswahl, ob Freitext-Feld für Abteilungen bei Ansprechpersonen im Kunden-/Lieferantenstamm angeboten wird
+-- @depends: release_3_5_5
+
+ALTER TABLE defaults ADD COLUMN contact_departments_use_textfield BOOLEAN;
+UPDATE defaults SET contact_departments_use_textfield = TRUE;
<td> [% L.yes_no_tag('defaults.contact_titles_use_textfield', SELF.defaults.contact_titles_use_textfield) %]</td>
<td>[% LxERP.t8('Use a text field to enter (new) contact titles if enabled. Otherwise, only a drop down box is offered.') %]</td>
</tr>
+ <tr>
+ <td align="right">[% LxERP.t8('Use text field for department of contacts') %]</td>
+ <td> [% L.yes_no_tag('defaults.contact_departments_use_textfield', SELF.defaults.contact_departments_use_textfield) %]</td>
+ <td>[% LxERP.t8('Use a text field to enter (new) contact departments if enabled. Otherwise, only a drop down box is offered.') %]</td>
+ </tr>
<tr>
<td align="right">[% LxERP.t8('Hourly Rate') %]</td>
<th align="right" nowrap>[% 'Department' | $T8 %]</th>
<td>
- [% L.input_tag('contact.cp_abteilung', SELF.contact.cp_abteilung, size = 40) %]
- [% L.select_tag('contact_cp_abteilung_select', SELF.all_departments, default = SELF.contact.cp_abteilung, with_empty = 1, onchange = '$("#contact_cp_abteilung").val(this.value);') %]
+ [%- IF INSTANCE_CONF.get_contact_departments_use_textfield -%]
+ [% L.input_tag('contact.cp_abteilung', SELF.contact.cp_abteilung, size = 40) %]
+ [% L.select_tag('contact_cp_abteilung_select', SELF.all_contact_departments, default = SELF.contact.cp_abteilung, value_key = 'description', title_key = 'description', with_empty = 1, onchange = '$("#contact_cp_abteilung").val(this.value);') %]
+ [%- ELSE -%]
+ [% L.select_tag('contact.cp_abteilung', SELF.all_contact_departments, default = SELF.contact.cp_abteilung, value_key = 'description', title_key = 'description', with_empty = 1) %]
+ [%- END -%]
</td>
</tr>