Update to acqui.simple system. Hopefully this is a lot more user friendly.
[koha.git] / acqui.simple / isbnsearch.pl
1 #!/usr/bin/perl
2
3 use CGI;
4 use strict;
5 use C4::Acquisitions;
6 use C4::Search;
7 use C4::Output;
8
9 my $input      = new CGI;
10 my $isbn       = $input->param('isbn');
11 my $offset     = $input->param('offset');
12 my $num        = $input->param('num');
13 my $showoffset = $offset + 1;
14 my $total;
15 my $count;
16 my @results;
17
18 if (! $isbn) {
19     print $input->redirect('addbooks.pl');
20 } else {
21     if (! $offset) {
22         $offset     = 0;
23         $showoffset = 1;
24     };
25     if (! $num) { $num = 10 };
26     ($count, @results) = isbnsearch($isbn);
27
28     if ($count < ($offset + $num)) {
29         $total = $count;
30     } else {
31         $total = $offset + $num;
32     } # else
33
34     print $input->header;
35     print startpage();
36     print startmenu('acquisitions');
37
38     print << "EOF";
39 <font size="6"><em>Biblio Search Results</em></font><br />
40 <CENTER>
41 You searched on <b>ISBN $isbn,</b> $count results found <br />
42 Results $showoffset to $total displayed
43 <div align="right">
44 <h2><a href="addbiblio.pl">Add New Biblio</a></h2>
45 </div>
46 <p />
47 <table border="0" cellspacing="0" cellpadding="5">
48 <tr valign=top bgcolor=#cccc99>
49 <td background="/images/background-mem.gif"><b>TITLE</b></td>
50 <td background="/images/background-mem.gif"><b>AUTHOR</b></td>
51 <td background="/images/background-mem.gif"><b>&copy;</b></td>
52 </tr>
53 EOF
54
55     for (my $i = $offset; $i < $total; $i++) {
56         if ($i % 2) {
57             print << "EOF";
58 <tr valign="top" bgcolor="#ffffcc">
59 EOF
60         } else {
61             print << "EOF";
62 <tr valign="top" bgcolor="#ffffff">
63 EOF
64         } # else
65
66         print << "EOF";
67 <td><a href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'title'}</a></td>
68 <td><a href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'author'}</a></td>
69 <td>$results[$i]->{'copyrightdate'}</td>
70 </tr>
71 EOF
72     } # for
73
74     print << "EOF";
75 <tr valign=top bgcolor=#cccc99>
76 <td background="/images/background-mem.gif">&nbsp;</td>
77 <td background="/images/background-mem.gif">&nbsp;</td>
78 <td background="/images/background-mem.gif">&nbsp;</td>
79 </tr>
80 </table>
81 <br />
82 EOF
83
84     for (my $i = 0; ($i * $num) < $count; $i++) {
85         my $newoffset = $i * $num;
86         my $shownumber = $i + 1;
87         print << "EOF";
88 <a href="isbnsearch.pl?isbn=$isbn&offset=$newoffset&num=$num">$shownumber</a>
89 EOF
90     } # for
91
92     print << "EOF";
93 <p />
94 Results per page:
95 <a href="isbnsearch.pl?isbn=$isbn&offset=$offset&num=5">5</a>
96 <a href="isbnsearch.pl?isbn=$isbn&offset=$offset&num=10">10</a>
97 <a href="isbnsearch.pl?isbn=$isbn&offset=$offset&num=20">20</a>
98 <a href="isbnsearch.pl?isbn=$isbn&offset=$offset&num=50">50</a>
99 </CENTER>
100 <br clear="all" />
101 <p>&nbsp;</p>
102 EOF
103
104     print endmenu();
105     print endpage();
106 } # else