From: Jan Büren Date: Wed, 23 Jan 2019 10:35:49 +0000 (+0100) Subject: Ansprechpartner um boolean Hauptansprechpartner erweitert X-Git-Tag: release-3.5.4~160 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=564b5410a5b4913215b53e659be6ee2a9cf259be;p=kivitendo-erp.git Ansprechpartner um boolean Hauptansprechpartner erweitert Entsprechend mit einigen Attributen für den Export von Kundenstammdaten hinzugefügt. Hintergrund: Ansprechpartner-Export gibt nur die Liste aller Ansprechpartner. Das Feld Kontakt (in der Tabelle Kunde) war wahrscheinlich der Vorgänger für die Ansprechpartner-Logik. Das ist etwas wenig, wenn man noch E-Mail, Telefon usw. personenbezogen unterbringen will. Deshalb die Ergänzung für diesen Bericht. --- diff --git a/SL/CT.pm b/SL/CT.pm index 57ee031ee..6a52ee716 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -254,10 +254,18 @@ sub search { my $pg_select = $form->{l_pricegroup} ? qq|, pg.pricegroup as pricegroup | : ''; my $pg_join = $form->{l_pricegroup} ? qq|LEFT JOIN pricegroup pg ON (ct.pricegroup_id = pg.id) | : ''; + + my $main_cp_select = ''; + if ($form->{l_main_contact_person}) { + $main_cp_select = qq/, (SELECT concat(cp.cp_givenname, ' ', cp.cp_name, ' | ', cp.cp_email, ' | ', cp.cp_phone1) + FROM contacts cp WHERE ct.id=cp.cp_cv_id AND cp.cp_main LIMIT 1) + AS main_contact_person /; + } my $query = qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | . qq| pt.description as payment | . $pg_select . + $main_cp_select . (qq|, NULL AS invnumber, NULL AS ordnumber, NULL AS quonumber, NULL AS invid, NULL AS module, NULL AS formtype, NULL AS closed | x!! $join_records) . qq|FROM $cv ct | . qq|LEFT JOIN business b ON (ct.business_id = b.id) | . diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index 4812f1b40..085b6d185 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -585,13 +585,17 @@ sub action_ajaj_get_contact { } qw( id gender abteilung title position givenname name email phone1 phone2 fax mobile1 mobile2 - satphone satfax project street zipcode city privatphone privatemail birthday + satphone satfax project street zipcode city privatphone privatemail birthday main ) ) }; $data->{contact_cvars} = $self->_prepare_cvar_configs_for_ajaj($self->{contact}->cvars_by_config); + # avoid two or more main_cp + my $has_main_cp = grep { $_->cp_main == 1 } @{ $self->{cv}->contacts }; + $data->{contact}->{disable_cp_main} = 1 if ($has_main_cp && !$data->{contact}->{cp_main}); + $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); } diff --git a/SL/DB/MetaSetup/Contact.pm b/SL/DB/MetaSetup/Contact.pm index 8d71fccf3..36afa038f 100644 --- a/SL/DB/MetaSetup/Contact.pm +++ b/SL/DB/MetaSetup/Contact.pm @@ -18,6 +18,7 @@ __PACKAGE__->meta->columns( cp_gender => { type => 'character', length => 1 }, cp_givenname => { type => 'text' }, cp_id => { type => 'integer', not_null => 1, sequence => 'id' }, + cp_main => { type => 'boolean' }, cp_mobile1 => { type => 'text' }, cp_mobile2 => { type => 'text' }, cp_name => { type => 'text' }, diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index fcc5b9043..555768d84 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -174,7 +174,8 @@ sub list_names { }; my @columns = ( - 'id', 'name', "$form->{db}number", 'contact', 'phone', 'discount', + 'id', 'name', "$form->{db}number", 'contact', 'main_contact_person', + 'phone', 'discount', 'fax', 'email', 'taxnumber', 'street', 'zipcode' , 'city', 'business', 'payment', 'invnumber', 'ordnumber', 'quonumber', 'salesman', 'country', 'gln', 'insertdate', 'pricegroup', 'contact_origin', 'invoice_mail', @@ -192,6 +193,7 @@ sub list_names { "$form->{db}number" => { 'text' => $locale->text('Number'), }, 'name' => { 'text' => $form->{IS_CUSTOMER} ? $::locale->text('Customer Name') : $::locale->text('Vendor Name'), }, 'contact' => { 'text' => $locale->text('Contact'), }, + 'main_contact_person' => { 'text' => $locale->text('Main Contact Person'), }, 'phone' => { 'text' => $locale->text('Phone'), }, 'fax' => { 'text' => $locale->text('Fax'), }, 'email' => { 'text' => $locale->text('E-mail'), }, diff --git a/doc/changelog b/doc/changelog index 73180d4b0..e5015bb21 100644 --- a/doc/changelog +++ b/doc/changelog @@ -21,7 +21,7 @@ Kleinere neue Features und Detailverbesserungen: - Kundenstammdaten um Feld Amtsgericht erweitert Falls das Feld Steuernummer mit dem Wert der Hr-Nr gefüllt wurde, wird auch das zuständige Registierungs-Gericht benötigt. - +- Ansprechpartner um Feld 'Hauptansprechpartner' erweitert und exportierbar im Kundenbericht gemacht 2019-01-03 - Release 3.5.3 diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index d489d07d3..f809e3498 100644 --- a/js/kivi.CustomerVendor.js +++ b/js/kivi.CustomerVendor.js @@ -71,7 +71,10 @@ namespace('kivi.CustomerVendor', function(ns) { $('#action_delete_contact').show(); else $('#action_delete_contact').hide(); - + if (data.contact.disable_cp_main === 1) + $("#contact_cp_main").prop("disabled", true); + else + $("#contact_cp_main").prop("disabled", false); if ( params.onFormSet ) params.onFormSet(); }); diff --git a/locale/de/all b/locale/de/all index 5e8ec3249..4d64c46d2 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1836,6 +1836,7 @@ $self->{texts} = { 'MIME type' => 'MIME-Typ', 'MT940 import' => 'MT940 Import', 'Mails' => 'E-Mails', + 'Main Contact Person' => 'Hauptansprechpartner', 'Main Preferences' => 'Grundeinstellungen', 'Main sorting' => 'Hauptsortierung', 'Make' => 'Lieferant', diff --git a/sql/Pg-upgrade2/contacts_add_main_contact.pl b/sql/Pg-upgrade2/contacts_add_main_contact.pl new file mode 100644 index 000000000..73af23c90 --- /dev/null +++ b/sql/Pg-upgrade2/contacts_add_main_contact.pl @@ -0,0 +1,20 @@ +# @tag: contacts_add_main_contact +# @description: Feld 'Hauptansprechpartner' für Kontakte +# @depends: release_3_5_3 +package SL::DBUpgrade2::contacts_add_main_contact; + +use strict; +use utf8; + +use parent qw(SL::DBUpgrade2::Base); + +sub run { + my ($self) = @_; + + $self->db_query('ALTER TABLE contacts ADD COLUMN cp_main boolean DEFAULT false', may_fail => 1); + $self->db_query("UPDATE contacts set cp_main='false'"); + + return 1; +} + +1; diff --git a/templates/webpages/ct/search.html b/templates/webpages/ct/search.html index a8dc689f7..090d4d986 100644 --- a/templates/webpages/ct/search.html +++ b/templates/webpages/ct/search.html @@ -228,6 +228,10 @@ + + + + diff --git a/templates/webpages/customer_vendor/tabs/contacts.html b/templates/webpages/customer_vendor/tabs/contacts.html index cc9b0b79c..edf5fa213 100644 --- a/templates/webpages/customer_vendor/tabs/contacts.html +++ b/templates/webpages/customer_vendor/tabs/contacts.html @@ -23,7 +23,10 @@ %] - + + [% 'Main Contact Person' | $T8 %] + [% L.yes_no_tag('contact.cp_main', SELF.contact.cp_main) %] + [% 'Gender' | $T8 %]