X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FEmailJournal.pm;h=5f3a51da83efc0ffa4589a1a7d69f31323ef3317;hb=0c564932ee0502911972f31f33a6041cfab5e98b;hp=6875b524995f63e39c7dbb5658503a0b2dbb1639;hpb=24ab7ec0bfb052edce7a3c7a6e37c151f9cd6a04;p=kivitendo-erp.git diff --git a/SL/DB/EmailJournal.pm b/SL/DB/EmailJournal.pm index 6875b5249..5f3a51da8 100644 --- a/SL/DB/EmailJournal.pm +++ b/SL/DB/EmailJournal.pm @@ -4,6 +4,7 @@ use strict; use SL::DB::MetaSetup::EmailJournal; use SL::DB::Manager::EmailJournal; +use SL::DB::Helper::AttrSorted; __PACKAGE__->meta->add_relationship( attachments => { @@ -15,4 +16,44 @@ __PACKAGE__->meta->add_relationship( __PACKAGE__->meta->initialize; +__PACKAGE__->attr_sorted('attachments'); + +sub compare_to { + my ($self, $other) = @_; + + return -1 if $self->sent_on && !$other->sent_on; + return 1 if !$self->sent_on && $other->sent_on; + + my $result = 0; + $result = $other->sent_on <=> $self->sent_on; + return $result || ($self->id <=> $other->id); +} + 1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::EmailJournal - RDBO model for email journal + +=head1 SYNOPSIS + +This is a standard Rose::DB::Object based model and can be used as one. + +=head1 METHODS + +=over 4 + +=item C + +Compares C<$self> with C<$other> and returns the newer entry. + +=back + +=cut +