View | Details | Raw Unified | Return to bug 13822
Collapse All | Expand All

(-)a/circ/ysearch.pl (-23 / +4 lines)
Lines 33-39 use C4::Members; Link Here
33
use C4::Auth qw/check_cookie_auth/;
33
use C4::Auth qw/check_cookie_auth/;
34
34
35
my $input   = new CGI;
35
my $input   = new CGI;
36
my $query   = $input->param('term');
36
my $term    = $input->param('term');
37
37
38
binmode STDOUT, ":encoding(UTF-8)";
38
binmode STDOUT, ":encoding(UTF-8)";
39
print $input->header(-type => 'text/plain', -charset => 'UTF-8');
39
print $input->header(-type => 'text/plain', -charset => 'UTF-8');
Lines 43-72 if ($auth_status ne "ok") { Link Here
43
    exit 0;
43
    exit 0;
44
}
44
}
45
45
46
my $dbh = C4::Context->dbh;
46
$term =~ s/,//g; #remove any commas from search string
47
my $sql = q(
47
my ($results) = Search( $term, undef, [ 10 ] );
48
    SELECT borrowernumber, surname, firstname, cardnumber, address, city, zipcode, country
49
    FROM borrowers
50
    WHERE ( surname LIKE ?
51
        OR firstname LIKE ?
52
        OR cardnumber LIKE ? )
53
);
54
if (   C4::Context->preference("IndependentBranches")
55
    && C4::Context->userenv
56
    && !C4::Context->IsSuperLibrarian()
57
    && C4::Context->userenv->{'branch'} )
58
{
59
    $sql .= " AND borrowers.branchcode ="
60
      . $dbh->quote( C4::Context->userenv->{'branch'} );
61
}
62
63
$sql    .= q( ORDER BY surname, firstname LIMIT 10);
64
my $sth = $dbh->prepare( $sql );
65
$sth->execute("$query%", "$query%", "$query%");
66
48
67
print "[";
49
print "[";
68
my $i = 0;
50
my $i = 0;
69
while ( my $rec = $sth->fetchrow_hashref ) {
51
foreach my $rec ( @$results ) {
70
    if($i > 0){ print ","; }
52
    if($i > 0){ print ","; }
71
    print "{\"borrowernumber\":\"" . $rec->{borrowernumber} . "\",\"" .
53
    print "{\"borrowernumber\":\"" . $rec->{borrowernumber} . "\",\"" .
72
          "surname\":\"".$rec->{surname} . "\",\"" .
54
          "surname\":\"".$rec->{surname} . "\",\"" .
73
- 

Return to bug 13822