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) : ());
+ $self->report_generator_list_objects(report => $self->{report}, objects => $price_rules, $::form->{inline} ? (layout => 0, header => 0) : (action_bar => 1));
}
sub action_new {
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
);
}
+sub setup_search_action_bar {
+ my ($self, %params) = @_;
+
+ return if $::form->{inline};
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Search'),
+ submit => [ '#search_form', { action => 'PriceRule/list' } ],
+ accesskey => 'enter',
+ ],
+ action => [
+ t8('Reset'),
+ call => [ 'kivi.PriceRule.reset_search_form' ],
+ ],
+
+ 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;
[%- USE L %]
[%- USE LxERP %]
[%- USE HTML %]
-<form action='controller.pl' method='post'>
+<form action='controller.pl' method='post' id='search_form'>
<div class='filter_toggle'>
<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Show Filter' | $T8 %]</a>
[% SELF.filter_summary | html %]
</table>
-[% L.hidden_tag('action', 'PriceRule/dispatch') %]
[% L.hidden_tag('sort_by', FORM.sort_by) %]
[% L.hidden_tag('sort_dir', FORM.sort_dir) %]
[% L.hidden_tag('page', FORM.page) %]
-[% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit') %]
-
-<a class='interact cursor-pointer' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);$("#filter_table select").val("")'>[% 'Reset' | $T8 %]</a>
</div>
[%- INCLUDE 'common/flash.html' %]
- <form method="post" action="controller.pl">
+ <form method="post" action="controller.pl" id="form">
[% L.hidden_tag("price_rule.id", SELF.price_rule.id) %]
[% L.hidden_tag("price_rule.type", SELF.price_rule.type) %]
<h3>[% 'Then' | $T8 %]:</h3>
<div>[% 'Set (set to)' | $T8 %] [% L.select_tag('price_rule.price_type', SELF.all_price_types, default=SELF.price_rule.price_type) %] [% 'to (set to)' | $T8 %] [% L.input_tag('price_rule.price_or_discount_as_number', SELF.price_rule.price_or_discount_as_number) %] <a id='price_rule_price_type_help' class='interact cursor-help' title='[% 'Price type explanation' | $T8 %]'>[?]</a>
</div>
-
- <p>
- [% L.hidden_tag("action", "PriceRule/dispatch") %]
- [% L.hidden_tag("callback", FORM.callback) %]
- [% L.submit_tag("action_" _ (SELF.price_rule.id ? "update" : "create"), LxERP.t8('Save')) %]
- [%- IF SELF.price_rule.id %]
- [% L.submit_tag("action_create", LxERP.t8('Save as new')) %]
- [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) IF !SELF.price_rule.in_use %]
- [%- END %]
- <a href="[% SELF.url_for(action='list', 'filter.type'=SELF.price_rule.type) %]">[%- LxERP.t8('Abort') %]</a>
- </p>
</form>