X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Fypattrodue-attr-search-authvalue.pl;h=517c8c050f81e0cf00969ad4cb9b67a3b3bbf066;hb=ec3735433aed8d2c1a42b7d0758b4405a3aa6b1c;hp=5ff1cd93b2722d60b9122d00dff3e4ac36707ff7;hpb=ab44e2986a0664c1f6c87d7a292d76e547ab978e;p=koha_fer diff --git a/circ/ypattrodue-attr-search-authvalue.pl b/circ/ypattrodue-attr-search-authvalue.pl index 5ff1cd93b2..517c8c050f 100755 --- a/circ/ypattrodue-attr-search-authvalue.pl +++ b/circ/ypattrodue-attr-search-authvalue.pl @@ -2,6 +2,7 @@ # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) +# Parts copyright 2012 Athens County Public Libraries # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the @@ -25,14 +26,14 @@ use C4::Auth qw/check_cookie_auth/; use C4::Debug; my $input = new CGI; -my $query = $input->param('query'); +my $query = $input->param('term'); my $attrcode = $input->path_info || ''; $attrcode =~ s|^/||; my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { circulate => '*' } ); exit 0 if $auth_status ne "ok"; -binmode STDOUT, ":utf8"; +binmode STDOUT, ":encoding(UTF-8)"; print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); print STDERR ">> CALLING $0 (attrcode=$attrcode, query=$query)\n" if $debug; @@ -45,8 +46,14 @@ my $sql = qq(SELECT authorised_value, lib description AND v.lib like ?); my $sth = $dbh->prepare($sql); $sth->execute( $attrcode, "$query%" ); + +print "["; +my $i = 0; while ( my $rec = $sth->fetchrow_hashref ) { print STDERR ">> attrcode=$attrcode match '$query' ==> $rec->{description} ($rec->{authorised_value})\n" if $debug; - print "$rec->{description}\t$rec->{authorised_value}\n"; + print "{\"description\":\"" . $rec->{description} . "\",\"" . + "authorised_value\":\"" . $rec->{authorised_value} . "\"" . + "}"; + $i++; } - +print "]"; \ No newline at end of file