- $main::lxdebug->leave_sub();
-
- return $rc;
-}
-
-sub update2_available {
- $main::lxdebug->enter_sub();
-
- my ($form, $controls) = @_;
-
- map({ $_->{"applied"} = 0; } values(%{$controls}));
-
- dbconnect_vars($form, $form->{"dbname"});
-
- my $dbh =
- DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) ||
- $form->dberror;
-
- my ($query, $tag, $sth);
-
- $query = qq|SELECT tag FROM schema_info|;
- $sth = $dbh->prepare($query);
- if ($sth->execute()) {
- while (($tag) = $sth->fetchrow_array()) {
- $controls->{$tag}->{"applied"} = 1 if (defined($controls->{$tag}));
- }
- }
- $sth->finish();
- $dbh->disconnect();
-
- map({ $main::lxdebug->leave_sub() and return 1 if (!$_->{"applied"}) }
- values(%{$controls}));
-
- $main::lxdebug->leave_sub();
- return 0;
-}
-
-sub save_member {
- $main::lxdebug->enter_sub();
-
- my ($self) = @_;
- my $form = \%main::form;
-
- # format dbconnect and dboptions string
- dbconnect_vars($self, $self->{dbname});
-
- map { $self->{$_} =~ s/\r//g; } qw(address signature);
-
- $main::auth->save_user($self->{login}, map { $_, $self->{$_} } config_vars());
-
- my $dbh = DBI->connect($self->{dbconnect}, $self->{dbuser}, $self->{dbpasswd});
- if ($dbh) {
- $self->create_employee_entry($form, $dbh, $self, 1);
- $dbh->disconnect();
- }
-
- $main::lxdebug->leave_sub();
-}
-
-sub create_employee_entry {
- $main::lxdebug->enter_sub();
-
- 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 ($id) = selectrow_query($form, $dbh, qq|SELECT id FROM employee WHERE login = ?|, $self->{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();