X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAM.pm;h=e4e5ad7cdd3ae87ffc89f0c5e6760f5544a31a89;hb=965a8ee142a6cd21c3056eacaa01a01818032c3e;hp=2aa1ad2b66c96a340ee73404874e3a22f765390e;hpb=2e3bdf1ae149f89f0cd9dbdda70372de38247f77;p=kivitendo-erp.git diff --git a/SL/AM.pm b/SL/AM.pm index 2aa1ad2b6..e4e5ad7cd 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -410,61 +410,6 @@ sub _delete_account { return 1; } -sub language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form, $return_list) = @_; - - my $dbh = SL::DB->client->dbh; - - my $query = - "SELECT id, description, template_code, article_code, " . - " output_numberformat, output_dateformat, output_longdates " . - "FROM language ORDER BY description"; - - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - my $ary = []; - - while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { - push(@{ $ary }, $ref); - } - - $sth->finish; - - $main::lxdebug->leave_sub(); - - if ($return_list) { - return @{$ary}; - } else { - $form->{ALL} = $ary; - } -} - -sub get_language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - my $dbh = SL::DB->client->dbh; - - my $query = - "SELECT description, template_code, article_code, " . - " output_numberformat, output_dateformat, output_longdates " . - "FROM language WHERE 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; - - $main::lxdebug->leave_sub(); -} - sub get_language_details { $main::lxdebug->enter_sub(); @@ -483,64 +428,6 @@ sub get_language_details { return @res; } -sub save_language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - SL::DB->client->with_transaction(sub { - my $dbh = SL::DB->client->dbh; - my (@values, $query); - - map({ push(@values, $form->{$_}); } - qw(description template_code article_code - output_numberformat output_dateformat output_longdates)); - - # id is the old record - if ($form->{id}) { - $query = - "UPDATE language SET " . - " description = ?, template_code = ?, article_code = ?, " . - " output_numberformat = ?, output_dateformat = ?, " . - " output_longdates = ? " . - "WHERE id = ?"; - push(@values, $form->{id}); - } else { - $query = - "INSERT INTO language (" . - " description, template_code, article_code, " . - " output_numberformat, output_dateformat, output_longdates" . - ") VALUES (?, ?, ?, ?, ?, ?)"; - } - do_query($form, $dbh, $query, @values); - 1; - }) or do { die SL::DB->client->error }; - - $main::lxdebug->leave_sub(); -} - -sub delete_language { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - my $query; - - SL::DB->client->with_transaction(sub { - my $dbh = SL::DB->client->dbh; - - foreach my $table (qw(generic_translations units_language)) { - $query = qq|DELETE FROM $table WHERE language_id = ?|; - do_query($form, $dbh, $query, $form->{"id"}); - } - - $query = "DELETE FROM language WHERE id = ?"; - do_query($form, $dbh, $query, $form->{"id"}); - 1; - }) or do { die SL::DB->client->error }; - - $main::lxdebug->leave_sub(); -} - sub prepare_template_filename { $main::lxdebug->enter_sub(); @@ -1292,76 +1179,6 @@ sub delete_tax { $main::lxdebug->leave_sub(); } -sub save_price_factor { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - SL::DB->client->with_transaction(sub { - my $dbh = SL::DB->client->dbh; - - my $query; - my @values = ($form->{description}, conv_i($form->{factor})); - - if ($form->{id}) { - $query = qq|UPDATE price_factors SET description = ?, factor = ? WHERE id = ?|; - push @values, conv_i($form->{id}); - - } else { - $query = qq|INSERT INTO price_factors (description, factor, sortkey) VALUES (?, ?, (SELECT COALESCE(MAX(sortkey), 0) + 1 FROM price_factors))|; - } - - do_query($form, $dbh, $query, @values); - 1; - }) or do { die SL::DB->client->error }; - - $main::lxdebug->leave_sub(); -} - -sub get_all_price_factors { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - my $dbh = SL::DB->client->dbh; - - $form->{PRICE_FACTORS} = selectall_hashref_query($form, $dbh, qq|SELECT * FROM price_factors ORDER BY sortkey|); - - $main::lxdebug->leave_sub(); -} - -sub get_price_factor { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - # connect to database - my $dbh = SL::DB->client->dbh; - - my $query = qq|SELECT description, factor, - ((SELECT COUNT(*) FROM parts WHERE price_factor_id = ?) + - (SELECT COUNT(*) FROM invoice WHERE price_factor_id = ?) + - (SELECT COUNT(*) FROM orderitems WHERE price_factor_id = ?)) = 0 AS orphaned - FROM price_factors WHERE id = ?|; - - ($form->{description}, $form->{factor}, $form->{orphaned}) = selectrow_query($form, $dbh, $query, (conv_i($form->{id})) x 4); - - $main::lxdebug->leave_sub(); -} - -sub delete_price_factor { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - SL::DB->client->with_transaction(sub { - do_query($form, SL::DB->client->dbh, qq|DELETE FROM price_factors WHERE id = ?|, conv_i($form->{id})); - 1; - }) or do { die SL::DB->client->error }; - - $main::lxdebug->leave_sub(); -} - sub save_warehouse { $main::lxdebug->enter_sub();