Revision 217751ab
Von Sven Schöling vor mehr als 12 Jahren hinzugefügt
SL/Controller/SellPriceInformation.pm | ||
---|---|---|
20 | 20 |
); |
21 | 21 |
|
22 | 22 |
my $db_args = $self->setup_for_list(%list_params); |
23 |
$self->{pages} = SL::DB::Manager::OrderItem->paginate(%list_params, args => $db_args, per_page => 5);
|
|
23 |
$self->{pages} = SL::DB::Manager::OrderItem->paginate(%list_params, args => $db_args, per_page => 10);
|
|
24 | 24 |
|
25 | 25 |
my $bottom = $::form->parse_html_template('price_information/report_bottom', { SELF => $self }); |
26 | 26 |
|
... | ... | |
51 | 51 |
page => $params{page}, |
52 | 52 |
); |
53 | 53 |
|
54 |
# $args{query} = [ @{ $args{query} || [] } ]; |
|
55 |
|
|
56 | 54 |
return \%args; |
57 | 55 |
} |
58 | 56 |
|
... | ... | |
64 | 62 |
return $sort_str; |
65 | 63 |
} |
66 | 64 |
|
65 |
sub column_defs { |
|
66 |
my ($self) = @_; |
|
67 |
return { |
|
68 |
transdate => { text => $::locale->text('Date'), |
|
69 |
sub => sub { $_[0]->order->transdate_as_date }}, |
|
70 |
ordnumber => { text => $::locale->text('Number'), |
|
71 |
sub => sub { $_[0]->order->ordnumber }, |
|
72 |
obj_link => sub { $self->link_to($_[0]->order) }}, |
|
73 |
customer => { text => $::locale->text('Customer'), |
|
74 |
sub => sub { $_[0]->order->customer->name }, |
|
75 |
obj_link => sub { $self->link_to($_[0]->order->customer) }}, |
|
76 |
customer => { text => $::locale->text('Customer'), |
|
77 |
sub => sub { $_[0]->order->customer->name }, |
|
78 |
obj_link => sub { $self->link_to($_[0]->order->customer) }}, |
|
79 |
ship => { text => $::locale->text('Delivered'), |
|
80 |
sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty) . ' ' . $_[0]->unit }}, |
|
81 |
qty => { text => $::locale->text('Qty'), |
|
82 |
sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit }}, |
|
83 |
sellprice => { text => $::locale->text('Sell Price'), |
|
84 |
sub => sub { $_[0]->sellprice_as_number }}, |
|
85 |
discount => { text => $::locale->text('Discount'), |
|
86 |
sub => sub { $_[0]->discount_as_percent . "%" }}, |
|
87 |
amount => { text => $::locale->text('Amount'), |
|
88 |
sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty * $_[0]->sellprice * (1 - $_[0]->discount), 2) }}, |
|
89 |
}; |
|
90 |
} |
|
91 |
|
|
67 | 92 |
sub prepare_report { |
68 | 93 |
my ($self, %params) = @_; |
69 | 94 |
|
... | ... | |
75 | 100 |
my @visible = qw(transdate ordnumber customer ship qty sellprice discount amount); |
76 | 101 |
my @sortable = qw(transdate ordnumber customer sellprice discount ); |
77 | 102 |
|
78 |
my %column_defs = ( |
|
79 |
transdate => { text => $::locale->text('Date'), |
|
80 |
sub => sub { $_[0]->order->transdate_as_date }}, |
|
81 |
ordnumber => { text => $::locale->text('Number'), |
|
82 |
sub => sub { $_[0]->order->ordnumber }, |
|
83 |
obj_link => sub { $self->link_to($_[0]->order) }}, |
|
84 |
customer => { text => $::locale->text('Customer'), |
|
85 |
sub => sub { $_[0]->order->customer->name }, |
|
86 |
obj_link => sub { $self->link_to($_[0]->order->customer) }}, |
|
87 |
customer => { text => $::locale->text('Customer'), |
|
88 |
sub => sub { $_[0]->order->customer->name }, |
|
89 |
obj_link => sub { $self->link_to($_[0]->order->customer) }}, |
|
90 |
ship => { text => $::locale->text('Delivered'), |
|
91 |
sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty) . ' ' . $_[0]->unit }}, |
|
92 |
qty => { text => $::locale->text('Qty'), |
|
93 |
sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit }}, |
|
94 |
sellprice => { text => $::locale->text('Sell Price'), |
|
95 |
sub => sub { $_[0]->sellprice_as_number }}, |
|
96 |
discount => { text => $::locale->text('Discount'), |
|
97 |
sub => sub { $_[0]->discount_as_percent . "%" }}, |
|
98 |
amount => { text => $::locale->text('Amount'), |
|
99 |
sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty * $_[0]->sellprice * (1 - $_[0]->discount), 2) }}, |
|
100 |
); |
|
103 |
my $column_defs = $self->column_defs; |
|
101 | 104 |
|
102 | 105 |
for my $col (@sortable) { |
103 |
$column_defs{$col}{link} = $self->self_url( |
|
106 |
$column_defs->{$col}{link} = $self->self_url(
|
|
104 | 107 |
sort_by => $col, |
105 | 108 |
sort_dir => ($self->{sort_by} eq $col ? 1 - $self->{sort_dir} : $self->{sort_dir}), |
106 | 109 |
page => $self->{pages}{cur}, |
107 | 110 |
); |
108 | 111 |
} |
109 | 112 |
|
110 |
map { $column_defs{$_}->{visible} = 1 } @visible;
|
|
113 |
map { $column_defs->{$_}{visible} = 1 } @visible;
|
|
111 | 114 |
|
112 |
$report->set_columns(%column_defs); |
|
115 |
$report->set_columns(%$column_defs);
|
|
113 | 116 |
$report->set_column_order(@columns); |
114 | 117 |
$report->set_options(allow_pdf_export => 0, allow_csv_export => 0); |
115 | 118 |
$report->set_sort_indicator(%params); |
... | ... | |
117 | 120 |
$report->set_options( |
118 | 121 |
%{ $params{report_generator_options} || {} }, |
119 | 122 |
output_format => 'HTML', |
120 |
top_info_text => $::locale->text('Sales Price Information'),
|
|
123 |
top_info_text => $self->displayable_filter($::form->{filter}),
|
|
121 | 124 |
title => $::locale->text('Sales Price information'), |
122 | 125 |
); |
123 | 126 |
$report->set_options_from_form; |
124 | 127 |
|
125 | 128 |
$self->{report_data} = { |
126 |
column_defs => \%column_defs,
|
|
129 |
column_defs => $column_defs,
|
|
127 | 130 |
columns => \@columns, |
128 | 131 |
visible => \@visible, |
129 | 132 |
sortable => \@sortable, |
... | ... | |
179 | 182 |
return $filter; |
180 | 183 |
} |
181 | 184 |
|
185 |
sub displayable_filter { |
|
186 |
my ($self, $filter) = @_; |
|
187 |
|
|
188 |
my $column_defs = $self->column_defs; |
|
189 |
my @texts; |
|
190 |
|
|
191 |
push @texts, [ $::locale->text('Type'), $::locale->text($filter->{order}{type}) ] if $filter->{order}{type}; |
|
192 |
push @texts, [ $::locale->text('Sort By'), $column_defs->{$self->{sort_by}}{text} ] if $column_defs->{$self->{sort_by}}{text}; |
|
193 |
push @texts, [ $::locale->text('Page'), $::locale->text($self->{pages}{cur}) ] if $self->{pages}{cur} != 1; |
|
194 |
|
|
195 |
return join '; ', map { "$_->[0]: $_->[1]" } @texts; |
|
196 |
} |
|
197 |
|
|
182 | 198 |
sub self_url { |
183 | 199 |
my ($self, %params) = @_; |
184 | 200 |
%params = ( |
185 | 201 |
action => $self->{action}, |
186 |
sort_by => $self->{sort}, |
|
202 |
sort_by => $self->{sort_by},
|
|
187 | 203 |
sort_dir => $self->{sort_dir}, |
188 | 204 |
page => $self->{pages}{cur}, |
189 | 205 |
filter => $::form->{filter}, |
Auch abrufbar als: Unified diff
displayable_filter