Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 55a74ec9

Von Moritz Bunkus vor mehr als 5 Jahren hinzugefügt

  • ID 55a74ec99d06cf44900f4b9dfba86a8525ed48b9
  • Vorgänger 03c9a231
  • Nachfolger e7088e23

Projekte: benutzerdefinierte Variablen in Suchmaske

Unterschiede anzeigen:

SL/Controller/Project.pm
30 30
use Rose::Object::MakeMethods::Generic
31 31
(
32 32
 scalar => [ qw(project) ],
33
 'scalar --get_set_init' => [ qw(models customers project_types project_statuses projects linked_records employees may_edit_invoice_permissions) ],
33
 'scalar --get_set_init' => [ qw(models customers project_types project_statuses projects linked_records employees may_edit_invoice_permissions
34
                                 cvar_configs includeable_cvar_configs include_cvars) ],
34 35
);
35 36

  
36 37
__PACKAGE__->run_before('check_auth',   except => [ qw(ajax_autocomplete) ]);
......
153 154
sub init_project_types    { SL::DB::Manager::ProjectType->get_all_sorted   }
154 155
sub init_employees        { SL::DB::Manager::Employee->get_all_sorted   }
155 156
sub init_may_edit_invoice_permissions { $::auth->assert('project_edit_view_invoices_permission', 1) }
157
sub init_cvar_configs                 { SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'Projects' ]) }
158
sub init_includeable_cvar_configs     { [ grep { $_->includeable } @{ $_[0]->cvar_configs } ] };
159

  
160
sub init_include_cvars {
161
  my ($self) = @_;
162
  return { map { ($_->name => $::form->{"include_cvars_" . $_->name}) }       @{ $self->cvar_configs } } if $::form->{_include_cvars_from_form};
163
  return { map { ($_->name => ($_->includeable && $_->included_by_default)) } @{ $self->cvar_configs } };
164
}
156 165

  
157 166
sub init_linked_records {
158 167
  my ($self) = @_;
......
303 312

  
304 313
  map { $column_defs{$_}->{text} ||= $::locale->text( $self->models->get_sort_spec->{$_}->{title} ) } keys %column_defs;
305 314

  
315
  # Custom variables
316
  my %cvar_column_defs = map {
317
    my $cfg = $_;
318
    (('cvar_' . $cfg->name) => {
319
      sub     => sub { my $var = $_[0]->cvar_by_name($cfg->name); $var ? $var->value_as_text : '' },
320
      text    => $cfg->description,
321
      visible => $self->include_cvars->{ $cfg->name } ? 1 : 0,
322
    })
323
  } @{ $self->includeable_cvar_configs };
324

  
325
  push @columns, map { 'cvar_' . $_->name } @{ $self->includeable_cvar_configs };
326
  %column_defs = (%column_defs, %cvar_column_defs);
327

  
328
  my @cvar_column_form_names = ('_include_cvars_from_form', map { "include_cvars_" . $_->name } @{ $self->includeable_cvar_configs });
329

  
306 330
  $report->set_options(
307 331
    std_column_visibility => 1,
308 332
    controller_class      => 'Project',
......
313 337
  );
314 338
  $report->set_columns(%column_defs);
315 339
  $report->set_column_order(@columns);
316
  $report->set_export_options(qw(list filter));
340
  $report->set_export_options(qw(list filter), @cvar_column_form_names);
317 341
  $report->set_options_from_form;
318 342
  $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
319 343
  $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);

Auch abrufbar als: Unified diff