PriceSource: Mehr Informationen an Preise übergeben
[kivitendo-erp.git] / SL / DB / Manager / CsvImportReport.pm
1 package SL::DB::Manager::CsvImportReport;
2
3 use strict;
4
5 use base qw(SL::DB::Helper::Manager);
6
7 sub object_class { 'SL::DB::CsvImportReport' }
8
9 __PACKAGE__->make_manager_methods;
10
11 sub cleanup {
12   my ($self) = @_;
13
14   $::auth->active_session_ids;
15
16   # get expired reports
17   my $objects = $self->get_all(query => [
18    '!session_id' => [ $::auth->active_session_ids ]
19   ]);
20
21   $_->destroy for @$objects;
22
23   # get reports for the active session that aren't the latest
24   $objects = $self->get_all(
25     query => [ session_id => $::auth->get_session_id, ],
26     order_by => [ 'id' ],
27   );
28
29   # skip the last one
30   for (0 .. $#$objects - 1) {
31     $objects->[$_]->destroy;
32   }
33 }
34
35 1;
36