skupni katalog NSK http://lib.fer.hr/cgi-bin/koha/svc/vuFind.pl?biblionumber=37822
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 8 Sep 2019 07:27:50 +0000 (09:27 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 8 Sep 2019 07:27:50 +0000 (09:27 +0200)
opac/cgi-bin/opac/svc/vuFind.pl [new file with mode: 0755]

diff --git a/opac/cgi-bin/opac/svc/vuFind.pl b/opac/cgi-bin/opac/svc/vuFind.pl
new file mode 100755 (executable)
index 0000000..c3b4432
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use CGI;
+use JSON;
+use FindBin;
+use C4::Context;
+use Koha::Caches;
+
+my $query = new CGI;
+
+use Data::Dump qw(dump);
+
+my $hash = [];
+my $cache = Koha::Caches->get_instance();
+
+my $sql = qq{
+       select
+               concat_ws('',stocknumber,copynumber) as copynumber,
+               itemnumber,
+               biblionumber,
+               itemcallnumber,
+               concat(branchname,' - ',authorised_values.lib) as location,
+               holdingbranch,
+               notforloan,
+               onloan,
+               itemnotes as note
+       from items
+       join authorised_values on (authorised_values.category = 'LOC' and authorised_values.authorised_value = items.location)
+       join branches on (holdingbranch = branchcode)
+       where biblionumber = ?
+};
+
+my $dbh = C4::Context->dbh;
+my $sth = $dbh->prepare($sql);
+
+if ( my $biblionumber = $query->param('biblionumber') ) {
+
+       if ( $hash = $cache->get_from_cache( "vuFind-$biblionumber" ) ) {
+               warn "# $biblionumber HIT\n";
+       } else {
+               $sth->execute( $biblionumber );
+               $hash = [];
+               while ( my $row = $sth->fetchrow_hashref ) {
+                       push @$hash, $row;
+               }
+               warn "# $biblionumber MISS\n";
+               $cache->set_in_cache( "vuFind-$biblionumber", $hash, { expiry => 5 * 60 } );
+       }
+}
+print "Content-type: application/json; charset=utf-8\r\n\r\n";
+warn $query->remote_addr, " $0 ",dump($hash);
+print encode_json $hash;
+