From: Moritz Bunkus Date: Tue, 21 Mar 2017 13:57:36 +0000 (+0100) Subject: ActionBar: Verwendung bei »System« → »Einheiten bearbeiten« X-Git-Tag: release-3.5.4~1192 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a3afc944f025a130a55d440b045eceadb0630466;p=kivitendo-erp.git ActionBar: Verwendung bei »System« → »Einheiten bearbeiten« --- diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index b3ca071c0..2aeba0372 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -39,6 +39,7 @@ use SL::Auth::PasswordPolicy; use SL::AM; use SL::CA; use SL::Form; +use SL::Helper::Flash; use SL::User; use SL::USTVA; use SL::Iconv; @@ -795,6 +796,29 @@ sub doclose { $main::lxdebug->leave_sub(); } +sub add_unit { + $::auth->assert('config'); + + # my $units = AM->retrieve_units(\%::myconfig, $::form, "resolved_"); + # # AM->units_in_use(\%::myconfig, $::form, $units); + + # $units->{$_}->{BASE_UNIT_DDBOX} = AM->unit_select_data($units, $units->{$_}->{base_unit}, 1) for keys %{$units}; + + my @languages = @{ SL::DB::Manager::Language->get_all_sorted }; + + my $units = AM->retrieve_units(\%::myconfig, $::form); + my $ddbox = AM->unit_select_data($units, undef, 1); + + setup_am_add_unit_action_bar(); + + $::form->{title} = $::locale->text("Add unit"); + $::form->header(); + print($::form->parse_html_template("am/add_unit", { + NEW_BASE_UNIT_DDBOX => $ddbox, + LANGUAGES => \@languages, + })); +} + sub edit_units { $main::lxdebug->enter_sub(); @@ -831,7 +855,9 @@ sub edit_units { $units = AM->retrieve_units(\%myconfig, $form); my $ddbox = AM->unit_select_data($units, undef, 1); - $form->{"title"} = $locale->text("Add and edit units"); + setup_am_edit_units_action_bar(); + + $form->{"title"} = $locale->text("Edit units"); $form->header(); print($form->parse_html_template("am/edit_units", { "UNITS" => \@unit_list, @@ -842,7 +868,7 @@ sub edit_units { $main::lxdebug->leave_sub(); } -sub add_unit { +sub create_unit { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -877,9 +903,9 @@ sub add_unit { AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages); - $form->{"saved_message"} = $locale->text("The unit has been saved."); + flash_later('info', $locale->text("The unit has been added.")); - edit_units(); + print $form->redirect_header('am.pl?action=edit_units'); $main::lxdebug->leave_sub(); } @@ -983,9 +1009,9 @@ sub save_unit { AM->save_units(\%myconfig, $form, $new_units, \@delete_units); - $form->{"saved_message"} = $locale->text("The units have been saved."); + flash_later('info', $locale->text("The units have been saved.")); - edit_units(); + print $form->redirect_header('am.pl?action=edit_units'); $main::lxdebug->leave_sub(); } @@ -1463,3 +1489,45 @@ sub setup_am_edit_tax_action_bar { ); } } + +sub setup_am_add_unit_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => "create_unit" } ], + accesskey => 'enter', + ], + + 'separator', + + link => [ + t8('Back'), + link => 'am.pl?action=edit_units', + ], + ); + } +} + +sub setup_am_edit_units_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => "save_unit" } ], + accesskey => 'enter', + ], + + 'separator', + + link => [ + t8('Add'), + link => 'am.pl?action=add_unit', + ], + ); + } +} diff --git a/locale/de/all b/locale/de/all index 41496079c..066901fa1 100755 --- a/locale/de/all +++ b/locale/de/all @@ -190,7 +190,6 @@ $self->{texts} = { 'Add Vendor Invoice' => 'Einkaufsrechnung erfassen', 'Add Warehouse' => 'Lager erfassen', 'Add acceptance status' => 'Abnahmestatus hinzufügen', - 'Add and edit units' => 'Einheiten erfassen und bearbeiten', 'Add bank account' => 'Bankkonto erfassen', 'Add booking group' => 'Buchungsgruppe erfassen', 'Add business' => 'Kunden-/Lieferantentyp hinzufügen', @@ -3128,7 +3127,7 @@ $self->{texts} = { 'The transfer has been canceled by the user.' => 'Der Vorgang wurde durch den Benutzer abgebrochen.', 'The transport cost article \'#1\' is missing. Do you want to continue anyway?' => 'Der Transportkostenartikel »#1« fehlt. Wollen Sie trotzdem fortfahren?', 'The type is missing.' => 'Der Typ fehlt.', - 'The unit has been saved.' => 'Die Einheit wurde gespeichert.', + 'The unit has been added.' => 'Die Einheit wurde erfasst.', 'The unit in row %d has been deleted in the meantime.' => 'Die Einheit in Zeile %d ist in der Zwischentzeit gelöscht worden.', 'The unit in row %d has been used in the meantime and cannot be changed anymore.' => 'Die Einheit in Zeile %d wurde in der Zwischenzeit benutzt und kann nicht mehr geändert werden.', 'The unit is missing.' => 'Die Einheit fehlt.', diff --git a/templates/webpages/am/_units_header_info.html b/templates/webpages/am/_units_header_info.html new file mode 100644 index 000000000..a54a782b0 --- /dev/null +++ b/templates/webpages/am/_units_header_info.html @@ -0,0 +1,7 @@ +[%- USE HTML -%][%- USE LxERP -%][%- USE T8 -%] +

+ [% LxERP.t8('All units have either no or exactly one base unit of which they are multiples.') %] + [% LxERP.t8('If you select a base unit then you also have to enter a factor.') %] + [% LxERP.t8('You have to define a unit as a multiple of a smaller unit.') %] + [% LxERP.t8('Therefore the definition of "kg" with the base unit "g" and a factor of 1000 is valid while defining "g" with a base unit of "kg" and a factor of "0.001" is not.') %] +

diff --git a/templates/webpages/am/add_unit.html b/templates/webpages/am/add_unit.html new file mode 100644 index 000000000..573121cb5 --- /dev/null +++ b/templates/webpages/am/add_unit.html @@ -0,0 +1,39 @@ +[%- USE HTML -%][%- USE T8 -%] +

[% 'Add unit' | $T8 %]

+ +[% PROCESS "am/_units_header_info.html" %] + +
+ +
+ + + + + + + + + + + + + + + + + + [% FOREACH language = LANGUAGES %] + + + + + + + [% END %] +
[% 'Unit' | $T8 %]
[% 'Base unit' | $T8 %] + +
[% 'Factor' | $T8 %]
[% language.description %][% 'Plural' | $T8 %]
+
diff --git a/templates/webpages/am/edit_units.html b/templates/webpages/am/edit_units.html index 1879d56b9..210ec0c0a 100644 --- a/templates/webpages/am/edit_units.html +++ b/templates/webpages/am/edit_units.html @@ -2,72 +2,27 @@ [% USE HTML %]

[% title %]

- [% IF saved_message %] -

[% saved_message %]

+[% PROCESS "common/flash.html" %] -
- [% END %] +[% PROCESS "am/_units_header_info.html" %] -
+
- - -

- [% LxERP.t8('All units have either no or exactly one base unit of which they are multiples.') %] - [% LxERP.t8('If you select a base unit then you also have to enter a factor.') %] - [% LxERP.t8('You have to define a unit as a multiple of a smaller unit.') %] - [% LxERP.t8('Therefore the definition of "kg" with the base unit "g" and a factor of 1000 is valid while defining "g" with a base unit of "kg" and a factor of "0.001" is not.') %] -

+

+ [% 'Units that have already been used (e.g. for parts and services or in invoices or warehouse transactions) cannot be changed.' | $T8 %] +

-
+

+ [% 'Units marked for deletion will be deleted upon saving.' | $T8 %] +

-

[% 'Add unit' | $T8 %]

+

+ [% 'You can declare different translations for singular and plural for each unit (e.g. "day" and "days).' | $T8 %] +

- - - - - - - - - - - - - - - [% FOREACH language = LANGUAGES %] - - - - - - - [% END %] -
[% 'Unit' | $T8 %]
[% 'Base unit' | $T8 %] - -
[% 'Factor' | $T8 %]
[% language.description %][% 'Plural' | $T8 %]
+ - - -
- -

[% 'Edit units' | $T8 %]

- -

- [% 'Units that have already been used (e.g. for parts and services or in invoices or warehouse transactions) cannot be changed.' | $T8 %] -

- -

- [% 'Units marked for deletion will be deleted upon saving.' | $T8 %] -

- -

- [% 'You can declare different translations for singular and plural for each unit (e.g. "day" and "days).' | $T8 %] -

+ @@ -127,9 +82,6 @@ - - [% L.sortable_element('#unit_list tbody', url => 'controller.pl?action=Unit/reorder', with => 'unit_id') %] -