use SL::DO;
use SL::IR;
use SL::IS;
+use SL::MoreCommon qw(ary_diff);
use SL::ReportGenerator;
use SL::WH;
require "bin/mozilla/arap.pl";
$form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"} * (1 - $form->{tradediscount}));
$form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"});
$form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
+
+ # get pricegroups for parts
+ IS->get_pricegroups_for_parts(\%myconfig, \%$form);
+
+ # build up html code for prices_$i
+ &set_pricegroup($i);
}
display_form();
$form->{simple_save} = 1;
if (!$params{no_redirect} && !$form->{print_and_save}) {
- set_headings("edit");
- update();
+ delete @{$form}{ary_diff([keys %{ $form }], [qw(login id script type cursor_fokus)])};
+ edit();
::end_of_request();
}
$main::lxdebug->leave_sub();
$form->{"sellprice_pg_$i"} = join '--', $form->{"sellprice_$i"}, $form->{"pricegroup_id_$i"};
}
IS->get_pricegroups_for_parts(\%myconfig, \%$form);
- set_pricegroup($_) for 1 .. $form->{rowcount};
+ set_pricegroup($form->{rowcount});
display_form();
if ($is_delivery_order) {
map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost);
- push @hidden_vars, qw(sellprice discount not_discountable price_factor_id lastcost pricegroup_id);
+ $form->{"pricegroup_id_$i"} = $form->{"pricegroup_old_$i"} if $form->{"pricegroup_old_$i"};
+ $form->{"sellprice_pg_$i"} = $form->{"hidden_prices_$i"} if $form->{"hidden_prices_$i"};
+ push @hidden_vars, grep { defined $form->{"${_}_${i}"} } qw(sellprice discount not_discountable price_factor_id lastcost pricegroup_id sellprice_pg);
push @hidden_vars, "stock_${stock_in_out}_sum_qty", "stock_${stock_in_out}";
}
$form->{"sellprice_$j"} = $item->{price} if $item->{selected} && $item->{pricegroup_id};
$form->{"price_new_$j"} = $form->{"sellprice_$j"} if $item->{selected} || !$item->{pricegroup_id};
}
+
+ # save hidden pricegroups for delivery_orders
+ next unless my @selected_prices = grep { $_->{selected} } @{ $form->{PRICES}{$j} };
+ $form->{"hidden_prices_$j"} = $selected_prices[-1]{price} . "--" . $selected_prices[-1]{pricegroup_id};
}
$main::lxdebug->leave_sub();
}