From: Moritz Bunkus Date: Wed, 1 Feb 2017 15:05:45 +0000 (+0100) Subject: SimpleSystemSetting: Umstellung von »Sprachen« X-Git-Tag: release-3.5.4~1549 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=60d0f05f9fe667d2c309175d8849428393c6739f;p=kivitendo-erp.git SimpleSystemSetting: Umstellung von »Sprachen« --- diff --git a/SL/AM.pm b/SL/AM.pm index 1f9a573d0..e4e5ad7cd 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -410,61 +410,6 @@ sub _delete_account { return 1; } -sub language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form, $return_list) = @_; - - my $dbh = SL::DB->client->dbh; - - my $query = - "SELECT id, description, template_code, article_code, " . - " output_numberformat, output_dateformat, output_longdates " . - "FROM language ORDER BY description"; - - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - my $ary = []; - - while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { - push(@{ $ary }, $ref); - } - - $sth->finish; - - $main::lxdebug->leave_sub(); - - if ($return_list) { - return @{$ary}; - } else { - $form->{ALL} = $ary; - } -} - -sub get_language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - my $dbh = SL::DB->client->dbh; - - my $query = - "SELECT description, template_code, article_code, " . - " output_numberformat, output_dateformat, output_longdates " . - "FROM language WHERE id = ?"; - my $sth = $dbh->prepare($query); - $sth->execute($form->{"id"}) || $form->dberror($query . " ($form->{id})"); - - my $ref = $sth->fetchrow_hashref("NAME_lc"); - - map { $form->{$_} = $ref->{$_} } keys %$ref; - - $sth->finish; - - $main::lxdebug->leave_sub(); -} - sub get_language_details { $main::lxdebug->enter_sub(); @@ -483,64 +428,6 @@ sub get_language_details { return @res; } -sub save_language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - SL::DB->client->with_transaction(sub { - my $dbh = SL::DB->client->dbh; - my (@values, $query); - - map({ push(@values, $form->{$_}); } - qw(description template_code article_code - output_numberformat output_dateformat output_longdates)); - - # id is the old record - if ($form->{id}) { - $query = - "UPDATE language SET " . - " description = ?, template_code = ?, article_code = ?, " . - " output_numberformat = ?, output_dateformat = ?, " . - " output_longdates = ? " . - "WHERE id = ?"; - push(@values, $form->{id}); - } else { - $query = - "INSERT INTO language (" . - " description, template_code, article_code, " . - " output_numberformat, output_dateformat, output_longdates" . - ") VALUES (?, ?, ?, ?, ?, ?)"; - } - do_query($form, $dbh, $query, @values); - 1; - }) or do { die SL::DB->client->error }; - - $main::lxdebug->leave_sub(); -} - -sub delete_language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - my $query; - - SL::DB->client->with_transaction(sub { - my $dbh = SL::DB->client->dbh; - - foreach my $table (qw(generic_translations units_language)) { - $query = qq|DELETE FROM $table WHERE language_id = ?|; - do_query($form, $dbh, $query, $form->{"id"}); - } - - $query = "DELETE FROM language WHERE id = ?"; - do_query($form, $dbh, $query, $form->{"id"}); - 1; - }) or do { die SL::DB->client->error }; - - $main::lxdebug->leave_sub(); -} - sub prepare_template_filename { $main::lxdebug->enter_sub(); diff --git a/SL/Controller/SimpleSystemSetting.pm b/SL/Controller/SimpleSystemSetting.pm index de0feb073..5fb975162 100644 --- a/SL/Controller/SimpleSystemSetting.pm +++ b/SL/Controller/SimpleSystemSetting.pm @@ -64,6 +64,24 @@ my %supported_types = ( }, }, + language => { + # Make locales.pl happy: $self->render("simple_system_setting/_language_form") + class => 'Language', + titles => { + list => t8('Languages'), + add => t8('Add language'), + edit => t8('Edit language'), + }, + list_attributes => [ + { method => 'description', title => t8('Description'), }, + { method => 'template_code', title => t8('Template Code'), }, + { method => 'article_code', title => t8('Article Code'), }, + { title => t8('Number Format'), formatter => sub { $_[0]->output_numberformat || t8('use program settings') } }, + { title => t8('Date Format'), formatter => sub { $_[0]->output_dateformat || t8('use program settings') } }, + { title => t8('Long Dates'), formatter => sub { $_[0]->output_longdates ? t8('yes') : t8('no') } }, + ], + }, + part_classification => { # Make locales.pl happy: $self->render("simple_system_setting/_part_classification_form") class => 'PartClassification', @@ -384,6 +402,13 @@ sub setup_requirement_spec_status { $self->{valid_names} = \@SL::DB::RequirementSpecStatus::valid_names; } +sub setup_language { + my ($self) = @_; + + $self->{numberformats} = [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ]; + $self->{dateformats} = [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ]; +} + 1; __END__ diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index d72b51184..8ef12063a 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -614,110 +614,6 @@ sub delete_account { $main::lxdebug->leave_sub(); } -sub add_language { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - - $main::auth->assert('config'); - - $form->{title} = "Add"; - - $form->{callback} = "am.pl?action=add_language" unless $form->{callback}; - - &language_header; - &form_footer; - - $main::lxdebug->leave_sub(); -} - -sub edit_language { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $main::auth->assert('config'); - - $form->{title} = "Edit"; - - AM->get_language(\%myconfig, \%$form); - - &language_header; - - $form->{orphaned} = 1; - &form_footer; - - $main::lxdebug->leave_sub(); -} - -sub list_language { - $::lxdebug->enter_sub; - $::auth->assert('config'); - - AM->language(\%::myconfig, $::form); - - $::form->{callback} = "am.pl?action=list_language"; - $::form->{title} = $::locale->text('Languages'); - - $::form->header; - - print $::form->parse_html_template('am/language_list'); - - $::lxdebug->leave_sub; -} - -sub language_header { - $::lxdebug->enter_sub; - $::auth->assert('config'); - - # $locale->text('Add Language') - # $locale->text('Edit Language') - $::form->{title} = $::locale->text("$::form->{title} Language"); - - $::form->header; - - print $::form->parse_html_template('am/language_header', { - numberformats => [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ], - dateformats => [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ], - }); - - $::lxdebug->leave_sub; -} - -sub save_language { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - $form->isblank("description", $locale->text('Language missing!')); - $form->isblank("template_code", $locale->text('Template Code missing!')); - $form->isblank("article_code", $locale->text('Article Code missing!')); - AM->save_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language saved!')); - - $main::lxdebug->leave_sub(); -} - -sub delete_language { - $main::lxdebug->enter_sub(); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $main::auth->assert('config'); - - AM->delete_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language deleted!')); - - $main::lxdebug->leave_sub(); -} - sub _build_cfg_options { my $form = $main::form; my %myconfig = %main::myconfig; diff --git a/locale/de/all b/locale/de/all index 94ea31fd8..ab95fef6c 100755 --- a/locale/de/all +++ b/locale/de/all @@ -161,7 +161,6 @@ $self->{texts} = { 'Add Follow-Up' => 'Wiedervorlage erstellen', 'Add Follow-Up for #1' => 'Wiedervorlage für #1 erstellen', 'Add General Ledger Transaction' => 'Dialogbuchen', - 'Add Language' => 'Sprache hinzufügen', 'Add Letter' => 'Brief hinzufügen', 'Add Part' => 'Ware erfassen', 'Add Price Factor' => 'Preisfaktor erfassen', @@ -199,6 +198,7 @@ $self->{texts} = { 'Add function block' => 'Funktionsblock hinzufügen', 'Add headers from last uploaded file (csv_import)' => 'Spalten aus der hochgeladenen Datei einfügen', 'Add invoices' => 'Rechnungen hinzufügen', + 'Add language' => 'Sprache hinzufügen', 'Add link: select records to link with' => 'Verknüpfungen hinzufügen: zu verknüpfende Belege auswählen', 'Add linked record' => 'Verknüpften Beleg hinzufügen', 'Add links' => 'Verknüpfungen hinzufügen', @@ -309,7 +309,6 @@ $self->{texts} = { 'Are you sure?' => 'Sind Sie sicher?', 'Article' => 'Artikel', 'Article Code' => 'Artikelkürzel', - 'Article Code missing!' => 'Artikelkürzel fehlt', 'Article classification' => 'Artikel-Klassifizierung', 'Article type' => 'Artikeltyp', 'Articles' => 'Artikel', @@ -1082,7 +1081,6 @@ $self->{texts} = { 'Edit Follow-Up' => 'Wiedervorlage bearbeiten', 'Edit Follow-Up for #1' => 'Wiedervorlage für #1 bearbeiten', 'Edit General Ledger Transaction' => 'Buchung im Hauptbuch bearbeiten', - 'Edit Language' => 'Sprache bearbeiten', 'Edit Letter' => 'Brief bearbeiten', 'Edit Part' => 'Ware bearbeiten', 'Edit Preferences for #1' => 'Einstellungen von #1 bearbeiten', @@ -1119,6 +1117,7 @@ $self->{texts} = { 'Edit file' => 'Datei bearbeiten', 'Edit general settings' => 'Grundeinstellungen bearbeiten', 'Edit greetings' => 'Anreden bearbeiten', + 'Edit language' => 'Sprache bearbeiten', 'Edit note' => 'Notiz bearbeiten', 'Edit part classification' => 'Artikel-Klassifizierung bearbeiten', 'Edit partsgroup' => 'Warengruppe bearbeiten', @@ -1627,9 +1626,6 @@ $self->{texts} = { 'Language' => 'Sprache', 'Language (database ID)' => 'Sprache (Datenbank-ID)', 'Language (name)' => 'Sprache (Name)', - 'Language deleted!' => 'Sprache gelöscht!', - 'Language missing!' => 'Sprache fehlt!', - 'Language saved!' => 'Sprache gespeichert!', 'Language settings' => 'Spracheinstellungen', 'Languages' => 'Sprachen', 'Languages and translations' => 'Sprachen und Übersetzungen', @@ -1678,7 +1674,6 @@ $self->{texts} = { 'Linked invoices' => 'Verknüpfte Rechnungen', 'Liquidity projection' => 'Liquiditätsübersicht', 'List Accounts' => 'Konten anzeigen', - 'List Languages' => 'Sprachen anzeigen', 'List Price' => 'Listenpreis', 'List Printers' => 'Drucker anzeigen', 'List Transactions' => 'Buchungsliste', @@ -2836,7 +2831,6 @@ $self->{texts} = { 'Telephone' => 'Telefon', 'Template' => 'Druckvorlage', 'Template Code' => 'Vorlagenkürzel', - 'Template Code missing!' => 'Vorlagenkürzel fehlt!', 'Template database' => 'Datenbankvorlage', 'Templates' => 'Vorlagen', 'Terms missing in row ' => '+Tage fehlen in Zeile ', diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml index 77ca36ea4..4e6f10a29 100644 --- a/menus/user/00-erp.yaml +++ b/menus/user/00-erp.yaml @@ -1183,18 +1183,11 @@ order: 1900 - parent: system_languages_and_translations id: system_languages_and_translations_add_language - name: Add Language + name: Languages order: 100 - module: am.pl - params: - action: add_language -- parent: system_languages_and_translations - id: system_languages_and_translations_list_languages - name: List Languages - order: 200 - module: am.pl params: - action: list_language + action: SimpleSystemSetting/list + type: language - parent: system_languages_and_translations id: system_languages_and_translations_greetings name: Greetings diff --git a/templates/webpages/am/language_header.html b/templates/webpages/am/language_header.html deleted file mode 100644 index 82124c0bd..000000000 --- a/templates/webpages/am/language_header.html +++ /dev/null @@ -1,40 +0,0 @@ -[%- USE L %] -[%- USE HTML %] -[%- USE LxERP %] -[%- USE T8 %] -

[% title | html %]

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[% 'Language' | $T8 %]
[% 'Template Code' | $T8 %]
[% 'Article Code' | $T8 %]
[% 'Number Format' | $T8 %][% L.select_tag('output_numberformat', numberformats, default = output_numberformat, with_empty = 1, empty_title = LxERP.t8('use program settings')) %]
[% 'Date Format' | $T8 %][% L.select_tag('output_dateformat', dateformats, default = output_dateformat, with_empty = 1, empty_title=LxERP.t8('use program settings')) %]
[% 'Long Dates' | $T8 %][% L.radio_button_tag('output_longdates', checked=output_longdates, label=LxERP.t8('Yes')) %] - [% L.radio_button_tag('output_longdates', checked=!output_longdates, label=LxERP.t8('No')) %]

diff --git a/templates/webpages/am/language_list.html b/templates/webpages/am/language_list.html deleted file mode 100644 index 9d71ddaa9..000000000 --- a/templates/webpages/am/language_list.html +++ /dev/null @@ -1,45 +0,0 @@ -[%- USE HTML %] -[%- USE L %] -[%- USE LxERP %] -[%- USE T8 %] -

[% title | html %]

- - - - - - - - -
- - - - - - - - - -[%- FOREACH row = ALL %] - - - - - - - -[%- END %] - -
[% 'Description' | $T8 %][% 'Template Code' | $T8 %][% 'Article Code' | $T8 %][% 'Number Format' | $T8 %][% 'Date Format' | $T8 %][% 'Long Dates' | $T8 %]
[% row.description %][% row.template_code | html %][% row.article_code | html %][% row.output_numberformat ? row.output_numberformat : LxERP.t8('use program settings') | html %][% row.output_dateformat ? row.output_dateformat : LxERP.t8('use program settings') | html %][% row.output_longdates ? LxERP.t8('Yes') : LxERP.t8('No') %]
-

- -
- - - - - - -
- diff --git a/templates/webpages/simple_system_setting/_language_form.html b/templates/webpages/simple_system_setting/_language_form.html new file mode 100644 index 000000000..0691f1712 --- /dev/null +++ b/templates/webpages/simple_system_setting/_language_form.html @@ -0,0 +1,28 @@ +[%- USE LxERP -%][%- USE L -%][%- USE HTML -%] +[% SET style="width: 250px" %] + + + + + + + + + + + + + + + + + + + + + + + + + +
[% LxERP.t8("Language") %][% L.input_tag("object.description", SELF.object.description, style=style, "data-validate"="required", "data-title"=LxERP.t8("Language")) %]
[% LxERP.t8("Template Code") %][% L.input_tag("object.template_code", SELF.object.template_code, style=style) %]
[% LxERP.t8("Article Code") %][% L.input_tag("object.article_code", SELF.object.article_code, style=style) %]
[% LxERP.t8("Number Format") %][% L.select_tag("object.output_numberformat", SELF.numberformats, default=SELF.object.output_numberformat, with_empty=1, empty_title=LxERP.t8("use program settings"), style=style) %]
[% LxERP.t8("Date Format") %][% L.select_tag("object.output_dateformat", SELF.dateformats, default=SELF.object.output_dateformat, with_empty=1, empty_title=LxERP.t8("use program settings"), style=style) %]
[% LxERP.t8("Long Dates") %][% L.yes_no_tag("object.output_longdates", SELF.object.output_longdates, style=style) %]