- if ($form->{"id_${i}"}) {
- my $price_source = SL::PriceSource->new(record_item => $record_item, record => $record);
- my $price = $price_source->price_from_source($::form->{"active_price_source_$i"});
- $::form->{price_sources}[$i] = $price_source;
- $column_data{price_source} .= $cgi->button(-value => $price->full_description, -onClick => "toggle_price_source($i)");
+ if ($form->{"id_${i}"} && !$is_delivery_order) {
+ my $price_source = SL::PriceSource->new(record_item => $record_item, record => $record);
+ my $price = $price_source->price_from_source($::form->{"active_price_source_$i"});
+ my $discount = $price_source->price_from_source($::form->{"active_discount_source_$i"});
+ my $best_price = $price_source->best_price;
+ my $best_discount = $price_source->best_discount;
+ $column_data{price_source} .= $cgi->button(-value => $price->source_description, -onClick => "kivi.io.price_chooser($i)");
+ if ($price->source) {
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->invalid, title => $price->invalid }) if $price->invalid;
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->missing, title => $price->missing }) if $price->missing;
+ if (!$price->missing && !$price->invalid) {
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This price has since gone up'), title => t8('This price has since gone up' ) }) if $price->price > $record_item->sellprice;
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This price has since gone down'), title => t8('This price has since gone down') }) if $price->price < $record_item->sellprice;
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png', alt => t8('There is a better price available'), title => t8('There is a better price available') }) if $best_price && $price->source ne $price_source->best_price->source;
+ }
+ }
+ if ($discount->source) {
+ $column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->invalid, title => $discount->invalid }) if $discount->invalid;
+ $column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->missing, title => $discount->missing }) if $discount->missing;
+ if (!$discount->missing && !$discount->invalid) {
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This discount has since gone up'), title => t8('This discount has since gone up') }) if $discount->discount * 100 > $record_item->discount;
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This discount has since gone down'), title => t8('This discount has since gone down') }) if $discount->discount * 100 < $record_item->discount;
+ $column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png', alt => t8('There is a better discount available'), title => t8('There is a better discount available') }) if $best_discount && $discount->source ne $price_source->best_discount->source;
+ }
+ }