From: Moritz Bunkus Date: Tue, 13 Nov 2012 08:16:38 +0000 (+0100) Subject: Preisgruppen in Artikelstammdatendialog in gleicher Reihenfolge anzeigen X-Git-Tag: release-3.0.0beta2~12^2~19 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=7c2886a7ca732655319fd0a33858174d2396ace8;p=kivitendo-erp.git Preisgruppen in Artikelstammdatendialog in gleicher Reihenfolge anzeigen Fixt #1873. --- diff --git a/SL/IC.pm b/SL/IC.pm index f506b9737..f39c169b2 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -109,60 +109,20 @@ sub get_part { $form->{amount}{IC_expense} = $form->{expense_accno}; $form->{amount}{IC_cogs} = $form->{expense_accno}; - my @pricegroups = (); - my @pricegroups_not_used = (); - # get prices - $query = - qq|SELECT p.parts_id, p.pricegroup_id, p.price, - (SELECT pg.pricegroup - FROM pricegroup pg - WHERE pg.id = p.pricegroup_id) AS pricegroup - FROM prices p - WHERE (parts_id = ?) - ORDER BY pricegroup|; - $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); - - #for pricegroups - my $i = 1; - while (($form->{"klass_$i"}, $form->{"pricegroup_id_$i"}, - $form->{"price_$i"}, $form->{"pricegroup_$i"}) - = $sth->fetchrow_array()) { - push @pricegroups, $form->{"pricegroup_id_$i"}; - $i++; - } - - $sth->finish; - - # get pricegroups - $query = qq|SELECT id, pricegroup FROM pricegroup|; - $form->{PRICEGROUPS} = selectall_hashref_query($form, $dbh, $query); - - #find not used pricegroups - while (my $tmp = pop(@{ $form->{PRICEGROUPS} })) { - my $in_use = 0; - foreach my $item (@pricegroups) { - if ($item eq $tmp->{id}) { - $in_use = 1; - last; - } - } - push(@pricegroups_not_used, $tmp) unless ($in_use); - } - - # if not used pricegroups are avaible - if (@pricegroups_not_used) { + $query = <{"klass_$i"} = "$name->{id}"; - $form->{"pricegroup_id_$i"} = "$name->{id}"; - $form->{"pricegroup_$i"} = "$name->{pricegroup}"; - $i++; - } + my $row = 1; + foreach $ref (selectall_hashref_query($form, $dbh, $query, conv_i($form->{id}))) { + $form->{"${_}_${row}"} = $ref->{$_} for qw(pricegroup_id pricegroup price); + $row++; } - - #correct rows - $form->{price_rows} = $i - 1; + $form->{price_rows} = $row - 1; # get makes if ($form->{makemodel}) { @@ -241,7 +201,7 @@ sub get_pricegroups { my $dbh = $form->dbconnect($myconfig); # get pricegroups - my $query = qq|SELECT id, pricegroup FROM pricegroup|; + my $query = qq|SELECT id, pricegroup FROM pricegroup ORDER BY lower(pricegroup)|; my $pricegroups = selectall_hashref_query($form, $dbh, $query); my $i = 1;