Positionen verknüpfen Auftrag -> Lieferschein
authorJan Büren <jan@kivitendo-premium.de>
Fri, 23 Jan 2015 07:53:11 +0000 (08:53 +0100)
committerJan Büren <jan@kivitendo-premium.de>
Fri, 23 Jan 2015 07:53:11 +0000 (08:53 +0100)
 - from_table -> to_table (tabelleneintrag)     i.O.
 - delete trigger                               i.O.
 - mittlere position löschen (vor speichern)    i.O.
 - update sicher in form                        i.O.
 - mehrfach speichern                           i.O.

SL/DO.pm
bin/mozilla/oe.pl

index 8fad24c..5309c15 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -403,6 +403,17 @@ SQL
                                 name_prefix  => 'ic_',
                                 name_postfix => "_$i",
                                 dbh          => $dbh);
+    # link order items with doi
+    if ($form->{"converted_from_order_orderitems_id_$i"}) {
+      RecordLinks->create_links('dbh'        => $dbh,
+                                'mode'       => 'ids',
+                                'from_table' => 'orderitems',
+                                'from_ids'   => $form->{"converted_from_order_orderitems_id_$i"},
+                                'to_table'   => 'delivery_order_items',
+                                'to_id'      =>  $form->{"delivery_order_items_id_$i"},
+      );
+      delete $form->{"converted_from_order_orderitems_id_$i"};
+    }
   }
 
   # 1. search for orphaned dois; processed_dois may be empty (no transfer) TODO: be supersafe and alter same statement for doi and oi
index 9a1da4a..09eb52a 100644 (file)
@@ -1893,11 +1893,11 @@ sub delivery_order {
 
   # reset
   delete @{$form}{qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal closed delivered)};
-  delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
 
   for my $i (1 .. $form->{rowcount}) {
     map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice lastcost basefactor discount);
-    $form->{"converted_from_order_orderitems_id_$_"} = $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
+    $form->{"converted_from_order_orderitems_id_$i"} = $form->{"orderitems_id_$i"};
+    delete $form->{"orderitems_id_$i"}; # even if they don't exist in form. cvars checks them before display_row
   }
 
   my %old_values = map { $_ => $form->{$_} } qw(customer_id oldcustomer customer vendor_id oldvendor vendor shipto_id);