BUG: fix keyboard shortcuts
[koha.git] / ffzg / vuFind.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use CGI;
7 use JSON;
8 use FindBin;
9 use C4::Context;
10 use Koha::Caches;
11
12 my $query = new CGI;
13
14 use Data::Dump qw(dump);
15
16 my $hash = [];
17 my $cache = Koha::Caches->get_instance();
18
19 my $sql = qq{
20         select
21                 concat_ws('',stocknumber,copynumber) as copynumber,
22                 itemnumber,
23                 biblionumber,
24                 itemcallnumber,
25                 concat(branchname,' - ',authorised_values.lib) as location,
26                 holdingbranch,
27                 notforloan,
28                 onloan,
29                 itemnotes as note
30         from items
31         join authorised_values on (authorised_values.category = 'LOC' and authorised_values.authorised_value = items.location)
32         join branches on (holdingbranch = branchcode)
33         where biblionumber = ?
34 };
35
36
37 if ( my $biblionumber = $query->param('biblionumber') ) {
38
39         if ( $hash = $cache->get_from_cache( "vuFind-$biblionumber" ) ) {
40                 warn "# $biblionumber HIT\n";
41         } else {
42
43                 my $dbh = C4::Context->dbh;
44                 my $sth = $dbh->prepare($sql);
45
46                 $sth->execute( $biblionumber );
47                 while ( my $row = $sth->fetchrow_hashref ) {
48                         push @$hash, $row;
49                 }
50                 warn "# $biblionumber MISS\n";
51                 $cache->set_in_cache( "vuFind-$biblionumber", $hash, { expiry => 5 * 60 } );
52         }
53 }
54 print "Content-type: application/json; charset=utf-8\r\n\r\n";
55 warn $query->remote_addr, " $0 ",dump($hash);
56 print encode_json $hash;