X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=a77632b7e690a25cffd07651e0828d7e7f4f0c37;hb=61a56bb4796ca9edb098541c55a00c990a9f227c;hp=e5b88c41c201ead1b17ab7c9c04898802f29e3de;hpb=dd33cbecc78ee154df73ebf578be8f660af2357c;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index e5b88c41c..a77632b7e 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -218,7 +218,7 @@ sub display_row { # special alignings my %align = map { $_ => 'right' } qw(qty ship right discount linetotal stock_in_out weight ship_missing); - my %nowrap = map { $_ => 1 } qw(description unit); + my %nowrap = map { $_ => 1 } qw(description unit price_source); $form->{marge_total} = 0; $form->{sellprice_total} = 0; @@ -336,24 +336,18 @@ sub display_row { $column_data{ship_missing} = $form->format_amount(\%myconfig, $ship_missing_qty) . ' ' . $form->{"unit_$i"} . '; ' . $form->format_amount(\%myconfig, $ship_missing_amount, $decimalplaces); } - my $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); - my $discount_value = $form->format_amount(\%myconfig, $form->{"discount_$i"}); - my $edit_prices = $main::auth->assert('edit_prices', 1) && !$::form->{"active_price_source_$i"}; - my $edit_discounts = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"}; - $column_data{sellprice} = (!$edit_prices) - ? $cgi->hidden( -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value - : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value); - $column_data{discount} = (!$edit_discounts) - ? $cgi->hidden( -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %' - : $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -value => $discount_value); $column_data{linetotal} = $form->format_amount(\%myconfig, $linetotal, 2); $column_data{bin} = $form->{"bin_$i"}; $column_data{weight} = $form->format_amount(\%myconfig, $form->{"qty_$i"} * $form->{"weight_$i"}, 3) . ' ' . $defaults->{weightunit} if $defaults->{show_weight}; + my $sellprice_value = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + my $discount_value = $form->format_amount(\%myconfig, $form->{"discount_$i"}); + + my $price; 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"}); + $price = $price_source->price_from_source($::form->{"active_price_source_$i"}); my $discount = $price_source->discount_from_source($::form->{"active_discount_source_$i"}); my $best_price = $price_source->best_price; my $best_discount = $price_source->best_discount; @@ -378,6 +372,15 @@ sub display_row { } } + my $edit_prices = $main::auth->assert('edit_prices', 1) && (!$::form->{"active_price_source_$i"} || !$price || $price->editable); + my $edit_discounts = $main::auth->assert('edit_prices', 1) && !$::form->{"active_discount_source_$i"}; + $column_data{sellprice} = (!$edit_prices) + ? $cgi->hidden( -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value + : $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value => $sellprice_value); + $column_data{discount} = (!$edit_discounts) + ? $cgi->hidden( -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %' + : $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -value => $discount_value); + if ($is_delivery_order) { $column_data{stock_in_out} = calculate_stock_in_out($i); } @@ -1828,25 +1831,44 @@ sub _make_record_item { $class = 'SL::DB::' . $class; + my %translated_methods = ( + 'SL::DB::OrderItem' => { + id => 'parts_id', + orderitems_id => 'id', + }, + 'SL::DB::DeliveryOrderItem' => { + id => 'parts_id', + delivery_order_items_id => 'id', + }, + 'SL::DB::InvoiceItem' => { + id => 'parts_id', + invoice_id => 'id', + }, + ); + eval "require $class"; my $obj = $::form->{"orderitems_id_$row"} ? $class->meta->convention_manager->auto_manager_class_name->find_by(id => $::form->{"orderitems_id_$row"}) : $class->new; - for my $method (apply { s/_$row$// } grep { /_$row$/ } keys %$::form) { + for my $key (grep { /_$row$/ } keys %$::form) { + my $method = $key; + $method =~ s/_$row$//; + $method = $translated_methods{$class}{$method} // $method; + my $value = $::form->{$key}; if ($obj->meta->column($method)) { if ($obj->meta->column($method)->isa('Rose::DB::Object::Metadata::Column::Date')) { - $obj->${\"$method\_as_date"}($::form->{"$method\_$row"}); + $obj->${\"$method\_as_date"}($value); } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::(?:Numeric|Float|DoublePrecsion)$/) { - $obj->${\"$method\_as_number"}($::form->{"$method\_$row"}); + $obj->${\"$method\_as_number"}($value); } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::Boolean$/) { - $obj->$method(!!$::form->{$method}); + $obj->$method(!!$value); } else { - $obj->$method($::form->{"$method\_$row"}); + $obj->$method($value); } } else { - $obj->{__additional_form_attributes}{$method} = $::form->{"$method\_$row"}; + $obj->{__additional_form_attributes}{$method} = $value; } }