View | Details | Raw Unified | Return to bug 35044
Collapse All | Expand All

(-)a/acqui/addorder.pl (-17 / +18 lines)
Lines 117-133 if it is an order from an existing suggestion : the id of this suggestion. Link Here
117
=cut
117
=cut
118
118
119
use Modern::Perl;
119
use Modern::Perl;
120
use CGI qw ( -utf8 );
120
use CGI  qw ( -utf8 );
121
use JSON qw ( to_json encode_json );
121
use JSON qw ( to_json encode_json );
122
122
123
use C4::Acquisition qw( FillWithDefaultValues ModOrderUsers );
123
use C4::Acquisition qw( FillWithDefaultValues ModOrderUsers );
124
use C4::Auth qw( get_template_and_user );
124
use C4::Auth        qw( get_template_and_user );
125
use C4::Barcodes;
125
use C4::Barcodes;
126
use C4::Biblio qw( AddBiblio GetMarcFromKohaField TransformHtmlToXml TransformKohaToMarc );
126
use C4::Biblio      qw( AddBiblio GetMarcFromKohaField TransformHtmlToXml TransformKohaToMarc );
127
use C4::Budgets qw( GetBudget GetBudgetSpent GetBudgetOrdered FieldsForCalculatingFundValues );
127
use C4::Budgets     qw( GetBudget GetBudgetSpent GetBudgetOrdered FieldsForCalculatingFundValues );
128
use C4::Items qw( AddItemFromMarc );
128
use C4::Items       qw( AddItemFromMarc );
129
use C4::Log qw( logaction );
129
use C4::Log         qw( logaction );
130
use C4::Output qw( output_html_with_http_headers );
130
use C4::Output      qw( output_html_with_http_headers );
131
use C4::Suggestions qw( ModSuggestion );
131
use C4::Suggestions qw( ModSuggestion );
132
use Koha::Acquisition::Baskets;
132
use Koha::Acquisition::Baskets;
133
use Koha::Acquisition::Currencies qw( get_active );
133
use Koha::Acquisition::Currencies qw( get_active );
Lines 387-403 if ( $op eq 'cud-order' ) { Link Here
387
        ModOrderUsers( $order->ordernumber, @order_users );
387
        ModOrderUsers( $order->ordernumber, @order_users );
388
388
389
        # Retrieve and save additional fields values
389
        # Retrieve and save additional fields values
390
        my @additional_fields = Koha::AdditionalFields->search( { tablename => 'aqorders' } )->as_list;
390
        my @additional_fields;
391
        my @additional_field_values;
391
        my $order_fields = Koha::AdditionalFields->search( { tablename => 'aqorders' } );
392
        foreach my $af (@additional_fields) {
392
        while ( my $field = $order_fields->next ) {
393
            my $id    = $af->id;
393
            my @field_values = $input->param( 'additional_field_' . $field->id );
394
            my $value = $input->param("additional_field_$id");
394
            foreach my $value (@field_values){
395
            push @additional_field_values, {
395
                push @additional_fields,
396
                id    => $id,
396
                {
397
                value => $value,
397
                    id    => $field->id,
398
                    value => $value,
399
                } if $value;
398
            };
400
            };
399
        }
401
        }
400
        $order->set_additional_fields( \@additional_field_values );
402
        $order->set_additional_fields( \@additional_fields );
401
403
402
        # now, add items if applicable
404
        # now, add items if applicable
403
        if ( $basket->effective_create_items eq 'ordering' ) {
405
        if ( $basket->effective_create_items eq 'ordering' ) {
Lines 482-485 if ( $op eq 'cud-order' ) { Link Here
482
    print $input->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=$basketno");
484
    print $input->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=$basketno");
483
    exit;
485
    exit;
484
}
486
}
485
(-)a/acqui/neworderempty.pl (-6 / +9 lines)
Lines 424-449 $quantity //= 0; Link Here
424
# Get additional fields
424
# Get additional fields
425
my $record;
425
my $record;
426
my @additional_fields = Koha::AdditionalFields->search({ tablename => 'aqorders' })->as_list;
426
my @additional_fields = Koha::AdditionalFields->search({ tablename => 'aqorders' })->as_list;
427
my %additional_field_values;
427
my $additional_field_values;
428
my $items;
428
my $items;
429
if ($ordernumber) {
429
if ($ordernumber) {
430
    my $order = Koha::Acquisition::Orders->find($ordernumber);
430
    my $order = Koha::Acquisition::Orders->find($ordernumber);
431
    foreach my $value ($order->additional_field_values->as_list) {
431
    $additional_field_values = $order->get_additional_field_values_for_template;
432
        $additional_field_values{$value->field_id} = $value->value;
433
    }
434
    $items = $order->items;
432
    $items = $order->items;
435
} elsif ( $biblionumber ) {
433
} elsif ( $biblionumber ) {
434
    my %additional_field_values;
436
    foreach my $af (@additional_fields) {
435
    foreach my $af (@additional_fields) {
436
        my @marc_field_values;
437
        if ($af->marcfield) {
437
        if ($af->marcfield) {
438
            $record //= Koha::Biblios->find($biblionumber)->metadata->record;
438
            $record //= Koha::Biblios->find($biblionumber)->metadata->record;
439
            my ($field, $subfield) = split /\$/, $af->marcfield;
439
            my ($field, $subfield) = split /\$/, $af->marcfield;
440
            $additional_field_values{$af->id} = $record->subfield($field, $subfield);
440
            push @marc_field_values, $record->subfield( $field, $subfield ) if $record->subfield( $field, $subfield );
441
            $additional_field_values{ $af->id } = \@marc_field_values;
441
        }
442
        }
442
    }
443
    }
444
    $additional_field_values = \%additional_field_values
443
}
445
}
446
444
$template->param(
447
$template->param(
445
    additional_fields => \@additional_fields,
448
    additional_fields => \@additional_fields,
446
    additional_field_values => \%additional_field_values,
449
    additional_field_values => $additional_field_values,
447
    items => $items,
450
    items => $items,
448
);
451
);
449
452
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-1 / +1 lines)
Lines 51-56 Link Here
51
    [% Asset.js("js/acq.js") | $raw %]
51
    [% Asset.js("js/acq.js") | $raw %]
52
    [% Asset.js("js/additem.js") | $raw %]
52
    [% Asset.js("js/additem.js") | $raw %]
53
    [% Asset.js("js/cataloging.js") | $raw %]
53
    [% Asset.js("js/cataloging.js") | $raw %]
54
    [% Asset.js("js/additional-fields-entry.js") | $raw %]
54
    [% INCLUDE 'calendar.inc' %]
55
    [% INCLUDE 'calendar.inc' %]
55
    [% INCLUDE 'select2.inc' %]
56
    [% INCLUDE 'select2.inc' %]
56
    <script>
57
    <script>
57
- 

Return to bug 35044