use CGI qw ( -utf8 );
use Date::Calc qw/Today Add_Delta_YM/;
+use POSIX qw( ceil );
use C4::Context;
use C4::Output;
use Koha::DateUtils;
use Koha::Acquisition::Baskets;
-my $input = new CGI;
+my $input = CGI->new;
my $startdate = $input->param('from');
my $enddate = $input->param('to');
my $ratio = $input->param('ratio');
my $include_ordered = $input->param('include_ordered');
+my $include_suspended = $input->param('include_suspended');
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "circ/reserveratios.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
flagsrequired => { circulate => "circulate_remaining_permissions" },
debug => 1,
}
: q{};
my $nfl_comparison = $include_ordered ? '<=' : '=';
+my $sus_comparison = $include_suspended ? '<=' : '<';
my $strsth =
"SELECT reservedate,
reserves.borrowernumber as borrowernumber,
$include_aqorders_qty_join
WHERE
notforloan $nfl_comparison 0 AND damaged = 0 AND itemlost = 0 AND withdrawn = 0
+ AND suspend $sus_comparison 1
$sqldatewhere
";
my $sth = $dbh->prepare($strsth);
$sth->execute(@query_params);
-my $ratio_atleast1 = ($ratio >= 1) ? 1 : 0;
my @reservedata;
while ( my $data = $sth->fetchrow_hashref ) {
my $thisratio = $data->{reservecount} / $data->{itemcount};
- my $ratiocalc = ($thisratio / $ratio);
- ($thisratio / $ratio) >= 1 or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause
+ my $ratiocalc = ceil($data->{reservecount}/$ratio - $data->{itemcount});
+ $ratiocalc >= 1 or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause
push(
@reservedata,
{
priority => $data->{priority},
name => $data->{borrower},
title => $data->{title},
- subtitle => C4::Biblio::SplitSubtitle($data->{'subtitle'});
+ subtitle => $data->{subtitle},
+ medium => $data->{medium},
+ part_number => $data->{part_number},
+ part_name => $data->{part_name},
author => $data->{author},
itemnum => $data->{itemnumber},
biblionumber => $data->{biblionumber},
itype => [split('\|', $data->{l_itype})],
reservecount => $data->{reservecount},
itemcount => $data->{itemcount},
- ratiocalc => sprintf( "%.0d", $ratio_atleast1 ? ( $thisratio / $ratio ) : $thisratio ),
+ ratiocalc => sprintf( "%.0d", $ratiocalc ),
thisratio => sprintf( "%.2f", $thisratio ),
thisratio_atleast1 => ( $thisratio >= 1 ) ? 1 : 0,
listcall => [split('\|', $data->{listcall})]
}
$template->param(
- ratio_atleast1 => $ratio_atleast1,
todaysdate => $todaysdate,
from => $startdate,
to => $enddate,
ratio => $ratio,
include_ordered => $include_ordered,
+ include_suspended => $include_suspended,
reserveloop => \@reservedata,
);