Revision 78a847e6
Von Werner Hahn vor etwa 1 Jahr hinzugefügt
SL/Model/Record.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
|
|
5 |
use SL::Locale::String qw(t8); |
|
6 | 6 |
|
7 | 7 |
|
8 | 8 |
sub new { |
... | ... | |
49 | 49 |
} |
50 | 50 |
|
51 | 51 |
sub delete { |
52 |
my ($class, $record, %flags) = @_; |
|
52 |
my ($class, $record, %params) = @_; |
|
53 |
|
|
54 |
my $errors = []; |
|
55 |
my $db = $record->db; |
|
56 |
|
|
57 |
$db->with_transaction( |
|
58 |
sub { |
|
59 |
my @spoolfiles = grep { $_ } map { $_->spoolfile } @{ SL::DB::Manager::Status->get_all(where => [ trans_id => $record->id ]) }; |
|
60 |
$record->delete; |
|
61 |
my $spool = $::lx_office_conf{paths}->{spool}; |
|
62 |
unlink map { "$spool/$_" } @spoolfiles if $spool; |
|
63 |
|
|
64 |
_save_history($record,'DELETED', \$params{history}); |
|
65 |
|
|
66 |
1; |
|
67 |
}) || push(@{$errors}, $db->error); |
|
53 | 68 |
|
69 |
if (scalar @{ $errors} ){ |
|
70 |
croak(t8('Error delete record')); |
|
71 |
}; |
|
54 | 72 |
# das hier sollte der code sein der in sub delete aus den controllern liegt |
55 | 73 |
# nicht nur record->delete, sondern auch andere elemente aufräumen |
56 | 74 |
# spool aufräumen |
Auch abrufbar als: Unified diff
Model::Record sub delete