fixing bug when a search gets more than 10 biblios : now, user can reach biblio 10, 20, 30...

This commit is contained in:
tipaul 2003-03-19 21:01:01 +00:00
parent 21bfaa4057
commit 13922e8276
2 changed files with 69 additions and 29 deletions

View file

@ -37,17 +37,17 @@ my $showoffset = $offset + 1;
my $total;
my $count;
my @results;
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui.simple/isbnsearch.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {catalogue => 1},
debug => 1,
});
if (! $isbn && !$title) {
print $input->redirect('addbooks.pl');
} else {
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "acqui.simple/isbnsearch.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {catalogue => 1},
debug => 1,
});
# fill with books in ACTIVE DB (biblio)
if (! $offset) {
$offset = 0;
@ -78,19 +78,48 @@ if (! $isbn && !$title) {
$row_data{copyrightdate} = $results[$i]->{'copyrightdate'};
push(@loop_data, \%row_data);
}
my @loop_links = ();
for (my $i = 0; ($i * $num) < $count; $i++) {
my %row_data;
$row_data{newoffset} = $i * $num;
$row_data{shownumber} = $i + 1;
$row_data{num} = $num;
push (@loop_links,\%row_data);
} # for
$template->param(startfrom => $offset+1);
($offset+$num<=$count) ? ($template->param(endat => $offset+$num)) : ($template->param(endat => $count));
$template->param(numrecords => $count);
my $nextstartfrom=($offset+$num<$count) ? ($offset+$num) : (-1);
my $prevstartfrom=($offset-$num>=0) ? ($offset-$num) : (-1);
$template->param(nextstartfrom => $nextstartfrom);
my $displaynext=1;
my $displayprev=0;
($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
$template->param(displaynext => $displaynext);
$template->param(displayprev => $displayprev);
my @numbers = ();
my $term;
my $value;
if ($isbn) {
$term = "isbn";
$value=$isbn;
} else {
$term ="title";
$value=$title;
}
if ($count>10) {
for (my $i=1; $i<$count/10+1; $i++) {
if ($i<16) {
my $highlight=0;
($offset==($i-1)*10) && ($highlight=1);
push @numbers, { number => $i, highlight => $highlight , term => $term, value => $value, startfrom => ($i-1)*10};
}
}
}
# fill with books in breeding farm
($count, @results) = breedingsearch($title,$isbn);
my @breeding_loop = ();
for (my $i=0; $i <= $#results; $i++) {
my %row_data;
if ($i % 2) {
$toggle="#ffffcc";
} else {
$toggle="white";
}
$row_data{toggle} = $toggle;
$row_data{id} = $results[$i]->{'id'};
$row_data{isbn} = $results[$i]->{'isbn'};
$row_data{file} = $results[$i]->{'file'};
@ -99,12 +128,16 @@ if (! $isbn && !$title) {
push (@breeding_loop, \%row_data);
}
$template->param(isbn => $isbn,
title => $title,
showoffset => $showoffset,
total => $total,
offset => $offset,
loop => \@loop_data,
breeding_loop => \@breeding_loop,
loop_links => \@loop_links);
numbers => \@numbers,
term => $term,
value => $value,
);
print $input->header(
-type => guesstype($template->output),

View file

@ -4,9 +4,28 @@
<CENTER>
You searched on <b><TMPL_IF name="isbn">ISBN <TMPL_VAR name="isbn"></TMPL_IF><TMPL_IF name="title">title <TMPL_VAR name="title"></TMPL_IF></b><br />
<TMPL_IF name="total">
<TMPL_VAR NAME=total> results found<br />
Results <TMPL_VAR name="showoffset"> to <TMPL_VAR name="total"> displayed
</TMPL_IF>
<p />
<!-- Row of numbers corresponding to search result pages -->
<TMPL_IF NAME=displayprev>
<a href=isbnsearch.pl?offset=<TMPL_VAR NAME="prevstartfrom">&<TMPL_VAR NAME=term>=<TMPL_VAR name="value" ESCAPE=URL>><img src=<TMPL_VAR name="themelang">/images/numbers/prev.gif border=0></a>
<TMPL_ELSE>
<img src=<TMPL_VAR name="themelang">/images/numbers/placeholder.gif border=0>
</TMPL_IF>
<TMPL_LOOP NAME=numbers>
<TMPL_IF NAME=highlight>
<img src=<TMPL_VAR name="themelang">/images/numbers/<TMPL_VAR NAME=number>-highlight.gif>
<TMPL_ELSE>
<a href=isbnsearch.pl?offset=<TMPL_VAR NAME=startfrom>&<TMPL_VAR NAME=term>=<TMPL_VAR name="value" ESCAPE=URL>><img src=<TMPL_VAR name="themelang">/images/numbers/<TMPL_VAR NAME=number>.gif border=0></a>
</TMPL_IF>
</TMPL_LOOP>
<TMPL_IF NAME=displaynext>
<a href=isbnsearch.pl?offset=<TMPL_VAR NAME="nextstartfrom">&<TMPL_VAR NAME=term>=<TMPL_VAR name="value" ESCAPE=URL>><img src=<TMPL_VAR name="themelang">/images/numbers/next.gif border=0></a>
<TMPL_ELSE>
<img src=<TMPL_VAR name="themelang">/images/numbers/placeholder.gif border=0>
</TMPL_IF>
<table width="80%" cellpadding="3">
<tr valign="center">
@ -71,16 +90,4 @@ Results <TMPL_VAR name="showoffset"> to <TMPL_VAR name="total"> displayed
</table>
<br />
<TMPL_LOOP name="loop_links">
<a href="isbnsearch.pl?isbn=<TMPL_VAR name="isbn">&offset=<TMPL_VAR name="newoffset">&num=<TMPL_VAR name="num">"><TMPL_VAR name="shownumber"></a>
</TMPL_LOOP>
<p />
Results per page:
<a href="isbnsearch.pl?isbn=<TMPL_VAR name="isbn">&offset=<TMPL_VAR name="offset">&num=5">5</a>
<a href="isbnsearch.pl?isbn=<TMPL_VAR name="isbn">&offset=<TMPL_VAR name="offset">&num=10">10</a>
<a href="isbnsearch.pl?isbn=<TMPL_VAR name="isbn">&offset=<TMPL_VAR name="offset">&num=20">20</a>
<a href="isbnsearch.pl?isbn=<TMPL_VAR name="isbn">&offset=<TMPL_VAR name="offset">&num=50">50</a>
</CENTER>
<br clear="all" />
<p>&nbsp;</p>
<TMPL_INCLUDE NAME="acquisitions-bottom.inc">