From: Moritz Bunkus Date: Wed, 1 Feb 2017 13:10:20 +0000 (+0100) Subject: SimpleSystemSetting: Umstellung von »Warengruppen« X-Git-Tag: release-3.5.4~1560 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=9c19433144efc5b50d90a969aa9ac6ea65b2dbbf;p=kivitendo-erp.git SimpleSystemSetting: Umstellung von »Warengruppen« --- diff --git a/SL/Controller/PartsGroup.pm b/SL/Controller/PartsGroup.pm deleted file mode 100644 index 603aa1258..000000000 --- a/SL/Controller/PartsGroup.pm +++ /dev/null @@ -1,159 +0,0 @@ -package SL::Controller::PartsGroup; - -use strict; - -use parent qw(SL::Controller::Base); - -use SL::Helper::Flash; -use SL::Locale::String; -use SL::DB::Default; -use SL::DB::Manager::PartsGroup; - -use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(partsgroup) ], - 'scalar --get_set_init' => [ qw(all_partsgroups) ], -); - -__PACKAGE__->run_before('check_auth'); -__PACKAGE__->run_before('load_partsgroup', only => [ qw(edit update delete) ]); - -# -# actions -# - -sub action_list { - my ($self) = @_; - - $self->render('partsgroup/list', - title => t8('Partsgroups'), - ); -} - -sub action_new { - my ($self) = @_; - - $self->partsgroup( SL::DB::PartsGroup->new ); - $self->render('partsgroup/form', - title => t8('Add partsgroup'), - ); -} - -sub action_edit { - my ($self) = @_; - - $self->render('partsgroup/form', - title => t8('Edit partsgroup'), - ); -} - -sub action_create { - my ($self) = @_; - - $self->partsgroup( SL::DB::PartsGroup->new ); - $self->create_or_update; -} - -sub action_update { - my ($self) = @_; - $self->create_or_update; -} - -sub action_delete { - my ($self) = @_; - - if ( !$self->partsgroup->orphaned ) { - flash_later('error', $::locale->text('The partsgroup has been used and cannot be deleted.')); - } elsif ( eval { $self->partsgroup->delete; 1; } ) { - flash_later('info', $::locale->text('The partsgroup has been deleted.')); - } else { - flash_later('error', $::locale->text('The partsgroup has been used and cannot be deleted.')); - }; - $self->redirect_to(action => 'list'); -} - -sub action_reorder { - my ($self) = @_; - - SL::DB::PartsGroup->reorder_list(@{ $::form->{partsgroup_id} || [] }); - $self->render(\'', { type => 'json' }); -} - -# -# filters -# - -sub check_auth { - $::auth->assert('config'); -} - -sub load_partsgroup { - my ($self) = @_; - - $self->partsgroup( SL::DB::PartsGroup->new(id => $::form->{id})->load ); -} - -sub init_all_partsgroups { SL::DB::Manager::PartsGroup->get_all_sorted } - -# -# helpers -# - -sub create_or_update { - my ($self) = @_; - my $is_new = !$self->partsgroup->id; - - my $params = delete($::form->{partsgroup}) || { }; - - $self->partsgroup->assign_attributes(%{ $params }); - - my @errors = $self->partsgroup->validate; - - if (@errors) { - flash('error', @errors); - $self->render('partsgroup/form', - title => $is_new ? t8('Add partsgroup') : t8('Edit partsgroup'), - ); - return; - } - - $self->partsgroup->save; - - flash_later('info', $is_new ? t8('The partsgroup has been created.') : t8('The partsgroup has been saved.')); - $self->redirect_to(action => 'list'); -} - -1; - -__END__ - -=encoding utf-8 - -=head1 NAME - -SL::Controller::PartsGroup - CRUD controller for partsgroups - -=head1 SYNOPSIS - -A new controller to create / edit / delete partsgroups. - -Partsgroups can only be deleted if they haven't been used anywhere. - -=head1 OBSOLETE PARTSGROUPS - -A partsgroup can be deleted if it hasn't been used anywhere / is orphaned. - -A partsgroup can be set to obsolete, which means new items can't be assigned -that partsgroup, but old items with that partsgroup can keep it. And you can -also still filter for these obsolete partsgroups in reports. - -=head1 ISSUES - -Unlike the old version (pe.pl/PE.pm), there is no way to filter/search the -partsgroups in the overview page, it always shows the complete (ordered) list, -ordered by sortkey. - -=head1 AUTHOR - -G. Richardson Egrichardson@kivitendo-premium.deE - -=cut diff --git a/SL/Controller/SimpleSystemSetting.pm b/SL/Controller/SimpleSystemSetting.pm index 429d2879b..9ce91f9f9 100644 --- a/SL/Controller/SimpleSystemSetting.pm +++ b/SL/Controller/SimpleSystemSetting.pm @@ -40,6 +40,20 @@ my %supported_types = ( ], }, + parts_group => { + # Make locales.pl happy: $self->render("simple_system_setting/_parts_group_form") + class => 'PartsGroup', + titles => { + list => t8('Partsgroups'), + add => t8('Add partsgroup'), + edit => t8('Edit partsgroup'), + }, + list_attributes => [ + { method => 'partsgroup', title => t8('Description') }, + { method => 'obsolete', title => t8('Obsolete'), formatter => sub { $_[0]->obsolete ? t8('yes') : t8('no') } }, + ], + }, + pricegroup => { # Make locales.pl happy: $self->render("simple_system_setting/_pricegroup_form") class => 'Pricegroup', diff --git a/locale/de/all b/locale/de/all index 55ca59862..7c4da9016 100644 --- a/locale/de/all +++ b/locale/de/all @@ -3074,10 +3074,6 @@ $self->{texts} = { 'The parts for this delivery order have already been transferred out.' => 'Die Artikel dieses Lieferscheins wurden bereits ausgelagert.', 'The parts have been removed.' => 'Die Waren wurden aus dem Lager entnommen.', 'The parts have been transferred.' => 'Die Waren wurden umgelagert.', - 'The partsgroup has been created.' => 'Die Warengruppe wurde erstellt.', - 'The partsgroup has been deleted.' => 'Die Warengruppe wurde gelöscht.', - 'The partsgroup has been saved.' => 'Die Warengruppe wurde gespeichert.', - 'The partsgroup has been used and cannot be deleted.' => 'Die Warengruppe wurde bereits verwendet und kann nicht gelöscht werden.', 'The password is too long (maximum length: #1).' => 'Das Passwort ist zu lang (maximale Länge: #1).', 'The password is too short (minimum length: #1).' => 'Das Password ist zu kurz (minimale Länge: #1).', 'The password is weak (e.g. it can be found in a dictionary).' => 'Das Passwort ist schwach (z.B. wenn es in einem Wörterbuch steht).', diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml index 546891511..d1f54c21f 100644 --- a/menus/user/00-erp.yaml +++ b/menus/user/00-erp.yaml @@ -1072,7 +1072,8 @@ name: Partsgroups order: 900 params: - action: PartsGroup/list + action: SimpleSystemSetting/list + type: parts_group - parent: system id: system_part_classification name: Parts Classification diff --git a/templates/webpages/partsgroup/form.html b/templates/webpages/partsgroup/form.html deleted file mode 100644 index 60134b736..000000000 --- a/templates/webpages/partsgroup/form.html +++ /dev/null @@ -1,50 +0,0 @@ -[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%] - -[% SET style="width: 400px" %] -[% SET size=15 %] - -

