$main::lxdebug->message(LXDebug->DEBUG1(), "Auth::create_database DSN: $dsn");
 
-  my $charset    = $main::dbcharset;
+  my $charset    = $::lx_office_conf{system}->{dbcharset};
   $charset     ||= Common::DEFAULT_CHARSET;
   my $encoding   = $Common::charset_to_db_encoding{$charset};
   $encoding    ||= 'UNICODE';
   my $self = shift;
   my $dbh  = $self->dbconnect();
 
-  my $charset    = $main::dbcharset;
+  my $charset    = $::lx_office_conf{system}->{dbcharset};
   $charset     ||= Common::DEFAULT_CHARSET;
 
   $dbh->rollback();
 
   my ($form) = @_;
 
   return $main::lxdebug->leave_sub()
-    unless ($main::webdav && $form->{id});
+    unless ($::lx_office_conf{system}->{webdav} && $form->{id});
 
   my ($path, $number);
 
 
       my $content_type  = $options->{type} eq 'js' ? 'text/javascript' : 'text/html';
 
       print $::form->create_http_response(content_type => $content_type,
-                                          charset      => $::dbcharset || Common::DEFAULT_CHARSET());
+                                          charset      => $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET());
 
     } else {
       $::form->{title} = $locals{title} if $locals{title};
                  AUTH     => $::auth,
                  FORM     => $::form,
                  LOCALE   => $::locale,
-                 LXCONFIG => { dbcharset              => $::dbcharset,
-                               webdav                 => $::webdav,
-                               lizenzen               => $::lizenzen,
+                 LXCONFIG => { dbcharset              => $::lx_office_conf{system}->{dbcharset},
+                               webdav                 => $::lx_office_conf{system}->{webdav},
+                               lizenzen               => $::lx_office_conf{system}->{lizenzen},
                                latex_templates        => $::lx_office_conf{print_templates}->{latex},
                                opendocument_templates => $::lx_office_conf{print_templates}->{opendocument},
-                               vertreter              => $::vertreter,
-                               show_best_before       => $::show_best_before,
+                               vertreter              => $::lx_office_conf{system}->{vertreter},
+                               show_best_before       => $::lx_office_conf{system}->{show_best_before},
                              },
                  LXDEBUG  => $::lxdebug,
                  MYCONFIG => \%::myconfig,
 
 sub _calculate_assembly_item {
   my ($self, $data, $part, $total_qty, $base_factor) = @_;
 
-  return 0 if $::eur || !$data->{is_invoice};
+  return 0 if $::lx_office_conf{system}->{eur} || !$data->{is_invoice};
 
   foreach my $assembly_entry (@{ $part->assemblies }) {
     push @{ $data->{assembly_items}->[-1] }, { part      => $assembly_entry->part,
 
   _dbg("cpsi tq " . $total_qty);
 
-  return 0 if $::eur || !$data->{is_invoice} || !$total_qty;
+  return 0 if $::lx_office_conf{system}->{eur} || !$data->{is_invoice} || !$total_qty;
 
   my ($entry);
   $base_factor           ||= 1;
 
 =item 6. Items in C<invoice> are updated according to their allocation
 status (regarding for costs of goold sold). Will only be done if
 Lx-Office is not configured to use Einnahmenüberschussrechnungen
-(C<$::eur>).
+(see config/lx_office.conf, section "system", variable "eur").
 
 =item 7. The invoice and its items are saved.
 
 
 
   return 0 if !@unapplied_scripts;
 
-  my $db_charset           = $main::dbcharset || Common::DEFAULT_CHARSET;
+  my $db_charset           = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
   $self->{form}->{login} ||= 'admin';
 
   map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $self->{all_controls} };
 
 
   $form->{saved_donumber} = $form->{donumber};
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   $main::lxdebug->leave_sub();
 
     $sth->finish();
   }
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   $main::lxdebug->leave_sub();
 
 
   my $template             = shift;
   my $error_type           = shift || '';
 
-  $::locale                = Locale->new($::language);
+  $::locale                = Locale->new($::lx_office_conf{system}->{language});
   $::form->{error}         = $::locale->text('The session is invalid or has expired.') if ($error_type eq 'session');
   $::form->{error}         = $::locale->text('Incorrect password!.')                   if ($error_type eq 'password');
-  $::myconfig{countrycode} = $::language;
+  $::myconfig{countrycode} = $::lx_office_conf{system}->{language};
   $::form->{stylesheet}    = 'css/lx-office-erp.css';
 
   $::form->header;
   $self->unrequire_bin_mozilla;
 
   $::cgi         = CGI->new('');
-  $::locale      = Locale->new($::language);
+  $::locale      = Locale->new($::lx_office_conf{system}->{language});
   $::form        = Form->new;
   %::called_subs = ();
 
 
 
 sub fix_print_and_internal_encoding_after_0_68 {
   return if version->new("$FCGI::VERSION")->numify <= version->new("0.68")->numify;
-  return if lc($::dbcharset) !~ m/^(?:utf-?8|unicode)$/;
+  return if lc($::lx_office_conf{system}->{dbcharset}) !~ m/^(?:utf-?8|unicode)$/;
 
   my $encoder             = Encode::find_encoding('UTF-8');
   my $original_fcgi_print = \&FCGI::Stream::PRINT;
 
     $self->_request_to_hash($content);
   }
 
-  my $db_charset   = $main::dbcharset;
+  my $db_charset   = $::lx_office_conf{system}->{dbcharset};
   $db_charset    ||= Common::DEFAULT_CHARSET;
 
   my $encoding     = $self->{INPUT_ENCODING} || $db_charset;
   # extra code is currently only used by menuv3 and menuv4 to set their css.
   # it is strongly deprecated, and will be changed in a future version.
   my ($self, $extra_code) = @_;
-  my $db_charset = $::dbcharset || Common::DEFAULT_CHARSET;
+  my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
   my @header;
 
   $::lxdebug->leave_sub and return if !$ENV{HTTP_USER_AGENT} || $self->{header}++;
 
   my ($self) = @_;
 
-  my $db_charset = $main::dbcharset ? $main::dbcharset : Common::DEFAULT_CHARSET;
+  my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
   my $cgi        = $main::cgi || CGI->new('');
   my $output     = $cgi->header('-charset' => $db_charset);
 
   my $language;
 
   if (!%::myconfig || !$::myconfig{"countrycode"}) {
-    $language = $main::language;
+    $language = $::lx_office_conf{system}->{language};
   } else {
     $language = $main::myconfig{"countrycode"};
   }
     map { $additional_params->{"myconfig_${_}"} = $main::myconfig{$_}; } keys %::myconfig;
   }
 
-  $additional_params->{"conf_dbcharset"}              = $::dbcharset;
-  $additional_params->{"conf_webdav"}                 = $::webdav;
-  $additional_params->{"conf_lizenzen"}               = $::lizenzen;
+  $additional_params->{"conf_dbcharset"}              = $::lx_office_conf{system}->{dbcharset};
+  $additional_params->{"conf_webdav"}                 = $::lx_office_conf{system}->{webdav};
+  $additional_params->{"conf_lizenzen"}               = $::lx_office_conf{system}->{lizenzen};
   $additional_params->{"conf_latex_templates"}        = $::lx_office_conf{print_templates}->{latex};
   $additional_params->{"conf_opendocument_templates"} = $::lx_office_conf{print_templates}->{opendocument};
-  $additional_params->{"conf_vertreter"}              = $::vertreter;
-  $additional_params->{"conf_show_best_before"}       = $::show_best_before;
-  $additional_params->{"conf_parts_image_css"}        = $::parts_image_css;
-  $additional_params->{"conf_parts_listing_images"}   = $::parts_listing_images;
-  $additional_params->{"conf_parts_show_image"}       = $::parts_show_image;
+  $additional_params->{"conf_vertreter"}              = $::lx_office_conf{system}->{vertreter};
+  $additional_params->{"conf_show_best_before"}       = $::lx_office_conf{system}->{show_best_before};
+  $additional_params->{"conf_parts_image_css"}        = $::lx_office_conf{features}->{parts_image_css};
+  $additional_params->{"conf_parts_listing_images"}   = $::lx_office_conf{features}->{parts_listing_images};
+  $additional_params->{"conf_parts_show_image"}       = $::lx_office_conf{features}->{parts_show_image};
 
   if (%main::debug_options) {
     map { $additional_params->{'DEBUG_' . uc($_)} = $main::debug_options{$_} } keys %main::debug_options;
 
       map { $mail->{$_} = $self->{$_} }
         qw(cc bcc subject message version format);
-      $mail->{charset} = $main::dbcharset ? $main::dbcharset : Common::DEFAULT_CHARSET;
+      $mail->{charset} = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
       $mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email};
       $mail->{from}   = qq|"$myconfig->{name}" <$myconfig->{email}>|;
       $mail->{fileid} = "$fileid.";
 
     $form->{"qty_$i"}  = $form->parse_amount($myconfig, $form->{"qty_$i"});
     $form->{"qty_$i"} *= -1 if $form->{storno};
 
-    $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"} if $main::eur;
+    $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"} if $::lx_office_conf{system}->{eur};
 
     # get item baseunit
     if (!$item_units{$form->{"id_$i"}}) {
   # delete zero entries
   do_query($form, $dbh, qq|DELETE FROM acc_trans WHERE amount = 0|);
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   # Link this record to the records it was created from.
   RecordLinks->create_links('dbh'        => $dbh,
   }
   $sth->finish();
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   $dbh->disconnect();
 
 
   # save printed, emailed and queued
   $form->save_status($dbh);
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   # Link this record to the records it was created from.
   RecordLinks->create_links('dbh'        => $dbh,
     # sellprice is the cost of the item
     my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / ( ($ref->{price_factor} || 1) * ( $basefactor || 1 )), 2);
 
-    if (!$main::eur) {
+    if (!$::lx_office_conf{system}->{eur}) {
       $ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno};
       # add to expense
       $form->{amount_cogs}{ $form->{id} }{ $ref->{expense_accno} } += -$linetotal;
     }
     $sth->finish;
 
-    Common::webdav_folder($form) if ($main::webdav);
+    Common::webdav_folder($form);
   }
 
   my $rc = $dbh->commit;
 
 
   my ($type, $country) = @_;
 
-  $country ||= $::language;
+  $country ||= $::lx_office_conf{system}->{language};
   $country   =~ s|.*/||;
   $country   =~ s|\.||g;
 
     }
   }
 
