From 0d19003522b2abb9fe8e22b162a66428f95ba845 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 13 Nov 2012 09:00:18 +0100 Subject: [PATCH] Refactoring: Preisgruppenpreise speichern Siehe #1873. --- SL/IC.pm | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) 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; -- 2.20.1