X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FUser.pm;h=21c3689f936b029ca68201c1422bfde3d54f0516;hb=e770cd180600810fecd3554e104546236a9c9597;hp=d6b870552c37f6aedcde7650a7177183f8ca2804;hpb=470a8fa1710b22e2b381eef4cacb01bebaeff725;p=kivitendo-erp.git diff --git a/SL/User.pm b/SL/User.pm index d6b870552..21c3689f9 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -49,12 +49,12 @@ use strict; sub new { $main::lxdebug->enter_sub(); - my ($type, $login) = @_; + my ($type, %params) = @_; my $self = {}; - if ($login ne "") { - my %user_data = $main::auth->read_user($login); + if ($params{id} || $params{login}) { + my %user_data = $main::auth->read_user(%params); map { $self->{$_} = $user_data{$_} } keys %user_data; } @@ -77,9 +77,9 @@ sub country_codes { my @dir = grep(!/(^\.\.?$|\..*)/, readdir(DIR)); foreach my $dir (@dir) { - next unless open(FH, "locale/$dir/LANGUAGE"); - @language = ; - close FH; + next unless open(my $fh, '<:encoding(UTF-8)', "locale/$dir/LANGUAGE"); + @language = <$fh>; + close $fh; $cc{$dir} = "@language"; } @@ -102,7 +102,7 @@ sub login { my $rc = -3; if ($self->{login}) { - my %myconfig = $main::auth->read_user($self->{login}); + my %myconfig = $main::auth->read_user(login => $self->{login}); # check if database is down my $dbh = SL::DBConnect->connect($myconfig{dbconnect}, $myconfig{dbuser}, $myconfig{dbpasswd}) @@ -120,6 +120,12 @@ sub login { $self->create_schema_info_table($form, $dbh); + my $dbupdater_auth = SL::DBUpgrade2->new(form => $form, dbdriver => 'Pg', auth => 1)->parse_dbupdate_controls; + if ($dbupdater_auth->unapplied_upgrade_scripts($::auth->dbconnect)) { + $::lxdebug->leave_sub; + return -3; + } + $rc = 0; my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $myconfig{dbdriver})->parse_dbupdate_controls; @@ -130,7 +136,6 @@ sub login { $dbh->disconnect; if ($update_available) { - $form->{"stylesheet"} = "lx-office-erp.css"; $form->{"title"} = $main::locale->text("Dataset upgrade"); $form->header(); print $form->parse_html_template("dbupgrade/header"); @@ -144,7 +149,7 @@ sub login { } # update the tables - if (!open(FH, ">" . $::lx_office_conf{paths}->{userspath} . "/nologin")) { + if (!$::lx_office_conf{debug}->{keep_installation_unlocked} && !open(FH, ">", $::lx_office_conf{paths}->{userspath} . "/nologin")) { $form->show_generic_error($main::locale->text('A temporary file could not be created. ' . 'Please verify that the directory "#1" is writeable by the webserver.', $::lx_office_conf{paths}->{userspath}), @@ -167,14 +172,7 @@ sub login { # remove lock file unlink($::lx_office_conf{paths}->{userspath} . "/nologin"); - my $menufile = - $self->{"menustyle"} eq "v3" ? "menuv3.pl" : - $self->{"menustyle"} eq "neu" ? "menunew.pl" : - $self->{"menustyle"} eq "js" ? "menujs.pl" : - $self->{"menustyle"} eq "xml" ? "menuXML.pl" : - "menu.pl"; - - print $form->parse_html_template("dbupgrade/footer", { "menufile" => $menufile }); + print $form->parse_html_template("dbupgrade/footer"); $rc = -2; } @@ -194,18 +192,14 @@ sub dbconnect_vars { 'Pg' => { 'yy-mm-dd' => 'set DateStyle to \'ISO\'', 'yyyy-mm-dd' => 'set DateStyle to \'ISO\'', 'mm/dd/yy' => 'set DateStyle to \'SQL, US\'', - 'mm-dd-yy' => 'set DateStyle to \'POSTGRES, US\'', 'dd/mm/yy' => 'set DateStyle to \'SQL, EUROPEAN\'', - 'dd-mm-yy' => 'set DateStyle to \'POSTGRES, EUROPEAN\'', 'dd.mm.yy' => 'set DateStyle to \'GERMAN\'' }, 'Oracle' => { 'yy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YY-MM-DD\'', 'yyyy-mm-dd' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'YYYY-MM-DD\'', 'mm/dd/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'MM/DD/YY\'', - 'mm-dd-yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'MM-DD-YY\'', 'dd/mm/yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD/MM/YY\'', - 'dd-mm-yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD-MM-YY\'', 'dd.mm.yy' => 'ALTER SESSION SET NLS_DATE_FORMAT = \'DD.MM.YY\'', }); @@ -398,6 +392,14 @@ sub dbcreate { $query = "UPDATE defaults SET coa = ?"; do_query($form, $dbh, $query, $form->{chart}); + $query = "UPDATE defaults SET accounting_method = ?"; + do_query($form, $dbh, $query, $form->{accounting_method}); + $query = "UPDATE defaults SET profit_determination = ?"; + do_query($form, $dbh, $query, $form->{profit_determination}); + $query = "UPDATE defaults SET inventory_system = ?"; + do_query($form, $dbh, $query, $form->{inventory_system}); + $query = "UPDATE defaults SET curr = ?"; + do_query($form, $dbh, $query, $form->{defaultcurrency}); $dbh->disconnect; @@ -686,7 +688,6 @@ sub save_member { $main::lxdebug->enter_sub(); my ($self) = @_; - my $form = \%main::form; # format dbconnect and dboptions string dbconnect_vars($self, $self->{dbname}); @@ -697,7 +698,7 @@ sub save_member { my $dbh = SL::DBConnect->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd}); if ($dbh) { - $self->create_employee_entry($form, $dbh, $self, 1); + $self->create_employee_entry($::form, $dbh, $self, 1); $dbh->disconnect(); } @@ -720,14 +721,17 @@ sub create_employee_entry { # add login to employee table if it does not exist # no error check for employee table, ignore if it does not exist - my ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); + my ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{login}); + my ($good_db) = selectrow_query($form, $dbh, qq|select * from pg_tables where tablename = ? and schemaname = ?|, 'schema_info', 'public'); + my $can_delete; + ($can_delete) = selectrow_query($form, $dbh, qq|SELECT tag FROM schema_info WHERE tag = ?|, 'employee_deleted') if $good_db; if (!$id) { my $query = qq|INSERT INTO employee (login, name, workphone, role) VALUES (?, ?, ?, ?)|; do_query($form, $dbh, $query, ($self->{login}, $myconfig->{name}, $myconfig->{tel}, "user")); - } elsif ($update_existing) { - my $query = qq|UPDATE employee SET name = ?, workphone = ?, role = 'user' WHERE id = ?|; + } elsif ($update_existing && $can_delete) { + my $query = qq|UPDATE employee SET name = ?, workphone = ?, role = 'user', deleted = 'f' WHERE id = ?|; do_query($form, $dbh, $query, $myconfig->{name}, $myconfig->{tel}, $id); } @@ -740,12 +744,12 @@ sub config_vars { my @conf = qw(address admin businessnumber company countrycode currency dateformat dbconnect dbdriver dbhost dbport dboptions dbname dbuser dbpasswd email fax name numberformat password - printer role sid signature stylesheet tel templates vclimit angebote + printer sid signature stylesheet tel templates vclimit angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen taxnumber co_ustid duns menustyle template_format default_media default_printer_id copies show_form_details favorites pdonumber sdonumber hide_cvar_search_options mandatory_departments - sepa_creditor_id); + sepa_creditor_id taxincluded_checked); $main::lxdebug->leave_sub(); @@ -776,5 +780,8 @@ sub error { $main::lxdebug->leave_sub(); } -1; +sub data { + +{ %{ $_[0] } } +} +1;