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
# 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);