1 package SL::Controller::ClientConfig;
4 use parent qw(SL::Controller::Base);
8 use SL::Locale::String qw(t8);
10 __PACKAGE__->run_before('check_auth');
12 use Rose::Object::MakeMethods::Generic (
13 'scalar --get_set_init' => [ qw(defaults all_warehouses posting_options payment_options accounting_options inventory_options profit_options) ],
17 my ($self, %params) = @_;
22 my ($self, %params) = @_;
24 my $defaults = delete($::form->{defaults}) || {};
26 # undef several fields if an empty value has been selected.
27 foreach (qw(warehouse_id bin_id warehouse_id_ignore_onhand bin_id_ignore_onhand)) {
28 undef $defaults->{$_} if !$defaults->{$_};
31 $self->defaults->update_attributes(%{ $defaults });
33 flash_later('info', t8('Client Configuration saved!'));
35 $self->redirect_to(action => 'edit');
42 sub init_defaults { SL::DB::Default->get }
43 sub init_all_warehouses { SL::DB::Manager::Warehouse->get_all_sorted }
45 sub init_posting_options {
46 [ { title => t8("never"), value => 0 },
47 { title => t8("every time"), value => 1 },
48 { title => t8("on the same day"), value => 2 }, ]
51 sub init_payment_options {
52 [ { title => t8("never"), value => 0 },
53 { title => t8("every time"), value => 1 },
54 { title => t8("on the same day"), value => 2 }, ]
57 sub init_accounting_options {
58 [ { title => t8("Accrual"), value => "accrual" },
59 { title => t8("cash"), value => "cash" }, ]
62 sub init_inventory_options {
63 [ { title => t8("perpetual"), value => "perpetual" },
64 { title => t8("periodic"), value => "periodic" }, ]
67 sub init_profit_options {
68 [ { title => t8("balance"), value => "balance" },
69 { title => t8("income"), value => "income" }, ]
77 $::auth->assert('admin');
86 $self->render('client_config/form', title => t8('Client Configuration'));