1 package SL::InstanceConfiguration;
7 use SL::System::Process;
9 use parent qw(Rose::Object);
10 use Rose::Object::MakeMethods::Generic (
11 'scalar --get_set_init' => [ qw(data currencies default_currency _table_currencies_exists crm_installed) ],
15 return {} if !$::auth->client;
16 return SL::DBUtils::selectfirst_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT * FROM defaults|);
19 sub init__table_currencies_exists {
20 return 0 if !$::auth->client;
21 return !!(SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT tablename FROM pg_tables WHERE (schemaname = 'public') AND (tablename = 'currencies')|))[0];
27 return [] if !$self->_table_currencies_exists;
28 return [ map { $_->{name} } SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT name FROM currencies ORDER BY id ASC|) ];
31 sub init_default_currency {
34 return undef if !$self->_table_currencies_exists || !$self->data->{currency_id};
35 return (SL::DBUtils::selectfirst_array_query($::form, $::form->get_standard_dbh, qq|SELECT name FROM currencies WHERE id = ?|, $self->data->{currency_id}))[0];
38 sub init_crm_installed {
39 return -f (SL::System::Process->exe_dir . '/crm/Changelog');
45 delete @{ $self }{qw(data currencies default_currency)};
52 return @{ $self->currencies };
59 my $method = $AUTOLOAD;
62 return if $method eq 'DESTROY';
64 if ($method =~ m/^get_/) {
65 $method = substr $method, 4;
66 return $self->data->{$method} if exists $self->data->{$method};
67 croak "Invalid method 'get_${method}'";
70 croak "Invalid method '${method}'" if !$self->can($method);
71 return $self->$method(@_);
84 SL::InstanceConfiguration - Provide instance-specific configuration data
88 kivitendo has two configuration levels: installation specific
89 (provided by the global variable C<%::lx_office_conf>) and instance
90 specific. The latter is provided by a global instance of this class,
97 =item C<get_currencies>
99 Returns an array of configured currencies.
105 Updates to the I<defaults> table require that the instance
106 configuration is re-read. This has not been implemented yet.
110 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>