-  my $db_charset            = $main::dbcharset || Common::DEFAULT_CHARSET;
-  $self->{is_utf8}          = (any { lc($::dbcharset || '') eq $_ } qw(utf8 utf-8 unicode)) ? 1 : 0;
+  my $db_charset            = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
+  $self->{is_utf8}          = (any { lc($::lx_office_conf{system}->{dbcharset} || '') eq $_ } qw(utf8 utf-8 unicode)) ? 1 : 0;
 
   if ($self->{is_utf8}) {
     binmode STDOUT, ":utf8";
 
   $form->{saved_xyznumber} = $form->{$form->{type} =~ /_quotation$/ ?
                                        "quonumber" : "ordnumber"};
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   my $rc = $dbh->commit;
 
 
   $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{transdate}, ($form->{vc} eq 'customer') ? "buy" : "sell");
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   $self->load_periodic_invoice_config($form);
 
 
   my $num_columns     = scalar @visible_columns;
   my $num_header_rows = 1;
 
-  my $font_encoding   = $main::dbcharset || 'ISO-8859-15';
+  my $font_encoding   = $::lx_office_conf{system}->{dbcharset} || 'ISO-8859-15';
 
   foreach my $name (@visible_columns) {
     push @column_props, { 'justify' => $self->{columns}->{$name}->{align} eq 'right' ? 'right' : 'left' };
 
   my $self = $type->SUPER::new(@_);
 
   $self->{"rnd"}   = int(rand(1000000));
-  $self->{"iconv"} = SL::Iconv->new($main::dbcharset, "UTF-8");
+  $self->{"iconv"} = SL::Iconv->new($::lx_office_conf{system}->{dbcharset}, "UTF-8");
 
   $self->set_tag_style('<%', '%>');
   $self->{quot_re} = '"';
 
     closedir(SQLDIR);
   }
 
