@@ -, +, @@ sudoc.fr (unimarc_field_009_ppn.pl) focus out of the input (by pressing Tab, or clicking elsewhere on the page) The 009 field should be automatically filled with "06735209X" input The 009 field should be automatically filled with "166197947" the input The 009 field should be automatically filled with "151662983" bibliographic record. "9782070424597". Click on the 009 field input, it should be automatically filled with "151662983" --- .../value_builder/unimarc_field_009_ppn.pl | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 cataloguing/value_builder/unimarc_field_009_ppn.pl --- a/cataloguing/value_builder/unimarc_field_009_ppn.pl +++ a/cataloguing/value_builder/unimarc_field_009_ppn.pl @@ -0,0 +1,118 @@ +#!/usr/bin/perl + +# Converted to new plugin style (Bug 13437) + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use LWP::Simple qw(); +use LWP::UserAgent; +use JSON; +use C4::Auth qw ( get_template_and_user ); +use C4::Output qw ( output_html_with_http_headers ); + +my $res; +my $builder = sub { + my ( $params ) = @_; + my $res= qq| + + |; + return $res; +}; + +my $launcher = sub { + my ( $params ) = @_; + my $input = $params->{cgi}; + my $isbn = $input->param('isbn'); + my $issn = $input->param('issn'); + my $ean = $input->param('ean'); + + my ($template, $loggedinuser, $cookie) = get_template_and_user({ + template_name => "cataloguing/value_builder/ajax.tt", + query => $input, + type => "intranet", + flagsrequired => {editcatalogue => '*'}, + }); + + my $url; + if ( $isbn ) { + $url = "https://www.sudoc.fr/services/isbn2ppn/$isbn&format=text/json"; + } elsif ( $issn ) { + $url = "https://www.sudoc.fr/services/issn2ppn/$issn&format=text/json"; + } elsif ( $ean ) { + $url = "https://www.sudoc.fr/services/ean2ppn/$ean&format=text/json"; + } + + if ($url) { + my $json = LWP::Simple::get($url); + if (defined $json) { + my $response = JSON->new->utf8->decode($json); + my $result = $response->{sudoc}->{query}->{result}; + my $ppn = ref $result eq 'ARRAY' ? $result->[0]->{ppn} : $result->{ppn}; + $template->param( return => $ppn ); + } + } + + output_html_with_http_headers $input, $cookie, $template->output; +}; + +return { builder => $builder, launcher => $launcher }; --