Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4bcb4508

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

  • ID 4bcb450849ddc6e67f7c7181b20c5912b604cdd1
  • Vorgänger f40865cb
  • Nachfolger 1260ff14

DeliveryPlan-Controller auf Paginate-Controller-Helper umstellen

Unterschiede anzeigen:

SL/Controller/DeliveryPlan.pm
5 5

  
6 6
use Clone qw(clone);
7 7
use SL::DB::OrderItem;
8
use SL::Controller::Helper::GetModels;
9
use SL::Controller::Helper::Paginated;
8 10
use SL::Controller::Helper::ParseFilter;
9 11
use SL::Controller::Helper::ReportGenerator;
10 12

  
13
use Rose::Object::MakeMethods::Generic
14
(
15
  scalar => [ qw(db_args) ],
16
);
17

  
11 18
__PACKAGE__->run_before(sub { $::auth->assert('sales_order_edit'); });
12 19

  
20
__PACKAGE__->get_models_url_params(sub {
21
  my ($self) = @_;
22
  return (
23
    %{ $self->{flat_filter} || {} },
24
    sort_dir => $self->{sort_dir},
25
    sort_by  => $self->{sort_by},
26
  );
27
});
28
__PACKAGE__->make_paginated(
29
  MODEL         => 'OrderItem',
30
  PAGINATE_ARGS => 'db_args',
31
  ONLY          => [ qw(list) ],
32
);
33

  
13 34
sub action_list {
14 35
  my ($self) = @_;
15 36
  my %list_params = (
16 37
    sort_by  => $::form->{sort_by} || 'reqdate',
17 38
    sort_dir => $::form->{sort_dir},
18 39
    filter   => $::form->{filter},
19
    page     => $::form->{page},
20 40
  );
21 41

  
22
  my $db_args = $self->setup_for_list(%list_params);
23
  $self->{pages} = SL::DB::Manager::OrderItem->paginate(%list_params, args => $db_args);
42
  $self->db_args($self->setup_for_list(%list_params));
24 43
  $self->{flat_filter} = { map { $_->{key} => $_->{value} } $::form->flatten_variables('filter') };
25 44
  $self->make_filter_summary;
26 45

  
......
36 55
    report_generator_export_options => [
37 56
      'list', qw(filter sort_by sort_dir),
38 57
    ],
39
    db_args => $db_args,
40 58
  );
41 59

  
42
  $self->{orderitems} = SL::DB::Manager::OrderItem->get_all(%$db_args);
60
  $self->{orderitems} = $self->get_models(%{ $self->db_args });
43 61

  
44 62
  $self->list_objects;
45 63
}
......
56 74
      launder_to => $self->{filter},
57 75
    ),
58 76
    sort_by => $self->set_sort_params(%params),
59
    page    => $params{page},
60 77
  );
61 78

  
62 79
  $args{query} = [ @{ $args{query} || [] },
......
160 177

  
161 178

  
162 179
  for my $col (@sortable) {
163
    $column_defs{$col}{link} = $self->url_for(
164
      action   => 'list',
180
    $column_defs{$col}{link} = $self->get_callback(
165 181
      sort_by  => $col,
166 182
      sort_dir => ($self->{sort_by} eq $col ? 1 - $self->{sort_dir} : $self->{sort_dir}),
167
      page     => $self->{pages}{cur},
168
      %{ $self->{flat_filter} },
169 183
    );
170 184
  }
171 185

  
......
184 198
  );
185 199
  $report->set_options_from_form;
186 200

  
187
  SL::DB::Manager::OrderItem->disable_paginating(args => $params{db_args}) if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
201
  $self->disable_pagination if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
188 202

  
189 203
  $self->{report_data} = {
190 204
    column_defs => \%column_defs,

Auch abrufbar als: Unified diff