X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/7447778283539ba5f36a43c97fcea3bc4f551729..07a735e0cb464b4cf96617578868957635410ad9:/SL/User.pm diff --git a/SL/User.pm b/SL/User.pm index e3f4a56c4..b63ffc2a0 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -124,10 +124,10 @@ sub login { $self->create_schema_info_table($form, $dbh); my $dbupdater = SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls; - my $update_available = $dbupdater->update2_available($dbh); + my @unapplied_scripts = $dbupdater->unapplied_upgrade_scripts($dbh); $dbh->disconnect; - if (!$update_available) { + if (!@unapplied_scripts) { SL::DB::Manager::Employee->update_entries_for_authorized_users; return LOGIN_OK(); } @@ -142,7 +142,7 @@ sub login { $form->{dbupdate} = "db" . $::auth->client->{dbname}; if ($form->{"show_dbupdate_warning"}) { - print $form->parse_html_template("dbupgrade/warning"); + print $form->parse_html_template("dbupgrade/warning", { unapplied_scripts => \@unapplied_scripts }); ::end_of_request(); } @@ -283,11 +283,16 @@ sub dbcreate { # create the tables $dbupdater->process_query($dbh, "sql/lx-office.sql"); + # process update-scripts needed before 1st user-login + $dbupdater->process_query($dbh, "sql/Pg-upgrade2/defaults_add_precision.sql"); + $self->create_schema_info_table($form, $dbh); + $dbh->do("INSERT INTO schema_info (tag, login) VALUES ('defaults_add_precision', 'admin')"); + # load chart of accounts $dbupdater->process_query($dbh, "sql/$form->{chart}-chart.sql"); - $query = qq|UPDATE defaults SET coa = ?, accounting_method = ?, profit_determination = ?, inventory_system = ?, curr = ?|; - do_query($form, $dbh, $query, map { $form->{$_} } qw(chart accounting_method profit_determination inventory_system defaultcurrency)); + $query = qq|UPDATE defaults SET coa = ?, accounting_method = ?, profit_determination = ?, inventory_system = ?, curr = ?, precision = ?|; + do_query($form, $dbh, $query, map { $form->{$_} } qw(chart accounting_method profit_determination inventory_system defaultcurrency precision)); $dbh->disconnect; @@ -374,19 +379,19 @@ sub create_schema_info_table { } sub dbupdate2 { - $main::lxdebug->enter_sub(); - my ($self, %params) = @_; my $form = $params{form}; my $dbupdater = $params{updater}; my $db = $params{database}; - my $rc = -2; map { $_->{description} = SL::Iconv::convert($_->{charset}, 'UTF-8', $_->{description}) } values %{ $dbupdater->{all_controls} }; &dbconnect_vars($form, $db); + # Flush potentially held database locks. + $form->get_standard_dbh->commit; + my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) or $form->dberror; $dbh->do($form->{dboptions}) if ($form->{dboptions}); @@ -395,26 +400,35 @@ sub dbupdate2 { my @upgradescripts = $dbupdater->unapplied_upgrade_scripts($dbh); - $dbh->disconnect and next if !@upgradescripts; - foreach my $control (@upgradescripts) { - # apply upgrade + # Apply upgrade. Control will only return to us if the upgrade has + # been applied correctly and if the update has not requested user + # interaction. $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); print $form->parse_html_template("dbupgrade/upgrade_message2", $control); $dbupdater->process_file($dbh, "sql/Pg-upgrade2/$control->{file}", $control); } - $rc = 0; $dbh->disconnect; - - $main::lxdebug->leave_sub(); - - return $rc; } sub data { +{ %{ $_[0] } } } +sub get_default_myconfig { + my ($self_or_class, %user_config) = @_; + + return ( + countrycode => 'de', + css_path => 'css', # Needed for menunew, see SL::Layout::Base::get_stylesheet_for_user + dateformat => 'dd.mm.yy', + numberformat => '1.000,00', + stylesheet => 'kivitendo.css', + timeformat => 'hh:mm', + %user_config, + ); +} + 1;