4 # Copyright 2008 Biblibre SARL
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 =head2 plugin_parameters
32 other parameters added when the plugin is called by the dopop function
36 sub plugin_parameters {
37 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
41 sub plugin_javascript {
42 my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
44 <script type='text/javascript'>
45 function Focus$field_number() {
49 function Blur$field_number() {
50 var isbn = document.getElementById('$field_number');
51 var url = '../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_010.pl&isbn=' + isbn.value;
52 var req = \$.get(url);
53 req.done(function(resp){
54 var elems = document.getElementsByTagName('input');
55 for( i = 0 ; elems[i] ; i++ )
57 if(elems[i].id.match(/^tag_210_subfield_c/)) {
58 elems[i].value = resp;
66 function Clic$field_number() {
72 return ($field_number,$res);
77 my $isbn = $input->param('isbn');
79 my ($template, $loggedinuser, $cookie)
80 = get_template_and_user({template_name => "cataloguing/value_builder/ajax.tt",
84 flagsrequired => {editcatalogue => '*'},
89 my $dbh = C4::Context->dbh;
91 my $sth = $dbh->prepare('SELECT publishercode FROM biblioitems WHERE REPLACE(isbn, "-", "") LIKE ? OR isbn LIKE ? LIMIT 1');
94 if (length ($isbn) == 13){
95 $isbn = substr($isbn, 3, length($isbn)-3);
98 if(length($isbn) <= 10){
101 if ( substr( $isbn, 0, 1 ) <= 7 ){
103 }elsif ( substr( $isbn, 0, 2 ) <= 94 ){
105 }elsif ( substr( $isbn, 0, 3 ) <= 995 ){
107 }elsif ( substr( $isbn, 0, 4 ) <= 9989 ){
111 my $x = substr( $isbn, $len );
114 if ( substr( $x, 0, 2 ) <= 19 ) {
115 $seg2 = substr( $x, 0, 2 );
117 elsif ( substr( $x, 0, 3 ) <= 699 ) {
118 $seg2 = substr( $x, 0, 3 );
120 elsif ( substr( $x, 0, 4 ) <= 8399 ) {
121 $seg2 = substr( $x, 0, 4 );
123 elsif ( substr( $x, 0, 5 ) <= 89999 ) {
124 $seg2 = substr( $x, 0, 5 );
126 elsif ( substr( $x, 0, 6 ) <= 9499999 ) {
127 $seg2 = substr( $x, 0, 6 );
130 $seg2 = substr( $x, 0, 7 );
137 $len = 10 -length($seg2);
143 $sth->execute($seg2, "978$seg2");
146 if( (my $publishercode) = $sth->fetchrow )
148 $template->param(return => $publishercode);
150 output_html_with_http_headers $input, $cookie, $template->output;