From: Bernd Bleßmann Date: Fri, 28 Feb 2014 11:53:23 +0000 (+0100) Subject: Preisgruppenpreise als Preisliste bei Kunden anzeigen X-Git-Tag: release-3.5.6.1~490 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ffe5434804888bf520dd69832d0f74d89bcf9999;p=kivitendo-erp.git Preisgruppenpreise als Preisliste bei Kunden anzeigen Wenn dem Kunden eine Preisgruppe zugeordnet ist, werden die Preise in den Kundenstammdaten als Preisliste (eigener Tab) angezeigt. --- diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index c8fd5fd9c..63b822eec 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -22,6 +22,7 @@ use SL::DB::TaxZone; use SL::DB::Note; use SL::DB::PaymentTerm; use SL::DB::Pricegroup; +use SL::DB::Price; use SL::DB::Contact; use SL::DB::FollowUp; use SL::DB::FollowUpLink; @@ -69,6 +70,7 @@ __PACKAGE__->run_before( 'update', 'ajaj_get_shipto', 'ajaj_get_contact', + 'ajax_list_prices', ] ); @@ -660,6 +662,62 @@ sub action_test_page { $_[0]->render('customer_vendor/test_page'); } +sub action_ajax_list_prices { + my ($self, %params) = @_; + + my $report = SL::ReportGenerator->new(\%::myconfig, $::form); + my @columns = qw(partnumber description price); + my @visible = qw(partnumber description price); + my @sortable = qw(partnumber description price); + + my %column_defs = ( + partnumber => { text => $::locale->text('Part Number'), sub => sub { $_[0]->parts->partnumber } }, + description => { text => $::locale->text('Part Description'), sub => sub { $_[0]->parts->description } }, + price => { text => $::locale->text('Price'), sub => sub { $::form->format_amount(\%::myconfig, $_[0]->price, 2) }, align => 'right' }, + ); + + $::form->{sort_by} ||= 'partnumber'; + $::form->{sort_dir} //= 1; + + for my $col (@sortable) { + $column_defs{$col}{link} = $self->url_for( + action => 'ajax_list_prices', + callback => $::form->{callback}, + db => $::form->{db}, + id => $self->{cv}->id, + sort_by => $col, + sort_dir => ($::form->{sort_by} eq $col ? 1 - $::form->{sort_dir} : $::form->{sort_dir}) + ); + } + + map { $column_defs{$_}{visible} = 1 } @visible; + + my $pricegroup; + $pricegroup = $self->{cv}->pricegroup->pricegroup if $self->{cv}->pricegroup; + + $report->set_columns(%column_defs); + $report->set_column_order(@columns); + $report->set_options(allow_pdf_export => 0, allow_csv_export => 0); + $report->set_sort_indicator($::form->{sort_by}, $::form->{sort_dir}); + $report->set_export_options(@{ $params{report_generator_export_options} || [] }); + $report->set_options( + %{ $params{report_generator_options} || {} }, + output_format => 'HTML', + top_info_text => $::locale->text('Pricegroup') . ': ' . $pricegroup, + title => $::locale->text('Price List'), + ); + + my $sort_param = $::form->{sort_by} eq 'price' ? 'price' : + $::form->{sort_by} eq 'description' ? 'parts.description' : + 'parts.partnumber'; + $sort_param .= ' ' . ($::form->{sort_dir} ? 'ASC' : 'DESC'); + my $prices = SL::DB::Manager::Price->get_all(where => [ pricegroup_id => $self->{cv}->pricegroup_id ], + sort_by => $sort_param, + with_objects => 'parts'); + + $self->report_generator_list_objects(report => $report, objects => $prices, layout => 0, header => 0); +} + sub is_vendor { return $::form->{db} eq 'vendor'; } diff --git a/doc/changelog b/doc/changelog index 6013a4f0a..f138d21c3 100644 --- a/doc/changelog +++ b/doc/changelog @@ -29,6 +29,11 @@ Kleinere neue Features und Detailverbesserungen: - Mahnungen nach Abteilung filtern +- Anzeige einer Kundenpreisliste in den Kundenstammdaten als Reiter. + Hier werden die Preisgruppenpreise angezeigt, falls einem Kunden eine + Preisgruppe zugeordnet ist. + + 2019-08-07 - Release 3.5.4 diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index 2bef3a771..2c192872a 100644 --- a/js/kivi.CustomerVendor.js +++ b/js/kivi.CustomerVendor.js @@ -455,7 +455,39 @@ namespace('kivi.CustomerVendor', function(ns) { ns.reinit_widgets(); } + ns.get_price_report = function(target, source, data) { + $.ajax({ + url: source, + success: function (rsp) { + $(target).html(rsp); + $(target).find('a.report-generator-header-link').click(function(event){ ns.price_report_redirect_event(event, target) }); + }, + }); + }; + + ns.price_report_redirect_event = function (event, target) { + event.preventDefault(); + ns.get_price_report(target, event.target + ''); + }; + + ns.price_list_init = function () { + $("#customer_vendor_tabs").on('tabsbeforeactivate', function(event, ui){ + if (ui.newPanel.attr('id') == 'price_list') { + ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val()); + } + return 1; + }); + + $("#customer_vendor_tabs").on('tabscreate', function(event, ui){ + if (ui.panel.attr('id') == 'price_list') { + ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val()); + } + return 1; + }); + } + $(function(){ ns.init(); + ns.price_list_init(); }); }); diff --git a/locale/de/all b/locale/de/all index 91d3e5889..918a7882f 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2387,6 +2387,7 @@ $self->{texts} = { 'Price #1' => 'Preis #1', 'Price Factor' => 'Preisfaktor', 'Price Factors' => 'Preisfaktoren', + 'Price List' => 'Preisliste', 'Price Rule' => 'Preisregel', 'Price Rules' => 'Preisregeln', 'Price Source' => 'Preisquelle', diff --git a/locale/en/all b/locale/en/all index b94f20daf..2a137534b 100644 --- a/locale/en/all +++ b/locale/en/all @@ -2387,6 +2387,7 @@ $self->{texts} = { 'Price #1' => '', 'Price Factor' => '', 'Price Factors' => '', + 'Price List' => '', 'Price Rule' => '', 'Price Rules' => '', 'Price Source' => '', diff --git a/templates/webpages/customer_vendor/form.html b/templates/webpages/customer_vendor/form.html index a5c43fbf3..3b461e837 100644 --- a/templates/webpages/customer_vendor/form.html +++ b/templates/webpages/customer_vendor/form.html @@ -37,6 +37,10 @@
  • [% 'Price Rules' | $T8 %]
  • [% END %] + [% IF ( SELF.cv.id && SELF.cv.pricegroup_id && AUTH.assert('part_service_assembly_details', 1) ) %] +
  • [% 'Price List' | $T8 %]
  • + [% END %] + [% IF SELF.cv.id %] [% IF ( FORM.db == 'customer' && AUTH.assert('show_extra_record_tab_customer',1) ) %]
  • [% LxERP.t8('Records') %] @@ -66,6 +70,9 @@ [% IF SELF.cv.id %] [% PROCESS "customer_vendor/tabs/price_rules.html" %] [% END %] + [% IF ( SELF.cv.id && SELF.cv.pricegroup_id && AUTH.assert('part_service_assembly_details', 1) ) %] + [% PROCESS "customer_vendor/tabs/price_list.html" %] + [% END %] diff --git a/templates/webpages/customer_vendor/tabs/price_list.html b/templates/webpages/customer_vendor/tabs/price_list.html new file mode 100644 index 000000000..e8fabf57c --- /dev/null +++ b/templates/webpages/customer_vendor/tabs/price_list.html @@ -0,0 +1,8 @@ +[%- USE T8 %] +[%- USE LxERP %] +[%- USE HTML %] +[%- USE L %] + +
    + [%- LxERP.t8("Loading...") %] +