Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5d195a27

Von Sven Schöling vor fast 11 Jahren hinzugefügt

  • ID 5d195a27c681ad7837ee45f1ee951f5aafc70e97
  • Vorgänger a7e58f7e
  • Nachfolger 2a3bcd6e

Finanzcontrolling auf getmodels umgestellt

Unterschiede anzeigen:

SL/Controller/FinancialControllingReport.pm
8 8
use SL::DB::Order;
9 9
use SL::DB::ProjectType;
10 10
use SL::Controller::Helper::GetModels;
11
use SL::Controller::Helper::Paginated;
12
use SL::Controller::Helper::Sorted;
13
use SL::Controller::Helper::ParseFilter;
14 11
use SL::Controller::Helper::ReportGenerator;
15 12
use SL::Locale::String;
16 13

  
17 14
use Rose::Object::MakeMethods::Generic (
18
  scalar => [ qw(db_args flat_filter project_types) ],
15
  scalar => [ qw(project_types) ],
16
  'scalar --get_set_init' => [ qw(models) ],
19 17
);
20 18

  
21 19
__PACKAGE__->run_before(sub { $::auth->assert('sales_order_edit'); });
22 20

  
23
__PACKAGE__->get_models_url_params('flat_filter');
24
__PACKAGE__->make_paginated(
25
  MODEL         => 'Order',
26
  PAGINATE_ARGS => 'db_args',
27
  ONLY          => [ qw(list) ],
28
);
29

  
30
__PACKAGE__->make_sorted(
31
  MODEL                   => 'Order',
32
  ONLY                    => [ qw(list) ],
33

  
34
  DEFAULT_BY              => 'globalprojectnumber',
35
  DEFAULT_DIR             => 1,
36

  
21
my %sort_columns = (
37 22
  ordnumber               => t8('Order'),
38 23
  customer                => t8('Customer'),
39 24
  transaction_description => t8('Transaction description'),
......
47 32

  
48 33
  $self->project_types(SL::DB::Manager::ProjectType->get_all_sorted);
49 34

  
50
  $self->db_args($self->setup_db_args_for_list(filter => $::form->{filter}));
51
  $self->flat_filter({ map { $_->{key} => $_->{value} } $::form->flatten_variables('filter') });
52 35
  $self->make_filter_summary;
53 36

  
54 37
  $self->prepare_report;
55 38

  
56
  $self->{orders} = $self->get_models(%{ $self->db_args });
39
  $self->{orders} = $self->models->get;
57 40

  
58 41
  $self->calculate_data;
59 42

  
......
62 45

  
63 46
# private functions
64 47

  
65
sub setup_db_args_for_list {
66
  my ($self) = @_;
67

  
68
  $self->{filter} = {};
69
  my %args     = ( parse_filter($::form->{filter}, with_objects => [ 'customer', 'globalproject', 'globalproject.project_type' ], launder_to => $self->{filter}));
70
  $args{query} = [
71
    @{ $args{query} || [] },
72
    SL::DB::Manager::Order->type_filter('sales_order'),
73
    '!closed' => 1,
74
    or        => [
75
      globalproject_id => undef,
76
      and              => [
77
        'globalproject.active' => 1,
78
        'globalproject.valid'  => 1,
79
      ]],
80
  ];
81

  
82
  return \%args;
83
}
84

  
85 48
sub prepare_report {
86 49
  my ($self)      = @_;
87 50

  
......
113 76
                                 sub      => sub { $_[0]->globalproject_id ? $_[0]->globalproject->project_type->description : '' }  },
114 77
  );
115 78

  
116
  map { $column_defs{$_}->{text} ||= $::locale->text( $self->get_sort_spec->{$_}->{title} ) } keys %column_defs;
79
  map { $column_defs{$_}->{text} ||= $::locale->text( $self->models->get_sort_spec->{$_}->{title} ) } keys %column_defs;
117 80
  map { $column_defs{$_}->{align} = 'right' } @{ $self->{number_columns} };
118 81

  
119 82
  $report->set_options(
......
121 84
    controller_class      => 'FinancialControllingReport',
122 85
    output_format         => 'HTML',
123 86
    top_info_text         => $::locale->text('Financial controlling report for open sales orders'),
124
    raw_top_info_text     => $self->render('financial_controlling_report/report_top',    { output => 0 }),
125
    raw_bottom_info_text  => $self->render('financial_controlling_report/report_bottom', { output => 0 }),
126 87
    title                 => $::locale->text('Financial Controlling Report'),
127 88
    allow_pdf_export      => 1,
128 89
    allow_csv_export      => 1,
......
131 92
  $report->set_column_order(@columns);
132 93
  $report->set_export_options(qw(list filter));
133 94
  $report->set_options_from_form;
134
  $self->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
135

  
136
  $self->disable_pagination if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
95
  $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
96
  $self->models->finalize;
97
  $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
98
  $report->set_options(
99
    raw_top_info_text     => $self->render('financial_controlling_report/report_top',    { output => 0 }),
100
    raw_bottom_info_text  => $self->render('financial_controlling_report/report_bottom', { output => 0 }, models => $self->models),
101
  );
137 102
}
138 103

  
139 104
sub calculate_data {
......
232 197
  $self->{filter_summary} = join ', ', @filter_strings;
233 198
}
234 199

  
200
sub init_models {
201
  my ($self) = @_;
202

  
203
  SL::Controller::Helper::GetModels->new(
204
    controller   => $self,
205
    model        => 'Order',
206
    sorted       => {
207
      _default     => {
208
        by           => 'globalprojectnumber',
209
        dir          => 1,
210
      },
211
      %sort_columns,
212
    },
213
    query => [
214
      SL::DB::Manager::Order->type_filter('sales_order'),
215
      '!closed' => 1,
216
      or        => [
217
        globalproject_id => undef,
218
        and              => [
219
          'globalproject.active' => 1,
220
          'globalproject.valid'  => 1,
221
        ]],
222
    ],
223
    with_objects => [ 'customer', 'globalproject', 'globalproject.project_type' ],
224
  );
225
}
226

  
235 227
sub link_to {
236 228
  my ($self, $object, %params) = @_;
237 229

  
SL/DB/MetaSetup/Project.pm
17 17
  mtime           => { type => 'timestamp' },
18 18
  project_type_id => { type => 'integer', not_null => 1 },
19 19
  projectnumber   => { type => 'text' },
20
  type            => { type => 'text' },
21 20
  valid           => { type => 'boolean', default => 'true' },
22 21
);
23 22

  
SL/DB/MetaSetup/ProjectType.pm
6 6

  
7 7
use base qw(SL::DB::Object);
8 8

  
9
__PACKAGE__->meta->setup(
10
  table   => 'project_types',
9
__PACKAGE__->meta->table('project_types');
11 10

  
12
  columns => [
13
    id          => { type => 'serial', not_null => 1 },
14
    position    => { type => 'integer', not_null => 1 },
15
    description => { type => 'text' },
16
  ],
17

  
18
  primary_key_columns => [ 'id' ],
11
__PACKAGE__->meta->columns(
12
  description => { type => 'text' },
13
  id          => { type => 'serial', not_null => 1 },
14
  position    => { type => 'integer', not_null => 1 },
19 15
);
20 16

  
17
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
18

  
21 19
1;
22 20
;
templates/webpages/financial_controlling_report/report_bottom.html
1 1
[% USE L %]
2
[%- L.paginate_controls %]
2
[%- L.paginate_controls(models=models) %]

Auch abrufbar als: Unified diff