X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FSerials.pm;h=8e5bbcb18d48c0763f8e140bc951234dc97241dd;hb=509d673f10bf8e03529602b922d1fab603457ee2;hp=20ad7067b41f23cf9dcef05213a64fa33808ac76;hpb=98c59fc3577b5904fc980781ce805bff875b157f;p=koha.git diff --git a/C4/Serials.pm b/C4/Serials.pm index 20ad7067b4..8e5bbcb18d 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -30,7 +30,7 @@ use C4::Debug; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); BEGIN { - $VERSION = 3.01; # set version for version checking + $VERSION = 3.07.00.049; # set version for version checking require Exporter; @ISA = qw(Exporter); @EXPORT = qw( @@ -545,15 +545,15 @@ sub GetFullSubscriptionsFromBiblionumber { =head2 GetSubscriptions -@results = GetSubscriptions($title,$ISSN,$biblionumber); -this function gets all subscriptions which have title like $title,ISSN like $ISSN and biblionumber like $biblionumber. +@results = GetSubscriptions($title,$ISSN,$ean,$biblionumber); +this function gets all subscriptions which have title like $title,ISSN like $ISSN,EAN like $ean and biblionumber like $biblionumber. return: a table of hashref. Each hash containt the subscription. =cut sub GetSubscriptions { - my ( $string, $issn, $biblionumber ) = @_; + my ( $string, $issn, $ean, $biblionumber ) = @_; #return unless $title or $ISSN or $biblionumber; my $dbh = C4::Context->dbh; @@ -566,7 +566,7 @@ sub GetSubscriptions { LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber ); my @bind_params; - my $sqlwhere; + my $sqlwhere = q{}; if ($biblionumber) { $sqlwhere = " WHERE biblio.biblionumber=?"; push @bind_params, $biblionumber; @@ -597,6 +597,20 @@ sub GetSubscriptions { } $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))"; } + if ($ean) { + my @sqlstrings; + my @strings_to_search; + @strings_to_search = map { "$_" } split( / /, $ean ); + foreach my $index qw(biblioitems.ean) { + push @bind_params, @strings_to_search; + my $tmpstring = "OR $index = ? " x scalar(@strings_to_search); + $debug && warn "$tmpstring"; + $tmpstring =~ s/^OR //; + push @sqlstrings, $tmpstring; + } + $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))"; + } + $sql .= "$sqlwhere ORDER BY title"; $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params ); $sth = $dbh->prepare($sql);