Verwaltung von Kunden-/Lieferantentypen auf Controller umgestellt
[kivitendo-erp.git] / scripts / rose_auto_create_model.pl
index b1a7040..bfb3e3d 100755 (executable)
@@ -8,6 +8,7 @@ BEGIN {
 }
 
 use CGI qw( -no_xhtml);
+use Config::Std;
 use Data::Dumper;
 use English qw( -no_match_vars );
 use List::MoreUtils qw(any);
@@ -18,12 +19,14 @@ use SL::DB;
 use SL::Form;
 use SL::Locale;
 use SL::LXDebug;
-use SL::DB::Helpers::ALL;
-use SL::DB::Helpers::Mappings;
+use SL::LxOfficeConf;
+use SL::DB::Helper::ALL;
+use SL::DB::Helper::Mappings;
 
 our $form;
 our $cgi;
 our $auth;
+our %lx_office_conf;
 
 our $script =  __FILE__;
 $script     =~ s:.*/::;
@@ -40,17 +43,12 @@ sub setup {
     exit 1;
   }
 
-  my $login     = shift @ARGV;
+  SL::LxOfficeConf->read;
 
-  $::userspath  = "users";
-  $::templates  = "templates";
-  $::sendmail   = "| /usr/sbin/sendmail -t";
+  my $login     = shift @ARGV;
 
   $::lxdebug    = LXDebug->new();
 
-  require "config/lx-erp.conf";
-  require "config/lx-erp-local.conf" if -f "config/lx-erp-local.conf";
-
   # locale messages
   $::locale       = Locale->new("de");
   $::form         = new Form;
@@ -71,17 +69,24 @@ sub setup {
 sub process_table {
   my @spec       =  split(/=/, shift, 2);
   my $table      =  $spec[0];
+  my $schema     = '';
+  ($schema, $table) = split(m/\./, $table) if $table =~ m/\./;
   my $package    =  ucfirst($spec[1] || $spec[0]);
   $package       =~ s/_+(.)/uc($1)/ge;
   my $meta_file  =  "${meta_path}/${package}.pm";
   my $file       =  "SL/DB/${package}.pm";
 
+  $schema        = <<CODE if $schema;
+    __PACKAGE__->meta->schema('$schema');
+CODE
+
   my $definition =  eval <<CODE;
     package SL::DB::AUTO::$package;
     use SL::DB::Object;
     use base qw(SL::DB::Object);
 
     __PACKAGE__->meta->table('$table');
+$schema
     __PACKAGE__->meta->auto_initialize;
 
     __PACKAGE__->meta->perl_class_definition(indent => 2); # , braces => 'bsd'
@@ -131,8 +136,8 @@ CODE
 
 setup();
 
-my %blacklist     = SL::DB::Helpers::Mappings->get_blacklist;
-my %package_names = SL::DB::Helpers::Mappings->get_package_names;
+my %blacklist     = SL::DB::Helper::Mappings->get_blacklist;
+my %package_names = SL::DB::Helper::Mappings->get_package_names;
 
 my @tables = ();
 if (($ARGV[0] eq '--all') || ($ARGV[0] eq '-a') || ($ARGV[0] eq '--sugar') || ($ARGV[0] eq '-s')) {