From: Bernd Bleßmann Date: Wed, 14 Jan 2015 13:46:45 +0000 (+0100) Subject: Item-Positionen in DB: Angebot/Auftrags-Masken honorieren und speichern diese. X-Git-Tag: release-3.2.0beta~77 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8b60748b133a65562d8d0e8617382347d4c978f7;p=kivitendo-erp.git Item-Positionen in DB: Angebot/Auftrags-Masken honorieren und speichern diese. --- diff --git a/SL/OE.pm b/SL/OE.pm index a179b2d7e..58792acef 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -515,20 +515,22 @@ sub save { $pricegroup_id *= 1; $pricegroup_id = undef if !$pricegroup_id; + my $position = $i; + # save detail record in orderitems table if (! $form->{"orderitems_id_$i"}) { $query = qq|SELECT nextval('orderitemsid')|; ($form->{"orderitems_id_$i"}) = selectrow_query($form, $dbh, $query); - $query = qq|INSERT INTO orderitems (id) VALUES (?)|; - do_query($form, $dbh, $query, $form->{"orderitems_id_$i"}); + $query = qq|INSERT INTO orderitems (id, position) VALUES (?, ?)|; + do_query($form, $dbh, $query, $form->{"orderitems_id_$i"}, conv_i($position)); } my $orderitems_id = $form->{"orderitems_id_$i"}; push @processed_orderitems, $orderitems_id; $query = <{id}), conv_i($form->{"id_$i"}), + conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"}), $form->{"description_$i"}, $restricter->process($form->{"longdescription_$i"}), $form->{"qty_$i"}, $baseqty, $fxsellprice, $form->{"discount_$i"}, @@ -960,7 +962,7 @@ sub retrieve { ($form->{id} ? qq|WHERE o.trans_id = ?| : qq|WHERE o.trans_id IN (| . join(", ", map("?", @ids)) . qq|)|) . - qq|ORDER BY o.oid|; + qq|ORDER BY o.trans_id, o.position|; @ids = $form->{id} ? ($form->{id}) : @ids; $sth = prepare_execute_query($form, $dbh, $query, @values); @@ -1092,7 +1094,7 @@ sub retrieve_simple { my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); my $oe_query = qq|SELECT * FROM oe WHERE id = ?|; - my $oi_query = qq|SELECT * FROM orderitems WHERE trans_id = ?|; + my $oi_query = qq|SELECT * FROM orderitems WHERE trans_id = ? ORDER BY position|; my $order = selectfirst_hashref_query($form, $dbh, $oe_query, conv_i($params{id})); $order->{orderitems} = selectall_hashref_query( $form, $dbh, $oi_query, conv_i($params{id}));