X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FPriceRule.pm;h=1a42a71a2e4061d6e227ad4bb7a7d4d0659b937a;hb=2d678531e9c4b3ac578d62e3c2e3f6589b2efc11;hp=c77a2da48e007a2f80ae863727318edf8bc67d3f;hpb=678f57a3852524663977b8903c47404070d17469;p=kivitendo-erp.git diff --git a/SL/Controller/PriceRule.pm b/SL/Controller/PriceRule.pm index c77a2da48..1a42a71a2 100644 --- a/SL/Controller/PriceRule.pm +++ b/SL/Controller/PriceRule.pm @@ -13,12 +13,11 @@ use SL::DB::Pricegroup; use SL::DB::PartsGroup; use SL::DB::Business; use SL::Helper::Flash; -use SL::ClientJS; use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(models price_rule vc js pricegroups partsgroups businesses) ], + 'scalar --get_set_init' => [ qw(models price_rule vc pricegroups partsgroups businesses) ], ); # __PACKAGE__->run_before('check_auth'); @@ -87,7 +86,11 @@ sub action_add_item_row { ->js ->before('#price_rule_new_items', $html) ->reinit_widgets - ->render($self); + ->render; +} + +sub action_price_type_help { + $_[0]->render('price_rule/price_type_help', { layout => 0 }); } # @@ -105,15 +108,35 @@ sub check_auth { sub display_form { my ($self, %params) = @_; my $is_new = !$self->price_rule->id; - my $title = $is_new ? - ($self->price_rule->is_sales ? t8('Create a new sales price rule') : t8('Create a new purchase price rule')) : - ($self->price_rule->is_sales ? t8('Edit sales price rule') : t8('Edit purchase price rule')); + my $title = $self->form_title(($is_new ? 'create' : 'edit'), $self->price_rule->type); $self->render('price_rule/form', title => $title, %params ); } +sub form_title { + my ($self, $action, $type) = @_; + + return { + edit => { + customer => t8('Edit sales price rule'), + vendor => t8('Edit purchase price rule'), + '' => t8('Edit price rule'), + }, + create => { + customer => t8('Create a new sales price rule'), + vendor => t8('Create a new purchase price rule'), + '' => t8('Create a new price rule'), + }, + list => { + customer => t8('Sales Price Rules'), + vendor => t8('Purchase Price Rules'), + '' => t8('Price Rules'), + }, + }->{$action}{$type}; +} + sub create_or_update { my $self = shift; my $is_new = !$self->price_rule->id; @@ -145,13 +168,14 @@ sub prepare_report { my $report = SL::ReportGenerator->new(\%::myconfig, $::form); $self->{report} = $report; - my @columns = qw(name type priority price discount items); - my @sortable = qw(name type priority price discount ); + my @columns = qw(name type priority price reduction discount items); + my @sortable = qw(name type priority price reduction discount ); my %column_defs = ( name => { obj_link => sub { $self->url_for(action => 'edit', 'price_rule.id' => $_[0]->id, callback => $callback) } }, priority => { sub => sub { $_[0]->priority_as_text } }, price => { sub => sub { $_[0]->price_as_number } }, + reduction => { sub => sub { $_[0]->reduction_as_number } }, discount => { sub => sub { $_[0]->discount_as_number } }, obsolete => { sub => sub { $_[0]->obsolete_as_bool_yn } }, items => { sub => sub { $_[0]->item_summary } }, @@ -166,7 +190,7 @@ sub prepare_report { std_column_visibility => 1, controller_class => 'PriceRule', output_format => 'HTML', - title => ($self->vc eq 'customer' ? t8('Sales Price Rules') : t8('Purchase Price Rules')) , + title => $self->form_title('list', $self->vc), allow_pdf_export => !$::form->{inline}, allow_csv_export => !$::form->{inline}, ); @@ -242,10 +266,6 @@ sub init_vc { $::form->{filter}{type}; } -sub init_js { - SL::ClientJS->new; -} - sub init_businesses { SL::DB::Manager::Business->get_all; } @@ -258,6 +278,10 @@ sub init_partsgroups { SL::DB::Manager::PartsGroup->get_all; } +sub all_price_types { + SL::DB::Manager::PriceRule->all_price_types; +} + sub init_models { my ($self) = @_; @@ -269,6 +293,7 @@ sub init_models { priority => t8('Priority'), price => t8('Price'), discount => t8('Discount'), + reduction => t8('Reduced Master Data'), obsolete => t8('Obsolete'), items => t8('Rule Details'), },