X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FPriceRule.pm;h=0579c534935ad7e6a31cde93eb1b2bda8799e1d4;hb=afd5395bfad1a84a590d567f8cb2d4e4967b16e3;hp=2ddccf15bce472f01f24b8c592d8473f7a5f49fe;hpb=5aec18fed79986d088e3a7ed05a9166c48d05b39;p=kivitendo-erp.git diff --git a/SL/Controller/PriceRule.pm b/SL/Controller/PriceRule.pm index 2ddccf15b..0579c5349 100644 --- a/SL/Controller/PriceRule.pm +++ b/SL/Controller/PriceRule.pm @@ -34,6 +34,8 @@ sub action_list { my $price_rules = $self->models->get; + $self->setup_search_action_bar; + $self->prepare_report; $self->report_generator_list_objects(report => $self->{report}, objects => $price_rules, $::form->{inline} ? (layout => 0, header => 0) : ()); @@ -109,6 +111,7 @@ sub display_form { my ($self, %params) = @_; my $is_new = !$self->price_rule->id; my $title = $self->form_title(($is_new ? 'create' : 'edit'), $self->price_rule->type); + $self->setup_form_action_bar; $self->render('price_rule/form', title => $title, %params @@ -236,7 +239,7 @@ sub all_price_rule_item_types { } sub add_javascripts { - $::request->{layout}->add_javascripts(qw(kivi.PriceRule.js autocomplete_customer.js autocomplete_vendor.js kivi.Part.js)); + $::request->{layout}->add_javascripts(qw(kivi.PriceRule.js autocomplete_vendor.js kivi.Part.js kivi.CustomerVendor.js)); } sub init_price_rule { @@ -300,4 +303,71 @@ sub init_models { ); } +sub setup_search_action_bar { + my ($self, %params) = @_; + + return if $::form->{inline}; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Update'), + submit => [ '#search_form', { action => 'PriceRule/list' } ], + accesskey => 'enter', + ], + + combobox => [ + action => [ + t8('Add'), + ], + link => [ + t8('New Sales Price Rule'), + link => $self->url_for(action => 'new', 'price_rule.type' => 'customer', callback => $self->models->get_callback), + ], + link => [ + t8('New Purchase Price Rule'), + link => $self->url_for(action => 'new', 'price_rule.type' => 'vendor', callback => $self->models->get_callback), + ], + ], # end of combobox "Add" + ); + } +} + +sub setup_form_action_bar { + my ($self) = @_; + + my $is_new = !$self->price_rule->id; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + combobox => [ + action => [ + $is_new ? t8('Create') : t8('Save'), + submit => [ '#form', { action => 'PriceRule/' . ($is_new ? 'create' : 'update') } ], + accesskey => 'enter', + ], + action => [ + t8('Use as new'), + submit => [ '#form', { action => 'PriceRule/create' } ], + disabled => $is_new ? t8('The object has not been saved yet.') : undef, + ], + ], # end of combobox "Save" + + action => [ + t8('Delete'), + submit => [ '#form', { action => 'PriceRule/destroy' } ], + confirm => t8('Do you really want to delete this object?'), + disabled => $is_new ? t8('The object has not been saved yet.') + : $self->price_rule->in_use ? t8('This object has already been used.') + : undef, + ], + + link => [ + t8('Abort'), + link => $self->url_for(action => 'list', 'filter.type' => $self->price_rule->type), + ], + ); + } +} + 1;