X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAM.pm;h=d637e2a59624d6f45ef71a7ce8745a2a775895b9;hb=d3835e76df74c5bc7f014048303a2845a1d2277e;hp=5a3b0f73ed99d7cebfb0a6b18a13881c5eb1b5bc;hpb=5c285a79647319ee0fc8966b5c41173b6ba9045d;p=kivitendo-erp.git diff --git a/SL/AM.pm b/SL/AM.pm index 5a3b0f73e..d637e2a59 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -41,6 +41,8 @@ use Carp; use Data::Dumper; use SL::DBUtils; +use strict; + sub get_account { $main::lxdebug->enter_sub(); @@ -645,7 +647,7 @@ sub business { # connect to database my $dbh = $form->dbconnect($myconfig); - my $query = qq|SELECT id, description, discount, customernumberinit + my $query = qq|SELECT id, description, discount, customernumberinit, salesman FROM business ORDER BY 2|; @@ -671,7 +673,7 @@ sub get_business { my $dbh = $form->dbconnect($myconfig); my $query = - qq|SELECT b.description, b.discount, b.customernumberinit + qq|SELECT b.description, b.discount, b.customernumberinit, b.salesman FROM business b WHERE b.id = ?|; my $sth = $dbh->prepare($query); @@ -697,20 +699,20 @@ sub save_business { # connect to database my $dbh = $form->dbconnect($myconfig); - my @values = ($form->{description}, $form->{discount}, - $form->{customernumberinit}); + my @values = ($form->{description}, $form->{discount}, $form->{customernumberinit}, $form->{salesman} ? 't' : 'f'); # id is the old record if ($form->{id}) { $query = qq|UPDATE business SET description = ?, discount = ?, - customernumberinit = ? + customernumberinit = ?, + salesman = ? WHERE id = ?|; push(@values, $form->{id}); } else { $query = qq|INSERT INTO business - (description, discount, customernumberinit) - VALUES (?, ?, ?)|; + (description, discount, customernumberinit, salesman) + VALUES (?, ?, ?, ?)|; } do_query($form, $dbh, $query, @values); @@ -1106,106 +1108,6 @@ sub swap_sortkeys { $main::lxdebug->leave_sub(); } -sub printer { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - # connect to database - my $dbh = $form->dbconnect($myconfig); - - my $query = qq|SELECT id, printer_description, template_code, printer_command - FROM printers - ORDER BY 2|; - - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - $form->{"ALL"} = []; - while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { - push @{ $form->{ALL} }, $ref; - } - - $sth->finish; - $dbh->disconnect; - - $main::lxdebug->leave_sub(); -} - -sub get_printer { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - # connect to database - my $dbh = $form->dbconnect($myconfig); - - my $query = - qq|SELECT p.printer_description, p.template_code, p.printer_command - FROM printers p - WHERE p.id = ?|; - my $sth = $dbh->prepare($query); - $sth->execute($form->{id}) || $form->dberror($query . " ($form->{id})"); - - my $ref = $sth->fetchrow_hashref("NAME_lc"); - - map { $form->{$_} = $ref->{$_} } keys %$ref; - - $sth->finish; - - $dbh->disconnect; - - $main::lxdebug->leave_sub(); -} - -sub save_printer { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - my $query; - - # connect to database - my $dbh = $form->dbconnect($myconfig); - - my @values = ($form->{printer_description}, - $form->{template_code}, - $form->{printer_command}); - - # id is the old record - if ($form->{id}) { - $query = qq|UPDATE printers SET - printer_description = ?, template_code = ?, printer_command = ? - WHERE id = ?|; - push(@values, $form->{id}); - } else { - $query = qq|INSERT INTO printers - (printer_description, template_code, printer_command) - VALUES (?, ?, ?)|; - } - do_query($form, $dbh, $query, @values); - - $dbh->disconnect; - - $main::lxdebug->leave_sub(); -} - -sub delete_printer { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - # connect to database - my $dbh = $form->dbconnect($myconfig); - - my $query = qq|DELETE FROM printers - WHERE id = ?|; - do_query($form, $dbh, $query, $form->{id}); - - $dbh->disconnect; - - $main::lxdebug->leave_sub(); -} - sub payment { $main::lxdebug->enter_sub(); @@ -1542,42 +1444,6 @@ sub save_preferences { $auth->create_or_refresh_session(); } - if ($webdav) { - my @webdavdirs = - qw(angebote bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen); - foreach my $directory (@webdavdirs) { - my $file = "webdav/" . $directory . "/webdav-user"; - my $newfile; - if ($myconfig->{$directory}) { - open(HTACCESS, "$file") or die "cannot open webdav-user $!\n"; - while () { - my ($login, $password) = split(/:/, $_); - if ($login ne $form->{login}) { - $newfile .= $_; - } - } - close(HTACCESS); - open(HTACCESS, "> $file") or die "cannot open webdav-user $!\n"; - $newfile .= $myconfig->{login} . ":" . $myconfig->{password} . "\n"; - print(HTACCESS $newfile); - close(HTACCESS); - } else { - $form->{$directory} = 0; - open(HTACCESS, "$file") or die "cannot open webdav-user $!\n"; - while () { - my ($login, $password) = split(/:/, $_); - if ($login ne $form->{login}) { - $newfile .= $_; - } - } - close(HTACCESS); - open(HTACCESS, "> $file") or die "cannot open webdav-user $!\n"; - print(HTACCESS $newfile); - close(HTACCESS); - } - } - } - $main::lxdebug->leave_sub(); return $rc; @@ -1776,7 +1642,7 @@ sub retrieve_units { my ($self, $myconfig, $form, $prefix) = @_; - my $dbh = $form->dbconnect($myconfig); + my $dbh = $form->get_standard_dbh; my $query = "SELECT *, base_unit AS original_base_unit FROM units"; @@ -1816,9 +1682,7 @@ sub retrieve_units { map({ $unit->{"LANGUAGES"}->{$ref->{"template_code"}}->{$_} = $ref->{$_} } keys(%{$ref})); } } - $sth->finish(); - - $dbh->disconnect(); + $sth->finish; $main::lxdebug->leave_sub();