use Modern::Perl;
use CGI qw ( -utf8 );
-use Date::Calc qw/Today Add_Delta_YM/;
use POSIX qw( ceil );
use C4::Context;
-use C4::Output;
-use C4::Auth;
-use C4::Debug;
+use C4::Output qw( output_html_with_http_headers );
+use C4::Auth qw( get_template_and_user );
use C4::Acquisition qw/GetOrdersByBiblionumber/;
-use Koha::DateUtils;
+use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Acquisition::Baskets;
my $input = CGI->new;
query => $input,
type => "intranet",
flagsrequired => { circulate => "circulate_remaining_permissions" },
- debug => 1,
}
);
my $dbh = C4::Context->dbh;
my $sqldatewhere = "";
-$debug and warn output_pref({ dt => $startdate, dateformat => 'iso', dateonly => 1 }) . "\n" . output_pref({ dt => $enddate, dateformat => 'iso', dateonly => 1 });
my @query_params = ();
$sqldatewhere .= " AND reservedate >= ?";
my @reservedata;
while ( my $data = $sth->fetchrow_hashref ) {
my $thisratio = $data->{reservecount} / $data->{itemcount};
- my $ratiocalc = ceil($data->{reservecount}/$ratio - $data->{itemcount});
- $ratiocalc >= 1 or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause
+ my $copies_to_buy = ceil($data->{reservecount}/$ratio - $data->{itemcount});
+ $thisratio >= $ratio or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause
push(
@reservedata,
{
itype => [split('\|', $data->{l_itype})],
reservecount => $data->{reservecount},
itemcount => $data->{itemcount},
- ratiocalc => sprintf( "%.0d", $ratiocalc ),
+ copies_to_buy => sprintf( "%d", $copies_to_buy ),
thisratio => sprintf( "%.2f", $thisratio ),
thisratio_atleast1 => ( $thisratio >= 1 ) ? 1 : 0,
listcall => [split('\|', $data->{listcall})]