Merge branch 'master' of git@lx-office.linet-services.de:lx-office-erp
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 15 Apr 2011 09:51:32 +0000 (11:51 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Fri, 15 Apr 2011 09:51:32 +0000 (11:51 +0200)
12 files changed:
SL/AP.pm
SL/Auth.pm
SL/Auth/PasswordPolicy.pm
SL/CA.pm
SL/DB.pm
SL/DBConnect.pm [new file with mode: 0644]
SL/Form.pm
SL/User.pm
bin/mozilla/common.pl
config/lx_office.conf.default
doc/changelog
locale/de/all

index e4ff230..ef7ca81 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -422,9 +422,12 @@ sub ap_transactions {
     push(@values, $form->like($form->{vendor}));
   }
   if ($form->{department}) {
-    my ($null, $department_id) = split /--/, $form->{department};
+    # ähnlich wie commit 0bbfb33b6aa8e38bb6c81d1684ab7d08e5b5c5af abteilung
+    # wird so nicht mehr als zeichenkette zusammengebaut
+    # hätte zu ee9f9f9aa4c3b9d5d20ab10a45c12bcaa6aa78d0 auffallen können ;-) jan
+    #my ($null, $department_id) = split /--/, $form->{department};
     $where .= " AND a.department_id = ?";
-    push(@values, $department_id);
+    push(@values, $form->{department});
   }
   if ($form->{invnumber}) {
     $where .= " AND a.invnumber ILIKE ?";
index 73a37c5..978fe49 100644 (file)
@@ -13,6 +13,7 @@ use SL::Auth::DB;
 use SL::Auth::LDAP;
 
 use SL::User;
+use SL::DBConnect;
 use SL::DBUpgrade2;
 use SL::DBUtils;
 
@@ -38,7 +39,7 @@ sub new {
 sub get_user_dbh {
   my ($self, $login) = @_;
   my %user = $self->read_user($login);
-  my $dbh  = DBI->connect(
+  my $dbh  = SL::DBConnect->connect(
     $user{dbconnect},
     $user{dbuser},
     $user{dbpasswd},
@@ -166,7 +167,7 @@ sub dbconnect {
 
   $main::lxdebug->message(LXDebug->DEBUG1, "Auth::dbconnect DSN: $dsn");
 
-  $self->{dbh} = DBI->connect($dsn, $cfg->{user}, $cfg->{password}, { pg_enable_utf8 => $::locale->is_utf8, AutoCommit => 1 });
+  $self->{dbh} = SL::DBConnect->connect($dsn, $cfg->{user}, $cfg->{password}, { pg_enable_utf8 => $::locale->is_utf8, AutoCommit => 1 });
 
   if (!$may_fail && !$self->{dbh}) {
     $main::form->error($main::locale->text('The connection to the authentication database failed:') . "\n" . $DBI::errstr);
@@ -246,7 +247,7 @@ sub create_database {
   my $encoding   = $Common::charset_to_db_encoding{$charset};
   $encoding    ||= 'UNICODE';
 
-  my $dbh        = DBI->connect($dsn, $params{superuser}, $params{superuser_password}, { pg_enable_utf8 => $charset =~ m/^utf-?8$/i });
+  my $dbh        = SL::DBConnect->connect($dsn, $params{superuser}, $params{superuser_password}, { pg_enable_utf8 => $charset =~ m/^utf-?8$/i });
 
   if (!$dbh) {
     $main::form->error($main::locale->text('The connection to the template database failed:') . "\n" . $DBI::errstr);
index 3cf5c14..5e0a9a4 100644 (file)
@@ -73,7 +73,7 @@ sub errors {
 sub init_config {
   my ($self) = @_;
 
-  my %cfg = %{ $::emmvee_conf{password_policy} || {} };
+  my %cfg = %{ $::lx_office_conf{password_policy} || {} };
 
   $cfg{valid_characters}      =~ s/[ \n\r]//g if $cfg{valid_characters};
   $cfg{invalid_characters}    =~ s/[ \n\r]//g if $cfg{invalid_characters};
index f9dd76d..c200b66 100644 (file)
--- a/SL/CA.pm
+++ b/SL/CA.pm
@@ -57,8 +57,12 @@ sub all_accounts {
   # 1.) Gehe zurück bis zu dem Datum an dem die Bücher geschlossen wurden
   # 2.) Falls die Bücher noch nie geschlossen wurden, gehe zurück bis zum Bearbeitungsstart
   # COALESCE((SELECT closedto FROM defaults),(SELECT itime FROM defaults))
+  # PROBLEM: Das date_trunc schneidet auf den 1.1.20XX ab und KEINE Buchungen werden angezeigt
+  # Lösung: date_trunc rausgeworfen und nicht mehr auf itime geprüft, sondern auf die erste Buchung
+  # in transdate jan 11.04.2011
 
-  my $closedto_sql = "COALESCE((SELECT closedto FROM defaults),(SELECT itime FROM defaults))";
+  my $closedto_sql = "COALESCE((SELECT closedto FROM defaults),
+                               (SELECT transdate from acc_trans order by transdate limit 1))";
 
   if ($form->{method} eq "cash") {  # EÜR
     $acc_cash_where = qq| AND (a.trans_id IN (SELECT id FROM ar WHERE datepaid>= $closedto_sql
@@ -66,7 +70,7 @@ sub all_accounts {
                           UNION SELECT id FROM gl WHERE transdate>= $closedto_sql
                         )) |;
   } else {  # Bilanzierung
-    $acc_cash_where = " AND ((select date_trunc('year', a.transdate::date)) >= $closedto_sql) ";
+    $acc_cash_where = " AND (a.transdate >= $closedto_sql) ";
   }
 
   my $query =
index 67888ef..491a033 100644 (file)
--- a/SL/DB.pm
+++ b/SL/DB.pm
@@ -16,24 +16,14 @@ my (%_db_registered, %_initial_sql_executed);
 sub dbi_connect {
   shift;
 
-  return DBI->connect(@_) unless $::lx_office_conf{debug} && $::lx_office_conf{debug}->{dbix_log4perl};
-
-  require Log::Log4perl;
-  require DBIx::Log4perl;
-
-  my $filename =  $LXDebug::file_name;
-  my $config   =  $::lx_office_conf{debug}->{dbix_log4perl_config};
-  $config      =~ s/LXDEBUGFILE/${filename}/g;
-
-  Log::Log4perl->init(\$config);
-  return DBIx::Log4perl->connect(@_);
+  return SL::DBConnect->connect(@_);
 }
 
 sub create {
   my $domain = shift || SL::DB->default_domain;
   my $type   = shift || SL::DB->default_type;
 
-  my ($domain, $type) = _register_db($domain, $type);
+  ($domain, $type) = _register_db($domain, $type);
 
   my $db = __PACKAGE__->new_or_cached(domain => $domain, type => $type);
 
@@ -91,7 +81,7 @@ sub _register_db {
   my %flattened_settings = _flatten_settings(%connect_settings);
 
   $domain = 'LXOFFICE' if $type =~ m/^LXOFFICE/;
-  $type  .= join($SUBSCRIPT_SEPARATOR, map { ($_, $flattened_settings{$_}) } sort keys %flattened_settings);
+  $type  .= join($SUBSCRIPT_SEPARATOR, map { ($_, $flattened_settings{$_} || '') } sort keys %flattened_settings);
   my $idx = "${domain}::${type}";
 
   if (!$_db_registered{$idx}) {
diff --git a/SL/DBConnect.pm b/SL/DBConnect.pm
new file mode 100644 (file)
index 0000000..fbcf1d5
--- /dev/null
@@ -0,0 +1,23 @@
+package SL::DBConnect;
+
+use strict;
+
+use DBI;
+
+sub connect {
+  shift;
+
+  return DBI->connect(@_) unless $::lx_office_conf{debug} && $::lx_office_conf{debug}->{dbix_log4perl};
+
+  require Log::Log4perl;
+  require DBIx::Log4perl;
+
+  my $filename =  $LXDebug::file_name;
+  my $config   =  $::lx_office_conf{debug}->{dbix_log4perl_config};
+  $config      =~ s/LXDEBUGFILE/${filename}/g;
+
+  Log::Log4perl->init(\$config);
+  return DBIx::Log4perl->connect(@_);
+}
+
+1;
index 11d72a6..31020ae 100644 (file)
@@ -52,6 +52,7 @@ use SL::AM;
 use SL::Common;
 use SL::CVar;
 use SL::DB;
+use SL::DBConnect;
 use SL::DBUtils;
 use SL::DO;
 use SL::IC;
@@ -1582,7 +1583,7 @@ sub dbconnect {
   my ($self, $myconfig) = @_;
 
   # connect to database
-  my $dbh = DBI->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options)
+  my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options)
     or $self->dberror;
 
   # set db options
@@ -1601,7 +1602,7 @@ sub dbconnect_noauto {
   my ($self, $myconfig) = @_;
 
   # connect to database
-  my $dbh = DBI->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options(AutoCommit => 0))
+  my $dbh = SL::DBConnect->connect($myconfig->{dbconnect}, $myconfig->{dbuser}, $myconfig->{dbpasswd}, $self->_dbconnect_options(AutoCommit => 0))
     or $self->dberror;
 
   # set db options
index 520bf42..d6b8705 100644 (file)
@@ -38,6 +38,7 @@ use IO::File;
 use Fcntl qw(:seek);
 
 #use SL::Auth;
+use SL::DBConnect;
 use SL::DBUpgrade2;
 use SL::DBUtils;
 use SL::Iconv;
@@ -104,9 +105,7 @@ sub login {
     my %myconfig = $main::auth->read_user($self->{login});
 
     # check if database is down
-    my $dbh =
-      DBI->connect($myconfig{dbconnect}, $myconfig{dbuser},
-                   $myconfig{dbpasswd})
+    my $dbh = SL::DBConnect->connect($myconfig{dbconnect}, $myconfig{dbuser}, $myconfig{dbpasswd})
       or $self->error($DBI::errstr);
 
     # we got a connection, check the version
@@ -252,8 +251,7 @@ sub dbsources {
   $form->{sid} = $form->{dbdefault};
   &dbconnect_vars($form, $form->{dbdefault});
 
-  my $dbh =
-    DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
+  my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
     or $form->dberror;
 
   if ($form->{dbdriver} eq 'Pg') {
@@ -270,8 +268,7 @@ sub dbsources {
         next if ($db =~ /^template/);
 
         &dbconnect_vars($form, $db);
-        my $dbh =
-          DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
+        my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
           or $form->dberror;
 
         $query =
@@ -326,7 +323,7 @@ sub dbclusterencoding {
 
   dbconnect_vars($form, $form->{dbdefault});
 
-  my $dbh                = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) || $form->dberror();
+  my $dbh                = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) || $form->dberror();
   my $query              = qq|SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'template0'|;
   my ($cluster_encoding) = $dbh->selectrow_array($query);
   $dbh->disconnect();
@@ -344,7 +341,7 @@ sub dbcreate {
   $form->{sid} = $form->{dbdefault};
   &dbconnect_vars($form, $form->{dbdefault});
   my $dbh =
-    DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
+    SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
     or $form->dberror;
   $form->{db} =~ s/\"//g;
   my %dbcreate = (
@@ -386,7 +383,7 @@ sub dbcreate {
 
   &dbconnect_vars($form, $form->{db});
 
-  $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
+  $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
     or $form->dberror;
 
   my $db_charset = $Common::db_encoding_to_charset{$form->{encoding}};
@@ -417,8 +414,7 @@ sub dbdelete {
 
   $form->{sid} = $form->{dbdefault};
   &dbconnect_vars($form, $form->{dbdefault});
-  my $dbh =
-    DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
+  my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
     or $form->dberror;
   my $query = $dbdelete{$form->{dbdriver}};
   do_query($form, $dbh, $query);
@@ -464,7 +460,7 @@ sub dbneedsupdate {
     map { $form->{$_} = $member->{$_} } qw(dbname dbuser dbpasswd dbhost dbport);
     dbconnect_vars($form, $form->{dbname});
 
-    my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd});
+    my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd});
 
     next unless $dbh;
 
@@ -594,8 +590,7 @@ sub dbupdate {
     $db =~ s/^db//;
     &dbconnect_vars($form, $db);
 
-    my $dbh =
-      DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
+    my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd})
       or $form->dberror;
 
     $dbh->do($form->{dboptions}) if ($form->{dboptions});
@@ -659,7 +654,7 @@ sub dbupdate2 {
     $db =~ s/^db//;
     &dbconnect_vars($form, $db);
 
-    my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) or $form->dberror;
+    my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) or $form->dberror;
 
     $dbh->do($form->{dboptions}) if ($form->{dboptions});
 
@@ -700,7 +695,7 @@ sub save_member {
 
   $main::auth->save_user($self->{login}, map { $_, $self->{$_} } config_vars());
 
-  my $dbh = DBI->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd});
+  my $dbh = SL::DBConnect->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd});
   if ($dbh) {
     $self->create_employee_entry($form, $dbh, $self, 1);
     $dbh->disconnect();
index cef7fca..dfa7d0f 100644 (file)
@@ -396,6 +396,32 @@ sub reformat_numbers {
 
 # -------------------------------------------------------------------------
 
+sub show_history {
+  $main::lxdebug->enter_sub();
+
+  my $form     = $main::form;
+  my %myconfig = %main::myconfig;
+  my $locale   = $main::locale;
+
+  my $dbh = $form->dbconnect(\%myconfig);
+  my ($sort, $sortby) = split(/\-\-/, $form->{order});
+  $sort =~ s/.*\.(.*)/$1/;
+
+  $form->{title} = $locale->text("History");
+  $form->header();
+  print $form->parse_html_template( "common/show_history", {
+    "DATEN"        => $form->get_history($dbh,$form->{input_name},"",$form->{order}),
+    "SUCCESS"      => ($form->get_history($dbh,$form->{input_name}) ne "0"),
+    uc($sort)      => 1,
+    uc($sort)."BY" => $sortby
+  } );
+
+  $dbh->disconnect();
+  $main::lxdebug->leave_sub();
+}
+
+# -------------------------------------------------------------------------
+
 sub call_sub {
   $main::lxdebug->enter_sub();
 
index 1972e95..e78f2c3 100644 (file)
@@ -224,4 +224,4 @@ watch_form = 0
 keep_temp_files = 0
 
 # The file name where the debug messages are written to.
-file_name = /tmp/mb-lxdebug.log
+file_name = /tmp/lx-office-debug.log
index d7cd59e..8c62579 100644 (file)
 
   - Bei Verkaufsgutschriften zusätzlich noch die Rechnungsnummer mitnehmen, damit der Bezug klarer ist.
 
+  - Kontenübersicht. Bei Auswahl Bilanz und keinem closedto (Bücher-Abschluss) wurden keine Konten
+    ausgewählt, falls das Installationsjahr gleich dem laufenden Jahr ist
+
+  - Verkauf -> Berichte -> Filter nach Abteilungen wieder aktiviert
+
+
   Liste gefixter Bugs aus dem Bugtracker:
 
   - Bugfix 1613: Status teilweise
index eed49d8..b7df1ba 100644 (file)
@@ -823,6 +823,7 @@ $self->{texts} = {
   'Help Template Variables'     => 'Hilfe zu Dokumenten-Variablen',
   'Here\'s an example command line:' => 'Hier ist eine Kommandozeile, die als Beispiel dient:',
   'Hide by default'             => 'Standardm&auml;&szlig;ig verstecken',
+  'History'                     => 'Historie',
   'History Search'              => 'Historien Suche',
   'History Search Engine'       => 'Historien Suchmaschine',
   'Homepage'                    => 'Homepage',