Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ffe54348

Von Bernd Bleßmann vor etwa 5 Jahren hinzugefügt

  • ID ffe5434804888bf520dd69832d0f74d89bcf9999
  • Vorgänger c75c19ad
  • Nachfolger 14fd13cd

Preisgruppenpreise als Preisliste bei Kunden anzeigen

Wenn dem Kunden eine Preisgruppe zugeordnet ist, werden die Preise in
den Kundenstammdaten als Preisliste (eigener Tab) angezeigt.

Unterschiede anzeigen:

SL/Controller/CustomerVendor.pm
22 22
use SL::DB::Note;
23 23
use SL::DB::PaymentTerm;
24 24
use SL::DB::Pricegroup;
25
use SL::DB::Price;
25 26
use SL::DB::Contact;
26 27
use SL::DB::FollowUp;
27 28
use SL::DB::FollowUpLink;
......
69 70
    'update',
70 71
    'ajaj_get_shipto',
71 72
    'ajaj_get_contact',
73
    'ajax_list_prices',
72 74
  ]
73 75
);
74 76

  
......
660 662
  $_[0]->render('customer_vendor/test_page');
661 663
}
662 664

  
665
sub action_ajax_list_prices {
666
  my ($self, %params) = @_;
667

  
668
  my $report   = SL::ReportGenerator->new(\%::myconfig, $::form);
669
  my @columns  = qw(partnumber description price);
670
  my @visible  = qw(partnumber description price);
671
  my @sortable = qw(partnumber description price);
672

  
673
  my %column_defs = (
674
    partnumber  => { text => $::locale->text('Part Number'),      sub => sub { $_[0]->parts->partnumber  } },
675
    description => { text => $::locale->text('Part Description'), sub => sub { $_[0]->parts->description } },
676
    price       => { text => $::locale->text('Price'),            sub => sub { $::form->format_amount(\%::myconfig, $_[0]->price, 2) }, align => 'right' },
677
  );
678

  
679
  $::form->{sort_by}  ||= 'partnumber';
680
  $::form->{sort_dir} //= 1;
681

  
682
  for my $col (@sortable) {
683
    $column_defs{$col}{link} = $self->url_for(
684
      action   => 'ajax_list_prices',
685
      callback => $::form->{callback},
686
      db       => $::form->{db},
687
      id       => $self->{cv}->id,
688
      sort_by  => $col,
689
      sort_dir => ($::form->{sort_by} eq $col ? 1 - $::form->{sort_dir} : $::form->{sort_dir})
690
    );
691
  }
692

  
693
  map { $column_defs{$_}{visible} = 1 } @visible;
694

  
695
  my $pricegroup;
696
  $pricegroup = $self->{cv}->pricegroup->pricegroup if $self->{cv}->pricegroup;
697

  
698
  $report->set_columns(%column_defs);
699
  $report->set_column_order(@columns);
700
  $report->set_options(allow_pdf_export => 0, allow_csv_export => 0);
701
  $report->set_sort_indicator($::form->{sort_by}, $::form->{sort_dir});
702
  $report->set_export_options(@{ $params{report_generator_export_options} || [] });
703
  $report->set_options(
704
    %{ $params{report_generator_options} || {} },
705
    output_format        => 'HTML',
706
    top_info_text        => $::locale->text('Pricegroup') . ': ' . $pricegroup,
707
    title                => $::locale->text('Price List'),
708
  );
709

  
710
  my $sort_param = $::form->{sort_by} eq 'price'       ? 'price'             :
711
                   $::form->{sort_by} eq 'description' ? 'parts.description' :
712
                   'parts.partnumber';
713
  $sort_param .= ' ' . ($::form->{sort_dir} ? 'ASC' : 'DESC');
714
  my $prices = SL::DB::Manager::Price->get_all(where        => [ pricegroup_id => $self->{cv}->pricegroup_id ],
715
                                               sort_by      => $sort_param,
716
                                               with_objects => 'parts');
717

  
718
  $self->report_generator_list_objects(report => $report, objects => $prices, layout => 0, header => 0);
719
}
720

  
663 721
sub is_vendor {
664 722
  return $::form->{db} eq 'vendor';
665 723
}
doc/changelog
29 29

  
30 30
- Mahnungen nach Abteilung filtern
31 31

  
32
- Anzeige einer Kundenpreisliste in den Kundenstammdaten als Reiter.
33
  Hier werden die Preisgruppenpreise angezeigt, falls einem Kunden eine
