Revision 9c42cae9
Von Tamino Steinert vor 11 Monaten hinzugefügt
SL/DB/Manager/RecordTemplate.pm | ||
---|---|---|
6 | 6 |
|
7 | 7 |
use SL::DB::Helper::Paginated; |
8 | 8 |
use SL::DB::Helper::Sorted; |
9 |
use SL::DB::Helper::Filtered; |
|
10 |
|
|
11 |
use List::MoreUtils qw(any); |
|
9 | 12 |
|
10 | 13 |
sub object_class { 'SL::DB::RecordTemplate' } |
11 | 14 |
|
12 | 15 |
__PACKAGE__->make_manager_methods; |
13 | 16 |
|
17 |
__PACKAGE__->add_filter_specs( |
|
18 |
type => sub { |
|
19 |
my ($key, $value, $prefix) = @_; |
|
20 |
return __PACKAGE__->type_filter($value, $prefix); |
|
21 |
}, |
|
22 |
); |
|
23 |
|
|
24 |
sub type_filter { |
|
25 |
my $class = shift; |
|
26 |
my $type = lc(shift || ''); |
|
27 |
my $prefix = shift || ''; |
|
28 |
|
|
29 |
# remove '_template' if needed |
|
30 |
my $template_type = $type; |
|
31 |
$template_type =~ s/_template$//; |
|
32 |
|
|
33 |
return ("${prefix}template_type" => $template_type) if( any {$template_type eq $_} ( |
|
34 |
'gl_transaction', |
|
35 |
'ar_transaction', |
|
36 |
'ap_transaction', |
|
37 |
)); |
|
38 |
|
|
39 |
die "Unknown type $type"; |
|
40 |
} |
|
41 |
|
|
14 | 42 |
sub _sort_spec { |
15 | 43 |
return ( |
16 | 44 |
default => [ 'template_name', 1 ], |
SL/DB/RecordTemplate.pm | ||
---|---|---|
19 | 19 |
__PACKAGE__->meta->initialize; |
20 | 20 |
|
21 | 21 |
sub items { goto &record_template_items; } |
22 |
sub record_type { goto &template_type; } |
|
23 |
|
|
24 |
sub displayable_name { |
|
25 |
my ($self) = @_; |
|
26 |
return join ' ', $self->template_name_to_use, $self->mtime->to_kivitendo; |
|
27 |
} |
|
22 | 28 |
|
23 | 29 |
sub _replace_variables { |
24 | 30 |
my ($self, %params) = @_; |
Auch abrufbar als: Unified diff
S:D:RecordTemplate: um Standard-Helferfunktionen erweitert