-  my $db_charset = $main::dbcharset;
+  my $db_charset = $::lx_office_conf{system}->{dbcharset};
   $db_charset ||= Common::DEFAULT_CHARSET;
 
   my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver});
   $form->{sid} = $form->{dbdefault};
 
   my $rc         = -2;
-  my $db_charset = $main::dbcharset || Common::DEFAULT_CHARSET;
+  my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
 
   map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $dbupdater->{all_controls} };
 
 
   }
   closedir SQLDIR;
 
-  my $default_charset = $main::dbcharset;
+  my $default_charset = $::lx_office_conf{system}->{dbcharset};
   $default_charset ||= Common::DEFAULT_CHARSET;
 
   my $cluster_encoding = User->dbclusterencoding($form);
   if ($cluster_encoding && ($cluster_encoding =~ m/^(?:UTF-?8|UNICODE)$/i)) {
-    if ($main::dbcharset !~ m/^UTF-?8$/i) {
+    if ($::lx_office_conf{system}->{dbcharset} !~ m/^UTF-?8$/i) {
       $form->show_generic_error($locale->text('The selected  PostgreSQL installation uses UTF-8 as its encoding. ' .
                                               'Therefore you have to configure Lx-Office to use UTF-8 as well.'),
                                 'back_button' => 1);
 
     map { $mail->{$_} = $form->{$_} } qw(from to cc subject message);
 
-    $mail->{charset}     = $main::dbcharset ? $main::dbcharset : Common::DEFAULT_CHARSET;
+    $mail->{charset}     = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
     $mail->{attachments} = [ { "filename" => $tmp, "name" => $name } ];
     $mail->send();
 
     $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.'));
   }
 
-  my $default_charset   = $main::dbcharset;
+  my $default_charset   = $::lx_office_conf{system}->{dbcharset};
   $default_charset    ||= Common::DEFAULT_CHARSET;
 
   $form->{DBENCODINGS}  = [];
 
   $form->{title} = $locale->text('Type of Business');
 
   my @column_index = qw(description discount customernumberinit);
-  push @column_index, 'salesman' if $::vertreter;
+  push @column_index, 'salesman' if $::lx_office_conf{system}->{vertreter};
   my %column_header;
   $column_header{description} =
       qq|<th class=listheading width=60%>|
     $form->format_amount(\%myconfig, $form->{discount} * 100);
 
   my $salesman_code;
-  if ($::vertreter) {
+  if ($::lx_office_conf{system}->{vertreter}) {
     $salesman_code = qq|
   <tr>
     <th align="right">| . $locale->text('Representative') . qq|</th>
   }
 
   my $linkaccounts;
-  if (!$main::eur) {
+  if (!$::lx_office_conf{system}->{eur}) {
     $linkaccounts = qq|
                <tr>
                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
 
   $form->{title} = $locale->text('Chart of Accounts');
 
-  if ($main::eur) {
+  if ($::lx_office_conf{system}->{eur}) {
     $form->{method} = "cash";
   }
 
           <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
         </tr>
 | if $form->{selectdepartment};
-  my $accrual = ($main::eur) ? ""        : "checked";
-  my $cash    = ($main::eur) ? "checked" : "";
+  my $accrual = $::lx_office_conf{system}->{eur} ? ""        : "checked";
+  my $cash    = $::lx_office_conf{system}->{eur} ? "checked" : "";
 
   my $name_1    = "fromdate";
   my $id_1      = "fromdate";
 
   $form->{description} =~ s/\"/"/g;
 
+  my $eur = $::lx_office_conf{system}->{eur};
+
   print qq|
 <body onLoad="$onload">
 
 <input type=hidden name=accno value=$form->{accno}>
 <input type=hidden name=description value="$form->{description}">
 <input type=hidden name=sort value=transdate>
-<input type=hidden name=eur value=$main::eur>
+<input type=hidden name=eur value=$eur>
 <input type=hidden name=accounttype value=$form->{accounttype}>
 
 <table border=0 width=100%>
 
                    taxzones  => "ALL_TAXZONES");
   $form->get_pricegroup(\%myconfig, { all => 1 });
 
-  $form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1 }) if $::vertreter;
+  $form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1 }) if $::lx_office_conf{system}->{vertreter};
 
   $form->{ALL_SALESMEN}   = $form->{ALL_EMPLOYEES};
   $form->{taxincluded}    = ($form->{taxincluded}) ? "checked" : "";
 
   $::form->isblank("name", $::locale->text("Name missing!"));
 
-  if ($::form->{new_salesman_id} && $::vertreter) {
+  if ($::form->{new_salesman_id} && $::lx_office_conf{system}->{vertreter}) {
     $::form->{salesman_id} = $::form->{new_salesman_id};
     delete $::form->{new_salesman_id};
   }
 
   $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
 
   # retrieve order/quotation
-  $form->{webdav}   = $main::webdav;
+  $form->{webdav}   = $::lx_office_conf{system}->{webdav};
   $form->{jsscript} = 1;
 
   my $editing = $form->{id};
     map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{ $ref };
     map { $form->{"${_}_$form->{rowcount}"} = $form->format_amount(\%myconfig, $ref->{$_}) } qw(qty sellprice lastcost);
 
-    if ($vc_discount){ # falls wir einen Lieferanten/Kundenrabatt haben 
+    if ($vc_discount){ # falls wir einen Lieferanten/Kundenrabatt haben
       # und keinen anderen discount wert an $i ...
       $form->{"discount_$form->{rowcount}"} ||= $vc_discount; # ... nehmen wir diesen Rabatt
     }
       foreach my $request (@{ DO->unpack_stock_information('packed' => $form->{"stock_out_$i"}) }) {
         $request->{parts_id} = $form->{"id_$i"};
         $request->{base_qty} = $request->{qty} * $units->{$request->{unit}}->{factor} / $base_unit_factor;
-        $request->{project_id} = $form->{"project_id_$i"} ? $form->{"project_id_$i"} : $form->{globalproject_id}; 
+        $request->{project_id} = $form->{"project_id_$i"} ? $form->{"project_id_$i"} : $form->{globalproject_id};
 
         my $map_key          = join '--', ($form->{"id_$i"}, @{$request}{qw(warehouse_id bin_id chargenumber bestbefore)});
 
         my $pinfo = $part_info_map{$request->{parts_id}};
         my $binfo = $bin_info_map{$request->{bin_id}};
 
-        if ($main::show_best_before) {
+        if ($::lx_office_conf{system}->{show_best_before}) {
             push @{ $form->{ERRORS} }, $locale->text("There is not enough available of '#1' at warehouse '#2', bin '#3', #4, #5, for the transfer of #6.",
                                                      $pinfo->{description},
                                                      $binfo->{warehouse_description},
 
 
   $auth->assert('part_service_assembly_edit');
 
-  $form->{eur}              = $main::eur; # config dumps into namespace - yuck
+  $form->{eur}              = $::lx_office_conf{system}->{eur}; # config dumps into namespace - yuck
   $form->{pg_keys}          = sub { "$_[0]->{partsgroup}--$_[0]->{id}" };
   $form->{description_area} = ($form->{rows} = $form->numtextrows($form->{description}, 40)) > 1;
   $form->{notes_rows}       =  max 4, $form->numtextrows($form->{notes}, 40), $form->numtextrows($form->{formel}, 40);
 
   return if (scalar(@missing_modules) == 0);
 
   use SL::Locale;
-  my $locale = new Locale($main::language, "installationcheck");
+
+  my $locale = new Locale($::lx_office_conf{system}->{language}, "installationcheck");
 
   print(qq|content-type: text/html
 
 
     ::end_of_request();
   }
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   #   if (   $form->{print_and_post}
   #       && $form->{second_run}
 
     qw(bin listprice inventory_accno income_accno expense_accno unit weight
        assembly taxaccounts partsgroup formel longdescription not_discountable
        part_payment_id partnotes id lastcost price_factor_id price_factor);
-  push @new_fields, "lizenzen" if ($main::lizenzen);
+  push @new_fields, "lizenzen" if $::lx_office_conf{system}->{lizenzen};
   push @new_fields, grep { m/^ic_cvar_/ } keys %{ $form->{item_list}->[0] };
 
   my $i = 0;
   foreach my $ref (@{ $form->{item_list} }) {
     my $checked = ($i++) ? "" : "checked";
 
-    if ($main::lizenzen) {
+    if ($::lx_office_conf{system}->{lizenzen}) {
       if ($ref->{inventory_accno} > 0) {
         $ref->{"lizenzen"} = qq|<option></option>|;
         foreach my $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
     $form->{payment_id} = $form->{"part_payment_id_$i"};
   }
 
-  if ($main::lizenzen) {
+  if ($::lx_office_conf{system}->{lizenzen}) {
     map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
   }
 
   my $script = $form->{"script"};
   $script =~ s|.*/||;
   $script =~ s|.pl$||;
-  $locale = new Locale($main::language, $script);
+  $locale = new Locale($::lx_office_conf{system}->{language}, $script);
 
   map { $form->{"select$_"} = "" } ($form->{vc}, "currency");
 
 
   $form->{vc} = 'vendor';
 
   # create links
-  $form->{webdav}   = $main::webdav;
+  $form->{webdav}   = $::lx_office_conf{system}->{webdav};
   $form->{jsscript} = 1;
 
   $form->create_links("AP", \%myconfig, "vendor");
 
   $form->{vc} = 'customer';
 
   # create links
-  $form->{webdav}   = $main::webdav;
-  $form->{lizenzen} = $main::lizenzen;
+  $form->{webdav}   = $::lx_office_conf{system}->{webdav};
+  $form->{lizenzen} = $::lx_office_conf{system}->{lizenzen};
 
   $form->create_links("AR", \%myconfig, "customer");
 
 
         $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
 
-        if ($main::lizenzen) {
+        if ($::lx_office_conf{system}->{lizenzen}) {
           if ($form->{"inventory_accno_$i"} ne "") {
             $form->{"lizenzen_$i"} = qq|<option></option>|;
             foreach my $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) {
 
 
   $form->{title} = $locale->text('Add License');
 
-  if (!$main::lizenzen) {
+  if (!$::lx_office_conf{system}->{lizenzen}) {
     $form->error(
                  $locale->text(
                    'The licensing module has been deactivated in lx-erp.conf.')
 
   $form->{title} = $locale->text('Licenses');
 
-  if (!$main::lizenzen) {
+  if (!$::lx_office_conf{system}->{lizenzen}) {
     $form->error(
                  $locale->text(
                    'The licensing module has been deactivated in lx-erp.conf.')
 
 sub show_error {
   my $template           = shift;
   my %myconfig           = %main::myconfig;
-  $myconfig{countrycode} = $main::language;
+  $myconfig{countrycode} = $::lx_office_conf{system}->{language};
   $form->{stylesheet}    = 'css/lx-office-erp.css';
 
   $form->header();
 
   my $form     = $main::form;
   my %myconfig = %main::myconfig;
 
-  my $charset = $main::dbcharset || 'ISO-8859-1';
+  my $charset = $::lx_office_conf{system}->{dbcharset} || 'ISO-8859-1';
   my $callback            = $form->unescape($form->{callback});
   $callback               = URI->new($callback)->rel($callback) if $callback;
   $callback               = "login.pl?action=company_logo"      if $callback =~ /^(\.\/)?$/;
 
   $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
 
   # retrieve order/quotation
-  $form->{webdav}   = $main::webdav;
+  $form->{webdav}   = $::lx_office_conf{system}->{webdav};
   $form->{jsscript} = 1;
 
   my $editing = $form->{id};
 
   print $form->parse_html_template("oe/form_footer", {
      %TMPL_VAR,
-     webdav          => $main::webdav,
+     webdav          => $::lx_office_conf{system}->{webdav},
      print_options   => print_options(inline => 1),
      label_edit      => $locale->text("Edit the $form->{type}"),
      label_workflow  => $locale->text("Workflow $form->{type}"),
 
   $form->language_payment(\%myconfig);
 
-  Common::webdav_folder($form) if ($main::webdav);
+  Common::webdav_folder($form);
 
   &form_header;
 
 
 
   $form->{title} = $locale->text($title{ $form->{report} });
 
-  my $accrual = ($main::eur) ? ""        : "checked";
-  my $cash    = ($main::eur) ? "checked" : "";
+  my $accrual = $::lx_office_conf{system}->{eur} ? ""        : "checked";
+  my $cash    = $::lx_office_conf{system}->{eur} ? "checked" : "";
 
   my $year = (localtime)[5] + 1900;
 
 
 
   my $sepa_xml   = SL::SEPA::XML->new('company'     => $myconfig->{company},
                                       'creditor_id' => $myconfig->{sepa_creditor_id},
-                                      'src_charset' => $main::dbcharset || 'ISO-8859-15',
+                                      'src_charset' => $::lx_office_conf{system}->{dbcharset} || 'ISO-8859-15',
                                       'message_id'  => $message_id,
                                       'grouped'     => 1,
                                       'collection'  => $vc eq 'customer',
 
     $form->error($locale->text('The warehouse or the bin is missing.'));
   }
 
-  if (!$main::show_best_before) {
+  if (!$::lx_office_conf{system}->{show_best_before}) {
       $form->{bestbefore} = '';
   }
 
 
-use Cwd;
-
-our (
-  $dbcharset, $eur, $language,
-  $lizenzen,
-  $parts_image_css, $parts_listing_images, $parts_show_image,
-  $show_best_before, $vertreter, $webdav
-);
-
-# Wenn Einnahmen-Überschussrechnung, dann auf 1 setzen
-# Wenn Bilanzierung (z.B. GmbH), dann auf 0 setzen
-$eur = 1;
-
-# set language for login and admin
-# currently "de" (German), "de_DE" (new German) and "en" (English, not perfect) are available
-$language = "de";
-
-# Aktivierung der verschiedenen Spezialmodule
-$webdav = 0;
-$lizenzen = 1;
-$vertreter = 0;
-
-# Zeige Felder für Mindesthaltbarkeitsdatum
-$show_best_before = 0;
-
-## Artikelbilder anzeigen
-# Artikelbild in der Detailansicht anzeigen
-$parts_show_image = 1; # [0|1]
-$parts_image_css = 'border:0;float:left;max-width:250px;margin-top:20px:margin-right:10px;margin-left:10px;'; # [belibige valide css definiton]
-# Artikelbilder per default in den Suchergebnissen anzeigen
-$parts_listing_images = 0; # [0|1]
-
-# Das charset, in dem die Daten in der Datenbank abgelegt sind.
-$dbcharset = 'UTF-8'; # Für UNICODE UTF-8
-# $dbcharset = "ISO-8859-15";
-
 1;
 
-use Cwd;
-
-our (
-  $dbcharset, $eur, $language,
-  $lizenzen,
-  $parts_image_css, $parts_listing_images, $parts_show_image,
-  $show_best_before, $vertreter, $webdav
-);
-
-# Wenn Einnahmen-Überschussrechnung, dann auf 1 setzen
-# Wenn Bilanzierung (z.B. GmbH), dann auf 0 setzen
-$eur = 1;
-
-# set language for login and admin
-# currently "de" (German), "de_DE" (new German) and "en" (English, not perfect) are available
-$language = "de";
-
-# Aktivierung der verschiedenen Spezialmodule
-$webdav = 0;
-$lizenzen = 1;
-$vertreter = 0;
-
-# Zeige Felder für Mindesthaltbarkeitsdatum
-$show_best_before = 0;
-
-## Artikelbilder anzeigen
-# Artikelbild in der Detailansicht anzeigen
-$parts_show_image = 1; # [0|1]
-$parts_image_css = 'border:0;float:left;max-width:250px;margin-top:20px:margin-right:10px;margin-left:10px;'; # [belibige valide css definiton]
-# Artikelbilder per default in den Suchergebnissen anzeigen
-$parts_listing_images = 0; # [0|1]
-
-# Das charset, in dem die Daten in der Datenbank abgelegt sind.
-$dbcharset = 'UTF-8'; # Für UNICODE UTF-8
-# $dbcharset = "ISO-8859-15";
-
 1;
 
+[system]
+# EUR: Einnahmen-Überschussrechnung (net income method). Set this to 1
+# if your company uses the net income method and to 0 for balacing.
+eur = 1
+
+# Set language for login and admin forms. Currently "de" (German),
+# "de_DE" (new German) and "en" (English, not perfect) are available.
+language = de
+
+# The database charset. Must match the database cluster you want to
+# connect to.
+dbcharset = UTF-8
+
+[features]
+# Activate certain optional features and modules.
+webdav = 0
+lizenzen = 1
+vertreter = 0
+
+# Show fields used for the best before date
+show_best_before = 0
+
+## Pictures for parts
+# Show the picture in the part form
+parts_show_image = 1
+# Style the picture with the following CSS code:
+parts_image_css = border:0;float:left;max-width:250px;margin-top:20px:margin-right:10px;margin-left:10px;
+# Show the picture in the results when you search for parts
+parts_listing_images = 0
+
 [paths]
 # path to temporary files (must be writeable by the web server)
 userspath = users
 
   SL::Dispatcher::_decode_recursively(\%::lx_office_conf);
 
   $::lxdebug = LXDebug->new;
-  $::locale = Locale->new($::language);
+  $::locale = Locale->new($::lx_office_conf{system}->{language});
   $::cgi    = CGI->new qw();
   $::form   = Form->new;
   $::auth   = SL::Auth->new;
 
   eval { require "config/lx-erp-local.conf"; 1; } or die $EVAL_ERROR if -f "config/lx-erp-local.conf";
 
   $::lxdebug = LXDebug->new;
-  $::locale  = Locale->new($::language);
+  $::locale  = Locale->new($::lx_office_conf{system}->{language});
   $::cgi     = CGI->new qw();
   $::form    = Form->new;
   $::auth    = SL::Auth->new;
       foreach my $job (@{ $jobs }) {
         # Provide fresh global variables in case legacy code modifies
         # them somehow.
-        $::locale = Locale->new($::language);
+        $::locale = Locale->new($::lx_office_conf{system}->{language});
         $::form   = Form->new;
 
         $job->run;
 
   $sth->execute() || mydberror($query);
 
   my $query_update = "UPDATE parts SET buchungsgruppen_id = ?";
-  $query_update .= ", inventory_accno_id = ?" if ($main::eur);
+  $query_update .= ", inventory_accno_id = ?" if $::lx_office_conf{system}->{eur};
   $query_update .= " WHERE id = ?";
   my $sth_update = $dbh->prepare($query_update);
 
   while (my $ref = $sth->fetchrow_hashref()) {
     foreach my $bg (@{$buchungsgruppen}) {
-      if (($main::eur ||
+      if (($::lx_office_conf{system}->{eur} ||
            ($ref->{"inventory_accno_id"} == $bg->{"inventory_accno_id"})) &&
           ($ref->{"income_accno_id"} == $bg->{"income_accno_id_0"}) &&
           ($ref->{"expense_accno_id"} == $bg->{"expense_accno_id_0"})) {
         my @values = ($bg->{"id"}, $ref->{"id"});
-        splice(@values, 1, 0, $bg->{"inventory_accno_id"}) if ($main::eur);
+        splice(@values, 1, 0, $bg->{"inventory_accno_id"}) if $::lx_office_conf{system}->{eur};
         $sth_update->execute(@values) ||
           mydberror($query_update . " (" . join(", ", @values) . ")");
         last;
       if (($ref->{"income_accno_id"} == $bg->{"income_accno_id_0"}) &&
           ($ref->{"expense_accno_id"} == $bg->{"expense_accno_id_0"})) {
         my @values = ($bg->{"id"}, $ref->{"id"});
-        splice(@values, 1, 0, undef) if ($main::eur);
+        splice(@values, 1, 0, undef) if $::lx_office_conf{system}->{eur};
         $sth_update->execute(@values) ||
           mydberror($query_update . " (" . join(", ", @values) . ")");
         last;
     $entry->{"ACC_INVENTORY"} = $acc_inventory;
     $entry->{"ACC_INCOME"} = $acc_income;
     $entry->{"ACC_EXPENSE"} = $acc_expense;
-    $entry->{"eur"} = $main::eur;
+    $entry->{"eur"} = $::lx_office_conf{system}->{eur};
   }
 
   # $form->parse_html_template("dbupgrade/buchungsgruppen_parts")
 
   # If balancing is off then force parts.inventory_accno_id to
   # a single value for parts.
-  force_inventory_accno_id_for_parts() if ($main::eur);
+  force_inventory_accno_id_for_parts() if $::lx_office_conf{system}->{eur};
 
   # Force "IC" to be present in chart.link for all accounts
   # which have been used as inventory accounts in parts.