Merge branch 'master' of lx-office.linet-services.de:lx-office-erp
[kivitendo-erp.git] / SL / InstanceConfiguration.pm
1 package SL::InstanceConfiguration;
2
3 use strict;
4
5 use SL::DBUtils;
6
7 sub new {
8   my ($class) = @_;
9
10   return bless {}, $class;
11 }
12
13 sub init {
14   my ($self) = @_;
15
16   $self->{data} = selectfirst_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT * FROM defaults|);
17
18   my $curr            =  $self->{data}->{curr} || '';
19   $curr               =~ s/\s+//g;
20   $self->{currencies} =  [ split m/:/, $curr ];
21
22   return $self;
23 }
24
25 sub get_default_currency {
26   my ($self) = @_;
27
28   return ($self->get_currencies)[0];
29 }
30
31 sub get_currencies {
32   my ($self) = @_;
33
34   return $self->{currencies} ? @{ $self->{currencies} } : ();
35 }
36
37 1;
38
39 __END__
40
41 =pod
42
43 =encoding utf8
44
45 =head1 NAME
46
47 SL::InstanceConfiguration - Provide instance-specific configuration data
48
49 =head1 SYNOPSIS
50
51 Lx-Office has two configuration levels: installation specific
52 (provided by the global variable C<%::lxoffice_conf>) and instance
53 specific. The latter is provided by a global instance of this class,
54 C<$::instance_conf>.
55
56 =head1 FUNCTIONS
57
58 =over 4
59
60 =item C<new>
61
62 Creates a new instance. Does not read the configuration.
63
64 =item C<init>
65
66 Reads the configuration from the database. Returns C<$self>.
67
68 =item C<get_currencies>
69
70 Returns an array of configured currencies.
71
72 =item C<get_default_currency>
73
74 Returns the default currency or undef if no currency has been
75 configured.
76
77 =back
78
79 =head1 BUGS
80
81 Updates to the I<defaults> table require that the instance
82 configuration is re-read. This has not been implemented yet.
83
84 =head1 AUTHOR
85
86 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
87
88 =cut