Revision 55a74ec9
Von Moritz Bunkus vor fast 6 Jahren hinzugefügt
SL/Controller/Project.pm | ||
---|---|---|
use Rose::Object::MakeMethods::Generic
|
||
(
|
||
scalar => [ qw(project) ],
|
||
'scalar --get_set_init' => [ qw(models customers project_types project_statuses projects linked_records employees may_edit_invoice_permissions) ],
|
||
'scalar --get_set_init' => [ qw(models customers project_types project_statuses projects linked_records employees may_edit_invoice_permissions
|
||
cvar_configs includeable_cvar_configs include_cvars) ],
|
||
);
|
||
|
||
__PACKAGE__->run_before('check_auth', except => [ qw(ajax_autocomplete) ]);
|
||
... | ... | |
sub init_project_types { SL::DB::Manager::ProjectType->get_all_sorted }
|
||
sub init_employees { SL::DB::Manager::Employee->get_all_sorted }
|
||
sub init_may_edit_invoice_permissions { $::auth->assert('project_edit_view_invoices_permission', 1) }
|
||
sub init_cvar_configs { SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'Projects' ]) }
|
||
sub init_includeable_cvar_configs { [ grep { $_->includeable } @{ $_[0]->cvar_configs } ] };
|
||
|
||
sub init_include_cvars {
|
||
my ($self) = @_;
|
||
return { map { ($_->name => $::form->{"include_cvars_" . $_->name}) } @{ $self->cvar_configs } } if $::form->{_include_cvars_from_form};
|
||
return { map { ($_->name => ($_->includeable && $_->included_by_default)) } @{ $self->cvar_configs } };
|
||
}
|
||
|
||
sub init_linked_records {
|
||
my ($self) = @_;
|
||
... | ... | |
|
||
map { $column_defs{$_}->{text} ||= $::locale->text( $self->models->get_sort_spec->{$_}->{title} ) } keys %column_defs;
|
||
|
||
# Custom variables
|
||
my %cvar_column_defs = map {
|
||
my $cfg = $_;
|
||
(('cvar_' . $cfg->name) => {
|
||
sub => sub { my $var = $_[0]->cvar_by_name($cfg->name); $var ? $var->value_as_text : '' },
|
||
text => $cfg->description,
|
||
visible => $self->include_cvars->{ $cfg->name } ? 1 : 0,
|
||
})
|
||
} @{ $self->includeable_cvar_configs };
|
||
|
||
push @columns, map { 'cvar_' . $_->name } @{ $self->includeable_cvar_configs };
|
||
%column_defs = (%column_defs, %cvar_column_defs);
|
||
|
||
my @cvar_column_form_names = ('_include_cvars_from_form', map { "include_cvars_" . $_->name } @{ $self->includeable_cvar_configs });
|
||
|
||
$report->set_options(
|
||
std_column_visibility => 1,
|
||
controller_class => 'Project',
|
||
... | ... | |
);
|
||
$report->set_columns(%column_defs);
|
||
$report->set_column_order(@columns);
|
||
$report->set_export_options(qw(list filter));
|
||
$report->set_export_options(qw(list filter), @cvar_column_form_names);
|
||
$report->set_options_from_form;
|
||
$self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
|
||
$self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
|
templates/webpages/project/_filter.html | ||
---|---|---|
[%- USE L %]
|
||
[%- USE LxERP %]
|
||
|
||
[% L.hidden_tag("_include_cvars_from_form", 1) %]
|
||
|
||
<table id="filter_table">
|
||
<tr>
|
||
<th align="right">[% 'Number' | $T8 %]</th>
|
||
... | ... | |
<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>
|
||
</tr>
|
||
|
||
[% CUSTOM_VARIABLES_FILTER_CODE %]
|
||
[% FOREACH cvar_cfg = SELF.cvar_configs %]
|
||
[%- IF cvar_cfg.searchable %]
|
||
<tr>
|
||
<th align="right">[% HTML.escape(cvar_cfg.description) %]</th>
|
||
<td>[% INCLUDE 'common/render_cvar_filter_input.html' cvar_cfg=cvar_cfg cvar_class="rs_input_field" %]</td>
|
||
</tr>
|
||
[% END %]
|
||
[% END %]
|
||
|
||
<tr>
|
||
<th>[% 'Include in Report' | $T8 %]</th>
|
||
... | ... | |
<td>[% L.select_tag('filter.status', [ [ 'all', LxERP.t8('All') ], [ 'orphaned', LxERP.t8('Orphaned') ] ], default=filter.status, style="width: 200px") %]</td>
|
||
</tr>
|
||
|
||
[% CUSTOM_VARIABLES_INCLUSION_CODE %]
|
||
[% FOREACH cvar_cfg = SELF.includeable_cvar_configs %]
|
||
<tr>
|
||
<td>
|
||
[% name__ = cvar_cfg.name;
|
||
L.checkbox_tag("include_cvars_" _ name__, value="1", checked=(SELF.include_cvars.$name__ ? 1 : ''), label=cvar_cfg.description) %]
|
||
</td>
|
||
</tr>
|
||
[% END %]
|
||
|
||
</table>
|
||
</td>
|
Auch abrufbar als: Unified diff
Projekte: benutzerdefinierte Variablen in Suchmaske