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;
55 var elems = document.getElementsByTagName('input');
56 for( i = 0 ; elems[i] ; i++ )
58 if(elems[i].id.match(/^tag_210_subfield_c/)) {
59 elems[i].value = o.responseText;
65 var transaction = YAHOO.util.Connect.asyncRequest('GET',url, blurcallback010, null);
69 function Clic$field_number() {
75 return ($field_number,$res);
80 my $isbn = $input->param('isbn');
82 my ($template, $loggedinuser, $cookie)
83 = get_template_and_user({template_name => "cataloguing/value_builder/ajax.tmpl",
87 flagsrequired => {editcatalogue => '*'},
92 my $dbh = C4::Context->dbh;
94 my $sth = $dbh->prepare('SELECT publishercode FROM biblioitems WHERE REPLACE(isbn, "-", "") LIKE ? OR isbn LIKE ? LIMIT 1');
97 if (length ($isbn) == 13){
98 $isbn = substr($isbn, 3, length($isbn)-3);
101 if(length($isbn) <= 10){
104 if ( substr( $isbn, 0, 1 ) <= 7 ){
106 }elsif ( substr( $isbn, 0, 2 ) <= 94 ){
108 }elsif ( substr( $isbn, 0, 3 ) <= 995 ){
110 }elsif ( substr( $isbn, 0, 4 ) <= 9989 ){
114 my $x = substr( $isbn, $len );
117 if ( substr( $x, 0, 2 ) <= 19 ) {
118 $seg2 = substr( $x, 0, 2 );
120 elsif ( substr( $x, 0, 3 ) <= 699 ) {
121 $seg2 = substr( $x, 0, 3 );
123 elsif ( substr( $x, 0, 4 ) <= 8399 ) {
124 $seg2 = substr( $x, 0, 4 );
126 elsif ( substr( $x, 0, 5 ) <= 89999 ) {
127 $seg2 = substr( $x, 0, 5 );
129 elsif ( substr( $x, 0, 6 ) <= 9499999 ) {
130 $seg2 = substr( $x, 0, 6 );
133 $seg2 = substr( $x, 0, 7 );
140 $len = 10 -length($seg2);
146 $sth->execute($seg2, "978$seg2");
149 if( (my $publishercode) = $sth->fetchrow )
151 $template->param(return => $publishercode);
153 output_html_with_http_headers $input, $cookie, $template->output;