From 63cb5b41d9b06d0b7f522ef154dd9f57ea428bae Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 4 Nov 2019 14:50:26 +0100 Subject: [PATCH] Mandantenkonfiguration: Adress-Feld in einzelne Bestandteile aufgeteilt --- SL/DB/Default.pm | 13 +++++ SL/DB/MetaSetup/Default.pm | 6 ++- SL/InstanceConfiguration.pm | 10 ++++ locale/de/all | 4 ++ sql/Pg-upgrade2/defaults_split_address.pl | 53 +++++++++++++++++++ .../client_config/_miscellaneous.html | 26 +++++++-- 6 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 sql/Pg-upgrade2/defaults_split_address.pl diff --git a/SL/DB/Default.pm b/SL/DB/Default.pm index ee9e2c232..f7eeb92b5 100644 --- a/SL/DB/Default.pm +++ b/SL/DB/Default.pm @@ -2,6 +2,7 @@ package SL::DB::Default; use strict; +use Carp; use SL::DB::MetaSetup::Default; __PACKAGE__->meta->initialize; @@ -21,4 +22,16 @@ sub get { return SL::DB::Manager::Default->get_all(limit => 1)->[0]; } +sub address { + # Compatibility function: back in the day there was only a single + # address field. + my $self = shift; + + croak("SL::DB::Default::address is a read-only accessor") if @_; + + my $zipcode_city = join ' ', grep { $_ } ($self->address_zipcode, $self->address_city); + + return join "\n", grep { $_ } ($self->address_street1, $self->address_street2, $zipcode_city, $self->address_country); +} + 1; diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index 9ad110939..73b75fe1b 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -10,7 +10,11 @@ __PACKAGE__->meta->table('defaults'); __PACKAGE__->meta->columns( accounting_method => { type => 'text' }, - address => { type => 'text' }, + address_city => { type => 'text' }, + address_country => { type => 'text' }, + address_street1 => { type => 'text' }, + address_street2 => { type => 'text' }, + address_zipcode => { type => 'text' }, allow_new_purchase_delivery_order => { type => 'boolean', default => 'true', not_null => 1 }, allow_new_purchase_invoice => { type => 'boolean', default => 'true', not_null => 1 }, allow_sales_invoice_from_sales_order => { type => 'boolean', default => 'true', not_null => 1 }, diff --git a/SL/InstanceConfiguration.pm b/SL/InstanceConfiguration.pm index 59ca8a035..4c767961d 100644 --- a/SL/InstanceConfiguration.pm +++ b/SL/InstanceConfiguration.pm @@ -52,6 +52,16 @@ sub get_currencies { return @{ $self->currencies }; } +sub get_address { + # Compatibility function: back in the day there was only a single + # address field. + my ($self) = @_; + + my $zipcode_city = join ' ', grep { $_ } ($self->get_address_zipcode, $self->get_address_city); + + return join "\n", grep { $_ } ($self->get_address_street1, $self->get_address_street2, $zipcode_city, $self->get_address_country); +} + sub AUTOLOAD { our $AUTOLOAD; diff --git a/locale/de/all b/locale/de/all index 6bd4b6659..79a155959 100755 --- a/locale/de/all +++ b/locale/de/all @@ -651,6 +651,7 @@ $self->{texts} = { 'Company' => 'Firma', 'Company Name' => 'Firmenname', 'Company name' => 'Firmenname', + 'Company name and address' => 'Firmenname und -adresse', 'Company settings' => 'Firmeneinstellungen', 'Compare to' => 'Gegenüberstellen zu', 'Complexities' => 'Komplexitätsgrade', @@ -3050,6 +3051,8 @@ $self->{texts} = { 'Storno (one letter abbreviation)' => 'S', 'Storno Invoice' => 'Stornorechnung', 'Street' => 'Straße', + 'Street 1' => 'Straße 1', + 'Street 2' => 'Straße 2', 'Strict and halt' => 'Strikt und Abbruch', 'Strict but replace' => 'Strikt mit Ersetzungen', 'Style the picture with the following CSS code' => 'Bildeigenschaft mit folgendem CSS-Style versehen', @@ -3980,6 +3983,7 @@ $self->{texts} = { 'Zip' => 'PLZ', 'Zip, City' => 'PLZ, Ort', 'Zipcode' => 'PLZ', + 'Zipcode and city' => 'PLZ und Stadt', '[email]' => '[email]', 'absolute' => 'absolut', 'account_description' => 'Beschreibung', diff --git a/sql/Pg-upgrade2/defaults_split_address.pl b/sql/Pg-upgrade2/defaults_split_address.pl new file mode 100644 index 000000000..a1a465364 --- /dev/null +++ b/sql/Pg-upgrade2/defaults_split_address.pl @@ -0,0 +1,53 @@ +# @tag: defaults_split_address +# @description: Adress-Feld in Mandantenkonfiguration in einzelne Bestandteile aufteilen +# @depends: release_3_5_4 +package SL::DBUpgrade2::defaults_split_address; + +use strict; +use utf8; + +use parent qw(SL::DBUpgrade2::Base); + +sub run { + my ($self) = @_; + + my ($address) = $self->dbh->selectrow_array("SELECT address FROM defaults"); + + my (@street, $zipcode, $city, $country); + my @lines = grep { $_ } split m{\r*\n+}, $address // ''; + + foreach my $line (@lines) { + if ($line =~ m{^(?:[a-z]+[ -])?(\d+) +(.+)}i) { + ($zipcode, $city) = ($1, $2); + + } elsif ($zipcode) { + $country = $line; + + } else { + push @street, $line; + } + } + + $self->db_query(<db_query(< [ map { $_ // '' } ($street[0], $street[1], $zipcode, $city, $country) ]); + UPDATE defaults + SET address_street1 = ?, + address_street2 = ?, + address_zipcode = ?, + address_city = ?, + address_country = ? +SQL + + return 1; +} + +1; diff --git a/templates/webpages/client_config/_miscellaneous.html b/templates/webpages/client_config/_miscellaneous.html index 35a9728d7..f938f7268 100644 --- a/templates/webpages/client_config/_miscellaneous.html +++ b/templates/webpages/client_config/_miscellaneous.html @@ -2,7 +2,7 @@ [% SET style="width: 400px" %]
- + @@ -10,10 +10,30 @@ - - + + + + + + + + + + + + + + + + + + + -- 2.20.1
[% LxERP.t8("Company settings") %]
[% LxERP.t8("Company name and address") %]
[% LxERP.t8("Company name") %]
[% LxERP.t8("Address") %][% L.textarea_tag('defaults.address', SELF.defaults.address, style=style, rows=4) %][% LxERP.t8("Street 1") %][% L.input_tag('defaults.address_street1', SELF.defaults.address_street1, style=style) %]
[% LxERP.t8("Street 2") %][% L.input_tag('defaults.address_street2', SELF.defaults.address_street2, style=style) %]
[% LxERP.t8("Zipcode and city") %] + [% L.input_tag('defaults.address_zipcode', SELF.defaults.address_zipcode, size=8) %] + [% L.input_tag('defaults.address_city', SELF.defaults.address_city, size=30) %] +
[% LxERP.t8("Country") %][% L.input_tag('defaults.address_country', SELF.defaults.address_country, style=style) %]
[% LxERP.t8("Company settings") %]
[% LxERP.t8("Signature") %] [% L.textarea_tag('defaults.signature', SELF.defaults.signature, style=style, rows=4) %]