package User;
-#use strict;
-
use IO::File;
use Fcntl qw(:seek);
-use SL::Auth;
+#use SL::Auth;
use SL::DBUpgrade2;
use SL::DBUtils;
use SL::Iconv;
use SL::Inifile;
+use strict;
+
sub new {
$main::lxdebug->enter_sub();
my $dbh =
DBI->connect($myconfig{dbconnect}, $myconfig{dbuser},
$myconfig{dbpasswd})
- or $self->error(DBI::errstr);
+ or $self->error($DBI::errstr);
# we got a connection, check the version
my $query = qq|SELECT version FROM defaults|;
$dbh->begin_work();
+ # setup dbup_ export vars
my %dbup_myconfig = ();
map({ $dbup_myconfig{$_} = $form->{$_}; }
qw(dbname dbuser dbpasswd dbhost dbport dbconnect));
last if ($version < $mindb);
# apply upgrade
- $main::lxdebug->message(LXDebug::DEBUG2, "Applying Update $upgradescript");
+ $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $upgradescript");
if ($file_type eq "sql") {
$self->process_query($form, $dbh, "sql/" . $form->{"dbdriver"} .
"-upgrade/$upgradescript", $str_maxdb, $db_charset);
my $file_type = $1;
# apply upgrade
- $main::lxdebug->message(LXDebug::DEBUG2, "Applying Update $control->{file}");
+ $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}");
print $form->parse_html_template("dbupgrade/upgrade_message2", $control);
if ($file_type eq "sql") {
my $dbh = DBI->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd});
if ($dbh) {
- $self->create_employee_entry($form, $dbh, $self);
+ $self->create_employee_entry($form, $dbh, $self, 1);
$dbh->disconnect();
}
sub create_employee_entry {
$main::lxdebug->enter_sub();
- my $self = shift;
- my $form = shift;
- my $dbh = shift;
- my $myconfig = shift;
+ my $self = shift;
+ my $form = shift;
+ my $dbh = shift;
+ my $myconfig = shift;
+ my $update_existing = shift;
+
+ if (!does_table_exist($dbh, 'employee')) {
+ $main::lxdebug->leave_sub();
+ return;
+ }
# add login to employee table if it does not exist
# no error check for employee table, ignore if it does not exist
- my ($login) = 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});
- if (!$login) {
+ 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 = ?|;
+ do_query($form, $dbh, $query, $myconfig->{name}, $myconfig->{tel}, $id);
}
$main::lxdebug->leave_sub();
bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen
taxnumber co_ustid duns menustyle template_format default_media
default_printer_id copies show_form_details favorites
- pdonumber sdonumber);
+ pdonumber sdonumber hide_cvar_search_options);
$main::lxdebug->leave_sub();