From: Bernd Bleßmann Date: Wed, 14 Jan 2015 13:26:06 +0000 (+0100) Subject: Item-Positionen in DB: Lieferschein-Masken honorieren und speichern diese. X-Git-Tag: release-3.2.0beta~78 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=340fd4354e902230359ef4b166047ea08bea6b01;p=kivitendo-erp.git Item-Positionen in DB: Lieferschein-Masken honorieren und speichern diese. --- diff --git a/SL/DO.pm b/SL/DO.pm index 469d36592..de9a728de 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -274,7 +274,7 @@ sub save { } my $q_item = <{rowcount}) { next if (!$form->{"id_$i"}); + my $position = $i; + if (!$form->{"delivery_order_items_id_$i"}) { # there is no persistent id, therefore create one with all necessary constraints my $q_item_id = qq|SELECT nextval('delivery_order_items_id')|; my $h_item_id = prepare_query($form, $dbh, $q_item_id); do_statement($form, $h_item_id, $q_item_id); $form->{"delivery_order_items_id_$i"} = $h_item_id->fetchrow_array(); - $query = qq|INSERT INTO delivery_order_items (id, delivery_order_id, parts_id) VALUES (?, ?, ?)|; + $query = qq|INSERT INTO delivery_order_items (id, delivery_order_id, position, parts_id) VALUES (?, ?, ?, ?)|; do_query($form, $dbh, $query, conv_i($form->{"delivery_order_items_id_$i"}), - conv_i($form->{"id"}), conv_i($form->{"id_$i"})); + conv_i($form->{"id"}), conv_i($position), conv_i($form->{"id_$i"})); $h_item_id->finish(); } $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); @@ -336,7 +338,7 @@ SQL $pricegroup_id = undef if !$pricegroup_id; # save detail record in delivery_order_items table - @values = (conv_i($form->{id}), conv_i($form->{"id_$i"}), + @values = (conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"}), $form->{"description_$i"}, $restricter->process($form->{"longdescription_$i"}), $form->{"qty_$i"}, $baseqty, $form->{"sellprice_$i"}, $form->{"discount_$i"} / 100, @@ -740,7 +742,7 @@ sub retrieve { LEFT JOIN project pr ON (doi.project_id = pr.id) LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) WHERE doi.delivery_order_id IN ($do_ids_placeholders) - ORDER BY doi.oid|; + ORDER BY doi.delivery_order_id, doi.position|; $form->{form_details} = selectall_hashref_query($form, $dbh, $query, @do_ids);