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= "100".(int(rand(100000))+1);
36 function Focus$function_name(subfield_managed) {
40 function Blur$function_name(subfield_managed) {
44 function Clic$function_name(index) {
45 defaultvalue=document.f.field_value[index].value;
46 newin=window.open(\"../plugin_launcher.pl?plugin_name=unimarc_field_60X.pl&index=\"+index+\"&result=\"+defaultvalue,\"unimarc 700\",'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');
67 newauthority($dbh,'NC',$insert,$insert,'',1,'');
68 $search_string=$insert;
70 if ($op eq "select") {
71 my $sti = $dbh->prepare("select stdlib from bibliothesaurus where id=?");
73 my ($freelib_text) = $sti->fetchrow_array;
74 $result = $freelib_text;
76 my $Rsearch_string="$search_string%";
77 my $authoritysep = C4::Context->preference('authoritysep');
78 my @splitted = /$authoritysep/,$search_string;
79 my $level = $#splitted+1;
81 if ($search_string) { # if no search pattern, returns only the 50 1st top level values
82 $sti=$dbh->prepare("select distinct freelib,father,level from bibliothesaurus where category='NC' and freelib like ? order by father,freelib");
84 $sti=$dbh->prepare("select distinct freelib,father,level from bibliothesaurus where category='NC' and level=0 and freelib like ? order by father,freelib limit 0,50");
86 $sti->execute($Rsearch_string);
88 while (my ($freelib,$father,$level)=$sti->fetchrow) {
91 $line{value} = "$father $freelib";
93 $line{value} = "$freelib";
95 $line{level} = $level+1;
96 $line{father} = $father;
97 push @results, \%line;
99 my @DeeperResults = SearchDeeper('NC',$search_string);
100 my ($template, $loggedinuser, $cookie)
101 = get_template_and_user({template_name => "value_builder/unimarc_field_60X.tmpl",
104 authnotrequired => 0,
105 flagsrequired => {parameters => 1},
108 # builds collection list : search isbn and editor, in parent, then load collections from bibliothesaurus table
109 $template->param(index => $index,
111 search_string => $search_string?$search_string:$result,
112 results => \@results,
113 deeper => \@DeeperResults,
115 print $input->header(-cookie => $cookie),$template->output;