Controller zur Verwaltung von BackgroundJobHistory-Einträgen
[kivitendo-erp.git] / SL / Controller / BackgroundJobHistory.pm
1 package SL::Controller::BackgroundJobHistory;
2
3 use strict;
4
5 use parent qw(SL::Controller::Base);
6
7 use SL::DB::BackgroundJobHistory;
8 use SL::Helper::Flash;
9 use SL::System::TaskServer;
10
11 use Rose::Object::MakeMethods::Generic
12 (
13   scalar                  => [ qw(history) ],
14   'scalar --get_set_init' => [ qw(task_server) ],
15 );
16
17 __PACKAGE__->run_before('check_auth');
18 __PACKAGE__->run_before('add_stylesheet');
19 __PACKAGE__->run_before('check_task_server');
20
21 #
22 # actions
23 #
24
25 sub action_list {
26   my ($self) = @_;
27
28   $self->render('background_job_history/list',
29                 title   => $::locale->text('Background job history'),
30                 ENTRIES => SL::DB::Manager::BackgroundJobHistory->get_all_sorted);
31 }
32
33 sub action_show {
34   my ($self) = @_;
35
36   my $back_to = $::form->{back_to} || $self->url_for(action => 'list');
37
38   $self->history(SL::DB::BackgroundJobHistory->new(id => $::form->{id})->load);
39   $self->render('background_job_history/show',
40                 title   => $::locale->text('View background job execution result'),
41                 back_to => $back_to);
42 }
43
44 #
45 # filters
46 #
47
48 sub check_auth {
49   $::auth->assert('admin');
50 }
51
52 #
53 # helpers
54 #
55
56 sub init_task_server {
57   return SL::System::TaskServer->new;
58 }
59
60 sub check_task_server {
61   my ($self) = @_;
62   flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running;
63 }
64
65 sub add_stylesheet {
66   $::form->use_stylesheet('lx-office-erp/background_jobs.css');
67 }
68
69 1;