From 3b2a457df44d5cd05cc8da0668ea28ab5a2fa41a Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Mon, 25 Sep 2017 16:22:51 -0400 Subject: [PATCH] Bug 17457 - Adv. Acquisition search with ISBN variations Advanced acquisition search will now follow the "SearchWithISBNVariations" system preference. Test plan : 0) Make sure you have orders pending or completed 1) Enable SearchWithISBNVariations if it is not enabled 2) Search for one of your orders by its ISBN, it should appear 3) Search for the same order by a variation of its ISBN, I used this website to find it : http://www.hahnlibrary.net/libraries/isbncalc.html You should not get a result. 4) Apply patch 5) Repeat step 2-3. You should get a hit both times. --- C4/Acquisition.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 7639fef..456ea86 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2282,6 +2282,22 @@ sub GetHistory { my $total_qtyreceived = 0; my $total_price = 0; + #get variation of isbn + my @params; + my @isbns; + if ($isbn){ + if ( C4::Context->preference("SearchWithISBNVariations") ){ + @isbns = C4::Koha::GetVariationsOfISBN( $isbn ); + foreach my $isb (@isbns){ + push @params, '?'; + } + } + unless (@isbns){ + push @isbns, $isbn; + push @params, '?'; + } + } + my $dbh = C4::Context->dbh; my $query =" SELECT @@ -2349,10 +2365,13 @@ sub GetHistory { push @query_params, "%$author%"; } - if ( $isbn ) { - $query .= " AND biblioitems.isbn LIKE ? "; - push @query_params, "%$isbn%"; + if ( @isbns ) { + $query .= " AND ( biblioitems.isbn LIKE " . join (" OR biblioitems.isbn LIKE ", @params ) . ")"; + foreach my $isbn (@isbns){ + push @query_params, "%$isbn%"; + } } + if ( $ean ) { $query .= " AND biblioitems.ean = ? "; push @query_params, "$ean"; -- 2.7.4