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

(-)a/serials/subscription-add.pl (-19 / +18 lines)
Lines 348-361 sub redirect_add_subscription { Link Here
348
    );
348
    );
349
349
350
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
350
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
351
    my @additional_field_values;
351
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
352
    for my $field ( @$additional_fields ) {
353
        my $af = Koha::AdditionalField->new({ id => $field->{id} });
354
        $af->{values} = {
355
            $subscriptionid => $query->param('additional_field_' . $field->{id})
356
        } if defined $query->param('additional_field_' . $field->{id});
357
        $af->insert_values;
358
    }
359
352
360
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
353
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
361
    return;
354
    return;
Lines 433-457 sub redirect_mod_subscription { Link Here
433
    );
426
    );
434
427
435
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
428
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
429
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
430
431
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
432
    return;
433
}
434
435
sub insert_additional_fields {
436
    my ( $additional_fiels, $biblionumber, $subscriptionid ) = @_;
436
    my @additional_field_values;
437
    my @additional_field_values;
438
    my $record = GetMarcBiblio( $biblionumber, 1 );
437
    for my $field ( @$additional_fields ) {
439
    for my $field ( @$additional_fields ) {
438
        my $af = Koha::AdditionalField->new({ id => $field->{id} })->fetch;
440
        my $af = Koha::AdditionalField->new({ id => $field->{id} })->fetch;
439
        if ( $af->{marcfield} ) {
441
        if ( $af->{marcfield} ) {
440
            my $record = GetMarcBiblio( $biblionumber, 1 );
441
            my ( $field, $subfield ) = split /\$/, $af->{marcfield};
442
            my ( $field, $subfield ) = split /\$/, $af->{marcfield};
442
            next unless $field and $subfield;
443
            $af->{values} = undef;
443
            my $value = $record->subfield( $field, $subfield );
444
            if ( $field and $subfield ) {
444
            $af->{values} = {
445
                my $value = $record->subfield( $field, $subfield );
445
                $subscriptionid => $value
446
                $af->{values} = {
446
            };
447
                    $subscriptionid => $value
448
                };
449
            }
447
        } else {
450
        } else {
448
            $af->{values} = {
451
            $af->{values} = {
449
                $subscriptionid => $query->param('additional_field_' . $field->{id})
452
                $subscriptionid => $query->param('additional_field_' . $field->{id})
450
            };
453
            } if defined $query->param('additional_field_' . $field->{id});
451
        }
454
        }
452
        $af->insert_values;
455
        $af->insert_values;
453
    }
456
    }
454
455
    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
456
    return;
457
}
457
}
458
- 

Return to bug 10855