@@ -, +, @@ --- acqui/addorder.pl | 21 ++++++++++--------- acqui/neworderempty.pl | 15 +++++++------ .../prog/en/modules/acqui/neworderempty.tt | 1 + 3 files changed, 21 insertions(+), 16 deletions(-) --- a/acqui/addorder.pl +++ a/acqui/addorder.pl @@ -371,17 +371,18 @@ if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { ModOrderUsers( $order->ordernumber, @order_users ); # Retrieve and save additional fields values - my @additional_fields = Koha::AdditionalFields->search({ tablename => 'aqorders' })->as_list; - my @additional_field_values; - foreach my $af (@additional_fields) { - my $id = $af->id; - my $value = $input->param("additional_field_$id"); - push @additional_field_values, { - id => $id, - value => $value, - }; + my @additional_fields; + my $order_fields = Koha::AdditionalFields->search( { tablename => 'aqorders' } ); + while ( my $field = $order_fields->next ) { + my @field_values = $input->param( 'additional_field_' . $field->id ); + foreach my $value (@field_values) { + push @additional_fields, { + id => $field->id, + value => $value, + } if $value; + } } - $order->set_additional_fields(\@additional_field_values); + $order->set_additional_fields(\@additional_fields); # now, add items if applicable if ($basket->effective_create_items eq 'ordering') { --- a/acqui/neworderempty.pl +++ a/acqui/neworderempty.pl @@ -419,24 +419,27 @@ $quantity //= 0; # Get additional fields my $record; my @additional_fields = Koha::AdditionalFields->search({ tablename => 'aqorders' })->as_list; -my %additional_field_values; +my $additional_field_values; if ($ordernumber) { my $order = Koha::Acquisition::Orders->find($ordernumber); - foreach my $value ($order->additional_field_values->as_list) { - $additional_field_values{$value->field_id} = $value->value; - } + $additional_field_values = $order->get_additional_field_values_for_template; } elsif ( $biblionumber ) { + my %additional_field_values; foreach my $af (@additional_fields) { + my @marc_field_values; if ($af->marcfield) { $record //= Koha::Biblios->find($biblionumber)->metadata->record; my ($field, $subfield) = split /\$/, $af->marcfield; - $additional_field_values{$af->id} = $record->subfield($field, $subfield); + push @marc_field_values, $record->subfield( $field, $subfield ) if $record->subfield( $field, $subfield ); + $additional_field_values{ $af->id } = \@marc_field_values; } } + $additional_field_values = \%additional_field_values } + $template->param( additional_fields => \@additional_fields, - additional_field_values => \%additional_field_values, + additional_field_values => $additional_field_values, ); # fill template --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -49,6 +49,7 @@ [% Asset.js("js/acq.js") | $raw %] [% Asset.js("js/additem.js") | $raw %] [% Asset.js("js/cataloging.js") | $raw %] + [% Asset.js("js/additional-fields-entry.js") | $raw %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'select2.inc' %]