use SL::DB::Customer;
use SL::DB::Vendor;
use SL::DB::Business;
+use SL::DB::ContactTitle;
use SL::DB::Employee;
use SL::DB::Greeting;
use SL::DB::Language;
}
$self->{cv}->greeting(trim $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;
+ 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
+ && $::instance_conf->get_contact_titles_use_textfield
+ && SL::DB::Manager::ContactTitle->get_all_count(where => [description => $self->{contact}->cp_title]) == 0;
my $db = $self->{cv}->db;
$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;
+
$self->{contact}->save(cascade => 1);
}
unshift @{$self->{all_greetings}}, (SL::DB::Greeting->new(description => $self->{cv}->greeting));
}
-
- $query =
- 'SELECT DISTINCT(cp_title) AS title
- FROM contacts
- WHERE cp_title IS NOT NULL AND cp_title != \'\'
- ORDER BY cp_title';
- $self->{all_titles} = [
- map(
- { $_->{title}; }
- selectall_hashref_query($::form, $dbh, $query)
- )
- ];
+ $self->{all_contact_titles} = SL::DB::Manager::ContactTitle->get_all_sorted();
+ foreach my $contact (@{ $self->{cv}->contacts }) {
+ if ($contact->cp_title && !grep {$contact->cp_title eq $_->description} @{$self->{all_contact_titles}}) {
+ unshift @{$self->{all_contact_titles}}, (SL::DB::ContactTitle->new(description => $contact->cp_title));
+ }
+ }
$self->{all_currencies} = SL::DB::Manager::Currency->get_all();
use strict;
+use SL::Util qw(trim);
+
use SL::DB::MetaSetup::ContactTitle;
use SL::DB::Manager::ContactTitle;
__PACKAGE__->meta->initialize;
+__PACKAGE__->before_save('_before_save_trim_content');
+
+sub _before_save_trim_content {
+ $_[0]->description(trim($_[0]->description));
+ return 1;
+}
+
1;
co_ustid => { type => 'text' },
coa => { type => 'text' },
company => { type => 'text' },
+ contact_titles_use_textfield => { type => 'boolean' },
create_part_if_not_found => { type => 'boolean', default => 'false' },
create_zugferd_invoices => { type => 'integer' },
currency_id => { type => 'integer', not_null => 1 },
kivi.CustomerVendor.setCustomVariablesFromAJAJ(data.contact_cvars, 'contact_cvars_');
- if ( contactId )
+ if ( contactId ) {
$('#action_delete_contact').show();
- else
+ $('#contact_cp_title_select').val(contact['cp_title']);
+ } else {
$('#action_delete_contact').hide();
+ $('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
+ }
if (data.contact.disable_cp_main === 1)
$("#contact_cp_main").prop("disabled", true);
else
params.onFormSet();
});
- $('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
};
var mapSearchStmts = [
'Use UStVA' => 'UStVA verwenden',
'Use WebDAV Repository' => 'Verwende WebDAV',
'Use WebDAV Storage backend' => 'Verwende WebDAV-Backend',
+ '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 default booking group because setting is \'all\'' => 'Standardbuchungsgruppe wird verwendet',
'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 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 this storage backend for all uploaded attachments' => 'Verwende dieses Backend für hochgeladene Dateien',
'Use this storage backend for uploaded images' => 'Verwende dieses Backend für hochgeladene Bilder',
'Use UStVA' => '',
'Use WebDAV Repository' => '',
'Use WebDAV Storage backend' => '',
+ '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 default booking group because setting is \'all\'' => '',
'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 greetings' => '',
+ 'Use text field for title of contacts' => '',
'Use this storage backend for all generated PDF-Files' => '',
'Use this storage backend for all uploaded attachments' => '',
'Use this storage backend for uploaded images' => '',
--- /dev/null
+-- @tag: defaults_contact_titles_use_textfield
+-- @description: Auswahl, ob Freitext-Feld für Titel von Ansprechpersonen im Kunden-/Lieferantenstamm angeboten wird
+-- @depends: release_3_5_5
+
+ALTER TABLE defaults ADD COLUMN contact_titles_use_textfield BOOLEAN;
+UPDATE defaults SET contact_titles_use_textfield = TRUE;
<td> [% L.yes_no_tag('defaults.vc_greetings_use_textfield', SELF.defaults.vc_greetings_use_textfield) %]</td>
<td>[% LxERP.t8('Use a text field to enter (new) greetings if enabled. Otherwise, only a drop down box is offered.') %]</td>
</tr>
+ <tr>
+ <td align="right">[% LxERP.t8('Use text field for title of contacts') %]</td>
+ <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('Hourly Rate') %]</td>
<th align="right" nowrap>[% 'Title' | $T8 %]</th>
<td>
- [% L.input_tag('contact.cp_title', SELF.contact.cp_title, size = 40) %]
- [% L.select_tag('contact_cp_title_select', SELF.all_titles, with_empty = 1, onchange = '$("#contact_cp_title").val(this.value);') %]
+ [%- IF INSTANCE_CONF.get_contact_titles_use_textfield -%]
+ [% L.input_tag('contact.cp_title', SELF.contact.cp_title, size = 40) %]
+ [% L.select_tag('contact_cp_title_select', SELF.all_contact_titles, default = SELF.contact.cp_title, value_key = 'description', title_key = 'description', with_empty = 1, onchange = '$("#contact_cp_title").val(this.value);') %]
+ [%- ELSE -%]
+ [% L.select_tag('contact.cp_title', SELF.all_contact_titles, default = SELF.contact.cp_title, value_key = 'description', title_key = 'description', with_empty = 1) %]
+ [%- END -%]
</td>
</tr>