records appear in message body instead of in attached file
[koha.git] / acqui.simple / websitesearch.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::Output;
26
27 my $input    = new CGI;
28 my $keywords = $input->param('keyword');
29 my $offset   = $input->param('offset');
30 my $num      = $input->param('num');
31 my $total;
32 my $count;
33 my @results;
34
35 if (! $keywords) {
36     print $input->redirect('addbooks.pl');
37 } else {
38     if (! $offset) { $offset = 0 };
39     if (! $num) { $num = 10 };
40
41     ($count, @results) = &websitesearch($keywords);
42
43     if ($count < ($offset + $num)) {
44         $total = $count;
45     } else {
46         $total = $offset + $num;
47     } # else
48
49     print $input->header;
50     print startpage();
51     print startmenu('acquisitions');
52
53     print << "EOF";
54 <font size="6"><em>Website Search Results</em></font><br />
55 <CENTER>
56 You searched on <b>keywords $keywords,</b> $count results found <br />
57 Results $offset to $total displayed
58 <div align="right">
59 <h2><a href="addbiblio.pl">Add New Biblio</a></h2>
60 </div>
61 <p />
62 <table border="0" cellspacing="0" cellpadding="5">
63 <tr valign=top bgcolor=#cccc99>
64 <td background="/images/background-mem.gif"><b>TITLE</b></td>
65 <td background="/images/background-mem.gif"><b>AUTHOR</b></td>
66 <td background="/images/background-mem.gif"><b>&copy;</b></td>
67 </tr>
68 EOF
69
70     for (my $i = $offset; $i < $total; $i++) {
71         if ($i % 2) {
72             print << "EOF";
73 <tr valign="top" bgcolor="#ffffcc">
74 EOF
75         } else {
76             print << "EOF";
77 <tr valign="top" bgcolor="#ffffff">
78 EOF
79         } # else
80
81         print << "EOF";
82 <td><a href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'title'}</a></td>
83 <td><a href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'author'}</a></td>
84 <td>$results[$i]->{'copyrightdate'}</td>
85 </tr>
86 EOF
87     } # for
88     print << "EOF";
89 <tr valign=top bgcolor=#cccc99>
90 <td background="/images/background-mem.gif">&nbsp;</td>
91 <td background="/images/background-mem.gif">&nbsp;</td>
92 <td background="/images/background-mem.gif">&nbsp;</td>
93 </tr>
94 </table>
95 <br />
96 EOF
97
98     for (my $i = 0; ($i * $num) < $count; $i++) {
99         my $newoffset = $i * $num;
100         print << "EOF";
101 <a href="keywordsearch.pl?keyword=$keywords&offset=$newoffset&num=$num">$i</a>
102 EOF
103     } # for
104
105     print << "EOF";
106 <p />
107 Results per page:
108 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=5">5</a>
109 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=10">10</a>
110 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=20">20</a>
111 <a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=50">50</a>
112 </CENTER>
113 <br clear="all" />
114 <p>&nbsp;</p>
115 EOF
116
117     print endmenu();
118     print endpage();
119 } # else