Trac 2300 / 2301 zweiter Versuch
[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   #To get all currencies and the default currency:
19   ($self->{data}->{curr}) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT name AS curr FROM currencies WHERE id = (SELECT currency_id FROM defaults)|);
20   $self->{currencies}     = [ map { $_->{name} } selectall_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT name FROM currencies ORDER BY id|) ];
21
22   return $self;
23 }
24
25 sub get_default_currency {
26   my ($self) = @_;
27
28   return $self->{data}->{curr};
29 }
30
31 sub get_currencies {
32   my ($self) = @_;
33
34   return @{ $self->{currencies} };
35 }
36
37 sub get_accounting_method {
38   my ($self) = @_;
39   return $self->{data}->{accounting_method};
40 }
41
42 sub get_inventory_system {
43   my ($self) = @_;
44   return $self->{data}->{inventory_system};
45 }
46
47 sub get_profit_determination {
48   my ($self) = @_;
49   return $self->{data}->{profit_determination};
50 }
51
52 sub get_is_changeable {
53   my ($self) = @_;
54   return $self->{data}->{is_changeable};
55 }
56
57 sub get_ir_changeable {
58   my ($self) = @_;
59   return $self->{data}->{ir_changeable};
60 }
61
62 sub get_ar_changeable {
63   my ($self) = @_;
64   return $self->{data}->{ar_changeable};
65 }
66
67 sub get_ap_changeable {
68   my ($self) = @_;
69   return $self->{data}->{ap_changeable};
70 }
71
72 sub get_gl_changeable {
73   my ($self) = @_;
74   return $self->{data}->{gl_changeable};
75 }
76
77 sub get_datev_check_on_sales_invoice {
78   my ($self) = @_;
79   return $self->{data}->{datev_check_on_sales_invoice};
80 }
81
82 sub get_datev_check_on_purchase_invoice {
83   my ($self) = @_;
84   return $self->{data}->{datev_check_on_purchase_invoice};
85 }
86
87 sub get_datev_check_on_ar_transaction {
88   my ($self) = @_;
89   return $self->{data}->{datev_check_on_ar_transaction};
90 }
91
92 sub get_datev_check_on_ap_transaction {
93   my ($self) = @_;
94   return $self->{data}->{datev_check_on_ap_transaction};
95 }
96
97 sub get_datev_check_on_gl_transaction {
98   my ($self) = @_;
99   return $self->{data}->{datev_check_on_gl_transaction};
100 }
101
102 sub get_show_bestbefore {
103   my ($self) = @_;
104   return $self->{data}->{show_bestbefore};
105 }
106
107 sub get_is_show_mark_as_paid {
108   my ($self) = @_;
109   return $self->{data}->{is_show_mark_as_paid};
110 }
111
112 sub get_ir_show_mark_as_paid {
113   my ($self) = @_;
114   return $self->{data}->{ir_show_mark_as_paid};
115 }
116
117 sub get_ar_show_mark_as_paid {
118   my ($self) = @_;
119   return $self->{data}->{ar_show_mark_as_paid};
120 }
121
122 sub get_ap_show_mark_as_paid {
123   my ($self) = @_;
124   return $self->{data}->{ap_show_mark_as_paid};
125 }
126
127 sub get_sales_order_show_delete {
128   my ($self) = @_;
129   return $self->{data}->{sales_order_show_delete};
130 }
131
132 sub get_purchase_order_show_delete {
133   my ($self) = @_;
134   return $self->{data}->{purchase_order_show_delete};
135 }
136
137 sub get_sales_delivery_order_show_delete {
138   my ($self) = @_;
139   return $self->{data}->{sales_delivery_order_show_delete};
140 }
141
142 sub get_purchase_delivery_order_show_delete {
143   my ($self) = @_;
144   return $self->{data}->{purchase_delivery_order_show_delete};
145 }
146
147 sub get_default_warehouse_id {
148   my ($self) = @_;
149   return ($self->{data}->{warehouse_id});
150 }
151
152 sub get_default_bin_id {
153   my ($self) = @_;
154   return ($self->{data}->{bin_id});
155 }
156 sub get_default_warehouse_id_ignore_onhand {
157   my ($self) = @_;
158   return ($self->{data}->{warehouse_id_ignore_onhand});
159 }
160
161 sub get_default_bin_id_ignore_onhand {
162   my ($self) = @_;
163   return ($self->{data}->{bin_id_ignore_onhand});
164 }
165
166
167 sub get_transfer_default {
168   my ($self) = @_;
169   return ($self->{data}->{transfer_default});
170 }
171
172 sub get_transfer_default_use_master_default_bin {
173   my ($self) = @_;
174   return ($self->{data}->{transfer_default_use_master_default_bin});
175 }
176
177 sub get_transfer_default_ignore_onhand {
178   my ($self) = @_;
179   return ($self->{data}->{transfer_default_ignore_onhand});
180 }
181 # currently unused - value is set via audit_control (Bücherkontrolle)
182 sub get_max_future_booking_interval {
183   my ($self) = @_;
184   return ($self->{data}->{max_future_booking_interval});
185 }
186
187 sub get_webdav {
188   my ($self) = @_;
189   return ($self->{data}->{webdav});
190 }
191
192 sub get_webdav_documents {
193   my ($self) = @_;
194   return ($self->{data}->{webdav_documents});
195 }
196
197 sub get_vertreter {
198   my ($self) = @_;
199   return ($self->{data}->{vertreter});
200 }
201
202 sub get_parts_show_image {
203   my ($self) = @_;
204   return ($self->{data}->{parts_show_image});
205 }
206
207 sub get_parts_listing_images{
208   my ($self) = @_;
209   return ($self->{data}->{parts_listing_image});
210 }
211
212 sub get_parts_image_css {
213   my ($self) = @_;
214   return ($self->{data}->{parts_image_css});
215 }
216
217
218 1;
219
220 __END__
221
222 =pod
223
224 =encoding utf8
225
226 =head1 NAME
227
228 SL::InstanceConfiguration - Provide instance-specific configuration data
229
230 =head1 SYNOPSIS
231
232 kivitendo has two configuration levels: installation specific
233 (provided by the global variable C<%::lx_office_conf>) and instance
234 specific. The latter is provided by a global instance of this class,
235 C<$::instance_conf>.
236
237 =head1 FUNCTIONS
238
239 =over 4
240
241 =item C<new>
242
243 Creates a new instance. Does not read the configuration.
244
245 =item C<init>
246
247 Reads the configuration from the database. Returns C<$self>.
248
249 =item C<get_currencies>
250
251 Returns an array of configured currencies.
252
253 =item C<get_default_currency>
254
255 Returns the default currency or undef if no currency has been
256 configured.
257
258 =item C<get_accounting_method>
259
260 Returns the default accounting method, accrual or cash
261
262 =item C<get_inventory_system>
263
264 Returns the default inventory system, perpetual or periodic
265
266 =item C<get_profit_determination>
267
268 Returns the default profit determination method, balance or income
269
270
271 =item C<get_is_changeable>
272
273 =item C<get_ir_changeable>
274
275 =item C<get_ar_changeable>
276
277 =item C<get_ap_changeable>
278
279 =item C<get_gl_changeable>
280
281 Returns if and when these record types are changeable or deleteable after
282 posting. 0 means never, 1 means always and 2 means on the same day.
283
284 =item C<get_datev_check_on_sales_invoice>
285
286 Returns true if datev check should be performed on sales invoices
287
288 =item C<get_datev_check_on_purchase_invoice>
289
290 Returns true if datev check should be performed on purchase invoices
291
292 =item C<get_datev_check_on_ar_transaction>
293
294 Returns true if datev check should be performed on ar transactions
295
296 =item C<get_datev_check_on_ap_transaction>
297
298 Returns true if datev check should be performed on ap transactions
299
300 =item C<get_datev_check_on_gl_transaction>
301
302 Returns true if datev check should be performed on gl transactions
303
304 =item C<get_show_bestbefore>
305
306 Returns the default behavior for showing best before date, true or false
307
308 =item C<get_is_show_mark_as_paid>
309
310 =item C<get_ir_show_mark_as_paid>
311
312 =item C<get_ar_show_mark_as_paid>
313
314 =item C<get_ap_show_mark_as_paid>
315
316 Returns the default behavior for showing the mark as paid button for the
317 corresponding record type (true or false).
318
319 =item C<get_sales_order_show_delete>
320
321 =item C<get_purchase_order_show_delete>
322
323 =item C<get_sales_delivery_order_show_delete>
324
325 =item C<get_purchase_delivery_order_show_delete>
326
327 Returns the default behavior for showing the delete button for the
328 corresponding record type (true or false).
329
330 =item C<get_default_warehouse_id>
331
332 Returns the default warehouse_id
333
334 =item C<get_default_bin_id>
335
336 Returns the default bin_id
337
338 =item C<get_default_warehouse_id_ignore_onhand>
339
340 Returns the default warehouse_id for transfers without checking the
341 current stock quantity
342
343 =item C<get_default_bin_id_ignore_onhand>
344
345 Returns the default bin_id for transfers without checking the.
346 current stock quantity
347
348
349
350 =item C<get_transfer_default>
351
352 =item C<get_transfer_default_use_master_default_bin>
353
354 =item C<get_transfer_default_ignore_onhand>
355
356 Returns the default behavior for the transfer out default feature (true or false)
357
358 =item C<get_max_future_booking_interval>
359
360 Returns the maximum interval value for future bookings
361
362 =item C<get_webdav>
363
364 Returns the configuration for webdav
365
366 =item C<get_webdav_documents>
367
368 Returns the configuration for storing documents in the corresponding webdav folder
369
370 =item C<get_vertreter>
371
372 Returns the configuration for "vertreter"
373
374 =item C<get_parts_show_image>
375
376 Returns the configuarion for show image in parts
377
378 =item C<get_parts_image_css>
379
380 Returns the css format string for images shown in parts
381
382 =item C<get_parts_listing_image>
383
384 Returns the configuartion for showing the picture in the results when you search for parts
385
386 =back
387
388 =head1 BUGS
389
390 Updates to the I<defaults> table require that the instance
391 configuration is re-read. This has not been implemented yet.
392
393 =head1 AUTHOR
394
395 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
396
397 =cut