Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 404d9b0a

Von Moritz Bunkus vor mehr als 8 Jahren hinzugefügt

  • ID 404d9b0abcb5019e99812e1c4121140aff64e292
  • Vorgänger b6d9b143
  • Nachfolger c4dd4a4d

Verkaufspreisinformationen: Preisentwicklung der Stammdaten anzeigen

Unterschiede anzeigen:

SL/Controller/PartsPriceHistory.pm
1
package SL::Controller::PartsPriceHistory;
2

  
3
use strict;
4
use parent qw(SL::Controller::Base);
5

  
6
use Clone qw(clone);
7
use SL::DB::PartsPriceHistory;
8
use SL::Controller::Helper::ParseFilter;
9
use SL::Controller::Helper::ReportGenerator;
10

  
11
sub action_list {
12
  my ($self) = @_;
13
  $self->{action} = 'list';
14

  
15
  my %list_params = (
16
    sort_by  => $::form->{sort_by} || 'valid_from',
17
    sort_dir => $::form->{sort_dir},
18
    filter   => $::form->{filter},
19
    page     => $::form->{page},
20
  );
21

  
22
  my $db_args    = $self->setup_for_list(%list_params);
23
  $self->{pages} = SL::DB::Manager::PartsPriceHistory->paginate(%list_params, args => $db_args, per_page => 5);
24

  
25
  my $bottom     = $::form->parse_html_template('parts_price_history/report_bottom', { SELF => $self });
26

  
27
  $self->prepare_report(
28
    db_args                  => $db_args,
29
    report_generator_options => {
30
      raw_bottom_info_text => $bottom,
31
      controller_class     => 'PartsPriceHistory',
32
    },
33
  );
34

  
35
  my $history = SL::DB::Manager::PartsPriceHistory->get_all(%{ $db_args });
36

  
37
  $self->report_generator_list_objects(
38
    report  => $self->{report},
39
    objects => $history,
40
    layout  => 0,
41
    header  => 0,
42
  );
43
}
44

  
45
# private functions
46

  
47
sub setup_for_list {
48
  my ($self, %params) = @_;
49

  
50
  $self->{filter} = clone($params{filter});
51

  
52
  my %args = (
53
    parse_filter($self->{filter}),
54
    sort_by => $self->set_sort_params(%params),
55
    page    => $params{page},
56
  );
57

  
58
  return \%args;
59
}
60

  
61
sub set_sort_params {
62
  my ($self, %params) = @_;
63

  
64
  my $sort_str;
65
  ($self->{sort_by}, $self->{sort_dir}, $sort_str) = SL::DB::Manager::PartsPriceHistory->make_sort_string(%params);
66
  return $sort_str;
67
}
68

  
69
sub column_defs {
70
  my ($self) = @_;
71

  
72
  return {
73
    valid_from => { text => $::locale->text('Date'),       sub => sub { $_[0]->valid_from_as_timestamp }},
74
    lastcost   => { text => $::locale->text('Lastcost'),   sub => sub { $_[0]->lastcost_as_number }},
75
    listprice  => { text => $::locale->text('List Price'), sub => sub { $_[0]->listprice_as_number }},
76
    sellprice  => { text => $::locale->text('Sell Price'), sub => sub { $_[0]->sellprice_as_number }},
77
  };
78
}
79

  
80
sub prepare_report {
81
  my ($self, %params) = @_;
82

  
83
  my $objects     = $params{objects} || [];
84
  my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
85
  $self->{report} = $report;
86

  
87
  my $title       = $::locale->text('Price history for master data');
88

  
89
  my @columns     = qw(valid_from lastcost listprice sellprice);
90

  
91
  my $column_defs = $self->column_defs;
92

  
93
  for my $col (@columns) {
94
    $column_defs->{$col}{link} = $self->self_url(
95
      sort_by  => $col,
96
      sort_dir => ($self->{sort_by} eq $col ? 1 - $self->{sort_dir} : $self->{sort_dir}),
97
      page     => $self->{pages}{cur},
98
    );
99
  }
100

  
101
  $column_defs->{$_}{visible} = 1 for @columns;
102

  
103
  $report->set_columns(%$column_defs);
104
  $report->set_column_order(@columns);
105
  $report->set_options(allow_pdf_export => 0, allow_csv_export => 0);
106
  $report->set_sort_indicator($self->{sort_by}, $self->{sort_dir});
107
  $report->set_export_options(@{ $params{report_generator_export_options} || [] });
108
  $report->set_options(
109
    %{ $params{report_generator_options} || {} },
110
    output_format => 'HTML',
111
    top_info_text => $self->displayable_filter($::form->{filter}),
112
    title         => $title,
113
  );
114
  $report->set_options_from_form;
115
}
116

  
117
sub displayable_filter {
118
  my ($self, $filter) = @_;
119

  
120
  my $column_defs = $self->column_defs;
121
  my @texts;
122

  
123
  push @texts, [ $::locale->text('Sort By'), $column_defs->{$self->{sort_by}}{text}  ] if $column_defs->{$self->{sort_by}}{text};
124
  push @texts, [ $::locale->text('Page'),    $::locale->text($self->{pages}{cur})    ] if $self->{pages}{cur} > 1;
125

  
126
  return join '; ', map { "$_->[0]: $_->[1]" } @texts;
127
}
128

  
129
sub self_url {
130
  my ($self, %params) = @_;
131

  
132
  %params = (
133
    action   => $self->{action},
134
    sort_by  => $self->{sort_by},
135
    sort_dir => $self->{sort_dir},
136
    page     => $self->{pages}{cur},
137
    filter   => $::form->{filter},
138
    %params,
139
  );
140

  
141
  return $self->url_for(%params);
142
}
143

  
144
1;
SL/DB/Manager/PartsPriceHistory.pm
4 4

  
5 5
use parent qw(SL::DB::Helper::Manager);
6 6

  
7
use SL::DB::Helper::Sorted;
8
use SL::DB::Helper::Paginated;
9

  
7 10
sub object_class { 'SL::DB::PartsPriceHistory' }
8 11

  
9 12
__PACKAGE__->make_manager_methods;
10 13

  
14
sub _sort_spec {
15
  (
16
    default  => [ 'valid_from', 0 ],
17
    columns  => {
18
      SIMPLE => 'ALL',
19
    },
20
  );
21
}
22

  
11 23
1;
SL/DB/PartsPriceHistory.pm
1
# This file has been auto-generated only because it didn't exist.
2
# Feel free to modify it at will; it will not be overwritten automatically.
3

  
4 1
package SL::DB::PartsPriceHistory;
5 2

  
6 3
use strict;
locale/de/all
2096 2096
  'Price group'                 => 'Preisgruppe',
