Auftragsimport: Artikel auch nach Beschreibung suchen können.
[kivitendo-erp.git] / SL / Controller / PriceRule.pm
index 60870e2..1d210d4 100644 (file)
@@ -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 {
@@ -90,6 +90,10 @@ sub action_add_item_row {
     ->render($self);
 }
 
+sub action_price_type_help {
+  $_[0]->render('price_rule/price_type_help', { layout => 0 });
+}
+
 #
 # filters
 #
@@ -105,15 +109,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 +169,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,14 +191,15 @@ 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')) ,
-    allow_pdf_export      => 1,
-    allow_csv_export      => 1,
+    title                 => $self->form_title('list', $self->vc),
+    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 }),
@@ -257,6 +283,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) = @_;
 
@@ -268,6 +298,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'),
     },