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

(-)a/C4/Suggestions.pm (-9 / +19 lines)
Lines 615-633 sub MarcRecordFromNewSuggestion { Link Here
615
    my ($suggestion) = @_;
615
    my ($suggestion) = @_;
616
    my $record = MARC::Record->new();
616
    my $record = MARC::Record->new();
617
617
618
    my ($title_tag, $title_subfield) = GetMarcFromKohaField('biblio.title', '');
618
    if (my $isbn = $suggestion->{isbn}) {
619
    $record->append_fields(
619
        for my $field (qw(biblioitems.isbn biblioitems.issn)) {
620
        MARC::Field->new($title_tag, ' ', ' ', $title_subfield => $suggestion->{title})
620
            my ($tag, $subfield) = GetMarcFromKohaField($field, '');
621
    );
621
            $record->append_fields(
622
622
                MARC::Field->new($tag, ' ', ' ', $subfield => $isbn)
623
    my ($author_tag, $author_subfield) = GetMarcFromKohaField('biblio.author', '');
623
            );
624
    if ($record->field( $author_tag )) {
624
        }
625
        $record->field( $author_tag )->add_subfields( $author_subfield => $suggestion->{author} );
626
    }
625
    }
627
    else {
626
    else {
627
        my ($title_tag, $title_subfield) = GetMarcFromKohaField('biblio.title', '');
628
        $record->append_fields(
628
        $record->append_fields(
629
            MARC::Field->new($author_tag, ' ', ' ', $author_subfield => $suggestion->{author})
629
            MARC::Field->new($title_tag, ' ', ' ', $title_subfield => $suggestion->{title})
630
        );
630
        );
631
632
        my ($author_tag, $author_subfield) = GetMarcFromKohaField('biblio.author', '');
633
        if ($record->field( $author_tag )) {
634
            $record->field( $author_tag )->add_subfields( $author_subfield => $suggestion->{author} );
635
        }
636
        else {
637
            $record->append_fields(
638
                MARC::Field->new($author_tag, ' ', ' ', $author_subfield => $suggestion->{author})
639
            );
640
        }
631
    }
641
    }
632
642
633
    my ($it_tag, $it_subfield) = GetMarcFromKohaField('biblioitems.itemtype', '');
643
    my ($it_tag, $it_subfield) = GetMarcFromKohaField('biblioitems.itemtype', '');
(-)a/suggestion/suggestion.pl (+1 lines)
Lines 132-137 if ( $op =~ /save/i ) { Link Here
132
            title => $suggestion_only->{title},
132
            title => $suggestion_only->{title},
133
            author => $suggestion_only->{author},
133
            author => $suggestion_only->{author},
134
            itemtype => $suggestion_only->{itemtype},
134
            itemtype => $suggestion_only->{itemtype},
135
            isbn => $suggestion_only->{isbn},
135
    });
136
    });
136
137
137
    my $manager = Koha::Patrons->find( $suggestion_only->{managedby} );
138
    my $manager = Koha::Patrons->find( $suggestion_only->{managedby} );
(-)a/t/db_dependent/Suggestions.t (-1 / +22 lines)
Lines 648-651 subtest 'ModSuggestion should work on suggestions without a suggester' => sub { Link Here
648
    is( $suggestion->{note}, "Test note", "ModSuggestion works on suggestions without a suggester" );
648
    is( $suggestion->{note}, "Test note", "ModSuggestion works on suggestions without a suggester" );
649
};
649
};
650
650
651
subtest 'Suggestion with ISBN' => sub {
652
    my $suggestion_with_isbn = {
653
        isbn     => '1940997232',
654
        title    => "The Clouds",
655
        author   => "Aristophanes",
656
    };
657
    my $record = MarcRecordFromNewSuggestion( $suggestion_with_isbn );
658
    is("MARC::Record", ref($record), "MarcRecordFromNewSuggestion should return a MARC::Record object");
659
660
    my ($isbn_tag, $isbn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.isbn', '');
661
    is($record->field( $isbn_tag )->subfield( $isbn_subfield ), "1940997232", "ISBN Record from suggestion ISBN should be '1940997232'");
662
663
    my ($issn_tag, $issn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.issn', '');
664
    is($record->field( $issn_tag )->subfield( $issn_subfield ), "1940997232", "ISSN Record from suggestion ISBN should also be '1940997232'");
665
666
    my ($title_tag, $title_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.title', '');
667
    is($record->field( $title_tag), undef, "Record from suggestion title should be empty");
668
669
    my ($author_tag, $author_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.author', '');
670
    is($record->field( $author_tag), undef, "Record from suggestion author should be emtpy");
671
}
672
651
$schema->storage->txn_rollback;
673
$schema->storage->txn_rollback;
652
- 

Return to bug 30195