a) keinen Fallunterschied für $vc im Template, sondern ein einfaches hidden flag vc
b) kein copy & paste von action_list(_ap), sondern parameter in erp.ini
c) performanteres grep, statt foreach in OrderItem (Details s.a. devel-liste)
d) my $vc nicht als statische Klassenvariable gesetzt
e) CSV-Export für beide Fälle richtig (filter vc übergeben)
use Rose::Object::MakeMethods::Generic (
scalar => [ qw(db_args flat_filter) ],
- 'scalar --get_set_init' => [ qw(models all_edit_right) ],
+ 'scalar --get_set_init' => [ qw(models all_edit_right vc) ],
);
__PACKAGE__->run_before(sub { $::auth->assert('delivery_plan'); });
value_of_goods => t8('Value of goods'),
);
-my $vc;
sub action_list {
my ($self) = @_;
-
- $vc = "customer";
- $self->make_filter_summary;
- $self->prepare_report;
-
- my $orderitems = $self->models->get;
-
- $self->report_generator_list_objects(report => $self->{report}, objects => $orderitems);
-}
-
-sub action_list_ap {
- my ($self) = @_;
-
- $vc = "vendor";
$self->make_filter_summary;
$self->prepare_report;
sub prepare_report {
my ($self) = @_;
+ my $vc = $self->vc;
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
);
$report->set_columns(%column_defs);
$report->set_column_order(@columns);
- $report->set_export_options(qw(list filter));
+ $report->set_export_options(qw(list filter vc));
$report->set_options_from_form;
$self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
$self->models->finalize; # for filter laundering
sub make_filter_summary {
my ($self) = @_;
+ my $vc = $self->vc;
my $filter = $::form->{filter} || {};
my @filter_strings;
}
sub delivery_plan_query {
+ my ($self) = @_;
+ my $vc = $self->vc;
my $employee_id = SL::DB::Manager::Employee->current->id;
my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND";
# check delivered state for delivery_orders (transferred out) if enabled
sub init_models {
my ($self) = @_;
+ my $vc = $self->vc;
SL::Controller::Helper::GetModels->new(
controller => $self,
sub init_all_edit_right {
$::auth->assert('sales_all_edit', 1)
}
+sub init_vc {
+ return $::form->{vc} || croak "self (DeliveryPlan) has no vc defined";
+}
sub link_to {
my ($self, $object, %params) = @_;
my ($self) = @_;
my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder');
- my @d_orders_delivered;
- foreach (@$d_orders) {
- push (@d_orders_delivered, $_) if $_->delivered;
- }
+ my @d_orders_delivered = grep { $_->delivered } @$d_orders;
my @doi_delivered = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @d_orders_delivered;
sub value_of_goods {
my ($self) = @_;
- my $price_factor = $self->price_factor ? $self->price_factor : 1;
+ my $price_factor = $self->price_factor || 1;
return ($self->qty * $self->sellprice * (1 - $self->discount ) / $price_factor);
}
ACCESS=delivery_plan
module=controller.pl
action=DeliveryPlan/list
+vc=customer
[AR--Reports--Financial Controlling]
ACCESS=sales_order_edit
[AP--Reports--Delivery Plan]
ACCESS=delivery_plan
module=controller.pl
-action=DeliveryPlan/list_ap
+action=DeliveryPlan/list
+vc=vendor
[Warehouse]
</tr>
[% IF vc == 'customer' %]
<tr>
- <th align="right">[% vc | $T8 %]</th>
+ <th align="right">[% Customer | $T8 %]</th>
<td>[% L.input_tag('filter.order.customer.name:substr::ilike', filter.order.customer.name_substr__ilike, size = 20) %]</td>
</tr>
<tr>
<td>[% L.input_tag('filter.order.customer.customernumber:substr::ilike', filter.order.customer.customernumber_substr__ilike, size = 20) %]</td>
</tr>
[% ELSE %] <tr>
- <th align="right">[% vc | $T8 %]</th>
+ <th align="right">[% Vendor | $T8 %]</th>
<td>[% L.input_tag('filter.order.vendor.name:substr::ilike', filter.order.vendor.name_substr__ilike, size = 20) %]</td>
</tr>
<tr>
[% L.hidden_tag('sort_by', FORM.sort_by) %]
[% L.hidden_tag('sort_dir', FORM.sort_dir) %]
[% L.hidden_tag('page', FORM.page) %]
-[% IF vc == 'customer' %]
+[% L.hidden_tag('vc', vc) %]
[% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit')%]
-[% ELSE %]
- [% L.input_tag('action_list_ap', LxERP.t8('Continue'), type = 'submit', class='submit')%]
-[% END %]
<a href='#' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);'>[% 'Reset' | $T8 %]</a>