[Koha-patches] [PATCH 1/2] Bug 5904 : ysearch.pl members improvements (Independant branches behaviour)

Chris Cormack chrisc at catalyst.net.nz
Sun Mar 20 22:25:18 CET 2011


From: Paul Poulain <paul.poulain at biblibre.com>

If IntependantBranchesPatron is set, then the search is limited to the librarian branch in circ member auto completion
---
 circ/ysearch.pl |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/circ/ysearch.pl b/circ/ysearch.pl
index f8fc52a..5d4442b 100755
--- a/circ/ysearch.pl
+++ b/circ/ysearch.pl
@@ -46,8 +46,14 @@ my $sql = qq(SELECT surname, firstname, cardnumber, address, city, zipcode, coun
              FROM borrowers 
              WHERE surname LIKE ?
              OR firstname LIKE ?
-             OR cardnumber LIKE ?
-             ORDER BY surname, firstname);
+             OR cardnumber LIKE ?);
+if (C4::Context->preference("IndependentBranchPatron")){
+  if (C4::Context->userenv && (C4::Context->userenv->{flags} % 2) !=1 && C4::Context->userenv->{'branch'}){
+     $sql.=" AND borrowers.branchcode =".$dbh->quote(C4::Context->userenv->{'branch'}) unless (C4::Context->userenv->{'branch'} eq "insecure");
+  }
+}
+
+$sql    .= qq( ORDER BY surname, firstname);
 my $sth = $dbh->prepare( $sql );
 $sth->execute("$query%", "$query%", "$query%");
 
-- 
1.7.1



More information about the Koha-patches mailing list