use C4::Members;
use C4::Koha;
use C4::Branch; # GetBranches
-use C4::VirtualShelves 3.02 qw(GetShelvesSummary);
+use C4::VirtualShelves;
# use utf8;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap);
$template->param( loggedinusername => $user );
$template->param( sessionID => $sessionID );
- my ($pubshelves, $barshelves) = C4::Context->get_shelves_userenv();
+ my ($total, $pubshelves, $barshelves) = C4::Context->get_shelves_userenv();
if (defined($pubshelves)) {
- $template->param( pubshelves => scalar (@$pubshelves));
- $template->param( pubshelvesloop => $pubshelves);
+ $template->param( pubshelves => scalar (@$pubshelves),
+ pubshelvesloop => $pubshelves,
+ );
+ $template->param( pubtotal => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar (@$pubshelves));
}
if (defined($barshelves)) {
- $template->param( barshelves => scalar (@$barshelves));
- $template->param( barshelvesloop => $barshelves);
+ $template->param( barshelves => scalar (@$barshelves),
+ barshelvesloop => $barshelves,
+ );
+ $template->param( bartotal => $total->{'bartotal'}, ) if ($total->{'bartotal'} > scalar (@$barshelves));
}
$borrowernumber = getborrowernumber($user);
$template->param( sessionID => $sessionID );
- my ($pubshelves) = C4::Context->get_shelves_userenv(); # an anonymous user has no 'barshelves'...
+ my ($total, $pubshelves) = C4::Context->get_shelves_userenv(); # an anonymous user has no 'barshelves'...
if (defined(($pubshelves))) {
- $template->param( pubshelves => scalar (@$pubshelves));
- $template->param( pubshelvesloop => $pubshelves);
+ $template->param( pubshelves => scalar (@$pubshelves),
+ pubshelvesloop => $pubshelves,
+ );
+ $template->param( pubtotal => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar (@$pubshelves));
}
}
);
C4::Context::set_shelves_userenv('bar',$session->param('barshelves'));
C4::Context::set_shelves_userenv('pub',$session->param('pubshelves'));
+ C4::Context::set_shelves_userenv('tot',$session->param('totshelves'));
$debug and printf STDERR "AUTH_SESSION: (%s)\t%s %s - %s\n", map {$session->param($_)} qw(cardnumber firstname surname branch) ;
$ip = $session->param('ip');
$lasttime = $session->param('lasttime');
$session->param('emailaddress'), $session->param('branchprinter')
);
- # Grab borrower's shelves and add to the session...
- $barshelves = GetShelvesSummary($borrowernumber,2,10);
- $session->param('barshelves', $barshelves);
- C4::Context::set_shelves_userenv('bar',$barshelves);
-
- # Grab the public shelves and add to the session...
- $pubshelves = GetShelvesSummary(0,2,10);
- $session->param('pubshelves', $pubshelves);
- C4::Context::set_shelves_userenv('pub',$pubshelves);
+ # Grab borrower's shelves and public shelves and add them to the session
+ # $row_count determines how many records are returned from the db query
+ # and the number of lists to be displayed of each type in the 'Lists' button drop down
+ my $row_count = 10; # FIXME:This probably should be a syspref
+ my ($total, $totshelves, $barshelves, $pubshelves);
+ ($barshelves, $totshelves) = GetRecentShelves(1, $row_count, $borrowernumber);
+ $total->{'bartotal'} = $totshelves;
+ ($pubshelves, $totshelves) = GetRecentShelves(2, $row_count, undef);
+ $total->{'pubtotal'} = $totshelves;
+ $session->param('barshelves', $barshelves->[0]);
+ $session->param('pubshelves', $pubshelves->[0]);
+ $session->param('totshelves', $total);
+
+ C4::Context::set_shelves_userenv('bar',$barshelves->[0]);
+ C4::Context::set_shelves_userenv('pub',$pubshelves->[0]);
+ C4::Context::set_shelves_userenv('tot',$total);
}
else {
if ($userid) {
$debug and warn "Initiating an anonymous session...";
# Grab the public shelves and add to the session...
- $pubshelves = GetShelvesSummary(0,2,10);
- $session->param('pubshelves', $pubshelves);
- C4::Context::set_shelves_userenv('pub',$pubshelves);
+ my $row_count = 20; # FIXME:This probably should be a syspref
+ my ($total, $totshelves, $pubshelves);
+ ($pubshelves, $totshelves) = GetRecentShelves(2, $row_count, undef);
+ $total->{'pubtotal'} = $totshelves;
+ $session->param('pubshelves', $pubshelves->[0]);
+ $session->param('totshelves', $total);
+ C4::Context::set_shelves_userenv('pub',$pubshelves->[0]);
+ C4::Context::set_shelves_userenv('tot',$total);
# setting a couple of other session vars...
$session->param('ip',$session->remote_addr());