-my ($template, $borrowernumber, $cookie)
- = get_template_and_user({template_name => "acqui/suggestion-select.tmpl",
- type => "intranet",
- query => $input,
- authnotrequired => 1,
- flagsrequired => {acquisition => 1},
- });
-
-if ($op eq 'connectDuplicate') {
- ConnectSuggestionAndBiblio($suggestionid,$duplicateNumber);
-}
-my $suggestions_loop= &SearchSuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
-foreach (@$suggestions_loop) {
- unless ($_->{biblionumber}) {
- my (@tags, @and_or, @excluding, @operator, @value, $offset,$length);
- # search on biblio.title
- if ($_->{title}) {
- my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.title","");
- push @tags, "'".$tag.$subfield."'";
- push @and_or, "and";
- push @excluding, "";
- push @operator, "contains";
- push @value, $_->{title};
- }
- if ($_->{author}) {
- my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblio.author","");
- push @tags, "'".$tag.$subfield."'";
- push @and_or, "and";
- push @excluding, "";
- push @operator, "contains";
- push @value, $_->{author};
- }
- # ... and on publicationyear.
- if ($_->{publicationyear}) {
- my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publicationyear","");
- push @tags, "'".$tag.$subfield."'";
- push @and_or, "and";
- push @excluding, "";
- push @operator, "=";
- push @value, $_->{publicationyear};
- }
- # ... and on publisher.
- if ($_->{publishercode}) {
- my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.publishercode","");
- push @tags, "'".$tag.$subfield."'";
- push @and_or, "and";
- push @excluding, "";
- push @operator, "=";
- push @value, $_->{publishercode};
- }
-
- my ($finalresult,$nbresult) = C4::SearchMarc::catalogsearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10);
- # there is at least 1 result => return the 1st one
- if ($nbresult) {
- # warn "$nbresult => ".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title};
-# warn "DUPLICATE ==>".@$finalresult[0]->{biblionumber},@$finalresult[0]->{bibid},@$finalresult[0]->{title};
- $_->{duplicateBiblionumber} = @$finalresult[0]->{biblionumber};
- }
- }