X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=circ%2Fysearch.pl;h=4a3663e34828db653401c22d76f76a608b1bd52b;hb=e273e11b084af645d5f9e4f4851cc2ad850c7675;hp=8a48c51f4b8aaaf23e4a4ac2616d5de62c427178;hpb=068e5be6395088793aeab66d67c36c2b9da2c5d9;p=koha.git diff --git a/circ/ysearch.pl b/circ/ysearch.pl index 8a48c51f4b..4a3663e348 100755 --- a/circ/ysearch.pl +++ b/circ/ysearch.pl @@ -44,13 +44,23 @@ if ($auth_status ne "ok") { } my $dbh = C4::Context->dbh; -my $sql = qq(SELECT surname, firstname, cardnumber, address, city, zipcode, country - FROM borrowers - WHERE surname LIKE ? - OR firstname LIKE ? - OR cardnumber LIKE ? - ORDER BY surname, firstname - LIMIT 10); +my $sql = q( + SELECT surname, firstname, cardnumber, address, city, zipcode, country + FROM borrowers + WHERE ( surname LIKE ? + OR firstname LIKE ? + OR cardnumber LIKE ? ) +); +if (C4::Context->preference("IndependentBranches")){ + if ( C4::Context->userenv + && (C4::Context->userenv->{flags} % 2) !=1 + && C4::Context->userenv->{'branch'} + ){ + $sql .= " AND borrowers.branchcode =" . $dbh->quote(C4::Context->userenv->{'branch'}); + } +} + +$sql .= q( ORDER BY surname, firstname LIMIT 10); my $sth = $dbh->prepare( $sql ); $sth->execute("$query%", "$query%", "$query%"); @@ -68,4 +78,4 @@ while ( my $rec = $sth->fetchrow_hashref ) { "}"; $i++; } -print "]"; \ No newline at end of file +print "]";