5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
31 sub plugin_javascript {
32 my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
33 my $function_name = $field_number;
35 <script type=\"text/javascript\">
36 function Focus$function_name(subfield_managed) {
40 function Blur$function_name(subfield_managed) {
44 function Clic$function_name(index) {
45 defaultvalue=document.getElementById(\"$field_number\").value;
46 window.open(\"plugin_launcher.pl?plugin_name=unimarc_field_60X.pl&index=$field_number&result=\"+defaultvalue,\"unimarc 600\",'width=700,height=300,toolbar=false,scrollbars=yes');
52 return ( $function_name, $res );
57 my $dbh = C4::Context->dbh;
58 my $index = $input->param('index');
59 my $result = $input->param('result');
60 my $search_string = $input->param('search_string');
61 my $op = $input->param('op');
62 my $id = $input->param('id');
63 my $insert = $input->param('insert');
68 newauthority( $dbh, 'NC', $insert, $insert, '', 1, '' );
69 $search_string = $insert;
71 if ( $op eq "select" ) {
73 $dbh->prepare("select stdlib from bibliothesaurus where id=?");
75 my ($freelib_text) = $sti->fetchrow_array;
76 $result = $freelib_text;
78 my $Rsearch_string = "$search_string%";
79 my $authoritysep = C4::Context->preference('authoritysep');
80 my @splitted = /$authoritysep/, $search_string;
81 my $level = $#splitted + 1;
84 { # if no search pattern, returns only the 50 1st top level values
87 "select distinct freelib,father,level from bibliothesaurus where category='NC' and freelib like ? order by father,freelib"
93 "select distinct freelib,father,level from bibliothesaurus where category='NC' and level=0 and freelib like ? order by father,freelib limit 0,50"
96 $sti->execute($Rsearch_string);
98 while ( my ( $freelib, $father, $level ) = $sti->fetchrow ) {
101 $line{value} = "$father $freelib";
104 $line{value} = "$freelib";
106 $line{level} = $level + 1;
107 $line{father} = $father;
108 push @results, \%line;
110 my @DeeperResults = SearchDeeper( 'NC', $search_string );
111 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
113 template_name => "cataloguing/value_builder/unimarc_field_60X.tmpl",
116 authnotrequired => 0,
117 flagsrequired => { editcatalogue => 1 },
122 # builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
126 search_string => $search_string ? $search_string : $result,
127 results => \@results,
128 deeper => \@DeeperResults,
130 output_html_with_http_headers $input, $cookie, $template->output;