use C4::Output;
use C4::Debug;
use C4::Letters;
+use C4::Biblio qw( GetMarcFromKohaField );
use Koha::DateUtils;
use Koha::Suggestions;
SearchSuggestion
DelSuggestionsOlderThan
GetUnprocessedSuggestions
+ MarcRecordFromNewSuggestion
);
=head1 NAME
return $s;
}
+=head2 MarcRecordFromNewSuggestion
+
+ $record = MarcRecordFromNewSuggestion ( $suggestion )
+
+This function build a marc record object from a suggestion
+
+=cut
+
+sub MarcRecordFromNewSuggestion {
+ my ($suggestion) = @_;
+ my $record = MARC::Record->new();
+
+ my ($title_tag, $title_subfield) = GetMarcFromKohaField('biblio.title', '');
+ $record->append_fields(
+ MARC::Field->new($title_tag, ' ', ' ', $title_subfield => $suggestion->{title})
+ );
+
+ my ($author_tag, $author_subfield) = GetMarcFromKohaField('biblio.author', '');
+ if ($record->field( $author_tag )) {
+ $record->field( $author_tag )->add_subfields( $author_subfield => $suggestion->{author} );
+ }
+ else {
+ $record->append_fields(
+ MARC::Field->new($author_tag, ' ', ' ', $author_subfield => $suggestion->{author})
+ );
+ }
+
+ my ($it_tag, $it_subfield) = GetMarcFromKohaField('biblioitems.itemtype', '');
+ if ($record->field( $it_tag )) {
+ $record->field( $it_tag )->add_subfields( $it_subfield => $suggestion->{itemtype} );
+ }
+ else {
+ $record->append_fields(
+ MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{author})
+ );
+ }
+
+ return $record;
+}
+
1;
__END__