Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7d8de6d3

Von Jan Büren vor etwa 10 Jahren hinzugefügt

  • ID 7d8de6d3bc1c10309351c115b398d7dc97f5fd3f
  • Vorgänger 38044b51
  • Nachfolger d827669e

Verbesserungen Einkaufs-Lieferplan

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)

Unterschiede anzeigen:

SL/Controller/DeliveryPlan.pm
11 11

  
12 12
use Rose::Object::MakeMethods::Generic (
13 13
  scalar => [ qw(db_args flat_filter) ],
14
  'scalar --get_set_init' => [ qw(models all_edit_right) ],
14
  'scalar --get_set_init' => [ qw(models all_edit_right vc) ],
15 15
);
16 16

  
17 17
__PACKAGE__->run_before(sub { $::auth->assert('delivery_plan'); });
......
30 30
  value_of_goods    => t8('Value of goods'),
31 31
);
32 32

  
33
my $vc;
34 33

  
35 34
sub action_list {
36 35
  my ($self) = @_;
37

  
38
  $vc = "customer";
39
  $self->make_filter_summary;
40
  $self->prepare_report;
41

  
42
  my $orderitems = $self->models->get;
43

  
44
  $self->report_generator_list_objects(report => $self->{report}, objects => $orderitems);
45
}
46

  
47
sub action_list_ap {
48
  my ($self) = @_;
49

  
50
  $vc = "vendor";
51 36
  $self->make_filter_summary;
52 37
  $self->prepare_report;
53 38

  
......
61 46
sub prepare_report {
62 47
  my ($self)      = @_;
63 48

  
49
  my $vc          = $self->vc;
64 50
  my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
65 51
  $self->{report} = $report;
66 52

  
......
101 87
  );
102 88
  $report->set_columns(%column_defs);
103 89
  $report->set_column_order(@columns);
104
  $report->set_export_options(qw(list filter));
90
  $report->set_export_options(qw(list filter vc));
105 91
  $report->set_options_from_form;
106 92
  $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
107 93
  $self->models->finalize; # for filter laundering
......
114 100

  
115 101
sub make_filter_summary {
116 102
  my ($self) = @_;
103
  my $vc     = $self->vc;
117 104

  
118 105
  my $filter = $::form->{filter} || {};
119 106
  my @filter_strings;
......
147 134
}
148 135

  
149 136
sub delivery_plan_query {
137
  my ($self) = @_;
138
  my $vc     = $self->vc;
150 139
  my $employee_id = SL::DB::Manager::Employee->current->id;
151 140
  my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND";
152 141
  # check delivered state for delivery_orders (transferred out) if enabled
......
254 243

  
255 244
sub init_models {
256 245
  my ($self) = @_;
246
  my $vc     = $self->vc;
257 247

  
258 248
  SL::Controller::Helper::GetModels->new(
259 249
    controller   => $self,
......
273 263
sub init_all_edit_right {
274 264
  $::auth->assert('sales_all_edit', 1)
275 265
}
266
sub init_vc {
267
  return $::form->{vc} || croak "self (DeliveryPlan) has no vc defined";
268
}
276 269

  
277 270
sub link_to {
278 271
  my ($self, $object, %params) = @_;
SL/DB/OrderItem.pm
38 38
  my ($self) = @_;
39 39

  
40 40
  my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder');
41
  my @d_orders_delivered;
42 41

  
43
  foreach (@$d_orders) {
44
    push (@d_orders_delivered, $_) if $_->delivered;
45
  }
42
  my @d_orders_delivered = grep { $_->delivered } @$d_orders;
46 43

  
47 44
  my @doi_delivered      = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @d_orders_delivered;
48 45

  
......
53 50
sub value_of_goods {
54 51
  my ($self) = @_;
55 52

  
56
  my $price_factor = $self->price_factor ? $self->price_factor : 1;
53
  my $price_factor = $self->price_factor || 1;
57 54

  
58 55
  return ($self->qty * $self->sellprice * (1 - $self->discount ) / $price_factor);
59 56
}
menus/erp.ini
192 192
ACCESS=delivery_plan
193 193
module=controller.pl
194 194
action=DeliveryPlan/list
195
vc=customer
195 196

  
196 197
[AR--Reports--Financial Controlling]
197 198
ACCESS=sales_order_edit
......
259 260
[AP--Reports--Delivery Plan]
260 261
ACCESS=delivery_plan
261 262
module=controller.pl
262
action=DeliveryPlan/list_ap
263
action=DeliveryPlan/list
264
vc=vendor
263 265

  
264 266
[Warehouse]
265 267

  
templates/webpages/delivery_plan/_filter.html
36 36
  </tr>
37 37
[% IF vc == 'customer' %]
38 38
    <tr>
39
     <th align="right">[% vc | $T8 %]</th>
39
     <th align="right">[% Customer | $T8 %]</th>
40 40
     <td>[% L.input_tag('filter.order.customer.name:substr::ilike', filter.order.customer.name_substr__ilike, size = 20) %]</td>
41 41
   </tr>
42 42
   <tr>
......
44 44
    <td>[% L.input_tag('filter.order.customer.customernumber:substr::ilike', filter.order.customer.customernumber_substr__ilike, size = 20) %]</td>
45 45
   </tr>
46 46
[% ELSE %]  <tr>
47
    <th align="right">[% vc | $T8 %]</th>
47
    <th align="right">[% Vendor | $T8 %]</th>
48 48
    <td>[% L.input_tag('filter.order.vendor.name:substr::ilike', filter.order.vendor.name_substr__ilike, size = 20) %]</td>
49 49
   </tr>
50 50
   <tr>
......
66 66
[% L.hidden_tag('sort_by', FORM.sort_by) %]
67 67
[% L.hidden_tag('sort_dir', FORM.sort_dir) %]
68 68
[% L.hidden_tag('page', FORM.page) %]
69
[% IF vc == 'customer' %]
69
[% L.hidden_tag('vc', vc) %]
70 70
  [% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit')%]
71
[% ELSE %]
72
  [% L.input_tag('action_list_ap', LxERP.t8('Continue'), type = 'submit', class='submit')%]
73
[% END %]
74 71

  
75 72

  
76 73
<a href='#' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);'>[% 'Reset' | $T8 %]</a>

Auch abrufbar als: Unified diff