Revision 3a707955
Von Jan Büren vor mehr als 9 Jahren hinzugefügt
SL/Controller/DeliveryPlan.pm | ||
---|---|---|
15 | 15 |
|
16 | 16 |
use Rose::Object::MakeMethods::Generic ( |
17 | 17 |
scalar => [ qw(db_args flat_filter) ], |
18 |
'scalar --get_set_init' => [ qw(models all_edit_right mode vc all_employees all_businesses) ],
|
|
18 |
'scalar --get_set_init' => [ qw(models all_edit_right vc all_employees all_businesses) ], |
|
19 | 19 |
); |
20 | 20 |
|
21 | 21 |
__PACKAGE__->run_before(sub { $::auth->assert('delivery_plan'); }); |
... | ... | |
25 | 25 |
description => t8('Description'), |
26 | 26 |
partnumber => t8('Part Number'), |
27 | 27 |
qty => t8('Qty'), |
28 |
unit => t8('Unit'), |
|
29 | 28 |
shipped_qty => t8('shipped'), |
30 | 29 |
delivered_qty => t8('transferred in / out'), |
31 | 30 |
not_shipped_qty => t8('not shipped'), |
32 | 31 |
ordnumber => t8('Order'), |
33 | 32 |
customer => t8('Customer'), |
34 | 33 |
vendor => t8('Vendor'), |
35 |
value_of_goods => t8('Value of transferred goods'), |
|
36 | 34 |
); |
37 | 35 |
|
38 | 36 |
|
... | ... | |
52 | 50 |
my ($self) = @_; |
53 | 51 |
|
54 | 52 |
my $vc = $self->vc; |
55 |
my $mode = $self->mode; |
|
56 | 53 |
my $report = SL::ReportGenerator->new(\%::myconfig, $::form); |
57 |
my $csv_option = $::form->{report_generator_output_format}; |
|
58 | 54 |
$self->{report} = $report; |
59 | 55 |
|
60 |
my @columns = qw(reqdate customer vendor ordnumber partnumber description qty shipped_qty not_shipped_qty delivered_qty value_of_goods);
|
|
56 |
my @columns = qw(reqdate customer vendor ordnumber partnumber description qty shipped_qty not_shipped_qty delivered_qty); |
|
61 | 57 |
|
62 | 58 |
my @sortable = qw(reqdate customer vendor ordnumber partnumber description); |
63 |
my $rp_csv_mod = ($csv_option eq 'CSV' && $mode eq 'delivery_value_report') ? 1 : ''; |
|
64 | 59 |
|
65 | 60 |
my %column_defs = ( |
66 | 61 |
reqdate => { sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date } }, |
... | ... | |
68 | 63 |
obj_link => sub { $self->link_to($_[0]->part) } }, |
69 | 64 |
partnumber => { sub => sub { $_[0]->part->partnumber }, |
70 | 65 |
obj_link => sub { $self->link_to($_[0]->part) } }, |
71 |
qty => { sub => sub { $_[0]->qty_as_number . |
|
72 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, |
|
73 |
unit => { sub => sub { $_[0]->unit }, |
|
74 |
visible => $rp_csv_mod }, |
|
75 |
shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]{shipped_qty}, 2) . |
|
76 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, |
|
77 |
not_shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]{shipped_qty}, 2) . |
|
78 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, |
|
79 |
delivered_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]{delivered_qty}, 2) . |
|
80 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } }, |
|
66 |
qty => { sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit } }, |
|
67 |
shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]{shipped_qty}, 2) . ' ' . $_[0]->unit } }, |
|
68 |
not_shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]{shipped_qty}, 2) . ' ' . $_[0]->unit } }, |
|
69 |
delivered_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]{delivered_qty}, 2) .' ' . $_[0]->unit } }, |
|
81 | 70 |
ordnumber => { sub => sub { $_[0]->order->ordnumber }, |
82 | 71 |
obj_link => sub { $self->link_to($_[0]->order) } }, |
83 | 72 |
vendor => { sub => sub { $_[0]->order->vendor->name }, |
... | ... | |
86 | 75 |
customer => { sub => sub { $_[0]->order->customer->name }, |
87 | 76 |
visible => $vc eq 'customer', |
88 | 77 |
obj_link => sub { $self->link_to($_[0]->order->customer) } }, |
89 |
value_of_goods => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->value_of_goods, 2) . ' ' . $_[0]->taxincluded }, |
|
90 |
visible => $mode eq 'delivery_value_report' }, |
|
91 | 78 |
); |
92 | 79 |
|
93 | 80 |
$column_defs{$_}->{text} = $sort_columns{$_} for keys %column_defs; |
... | ... | |
96 | 83 |
std_column_visibility => 1, |
97 | 84 |
controller_class => 'DeliveryPlan', |
98 | 85 |
output_format => 'HTML', |
99 |
top_info_text => ($vc eq 'customer') ? (($mode eq 'delivery_plan') ? $::locale->text('Delivery Plan for currently outstanding sales orders') : |
|
100 |
$::locale->text('Delivery Value Report for currently open sales orders')) : |
|
101 |
($mode eq 'delivery_value_report') ? $::locale->text('Delivery Value Report for currently outstanding purchase orders') : |
|
86 |
top_info_text => ($vc eq 'customer') ? $::locale->text('Delivery Plan for currently outstanding sales orders') : |
|
102 | 87 |
$::locale->text('Delivery Plan for currently outstanding purchase orders'), |
103 |
title => ($mode eq 'delivery_plan') ? $::locale->text('Delivery Plan') : $::locale->text('Delivery Value Report'),
|
|
88 |
title => $::locale->text('Delivery Plan'),
|
|
104 | 89 |
allow_pdf_export => 1, |
105 | 90 |
allow_csv_export => 1, |
106 | 91 |
); |
107 | 92 |
$report->set_columns(%column_defs); |
108 | 93 |
$report->set_column_order(@columns); |
109 |
$report->set_export_options(qw(list filter vc mode));
|
|
94 |
$report->set_export_options(qw(list filter vc)); |
|
110 | 95 |
$report->set_options_from_form; |
111 | 96 |
$self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i; |
112 | 97 |
$self->models->finalize; # for filter laundering |
... | ... | |
152 | 137 |
sub make_filter_summary { |
153 | 138 |
my ($self) = @_; |
154 | 139 |
my $vc = $self->vc; |
155 |
my $mode = $self->mode; |
|
156 | 140 |
my ($business, $employee); |
157 | 141 |
|
158 | 142 |
my $filter = $::form->{filter} || {}; |
... | ... | |
197 | 181 |
sub delivery_plan_query { |
198 | 182 |
my ($self) = @_; |
199 | 183 |
my $vc = $self->vc; |
200 |
my $mode = $self->mode; |
|
201 | 184 |
my $employee_id = SL::DB::Manager::Employee->current->id; |
202 | 185 |
my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND"; |
203 | 186 |
# check delivered state for delivery_orders (transferred out) if enabled |
204 |
# OR if we are delivery_value_report mode |
|
205 |
my $filter_delivered = ($::instance_conf->get_delivery_plan_calculate_transferred_do || |
|
206 |
$mode eq 'delivery_value_report' ) ? |
|
207 |
"AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : ''; |
|
208 |
# Show ALL open orders in delivery_value_report mode |
|
209 |
my $comment_show_all_open_orders = ($mode eq 'delivery_value_report' ) ? "-- " : ""; |
|
187 |
my $filter_delivered = ($::instance_conf->get_delivery_plan_calculate_transferred_do) ? |
|
188 |
"AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : ''; |
|
210 | 189 |
[ |
211 | 190 |
"order.${vc}_id" => { gt => 0 }, |
212 | 191 |
'order.closed' => 0, |
... | ... | |
299 | 278 |
FROM record_links rl |
300 | 279 |
WHERE oi.trans_id = rl.from_id AND rl.from_table = 'oe' AND rl.to_table = 'delivery_orders' |
301 | 280 |
) AND |
302 |
$comment_show_all_open_orders coalesce(sum, 0) < oi.qty AND
|
|
281 |
coalesce(sum, 0) < oi.qty AND |
|
303 | 282 |
oe.${vc}_id IS NOT NULL AND |
304 | 283 |
$oe_owner |
305 | 284 |
(oe.quotation = 'f' OR oe.quotation IS NULL) AND NOT oe.closed |
... | ... | |
310 | 289 |
sub init_models { |
311 | 290 |
my ($self) = @_; |
312 | 291 |
my $vc = $self->vc; |
313 |
my $mode = $self->mode; |
|
292 |
|
|
314 | 293 |
SL::Controller::Helper::GetModels->new( |
315 |
controller => $self,
|
|
316 |
model => 'OrderItem',
|
|
317 |
sorted => {
|
|
318 |
_default => {
|
|
319 |
by => 'reqdate',
|
|
320 |
dir => 1,
|
|
294 |
controller => $self, |
|
295 |
model => 'OrderItem', |
|
296 |
sorted => { |
|
297 |
_default => { |
|
298 |
by => 'reqdate', |
|
299 |
dir => 1, |
|
321 | 300 |
}, |
322 | 301 |
%sort_columns, |
323 | 302 |
}, |
324 |
query => $self->delivery_plan_query,
|
|
325 |
with_objects => [ 'order', "order.$vc", 'part' ],
|
|
326 |
additional_url_params => { vc => $vc, mode => $mode},
|
|
303 |
query => $self->delivery_plan_query, |
|
304 |
with_objects => [ 'order', "order.$vc", 'part' ], |
|
305 |
additional_url_params => { vc => $vc}, |
|
327 | 306 |
); |
328 | 307 |
} |
329 | 308 |
|
... | ... | |
333 | 312 |
sub init_vc { |
334 | 313 |
return $::form->{vc} if ($::form->{vc} eq 'customer' || $::form->{vc} eq 'vendor') || croak "self (DeliveryPlan) has no vc defined"; |
335 | 314 |
} |
336 |
sub init_mode { |
|
337 |
return $::form->{mode} if ($::form->{mode} eq 'delivery_value_report' || $::form->{mode} eq 'delivery_plan') || croak "self (DeliveryPlan) has no mode defined"; |
|
338 |
} |
|
339 | 315 |
|
340 | 316 |
sub init_all_employees { |
341 | 317 |
return SL::DB::Manager::Employee->get_all_sorted; |
Auch abrufbar als: Unified diff
Lieferplan Modus Lieferwertbericht entfernt
Der Modus ist jetzt unnötig, da der Lieferwertbericht einen
eigenen Controller hat.