Sonderbehandlung im template
[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->{posting_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->{payment_options} = [ { title => $::locale->text("never"), value => 0 },
19                                { title => $::locale->text("every time"), value => 1 },
20                                { title => $::locale->text("on the same day"), value => 2 }, ];
21   $self->{accounting_options} = [ { title => $::locale->text("Accrual"), value => "accrual" },
22                                   { title => $::locale->text("cash"), value => "cash" }, ];
23   $self->{inventory_options} = [ { title => $::locale->text("perpetual"), value => "perpetual" },
24                                  { title => $::locale->text("periodic"), value => "periodic" }, ];
25   $self->{profit_options} = [ { title => $::locale->text("balance"), value => "balance" },
26                               { title => $::locale->text("income"), value => "income" }, ];
27
28   map { $self->{$_} = SL::DB::Default->get->$_ } qw(is_changeable ir_changeable ar_changeable ap_changeable gl_changeable);
29
30   $self->{payments_changeable} = SL::DB::Default->get->payments_changeable;
31
32   map { $self->{$_} = SL::DB::Default->get->$_ } qw(is_show_mark_as_paid ir_show_mark_as_paid ar_show_mark_as_paid ap_show_mark_as_paid);
33
34   map { $self->{$_} = SL::DB::Default->get->$_ } qw(accounting_method inventory_system profit_determination);
35
36   $self->{show_bestbefore}     = SL::DB::Default->get->show_bestbefore;
37
38   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);
39   # datev check: not implemented yet:
40   #check_on_cash_and_receipt = 0
41   #check_on_dunning = 0
42   #check_on_sepa_import = 0
43
44   map { $self->{$_} = SL::DB::Default->get->$_ } qw(sales_order_show_delete purchase_order_show_delete sales_delivery_order_show_delete purchase_delivery_order_show_delete);
45
46   $self->render('client_config/form', title => $::locale->text('Client Configuration'));
47 }
48
49
50 sub action_save {
51   my ($self, %params) = @_;
52
53   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(is_changeable ir_changeable ar_changeable ap_changeable gl_changeable);
54
55   SL::DB::Default->get->update_attributes('payments_changeable' => $::form->{payments_changeable});
56
57   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(is_show_mark_as_paid ir_show_mark_as_paid ar_show_mark_as_paid ap_show_mark_as_paid);
58
59   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(accounting_method inventory_system profit_determination);
60
61   SL::DB::Default->get->update_attributes('show_bestbefore'     => $::form->{show_bestbefore});
62
63   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);
64
65   map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(sales_order_show_delete purchase_order_show_delete sales_delivery_order_show_delete purchase_delivery_order_show_delete);
66
67   flash_later('info', $::locale->text('Client Configuration saved!'));
68
69   $self->redirect_to(action => 'edit');
70 }
71
72
73 #################### private stuff ##########################
74
75 sub check_auth {
76   $::auth->assert('admin');
77 }
78
79 1;