From: Bernd Bleßmann Date: Fri, 8 May 2020 15:20:52 +0000 (+0200) Subject: Abteilungen bei Ansprechpersonen: Freitext-Feld und/oder Auswahlliste X-Git-Tag: release-3.5.6.1~200 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=cc6d7fecf8eb51ffb76504d6798b7c361371e5c2;p=kivitendo-erp.git 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 --- diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index e741dd6d5..2c0b0895a 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -17,6 +17,7 @@ use SL::Controller::Helper::ParseFilter; 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; @@ -165,15 +166,20 @@ sub _save { } $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 { @@ -203,7 +209,8 @@ sub _save { $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); } @@ -951,6 +958,13 @@ sub _pre_render { } } + $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(); @@ -987,18 +1001,6 @@ sub _pre_render { $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} ||= []; diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index ecb92185e..fe3e5f7b5 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -40,6 +40,7 @@ __PACKAGE__->meta->columns( 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' }, diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index 7c50f05f6..e8cd9236d 100644 --- a/js/kivi.CustomerVendor.js +++ b/js/kivi.CustomerVendor.js @@ -70,6 +70,7 @@ namespace('kivi.CustomerVendor', function(ns) { 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(''); diff --git a/locale/de/all b/locale/de/all index ea5f995d3..2123bf77a 100755 --- a/locale/de/all +++ b/locale/de/all @@ -3823,6 +3823,7 @@ $self->{texts} = { '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', @@ -3835,6 +3836,7 @@ $self->{texts} = { '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', diff --git a/locale/en/all b/locale/en/all index a3d1900e1..788b74077 100644 --- a/locale/en/all +++ b/locale/en/all @@ -3822,6 +3822,7 @@ $self->{texts} = { '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' => '', @@ -3834,6 +3835,7 @@ $self->{texts} = { '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' => '', diff --git a/sql/Pg-upgrade2/defaults_contact_departments_use_textfield.sql b/sql/Pg-upgrade2/defaults_contact_departments_use_textfield.sql new file mode 100644 index 000000000..a44823e93 --- /dev/null +++ b/sql/Pg-upgrade2/defaults_contact_departments_use_textfield.sql @@ -0,0 +1,6 @@ +-- @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; diff --git a/templates/webpages/client_config/_features.html b/templates/webpages/client_config/_features.html index d7b5e4995..ec622e5a8 100644 --- a/templates/webpages/client_config/_features.html +++ b/templates/webpages/client_config/_features.html @@ -144,6 +144,11 @@ [% L.yes_no_tag('defaults.contact_titles_use_textfield', SELF.defaults.contact_titles_use_textfield) %] [% LxERP.t8('Use a text field to enter (new) contact titles if enabled. Otherwise, only a drop down box is offered.') %] + + [% LxERP.t8('Use text field for department of contacts') %] + [% L.yes_no_tag('defaults.contact_departments_use_textfield', SELF.defaults.contact_departments_use_textfield) %] + [% LxERP.t8('Use a text field to enter (new) contact departments if enabled. Otherwise, only a drop down box is offered.') %] + [% LxERP.t8('Hourly Rate') %] diff --git a/templates/webpages/customer_vendor/tabs/contacts.html b/templates/webpages/customer_vendor/tabs/contacts.html index 4adabb207..90793f402 100644 --- a/templates/webpages/customer_vendor/tabs/contacts.html +++ b/templates/webpages/customer_vendor/tabs/contacts.html @@ -58,8 +58,12 @@ [% 'Department' | $T8 %] - [% 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 -%]