Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[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   $self->{accounting_options} = [ { title => $::locale->text("accrual"), value => "accrual" },
19                                   { title => $::locale->text("cash"), value => "cash" }, ];
20   $self->{inventory_options} = [ { title => $::locale->text("perpetual"), value => "perpetual" },
21                                  { title => $::locale->text("periodic"), value => "periodic" }, ];
22   $self->{profit_options} = [ { title => $::locale->text("balance"), value => "balance" },
23                               { title => $::locale->text("income"), value => "income" }, ];
24
25   $self->{payments_changeable} = SL::DB::Default->get->payments_changeable;
26
27   map { $self->{$_} = SL::DB::Default->get->$_ } qw(accounting_method inventory_system profit_determination);
28
29   $self->{show_bestbefore}     = SL::DB::Default->get->show_bestbefore;
30
31   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);
32   # datev check: not implemented yet:
33   #check_on_cash_and_receipt = 0
34   #check_on_dunning = 0
35   #check_on_sepa_import = 0
36
37   $self->render('client_config/form', title => $::locale->text('Client Configuration'));
38 }
39
40
41 sub action_save {
42   my ($self, %params) = @_;
43
44   SL::DB::Default->get->update_attributes('payments_changeable' => $::form->{payments_changeable});
45
46   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(accounting_method inventory_system profit_determination);
47
48   SL::DB::Default->get->update_attributes('show_bestbefore'     => $::form->{show_bestbefore});
49
50   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);
51
52   flash_later('info', $::locale->text('Client Configuration saved!'));
53
54   $self->redirect_to(action => 'edit');
55 }
56
57
58 #################### private stuff ##########################
59
60 sub check_auth {
61   $::auth->assert('admin');
62 }
63
64 1;