From dbddca1f5a046cde43e0072f0b5b9c1e9a60da07 Mon Sep 17 00:00:00 2001 From: Nahuel Angelinetti Date: Thu, 11 Dec 2008 16:39:27 +0100 Subject: [PATCH] bug 2829: add a plugin for 010$a field and 210$c This plugin use the 'ISBN' field(010$a) to search the "publishercode"(editor) and set it in as 210$c. Signed-off-by: Galen Charlton --- .../value_builder/unimarc_field_010.pl | 117 ++++++++++++++++++ .../cataloguing/value_builder/ajax.tmpl | 1 + 2 files changed, 118 insertions(+) create mode 100644 cataloguing/value_builder/unimarc_field_010.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/ajax.tmpl diff --git a/cataloguing/value_builder/unimarc_field_010.pl b/cataloguing/value_builder/unimarc_field_010.pl new file mode 100644 index 0000000000..54d887f83d --- /dev/null +++ b/cataloguing/value_builder/unimarc_field_010.pl @@ -0,0 +1,117 @@ +#!/usr/bin/perl + + +# Copyright 2008 Biblibre SARL +# +# 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use warnings; +use C4::Auth; +use CGI; +use C4::Context; + + +=head1 + +plugin_parameters : other parameters added when the plugin is called by the dopop function + +=cut + +sub plugin_parameters { + my ($dbh,$record,$tagslib,$i,$tabloop) = @_; + return ""; +} + +sub plugin_javascript { + my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; + my $res=" + + "; + + return ($field_number,$res); +} + +sub plugin { + my ($input) = @_; + my $isbn = $input->param('isbn'); + + my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "cataloguing/value_builder/ajax.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {editcatalogue => 1}, + debug => 1, + }); + + + my $dbh = C4::Context->dbh; + my $seg1; + + if (length ($isbn)<13){ + if ( substr( $isbn, 0, 1 ) <= 7 ) { + $seg1 = substr( $isbn, 0, 1 ); + }elsif ( substr( $isbn, 0, 2 ) <= 94 ) { + $seg1 = substr( $isbn, 0, 2 ); + }elsif ( substr( $isbn, 0, 3 ) <= 995 ) { + $seg1 = substr( $isbn, 0, 3 ); + }elsif ( substr( $isbn, 0, 4 ) <= 9989 ) { + $seg1 = substr( $isbn, 0, 4 ); + }else { + $seg1 = substr( $isbn, 0, 5 ); + } + } + + $seg1 .= "%"; + my $sth = $dbh->prepare('SELECT publishercode FROM biblioitems WHERE isbn LIKE ? LIMIT 1'); + $sth->execute($seg1); + + if( (my $publishercode) = $sth->fetchrow ) + { + $template->param(return => $publishercode); + } + output_html_with_http_headers $input, $cookie, $template->output; +} +1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/ajax.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/ajax.tmpl new file mode 100644 index 0000000000..fa44f11d51 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/ajax.tmpl @@ -0,0 +1 @@ + \ No newline at end of file -- 2.39.5