X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/72180323f463c9814fbcf21c3376201e6829b21b..fa93c93c7e076d13c6eed7be9be98cd2097fe1a3:/SL/Controller/PriceRule.pm diff --git a/SL/Controller/PriceRule.pm b/SL/Controller/PriceRule.pm index 013445570..c77a2da48 100644 --- a/SL/Controller/PriceRule.pm +++ b/SL/Controller/PriceRule.pm @@ -37,7 +37,7 @@ sub action_list { $self->prepare_report; - $self->report_generator_list_objects(report => $self->{report}, objects => $price_rules); + $self->report_generator_list_objects(report => $self->{report}, objects => $price_rules, $::form->{inline} ? (layout => 0, header => 0) : ()); } sub action_new { @@ -105,7 +105,9 @@ sub check_auth { sub display_form { my ($self, %params) = @_; my $is_new = !$self->price_rule->id; - my $title = $is_new ? t8('Create a new price rule') : t8('Edit price rule'); + 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')); $self->render('price_rule/form', title => $title, %params @@ -143,8 +145,8 @@ sub prepare_report { my $report = SL::ReportGenerator->new(\%::myconfig, $::form); $self->{report} = $report; - my @columns = qw(name type priority price discount); - my @sortable = qw(name type priority price discount); + my @columns = qw(name type priority price discount items); + my @sortable = qw(name type priority price discount ); my %column_defs = ( name => { obj_link => sub { $self->url_for(action => 'edit', 'price_rule.id' => $_[0]->id, callback => $callback) } }, @@ -152,6 +154,7 @@ sub prepare_report { price => { sub => sub { $_[0]->price_as_number } }, discount => { sub => sub { $_[0]->discount_as_number } }, obsolete => { sub => sub { $_[0]->obsolete_as_bool_yn } }, + items => { sub => sub { $_[0]->item_summary } }, ); map { $column_defs{$_}->{text} ||= $::locale->text( $self->models->get_sort_spec->{$_}->{title} ) } keys %column_defs; @@ -163,14 +166,15 @@ sub prepare_report { std_column_visibility => 1, controller_class => 'PriceRule', output_format => 'HTML', - title => $::locale->text('Price Rules'), - allow_pdf_export => 1, - allow_csv_export => 1, + title => ($self->vc eq 'customer' ? t8('Sales Price Rules') : t8('Purchase Price Rules')) , + allow_pdf_export => !$::form->{inline}, + allow_csv_export => !$::form->{inline}, ); $report->set_columns(%column_defs); $report->set_column_order(@columns); $report->set_export_options(qw(list filter)); $report->set_options_from_form; + $self->models->get_models_url_params(sub{ map { $_ => $::form->{$_} } qw(inline) }); $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable); $report->set_options( raw_bottom_info_text => $self->render('price_rule/report_bottom', { output => 0 }), @@ -194,11 +198,17 @@ sub make_filter_summary { push @filter_strings, "$_->[1]: $_->[0]" if $_->[0]; } + if ($filter->{has_item_type}) { + push @filter_strings, sprintf "%s: %s", t8('Has item type'), join ', ', map { + SL::DB::Manager::PriceRuleItem->get_type($_)->{description} + } @{ $filter->{has_item_type} || [] }; + } + $self->{filter_summary} = join ', ', @filter_strings; } sub all_price_rule_item_types { - SL::DB::Manager::PriceRuleItem->get_all_types($_[0]->price_rule->type); + SL::DB::Manager::PriceRuleItem->get_all_types($_[0]->vc || $_[0]->price_rule->type); } sub add_javascripts { @@ -260,6 +270,7 @@ sub init_models { price => t8('Price'), discount => t8('Discount'), obsolete => t8('Obsolete'), + items => t8('Rule Details'), }, ); }