Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9adabd2e

Von Moritz Bunkus vor mehr als 12 Jahren hinzugefügt

  • ID 9adabd2e0abdb11b5f228ffdf4409f80c1133bfd
  • Vorgänger d08c706c
  • Nachfolger 6454c25f

Refactoring: Vereinfachung vom Lieferplancontroller

Unterschiede anzeigen:

SL/Controller/DeliveryPlan.pm
35 35
  description => 'Description',
36 36
  partnumber  => 'Part Number',
37 37
  qty         => 'Qty',
38
  missing     => 'Missing qty',
39 38
  shipped_qty => 'shipped',
40 39
  ordnumber   => 'Order',
41 40
  customer    => 'Customer',
......
43 42

  
44 43
sub action_list {
45 44
  my ($self) = @_;
46
  my %list_params = (
47
    filter   => $::form->{filter},
48
  );
49 45

  
50
  $self->db_args($self->setup_for_list(%list_params));
46
  $self->db_args($self->setup_for_list(filter => $::form->{filter}));
51 47
  $self->flat_filter({ map { $_->{key} => $_->{value} } $::form->flatten_variables('filter') });
52 48
  $self->make_filter_summary;
53 49

  
54
  my $top    = $::form->parse_html_template('delivery_plan/report_top', { FORM => $::form, SELF => $self });
55
  my $bottom = $::form->parse_html_template('delivery_plan/report_bottom', { SELF => $self });
56

  
57
  $self->prepare_report(
58
    report_generator_options => {
59
      raw_top_info_text    => $top,
60
      raw_bottom_info_text => $bottom,
61
      controller_class     => 'DeliveryPlan',
62
    },
63
    report_generator_export_options => [ qw(list filter) ],
64
  );
50
  $self->prepare_report;
65 51

  
66 52
  $self->{orderitems} = $self->get_models(%{ $self->db_args });
67 53

  
......
139 125
}
140 126

  
141 127
sub prepare_report {
142
  my ($self, %params) = @_;
128
  my ($self)      = @_;
143 129

  
144
  my $objects  = $params{objects} || [];
145
  my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
130
  my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
146 131
  $self->{report} = $report;
147 132

  
148
  my @columns  = qw(reqdate customer ordnumber partnumber description qty shipped_qty);
149
  my @visible  = qw(reqdate partnumber description qty shipped_qty ordnumber customer);
150
  my @sortable = qw(reqdate partnumber description                 ordnumber customer);
133
  my @columns     = qw(reqdate customer ordnumber partnumber description qty shipped_qty);
134
  my @sortable    = qw(reqdate customer ordnumber partnumber description                );
151 135

  
152 136
  my %column_defs = (
153
    reqdate                 => {      sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date }},
154
    description             => {      sub => sub { $_[0]->description },
155
                                 obj_link => sub { $self->link_to($_[0]->part) }},
156
    partnumber              => {      sub => sub { $_[0]->part->partnumber },
157
                                 obj_link => sub { $self->link_to($_[0]->part) }},
158
    qty                     => {      sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit }},
159
    missing                 => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit }},
160
    shipped_qty             => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit }},
161
    ordnumber               => {      sub => sub { $_[0]->order->ordnumber },
162
                                 obj_link => sub { $self->link_to($_[0]->order) }},
163
    customer                => {      sub => sub { $_[0]->order->customer->name },
164
                                 obj_link => sub { $self->link_to($_[0]->order->customer) }},
137
    reqdate       => {      sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date                         } },
138
    description   => {      sub => sub { $_[0]->description                                                              },
139
                       obj_link => sub { $self->link_to($_[0]->part)                                                     } },
140
    partnumber    => {      sub => sub { $_[0]->part->partnumber                                                         },
141
                       obj_link => sub { $self->link_to($_[0]->part)                                                     } },
142
    qty           => {      sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit                                        } },
143
    shipped_qty   => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
144
    ordnumber     => {      sub => sub { $_[0]->order->ordnumber                                                         },
145
                       obj_link => sub { $self->link_to($_[0]->order)                                                    } },
146
    customer      => {      sub => sub { $_[0]->order->customer->name                                                    },
147
                       obj_link => sub { $self->link_to($_[0]->order->customer)                                          } },
165 148
  );
166 149

  
167 150
  map { $column_defs{$_}->{text} = $::locale->text( $self->get_sort_spec->{$_}->{title} ) } keys %column_defs;
168 151

  
169
  map { $column_defs{$_}->{visible} = 1 } @visible;
170

  
171
  $report->set_columns(%column_defs);
172
  $report->set_column_order(@columns);
173
  $report->set_options(allow_pdf_export => 1, allow_csv_export => 1);
174
  $report->set_export_options(@{ $params{report_generator_export_options} || [] });
175 152
  $report->set_options(
176
    %{ $params{report_generator_options} || {} },
177
    output_format        => 'HTML',
178
    top_info_text        => $::locale->text('Delivery Plan for currently outstanding sales orders'),
179
    title                => $::locale->text('Delivery Plan'),
153
    std_column_visibility => 1,
154
    controller_class      => 'DeliveryPlan',
155
    output_format         => 'HTML',
156
    top_info_text         => $::locale->text('Delivery Plan for currently outstanding sales orders'),
157
    raw_top_info_text     => $self->render('delivery_plan/report_top',    { no_output => 1, partial => 1 }),
158
    raw_bottom_info_text  => $self->render('delivery_plan/report_bottom', { no_output => 1, partial => 1 }),
159
    title                 => $::locale->text('Delivery Plan'),
160
    allow_pdf_export      => 1,
161
    allow_csv_export      => 1,
180 162
  );
163
  $report->set_columns(%column_defs);
164
  $report->set_column_order(@columns);
165
  $report->set_export_options(qw(list filter));
181 166
  $report->set_options_from_form;
182 167
  $self->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
183 168

  
184 169
  $self->disable_pagination if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
185 170

  
186 171
  $self->{report_data} = {
187
    column_defs => \%column_defs,
188
    columns     => \@columns,
189
    visible     => \@visible,
190
    sortable    => \@sortable,
172
    column_defs        => \%column_defs,
173
    columns            => \@columns,
191 174
  };
192 175
}
193 176

  

Auch abrufbar als: Unified diff