(bug #2829) allow isbn13 in sql requests
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Wed, 17 Jun 2009 13:46:45 +0000 (15:46 +0200)
committerGalen Charlton <galen.charlton@liblime.com>
Wed, 17 Jun 2009 16:40:25 +0000 (11:40 -0500)
this patch add the support of the plugin to search for isbn13.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
cataloguing/value_builder/unimarc_field_010.pl

index 11a4ba5..9acfceb 100755 (executable)
@@ -89,7 +89,7 @@ sub plugin {
 
     my $dbh = C4::Context->dbh;
     my $len = 0;
-    my $sth = $dbh->prepare('SELECT publishercode FROM biblioitems WHERE isbn LIKE ? LIMIT 1');
+    my $sth = $dbh->prepare('SELECT publishercode FROM biblioitems WHERE isbn LIKE ? OR isbn LIKE ? LIMIT 1');
     
     if (length ($isbn) == 13){
         $isbn = substr(3, length($isbn));
@@ -103,8 +103,9 @@ sub plugin {
         $len = 4 if ( substr( $isbn, 0, 4 ) <= 9989 );
 
         my $x = substr( $isbn, $len );
-        my $seg2;
+        my $seg2 = "";
+        my $seg3 = "";
+        
         if ( substr( $x, 0, 2 ) <= 19 ) {    
             $seg2 = substr( $x, 0, 2 );
         }
@@ -129,8 +130,8 @@ sub plugin {
         }
     
         $seg2 .= "%";
-        warn $seg2;
-        $sth->execute($seg2);
+        $seg3 = "978" . $seg2; #support of ISBN13
+        $sth->execute($seg2, $seg3);
     }
     
     if( (my $publishercode) = $sth->fetchrow )