records appear in message body instead of in attached file
[koha.git] / acqui.simple / keywordsearch.pl
1 #!/usr/bin/perl
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA  02111-1307 USA
20
21 use CGI;
22 use strict;
23 use C4::Catalogue;
24 use C4::Biblio;
25 use C4::Search;
26 use C4::Output;
27
28 my $input    = new CGI;
29 my $keywords = $input->param('keyword');
30 my $offset   = $input->param('offset');
31 my $num      = $input->param('num');
32 my $total;
33 my $count;
34 my @results;
35
36 if (! $keywords) {
37     print $input->redirect('addbooks.pl');
38 } else {
39     if (! $offset) { $offset = 0 };
40     if (! $num) { $num = 10 };
41     my %search;
42     $search{'keyword'}=$keywords;
43     ($count, @results) = KeywordSearch(undef,'intra',\%search,$num,$offset);
44
45     if ($count < ($offset + $num)) {
46         $total = $count;
47     } else {
48         $total = $offset + $num;
49     } # else
50
51     print $input->header;
52     print startpage();
53     print startmenu('acquisitions');
54
55     print << "EOF";
56 <font size="6"><em>Biblio Search Results</em></font><br />
57 <CENTER>
58 You searched on <b>keywords $keywords,</b> $count results found <br />
59 Results $offset to $total displayed
60 <div align="right">
61 <h2><a href="addbiblio.pl">Add New Biblio</a></h2>
62 </div>
63 <p />
64 <table border="0" cellspacing="0" cellpadding="5">
65 <tr valign=top bgcolor=#cccc99>
66 <td background="/images/background-mem.gif"><b>TITLE</b></td>
67 <td background="/images/background-mem.gif"><b>AUTHOR</b></td>
68 <td background="/images/background-mem.gif"><b>&copy;</b></td>
69 </tr>
70 EOF
71
72     for (my $i = 0; $i < ($total - $offset); $i++) {
73         if ($i % 2) {
74             print << "EOF";
75 <tr valign="top" bgcolor="#ffffcc">
76 EOF
77         } else {
78             print << "EOF";
79 <tr valign="top" bgcolor="#ffffff">
80 EOF
81         } # else
82
83         print << "EOF";
84 <td><a href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'title'}</a></td>
85 <td><a href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'author'}</a></td>
86 <td>$results[$i]->{'copyrightdate'}</td>
87 </tr>
88 EOF
89     } # for
90
91     print << "EOF";
92 <tr valign=top bgcolor=#cccc99>
93 <td background="/images/background-mem.gif">&nbsp;</td>
94 <td background="/images/background-mem.gif">&nbsp;</td>
95 <td background="/images/background-mem.gif">&nbsp;</td>
96 </tr>
97 </table>
98 <br />
99 EOF
100
101     for (my $i = 0; ($i * $num) < $count; $i++) {
102         my $newoffset = $i * $num;
103         my $shownumber = $i + 1;
104         print << "EOF";
105 <a href="keywordsearch.pl?keyword=$keywords&offset=$newoffset&num=$num">$shownumber</a>
106 EOF
107     } # for
108
109     print << "EOF";
110 <p />
111 Results per page:
112 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=5">5</a>
113 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=10">10</a>
114 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=20">20</a>
115 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=50">50</a>
116 </CENTER>
117 <br clear="all" />
118 <p>&nbsp;</p>
119 EOF
120
121     print endmenu();
122     print endpage();
123 } # else