3 # Copyright Dobrica Pavlinusic 2014
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 print "Content-type: application/json; charset=utf-8\r\n\r\n";
30 my $dbh = C4::Context->dbh;
36 foreach my $name (qw( OIB JMBAG RFID_SID )) {
37 if ( my $val = $query->param($name) ) {
38 $json->{param}->{$name} = $val;
39 push @where, "( code = '$name' and attribute = ? )";
47 b.borrowernumber, firstname, surname, email, userid, cardnumber
48 from borrower_attributes ba
49 join borrowers b on b.borrowernumber = ba.borrowernumber
50 where (} . join(') or (', @where) . qq{)};
54 my $sth = $dbh->prepare( $sql );
55 $sth->execute( @execute );
57 $json->{rows} = $sth->rows;
59 if ( $sth->rows < 1 ) {
60 $json->{error} = "borrower not found";
61 } elsif ( $sth->rows > 1 ) {
62 $json->{error} = "more than one borrower found";
64 $json->{borrower} = $sth->fetchrow_hashref;
67 $json = encode_json( $json );
68 if ( my $callback = $query->param('callback') ) {
69 print $callback, '(', $json, ')';