Revision ea5d75b5
Von Sven Schöling vor etwa 8 Jahren hinzugefügt
SL/DB/Letter.pm | ||
---|---|---|
6 | 6 |
use strict; |
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::Letter; |
9 |
use SL::DB::Manager::Letter; |
|
10 |
|
|
11 |
__PACKAGE__->meta->add_relationships( |
|
12 |
customer => { |
|
13 |
type => 'many to one', |
|
14 |
class => 'SL::DB::Customer', |
|
15 |
column_map => { vc_id => 'id' }, |
|
16 |
}, |
|
17 |
|
|
18 |
); |
|
9 | 19 |
|
10 | 20 |
__PACKAGE__->meta->initialize; |
11 | 21 |
|
12 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
13 |
__PACKAGE__->meta->make_manager_class; |
|
22 |
sub new_from_draft { |
|
23 |
my ($class, $draft) = @_; |
|
24 |
|
|
25 |
my $self = $class->new; |
|
26 |
|
|
27 |
if (!ref $draft) { |
|
28 |
require SL::DB::LetterDraft; |
|
29 |
$draft = SL::DB::LetterDraft->new(id => $draft)->load; |
|
30 |
} |
|
31 |
|
|
32 |
$self->assign_attributes(map { $_ => $draft->$_ } $draft->meta->columns); |
|
33 |
|
|
34 |
$self->id(undef); |
|
35 |
|
|
36 |
$self; |
|
37 |
} |
|
14 | 38 |
|
15 | 39 |
1; |
Auch abrufbar als: Unified diff
Letter Controller rewrite
Jetzt auf einigermassen aktuellem technischen Stand.