Release notes 3.0.6
[koha.git] / circ / ysearch.pl
index cdd2530..6288387 100755 (executable)
@@ -45,10 +45,17 @@ my $sql = qq(SELECT surname, firstname, cardnumber, address, city, zipcode
              FROM borrowers 
              WHERE surname LIKE ?
              OR firstname LIKE ?
-             ORDER BY surname, firstname);
-            #"OR cardnumber LIKE '" . $query . "%' " . 
+             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%");
+$sth->execute("$query%", "$query%", "$query%");
+
 while ( my $rec = $sth->fetchrow_hashref ) {
     print $rec->{surname} . ", " . $rec->{firstname} . "\t" .
           $rec->{cardnumber} . "\t" .