Option für Datev-Check in Mandantenkonfiguration verschoben.
[kivitendo-erp.git] / SL / Controller / ClientConfig.pm
1 package SL::Controller::ClientConfig;
2
3 use strict;
4 use parent qw(SL::Controller::Base);
5
6 use SL::DB::Default;
7 use SL::Helper::Flash;
8
9 __PACKAGE__->run_before('check_auth');
10
11
12 sub action_edit {
13   my ($self, %params) = @_;
14
15   $self->{payment_options} = [ { title => $::locale->text("never"), value => 0 },
16                                { title => $::locale->text("every time"), value => 1 },
17                                { title => $::locale->text("on the same day"), value => 2 }, ];
18
19   $self->{payments_changeable} = SL::DB::Default->get->payments_changeable;
20   $self->{show_bestbefore}     = SL::DB::Default->get->show_bestbefore;
21
22   map { $self->{$_} = SL::DB::Default->get->$_ } qw(datev_check_on_sales_invoice datev_check_on_purchase_invoice datev_check_on_ar_transaction datev_check_on_ap_transaction datev_check_on_gl_transaction);
23   # datev check: not implemented yet:
24   #check_on_cash_and_receipt = 0
25   #check_on_dunning = 0
26   #check_on_sepa_import = 0
27
28   $self->render('client_config/form', title => $::locale->text('Client Configuration'));
29 }
30
31
32 sub action_save {
33   my ($self, %params) = @_;
34
35   SL::DB::Default->get->update_attributes('payments_changeable' => $::form->{payments_changeable});
36   SL::DB::Default->get->update_attributes('show_bestbefore'     => $::form->{show_bestbefore});
37
38   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(datev_check_on_sales_invoice datev_check_on_purchase_invoice datev_check_on_ar_transaction datev_check_on_ap_transaction datev_check_on_gl_transaction);
39
40   flash_later('info', $::locale->text('Client Configuration saved!'));
41
42   $self->redirect_to(action => 'edit');
43 }
44
45
46 #################### private stuff ##########################
47
48 sub check_auth {
49   $::auth->assert('admin');
50 }
51
52 1;