Fixed up the reserves code to use the new Reserves2.pm methods.
[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 use strict;
7 use CGI;
8 use C4::Database;
9 use C4::Search;
10 use C4::Circulation::Circ2;
11 use C4::Output;
12
13 # get all the data ....
14 my %env;
15
16 my $input = new CGI;
17 my $subject = $input->param('subject');
18 my $search_string= $input->param('search_string');
19 my $op = $input->param('op');
20 my $freelib_text = $input->param('freelib_text');
21
22 my $dbh=C4Connect;
23
24 # make the page ...
25 print $input->header;
26 if ($op eq "select") {
27         $subject = $subject."|$freelib_text";
28 }
29 print <<"EOF";
30         <html>
31         <head>
32         <title>Subject builder</title>
33         </head>
34         <body>
35         <form name="f_pop" action="thesaurus_popup.pl" method="post">
36         <textarea name="subject" rows=10 cols=60>$subject </textarea></br>
37         <p><input type="text" name="search_string" value="$search_string">
38         <input type="hidden" name="op" value="search">
39         <input type="submit" value="Search"></p>
40         </form>
41 EOF
42 # /search thesaurus terms starting by search_string
43         if ($search_string) {
44                 print '<form name="f2_pop" action="thesaurus_popup.pl" method="post">';
45                 print '<select name="freelib_text">';
46                 my $sti=$dbh->prepare("select freelib,stdlib from bibliothesaurus where freelib like '".$search_string."%'");
47                 $sti->execute;
48                 while (my $line=$sti->fetchrow_hashref) {
49                         print "<option value='$line->{'stdlib'}'>$line->{freelib}</option>";
50                 }
51         print <<"EOF";
52                 </select>
53                 <input type="hidden" name="op" value="select">
54                 <input type="hidden" name="subject" value="$subject">
55                 <input type="submit" name="OK" value="OK">
56                 </form>
57 EOF
58         }
59         print <<"EOF";
60                 <form name="f3_pop" onSubmit="javascript:report()">
61                 <input type="submit" value="END">
62                 </form>
63                 <script>
64                 function report() {
65                         alert("REPORT");
66                         opener.document.f.subject.value= document.f_pop.subject.value;
67                         self.close();
68                         return false;
69                 }
70                 </script>
71                 </body>
72                 </html>
73 EOF