From: Moritz Bunkus Date: Tue, 13 Nov 2012 08:00:18 +0000 (+0100) Subject: Refactoring: Preisgruppenpreise speichern X-Git-Tag: release-3.0.0beta2~12^2~20 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0d19003522b2abb9fe8e22b162a66428f95ba845;p=kivitendo-erp.git Refactoring: Preisgruppenpreise speichern Siehe #1873. --- diff --git a/SL/IC.pm b/SL/IC.pm index f5f014b9d..f506b9737 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -471,26 +471,20 @@ sub save { # delete price records do_query($form, $dbh, qq|DELETE FROM prices WHERE parts_id = ?|, conv_i($form->{id})); + $query = qq|INSERT INTO prices (parts_id, pricegroup_id, price) VALUES(?, ?, ?)|; + $sth = prepare_query($form, $dbh, $query); + # insert price records only if different to sellprice for my $i (1 .. $form->{price_rows}) { my $price = $form->parse_amount($myconfig, $form->{"price_$i"}); - if ($price == 0) { - $form->{"price_$i"} = $form->{sellprice}; - } - if ( - ( $price - || $form->{"klass_$i"} - || $form->{"pricegroup_id_$i"}) - and $price != $form->{sellprice} - ) { - #$klass = $form->parse_amount($myconfig, $form->{"klass_$i"}); - $query = qq|INSERT INTO prices (parts_id, pricegroup_id, price) | . - qq|VALUES(?, ?, ?)|; - @values = (conv_i($form->{id}), conv_i($form->{"pricegroup_id_$i"}), $price); - do_query($form, $dbh, $query, @values); - } + next unless $price && ($price != $form->{sellprice}); + + @values = (conv_i($form->{id}), conv_i($form->{"pricegroup_id_$i"}), $price); + do_statement($form, $sth, $query, @values); } + $sth->finish; + # insert makemodel records my $lastupdate = ''; my $value = 0;