From c383fc0b2cf6b284a428ecca41c5f00190ca640b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 18 Dec 2014 14:21:34 +0100 Subject: [PATCH] =?utf8?q?PriceRule:=20Ein=20men=C3=BCeintrag=20und=20Type?= =?utf8?q?n=20frei=20filterbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/PriceRule.pm | 28 ++++++++++++++++--- SL/DB/Manager/PriceRuleItem.pm | 4 ++- js/kivi.PriceRule.js | 19 +++++++++++++ locale/de/all | 5 +++- menus/erp.ini | 10 +------ templates/webpages/price_rule/_filter.html | 21 +++++++------- .../webpages/price_rule/report_bottom.html | 3 +- 7 files changed, 63 insertions(+), 27 deletions(-) diff --git a/SL/Controller/PriceRule.pm b/SL/Controller/PriceRule.pm index 23dacc03c..1d210d426 100644 --- a/SL/Controller/PriceRule.pm +++ b/SL/Controller/PriceRule.pm @@ -109,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; @@ -171,7 +191,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}, ); diff --git a/SL/DB/Manager/PriceRuleItem.pm b/SL/DB/Manager/PriceRuleItem.pm index f45db3d4e..83a4bf169 100644 --- a/SL/DB/Manager/PriceRuleItem.pm +++ b/SL/DB/Manager/PriceRuleItem.pm @@ -75,7 +75,9 @@ sub not_matching_sql_and_values { sub get_all_types { my ($class, $vc) = @_; - [ map { [ $_, $types{$_}{description} ] } grep { $types{$_}{$vc} } map { $_ } @types ]; + $vc + ? [ map { [ $_, $types{$_}{description} ] } grep { $types{$_}{$vc} } map { $_ } @types ] + : [ map { [ $_, $types{$_}{description} ] } map { $_ } @types ] } sub get_type { diff --git a/js/kivi.PriceRule.js b/js/kivi.PriceRule.js index 5c56b87b0..00ed4fb36 100644 --- a/js/kivi.PriceRule.js +++ b/js/kivi.PriceRule.js @@ -15,6 +15,24 @@ namespace('kivi.PriceRule', function(ns) { }); } + ns.on_change_filter_type = function() { + var val = $('#price_rule_filter_type').val(); + if (val == 'vendor') { + $('#price_rule_filter_customer').data('customer_vendor_picker').set_item({}); + $('#price_rule_filter_customer_tr').hide(); + $('#price_rule_filter_vendor_tr').show(); + } + if (val == 'customer') { + $('#price_rule_filter_vendor').data('customer_vendor_picker').set_item({}); + $('#price_rule_filter_vendor_tr').hide(); + $('#price_rule_filter_customer_tr').show(); + } + if (val == '') { + $('#price_rule_filter_customer_tr').show(); + $('#price_rule_filter_vendor_tr').show(); + } + } + $(function() { $('#price_rule_item_add').click(function() { ns.add_new_row($('#price_rules_empty_item_select').val()); @@ -23,5 +41,6 @@ namespace('kivi.PriceRule', function(ns) { $(this).closest('div').remove(); }) $('#price_rule_price_type_help').click(ns.open_price_type_help_popup); + $('#price_rule_filter_type').change(ns.on_change_filter_type); }); }); diff --git a/locale/de/all b/locale/de/all index 0209437ff..84310672e 100755 --- a/locale/de/all +++ b/locale/de/all @@ -590,6 +590,7 @@ $self->{texts} = { 'Create a new group' => 'Neue Benutzergruppe erfassen', 'Create a new payment term' => 'Neue Zahlungsbedingungen anlegen', 'Create a new predefined text' => 'Einen neuen vordefinierten Textblock anlegen', + 'Create a new price rule' => 'Neue Preisregel anlegen', 'Create a new printer' => 'Einen neuen Drucker anlegen', 'Create a new project' => 'Neues Projekt anlegen', 'Create a new project and link to it.' => 'Neues Projekt anlegen und damit verknüpfen.', @@ -984,6 +985,7 @@ $self->{texts} = { 'Edit payment term' => 'Zahlungsbedingungen bearbeiten', 'Edit picture' => 'Bild bearbeiten', 'Edit predefined text' => 'Vordefinierten Textblock bearbeiten', + 'Edit price rule' => 'Preisregel bearbeiten', 'Edit prices and discount (if not used, textfield is ONLY set readonly)' => 'Preise und Rabatt in Formularen frei anpassen (falls deaktiviert, wird allerdings NUR das textfield auf READONLY gesetzt / kann je nach Browserversion und technischen Fähigkeiten des Anwenders noch umgangen werden)', 'Edit project' => 'Projekt bearbeiten', 'Edit project #1' => 'Projekt #1 bearbeiten', @@ -1540,7 +1542,8 @@ $self->{texts} = { 'Net amount (for verification)' => 'Nettobetrag (zur Überprüfung)', 'Netto Terms' => 'Zahlungsziel netto', 'New Password' => 'Neues Passwort', - 'New Price Rule' => 'Neue Preisregel', + 'New Purchase Price Rule' => 'Neue Einkaufspreisregel', + 'New Sales Price Rule' => 'Neue Verkaufspreisregel', 'New assembly' => 'Neues Erzeugnis', 'New bank account' => 'Neues Bankkonto', 'New client #1: The database configuration fields "host", "port", "name" and "user" must not be empty.' => 'Neuer Mandant #1: Die Datenbankkonfigurationsfelder "Host", "Port" und "Name" dürfen nicht leer sein.', diff --git a/menus/erp.ini b/menus/erp.ini index c2559d367..bce61f9a9 100644 --- a/menus/erp.ini +++ b/menus/erp.ini @@ -46,18 +46,10 @@ ACCESS=part_service_assembly_edit module=ic.pl action=search_update_prices -[Master Data--Sales Price Rules ] +[Master Data--Price Rules] ACCESS=part_service_assembly_edit module=controller.pl action=PriceRule/list -filter.type=customer -filter.obsolete=0 - -[Master Data--Purchase Price Rules ] -ACCESS=part_service_assembly_edit -module=controller.pl -action=PriceRule/list -filter.type=vendor filter.obsolete=0 [Master Data--Reports] diff --git a/templates/webpages/price_rule/_filter.html b/templates/webpages/price_rule/_filter.html index 8dc346d36..93d18636e 100644 --- a/templates/webpages/price_rule/_filter.html +++ b/templates/webpages/price_rule/_filter.html @@ -14,22 +14,22 @@ [% 'Description' | $T8 %] [% L.input_tag('filter.name:substr::ilike', filter.name_substr__ilike, size = 20, style='width: 300px') %] + + [% 'Type' | $T8 %] + [% L.select_tag('filter.type', [ [ 'customer', LxERP.t8('Sales Price Rules '), ] [ 'vendor', LxERP.t8('Purchase Price Rules ') ] ], with_empty=1, default=filter.type, id='price_rule_filter_type', style='width: 300px') %] + [% 'Part' | $T8 %] [% L.part_picker('filter.item_type_matches[].part', FORM.filter.item_type_matches.0.part, style='width: 300px') %] -[%- IF SELF.vc == 'customer' %] - + [% 'Customer' | $T8 %] - [% L.customer_vendor_picker('filter.item_type_matches[].customer', FORM.filter.item_type_matches.0.customer, type='customer', style='width: 300px') %] + [% L.customer_vendor_picker('filter.item_type_matches[].customer', FORM.filter.item_type_matches.0.customer, type='customer', id='price_rule_filter_customer', style='width: 300px') %] -[%- END %] -[%- IF SELF.vc == 'vendor' %] - + [% 'Vendor' | $T8 %] - [% L.customer_vendor_picker('filter.item_type_matches[].vendor', FORM.filter.item_type_matches.0.vendor, type='vendor', style='width: 300px') %] + [% L.customer_vendor_picker('filter.item_type_matches[].vendor', FORM.filter.item_type_matches.0.vendor, type='vendor', id='price_rule_filter_vendor', style='width: 300px') %] -[%- END %] [% 'Business' | $T8 %] [% L.select_tag('filter.item_type_matches[].business', SELF.businesses, title_key='description', default=FORM.filter.item_type_matches.0.business, with_empty=1, style='width: 300px') %] @@ -87,13 +87,12 @@ [% L.hidden_tag('action', 'PriceRule/dispatch') %] -[% L.hidden_tag('filter.type', FORM.filter.type) %] [% 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')%] +[% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit') %] -[% 'Reset' | $T8 %] +[% 'Reset' | $T8 %] diff --git a/templates/webpages/price_rule/report_bottom.html b/templates/webpages/price_rule/report_bottom.html index 97254866a..f471ab703 100644 --- a/templates/webpages/price_rule/report_bottom.html +++ b/templates/webpages/price_rule/report_bottom.html @@ -4,5 +4,6 @@ [%- L.paginate_controls(models=SELF.models) %] [%- UNLESS FORM.inline %] -[% 'New Price Rule' | $T8 %] +[% 'New Sales Price Rule' | $T8 %] +[% 'New Purchase Price Rule' | $T8 %] [%- END %] -- 2.20.1