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);
templates/webpages/project/_filter.html
3 3
[%- USE L %]
4 4
[%- USE LxERP %]
5 5

  
6
[% L.hidden_tag("_include_cvars_from_form", 1) %]
7

  
6 8
<table id="filter_table">
7 9
 <tr>
8 10
  <th align="right">[% 'Number' | $T8 %]</th>
......
29 31
  <td>[% L.select_tag('filter.project_status_id', SELF.project_statuses, default=filter.project_status_id, title_key='description', with_empty=1, style="width: 200px") %]</td>
30 32
 </tr>
31 33

  
32
 [% CUSTOM_VARIABLES_FILTER_CODE %]
34
 [% FOREACH cvar_cfg = SELF.cvar_configs %]
35
  [%- IF cvar_cfg.searchable %]
36
   <tr>
37
    <th align="right">[% HTML.escape(cvar_cfg.description) %]</th>
38
    <td>[% INCLUDE 'common/render_cvar_filter_input.html' cvar_cfg=cvar_cfg cvar_class="rs_input_field" %]</td>
39
   </tr>
40
  [% END %]
41
 [% END %]
33 42

  
34 43
 <tr>
35 44
  <th>[% 'Include in Report' | $T8 %]</th>
......
47 56
     <td>[% L.select_tag('filter.status', [ [ 'all', LxERP.t8('All') ], [ 'orphaned', LxERP.t8('Orphaned') ] ], default=filter.status, style="width: 200px") %]</td>
48 57
    </tr>
49 58

  
50
    [% CUSTOM_VARIABLES_INCLUSION_CODE %]
59
    [% FOREACH cvar_cfg = SELF.includeable_cvar_configs %]
60
     <tr>
61
      <td>
62
       [% name__ = cvar_cfg.name;
63
          L.checkbox_tag("include_cvars_" _ name__, value="1", checked=(SELF.include_cvars.$name__ ? 1 : ''), label=cvar_cfg.description) %]
64
      </td>
65
     </tr>
66
    [% END %]
51 67

  
52 68
   </table>
53 69
  </td>

Auch abrufbar als: Unified diff