Added POD.
[koha.git] / thesaurus_popup.pl
1 #!/usr/bin/perl
2
3 # written 10/5/2002 by Paul
4 # build Subject field using bibliothesaurus table
5
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
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
14 # version.
15 #
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.
19 #
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
23
24 use strict;
25 use CGI;
26 use C4::Database;
27 use C4::Search;
28 use C4::Circulation::Circ2;
29 use C4::Output;
30
31 # get all the data ....
32 my %env;
33
34 my $input = new CGI;
35 my $subject = $input->param('subject');
36 my $search_string= $input->param('search_string');
37 my $op = $input->param('op');
38 my $freelib_text = $input->param('freelib_text');
39
40 my $dbh=C4Connect;
41
42 # make the page ...
43 print $input->header;
44 if ($op eq "select") {
45         $subject = $subject."|$freelib_text";
46 }
47 print <<"EOF";
48         <html>
49         <head>
50         <title>Subject builder</title>
51         </head>
52         <body>
53         <form name="f_pop" action="thesaurus_popup.pl" method="post">
54         <textarea name="subject" rows=10 cols=60>$subject </textarea></br>
55         <p><input type="text" name="search_string" value="$search_string">
56         <input type="hidden" name="op" value="search">
57         <input type="submit" value="Search"></p>
58         </form>
59 EOF
60 # /search thesaurus terms starting by search_string
61         if ($search_string) {
62                 print '<form name="f2_pop" action="thesaurus_popup.pl" method="post">';
63                 print '<select name="freelib_text">';
64                 my $sti=$dbh->prepare("select freelib,stdlib from bibliothesaurus where freelib like '".$search_string."%'");
65                 $sti->execute;
66                 while (my $line=$sti->fetchrow_hashref) {
67                         print "<option value='$line->{'stdlib'}'>$line->{freelib}</option>";
68                 }
69         print <<"EOF";
70                 </select>
71                 <input type="hidden" name="op" value="select">
72                 <input type="hidden" name="subject" value="$subject">
73                 <input type="submit" name="OK" value="OK">
74                 </form>
75 EOF
76         }
77         print <<"EOF";
78                 <form name="f3_pop" onSubmit="javascript:report()">
79                 <input type="submit" value="END">
80                 </form>
81                 <script>
82                 function report() {
83                         alert("REPORT");
84                         opener.document.f.subject.value= document.f_pop.subject.value;
85                         self.close();
86                         return false;
87                 }
88                 </script>
89                 </body>
90                 </html>
91 EOF