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

(-)a/C4/Breeding.pm (-20 / +10 lines)
Lines 22-28 use strict; Link Here
22
use warnings;
22
use warnings;
23
23
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Koha qw( GetNormalizedISBN );
25
use C4::Koha qw( GetVariationsOfISBNs );
26
use C4::Charset qw( MarcToUTF8Record SetUTF8Flag );
26
use C4::Charset qw( MarcToUTF8Record SetUTF8Flag );
27
use MARC::File::USMARC;
27
use MARC::File::USMARC;
28
use MARC::Field;
28
use MARC::Field;
Lines 56-64 cataloguing reservoir features. Link Here
56
56
57
=head2 BreedingSearch
57
=head2 BreedingSearch
58
58
59
($count, @results) = &BreedingSearch($title,$isbn);
59
($count, @results) = &BreedingSearch($term);
60
C<$title> contains the title,
60
C<$term> contains the term to search, it wil be searched as title,author, or isbn
61
C<$isbn> contains isbn or issn,
62
61
63
C<$count> is the number of items in C<@results>. C<@results> is an
62
C<$count> is the number of items in C<@results>. C<@results> is an
64
array of references-to-hash; the keys are the items from the C<import_records> and
63
array of references-to-hash; the keys are the items from the C<import_records> and
Lines 67-100 C<import_biblios> tables of the Koha database. Link Here
67
=cut
66
=cut
68
67
69
sub BreedingSearch {
68
sub BreedingSearch {
70
    my ($search,$isbn) = @_;
69
    my ($term) = @_;
71
    my $dbh   = C4::Context->dbh;
70
    my $dbh   = C4::Context->dbh;
72
    my $count = 0;
71
    my $count = 0;
73
    my ($query,@bind);
72
    my ($query,@bind);
74
    my $sth;
73
    my $sth;
75
    my @results;
74
    my @results;
76
75
76
    my $authortitle = $term;
77
    $authortitle =~ s/(\s+)/\%/g; #Replace spaces with wildcard
78
    $authortitle = "%" . $authortitle . "%"; #Add wildcard to start and end of string
77
    # normalise ISBN like at import
79
    # normalise ISBN like at import
78
    $isbn = C4::Koha::GetNormalizedISBN($isbn);
80
    my @isbns = C4::Koha::GetVariationsOfISBNs($term);
79
81
80
    $query = "SELECT import_record_id, file_name, isbn, title, author
82
    $query = "SELECT import_record_id, file_name, isbn, title, author
81
              FROM  import_biblios 
83
              FROM  import_biblios 
82
              JOIN import_records USING (import_record_id)
84
              JOIN import_records USING (import_record_id)
83
              JOIN import_batches USING (import_batch_id)
85
              JOIN import_batches USING (import_batch_id)
84
              WHERE ";
86
              WHERE title LIKE ? OR author LIKE ? OR isbn IN (" . join(',',('?') x @isbns) . ")";
85
    @bind=();
87
    @bind=( $authortitle, $authortitle, @isbns );
86
    if (defined($search) && length($search)>0) {
87
        $search =~ s/(\s+)/\%/g;
88
        $query .= "title like ? OR author like ?";
89
        push(@bind,"%$search%", "%$search%");
90
    }
91
    if ($#bind!=-1 && defined($isbn) && length($isbn)>0) {
92
        $query .= " and ";
93
    }
94
    if (defined($isbn) && length($isbn)>0) {
95
        $query .= "isbn like ?";
96
        push(@bind,"$isbn%");
97
    }
98
    $sth = $dbh->prepare($query);
88
    $sth = $dbh->prepare($query);
99
    $sth->execute(@bind);
89
    $sth->execute(@bind);
100
    while (my $data = $sth->fetchrow_hashref) {
90
    while (my $data = $sth->fetchrow_hashref) {
(-)a/cataloguing/addbooks.pl (-9 / +1 lines)
Lines 106-119 if ($query) { Link Here
106
my $countbr = 0;
106
my $countbr = 0;
107
my @resultsbr;
107
my @resultsbr;
108
if ($query) {
108
if ($query) {
109
    my ( $title, $isbn );
109
    ( $countbr, @resultsbr ) = BreedingSearch( $query );
110
    my $isbn_valid = Business::ISBN->new($query);
111
    if ( $isbn_valid && $isbn_valid->is_valid() ) {
112
        $isbn = $query;
113
    } else {
114
        $title = $query;
115
    }
116
    ( $countbr, @resultsbr ) = BreedingSearch( $title, $isbn );
117
}
110
}
118
my $breeding_loop = [];
111
my $breeding_loop = [];
119
for my $resultsbr (@resultsbr) {
112
for my $resultsbr (@resultsbr) {
120
- 

Return to bug 29437