[% HTML.escape(title) %]

- -
- -[%- INCLUDE 'common/flash.html' %] - -[%- L.hidden_tag("id", SELF.partsgroup.id) %] - - - - - - [% IF SELF.partsgroup.id %] - - - - - - [% END %] -
[% 'Description' | $T8 %] - [%- L.input_tag("partsgroup.partsgroup", SELF.partsgroup.partsgroup) %] -
[% 'Obsolete' | $T8 %][% L.checkbox_tag('partsgroup.obsolete', checked = SELF.partsgroup.obsolete, for_submit=1) %]
- -

- [% L.hidden_tag("action", "PartsGroup/dispatch") %] - [% L.submit_tag("action_" _ (SELF.partsgroup.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %] - [%- IF SELF.partsgroup.id AND SELF.partsgroup.orphaned -%] - [% L.submit_tag("action_delete", LxERP.t8('Delete')) %] - [%- END %] - [%- LxERP.t8("Cancel") %] -

- -
- - diff --git a/templates/webpages/partsgroup/list.html b/templates/webpages/partsgroup/list.html deleted file mode 100644 index 72893932f..000000000 --- a/templates/webpages/partsgroup/list.html +++ /dev/null @@ -1,33 +0,0 @@ -[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%][%- INCLUDE 'common/flash.html' %] - -

[% title %]

- -

- - - - - - - - - - - [%- FOREACH partsgroup = SELF.all_partsgroups %] - - - - - - [%- END %] - -
[ LxERP.t8('reorder item') %][% 'Description' | $T8 %][% 'Obsolete' | $T8 %]
[ LxERP.t8('reorder item') %][% HTML.escape(partsgroup.partsgroup) %][% HTML.escape(partsgroup.obsolete) %]
-

- -
- -[% L.sortable_element('#partsgroup_list tbody', url=SELF.url_for(action='reorder'), with='partsgroup_id') %] - -

- [%- 'Add' | $T8 %] -

diff --git a/templates/webpages/simple_system_setting/_parts_group_form.html b/templates/webpages/simple_system_setting/_parts_group_form.html new file mode 100644 index 000000000..8e9025a5b --- /dev/null +++ b/templates/webpages/simple_system_setting/_parts_group_form.html @@ -0,0 +1,13 @@ +[%- USE LxERP -%][%- USE L -%] + + + + + + + + + +
[% LxERP.t8("Description") %] + [%- L.input_tag("object.partsgroup", SELF.object.partsgroup, "data-validate"="required", "data-title"=LxERP.t8("Description")) %] +
[% LxERP.t8("Obsolete") %][% L.checkbox_tag("object.obsolete", checked=SELF.object.obsolete, for_submit=1) %]