use strict;
+use Carp;
use SL::DB::MetaSetup::Default;
__PACKAGE__->meta->initialize;
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;
__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 },
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;
'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',
'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',
'Zip' => 'PLZ',
'Zip, City' => 'PLZ, Ort',
'Zipcode' => 'PLZ',
+ 'Zipcode and city' => 'PLZ und Stadt',
'[email]' => '[email]',
'absolute' => 'absolut',
'account_description' => 'Beschreibung',
--- /dev/null
+# @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(<<SQL);
+ ALTER TABLE defaults
+ ADD COLUMN address_street1 TEXT,
+ ADD COLUMN address_street2 TEXT,
+ ADD COLUMN address_zipcode TEXT,
+ ADD COLUMN address_city TEXT,
+ ADD COLUMN address_country TEXT,
+ DROP COLUMN address
+SQL
+
+ $self->db_query(<<SQL, bind => [ 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;
[% SET style="width: 400px" %]
<div id="miscellaneous">
<table>
- <tr><td class="listheading" colspan="4">[% LxERP.t8("Company settings") %]</td></tr>
+ <tr><td class="listheading" colspan="4">[% LxERP.t8("Company name and address") %]</td></tr>
<tr>
<td align="right">[% LxERP.t8("Company name") %]</td>
</tr>
<tr>
- <td align="right" valign="top">[% LxERP.t8("Address") %]</td>
- <td valign="top">[% L.textarea_tag('defaults.address', SELF.defaults.address, style=style, rows=4) %]</td>
+ <td align="right" valign="top">[% LxERP.t8("Street 1") %]</td>
+ <td>[% L.input_tag('defaults.address_street1', SELF.defaults.address_street1, style=style) %]</td>
+ </tr>
+
+ <tr>
+ <td align="right" valign="top">[% LxERP.t8("Street 2") %]</td>
+ <td>[% L.input_tag('defaults.address_street2', SELF.defaults.address_street2, style=style) %]</td>
</tr>
+ <tr>
+ <td align="right" valign="top">[% LxERP.t8("Zipcode and city") %]</td>
+ <td>
+ [% L.input_tag('defaults.address_zipcode', SELF.defaults.address_zipcode, size=8) %]
+ [% L.input_tag('defaults.address_city', SELF.defaults.address_city, size=30) %]
+ </td>
+ </tr>
+
+ <tr>
+ <td align="right" valign="top">[% LxERP.t8("Country") %]</td>
+ <td>[% L.input_tag('defaults.address_country', SELF.defaults.address_country, style=style) %]</td>
+ </tr>
+
+ <tr><td class="listheading" colspan="4">[% LxERP.t8("Company settings") %]</td></tr>
+
<tr>
<td align="right" valign="top">[% LxERP.t8("Signature") %]</td>
<td valign="top">[% L.textarea_tag('defaults.signature', SELF.defaults.signature, style=style, rows=4) %]</td>