3 # written 10/5/2002 by Paul
4 # build result field using bibliothesaurus table
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
31 use C4::Interface::CGI::Output;
32 # get all the data ....
36 my $result = $input->param('result');
37 my $search_string= $input->param('search_string');
38 $search_string = $result unless ($search_string);
39 my $op = $input->param('op');
40 my $id = $input->param('id');
41 my $category = $input->param('category');
42 my $index= $input->param('index');
43 my $insert = $input->param('insert');
44 my $nohierarchy = $input->param('nohierarchy'); # if 1, just show the last part of entry (Marseille). If 0, show everything (Europe -- France --Marseille)
45 my $dbh = C4::Context->dbh;
48 #print $input->header;
49 if ($op eq "select") {
50 my $sti = $dbh->prepare("select father,stdlib from bibliothesaurus where id=?");
52 my ($father,$freelib_text) = $sti->fetchrow_array;
53 if (length($result)>0) {
55 $result .= "|$freelib_text";
57 $result .= "|$father $freelib_text";
61 $result = "$freelib_text";
63 $result = "$father $freelib_text";
68 newauthority($dbh,$category,$insert,$insert,'',1,'');
69 $search_string=$insert;
71 my ($template, $loggedinuser, $cookie)
72 = get_template_and_user({template_name => "cataloguing/thesaurus_popup.tmpl",
76 flagsrequired => {editcatalogue => 1},
79 # /search thesaurus terms starting by search_string
84 # my $sti=$dbh->prepare("select id,freelib from bibliothesaurus where freelib like '".$search_string."%' and category ='$category'");
85 my $sti=$dbh->prepare("select id,freelib,father from bibliothesaurus where match (category,freelib) AGAINST (?) and category =?");
86 $sti->execute($search_string,$category);
87 while (my $line=$sti->fetchrow_hashref) {
89 $stdlib{$line->{'id'}} = "$line->{'freelib'}";
91 $stdlib{$line->{'id'}} = "$line->{'father'} $line->{'freelib'}";
93 push(@freelib,$line->{'id'});
95 $select_list= CGI::scrolling_list( -name=>'id',
103 my @x = SearchDeeper('',$category,$search_string);
105 #foreach (my $value @$x) {
106 # warn \@$x[$value]->{'stdlib'};
108 my $dig_list= CGI::scrolling_list( -name=>'search_string',
115 $template->param(select_list => $select_list,
116 search_string => $search_string,
117 dig_list => $dig_list,
119 category => $category,
121 nohierarchy => $nohierarchy,
123 output_html_with_http_headers $input, $cookie, $template->output;