In SL::InstanceConfiguration keine Rose-Objekte nutzen
[kivitendo-erp.git] / SL / InstanceConfiguration.pm
1 package SL::InstanceConfiguration;
2
3 use strict;
4
5 use Carp;
6 use SL::DBUtils ();
7
8 use parent qw(Rose::Object);
9 use Rose::Object::MakeMethods::Generic (
10   'scalar --get_set_init' => [ qw(data currencies) ],
11 );
12
13 sub init_data {
14   my $dbh                   = $::form->get_standard_dbh;
15   my $data                  = SL::DBUtils::selectfirst_hashref_query($::form, $dbh, qq|SELECT * FROM defaults|);
16   $data->{default_currency} = (SL::DBUtils::selectfirst_array_query($::form, $dbh, qq|SELECT name FROM currencies WHERE id = ?|, $data->{currency_id}))[0] if $data->{currency_id};
17
18   return $data;
19 }
20
21 sub init_currencies {
22   return [ map { $_->{name} } SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT name FROM currencies ORDER BY id ASC|) ];
23 }
24
25 sub reload {
26   my ($self)          = @_;
27   $self->{data}       = $self->init_data;
28   $self->{currencies} = $self->init_currencies;
29   return $self;
30 }
31
32 sub get_currencies {
33   my ($self) = @_;
34   return @{ $self->currencies };
35 }
36
37 sub AUTOLOAD {
38   our $AUTOLOAD;
39
40   my $self   =  shift;
41   my $method =  $AUTOLOAD;
42   $method    =~ s/.*:://;
43
44   if ($method =~ m/^get_/) {
45     $method = substr $method, 4;
46     return $self->data->{$method} if exists $self->data->{$method};
47     croak "Invalid method 'get_${method}'";
48   }
49
50   croak "Invalid method '${method}'" if !$self->can($method);
51   return $self->$method(@_);
52 }
53
54 1;
55
56 __END__
57
58 =pod
59
60 =encoding utf8
61
62 =head1 NAME
63
64 SL::InstanceConfiguration - Provide instance-specific configuration data
65
66 =head1 SYNOPSIS
67
68 kivitendo has two configuration levels: installation specific
69 (provided by the global variable C<%::lx_office_conf>) and instance
70 specific. The latter is provided by a global instance of this class,
71 C<$::instance_conf>.
72
73 =head1 FUNCTIONS
74
75 =over 4
76
77 =item C<new>
78
79 Creates a new instance. Does not read the configuration.
80
81 =item C<init>
82
83 Reads the configuration from the database. Returns C<$self>.
84
85 =item C<get_currencies>
86
87 Returns an array of configured currencies.
88
89 =item C<get_default_currency>
90
91 Returns the default currency or undef if no currency has been
92 configured.
93
94 =item C<get_accounting_method>
95
96 Returns the default accounting method, accrual or cash
97
98 =item C<get_inventory_system>
99
100 Returns the default inventory system, perpetual or periodic
101
102 =item C<get_profit_determination>
103
104 Returns the default profit determination method, balance or income
105
106
107 =item C<get_is_changeable>
108
109 =item C<get_ir_changeable>
110
111 =item C<get_ar_changeable>
112
113 =item C<get_ap_changeable>
114
115 =item C<get_gl_changeable>
116
117 Returns if and when these record types are changeable or deleteable after
118 posting. 0 means never, 1 means always and 2 means on the same day.
119
120 =item C<get_datev_check_on_sales_invoice>
121
122 Returns true if datev check should be performed on sales invoices
123
124 =item C<get_datev_check_on_purchase_invoice>
125
126 Returns true if datev check should be performed on purchase invoices
127
128 =item C<get_datev_check_on_ar_transaction>
129
130 Returns true if datev check should be performed on ar transactions
131
132 =item C<get_datev_check_on_ap_transaction>
133
134 Returns true if datev check should be performed on ap transactions
135
136 =item C<get_datev_check_on_gl_transaction>
137
138 Returns true if datev check should be performed on gl transactions
139
140 =item C<get_show_bestbefore>
141
142 Returns the default behavior for showing best before date, true or false
143
144 =item C<get_is_show_mark_as_paid>
145
146 =item C<get_ir_show_mark_as_paid>
147
148 =item C<get_ar_show_mark_as_paid>
149
150 =item C<get_ap_show_mark_as_paid>
151
152 Returns the default behavior for showing the mark as paid button for the
153 corresponding record type (true or false).
154
155 =item C<get_sales_order_show_delete>
156
157 =item C<get_purchase_order_show_delete>
158
159 =item C<get_sales_delivery_order_show_delete>
160
161 =item C<get_purchase_delivery_order_show_delete>
162
163 Returns the default behavior for showing the delete button for the
164 corresponding record type (true or false).
165
166 =item C<get_default_warehouse_id>
167
168 Returns the default warehouse_id
169
170 =item C<get_default_bin_id>
171
172 Returns the default bin_id
173
174 =item C<get_default_warehouse_id_ignore_onhand>
175
176 Returns the default warehouse_id for transfers without checking the
177 current stock quantity
178
179 =item C<get_default_bin_id_ignore_onhand>
180
181 Returns the default bin_id for transfers without checking the.
182 current stock quantity
183
184
185
186 =item C<get_transfer_default>
187
188 =item C<get_transfer_default_use_master_default_bin>
189
190 =item C<get_transfer_default_ignore_onhand>
191
192 Returns the default behavior for the transfer out default feature (true or false)
193
194 =item C<get_max_future_booking_interval>
195
196 Returns the maximum interval value for future bookings
197
198 =item C<get_webdav>
199
200 Returns the configuration for webdav
201
202 =item C<get_webdav_documents>
203
204 Returns the configuration for storing documents in the corresponding webdav folder
205
206 =item C<get_vertreter>
207
208 Returns the configuration for "vertreter"
209
210 =item C<get_parts_show_image>
211
212 Returns the configuarion for show image in parts
213
214 =item C<get_parts_image_css>
215
216 Returns the css format string for images shown in parts
217
218 =item C<get_parts_listing_image>
219
220 Returns the configuartion for showing the picture in the results when you search for parts
221
222 =back
223
224 =head1 BUGS
225
226 Updates to the I<defaults> table require that the instance
227 configuration is re-read. This has not been implemented yet.
228
229 =head1 AUTHOR
230
231 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
232
233 =cut