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