2097 2097
  'Price group (database ID)'   => 'Preisgruppe (Datenbank-ID)',
2098 2098
  'Price group (name)'          => 'Preisgruppe (Name) ',
2099
  'Price history for master data' => 'Preisentwicklung für Stammdaten',
2099 2100
  'Price information'           => 'Preisinformation',
2100 2101
  'Price or discount must not be zero.' => 'Preis/Rabatt darf nicht 0,00 sein',
2101 2102
  'Price rules must have at least one rule.' => 'Preisregeln brauchen mindestens eine Bedingung.',
templates/webpages/ic/sales_price_information.html
1 1
<div id='sales_price_information_sales_order'></div>
2 2
<div id='sales_price_information_sales_quotation'></div>
3
<div id='parts_price_history'></div>
3 4

  
4 5
<script type='text/javascript'>
5 6
  function get_report(target, source, data){
......
24 25
    if (ui.newPanel.attr('id') == 'sales_price_information') {
25 26
      get_report('#sales_price_information_sales_order', 'controller.pl', { action: 'SellPriceInformation/list', 'filter.part.id': [% id %], 'filter.order.type': 'sales_order' });
26 27
      get_report('#sales_price_information_sales_quotation', 'controller.pl', { action: 'SellPriceInformation/list', 'filter.part.id': [% id %], 'filter.order.type': 'sales_quotation' });
28
      get_report('#parts_price_history', 'controller.pl', { action: 'PartsPriceHistory/list', 'filter.part_id': [% id %] });
27 29
    }
28 30
    return 1;
29 31
  });
templates/webpages/parts_price_history/report_bottom.html
1
<p align=right>[% PROCESS 'common/paginate.html' pages=SELF.pages, base_url=SELF.self_url %]</p>

Auch abrufbar als: Unified diff