34
  Preisgruppe zugeordnet ist.
35

  
36

  
32 37
2019-08-07 - Release 3.5.4
33 38

  
34 39

  
js/kivi.CustomerVendor.js
455 455
    ns.reinit_widgets();
456 456
  }
457 457

  
458
  ns.get_price_report = function(target, source, data) {
459
    $.ajax({
460
      url:        source,
461
      success:    function (rsp) {
462
        $(target).html(rsp);
463
        $(target).find('a.report-generator-header-link').click(function(event){ ns.price_report_redirect_event(event, target) });
464
      },
465
    });
466
  };
467

  
468
  ns.price_report_redirect_event = function (event, target) {
469
    event.preventDefault();
470
    ns.get_price_report(target, event.target + '');
471
  };
472

  
473
  ns.price_list_init = function () {
474
    $("#customer_vendor_tabs").on('tabsbeforeactivate', function(event, ui){
475
      if (ui.newPanel.attr('id') == 'price_list') {
476
        ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val());
477
      }
478
      return 1;
479
    });
480

  
481
    $("#customer_vendor_tabs").on('tabscreate', function(event, ui){
482
      if (ui.panel.attr('id') == 'price_list') {
483
        ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val());
484
      }
485
      return 1;
486
    });
487
  }
488

  
458 489
  $(function(){
459 490
    ns.init();
491
    ns.price_list_init();
460 492
  });
461 493
});
locale/de/all
2387 2387
  'Price #1'                    => 'Preis #1',
2388 2388
  'Price Factor'                => 'Preisfaktor',
2389 2389
  'Price Factors'               => 'Preisfaktoren',
2390
  'Price List'                  => 'Preisliste',
2390 2391
  'Price Rule'                  => 'Preisregel',
2391 2392
  'Price Rules'                 => 'Preisregeln',
2392 2393
  'Price Source'                => 'Preisquelle',
locale/en/all
2387 2387
  'Price #1'                    => '',
2388 2388
  'Price Factor'                => '',
2389 2389
  'Price Factors'               => '',
2390
  'Price List'                  => '',
2390 2391
  'Price Rule'                  => '',
2391 2392
  'Price Rules'                 => '',
2392 2393
  'Price Source'                => '',
templates/webpages/customer_vendor/form.html
37 37
        <li><a href="#price_rules">[% 'Price Rules' | $T8 %]</a></li>
38 38
      [% END %]
39 39

  
40
      [% IF ( SELF.cv.id && SELF.cv.pricegroup_id && AUTH.assert('part_service_assembly_details', 1) ) %]
41
        <li><a href="#price_list">[% 'Price List' | $T8 %]</a></li>
42
      [% END %]
43

  
40 44
      [% IF SELF.cv.id %]
41 45
        [% IF ( FORM.db == 'customer' && AUTH.assert('show_extra_record_tab_customer',1) ) %]
42 46
          <li><a href="[% 'controller.pl?action=CustomerVendorTurnover/list_turnover&id=' _ SELF.cv.id _ '&db=' _ FORM.db %]">[% LxERP.t8('Records') %]
......
66 70
    [% IF SELF.cv.id %]
67 71
      [% PROCESS "customer_vendor/tabs/price_rules.html" %]
68 72
    [% END %]
73
    [% IF ( SELF.cv.id && SELF.cv.pricegroup_id && AUTH.assert('part_service_assembly_details', 1) ) %]
74
      [% PROCESS "customer_vendor/tabs/price_list.html" %]
75
    [% END %]
69 76
  </div>
70 77
</form>
71 78

  
templates/webpages/customer_vendor/tabs/price_list.html
1
[%- USE T8 %]
2
[%- USE LxERP %]
3
[%- USE HTML %]
4
[%- USE L %]
5

  
6
<div id="price_list">
7
  [%- LxERP.t8("Loading...") %]
8
</div>

Auch abrufbar als: Unified diff