Lines 27-36
use Date::Calc qw/Today Add_Delta_YM/;
Link Here
|
27 |
use C4::Context; |
27 |
use C4::Context; |
28 |
use C4::Output; |
28 |
use C4::Output; |
29 |
use C4::Auth; |
29 |
use C4::Auth; |
30 |
use C4::Dates qw/format_date format_date_in_iso/; |
|
|
31 |
use C4::Debug; |
30 |
use C4::Debug; |
32 |
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/; |
31 |
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/; |
33 |
use C4::Acquisition qw/GetOrdersByBiblionumber/; |
32 |
use C4::Acquisition qw/GetOrdersByBiblionumber/; |
|
|
33 |
use Koha::DateUtils; |
34 |
|
34 |
|
35 |
my $input = new CGI; |
35 |
my $input = new CGI; |
36 |
my $startdate = $input->param('from'); |
36 |
my $startdate = $input->param('from'); |
Lines 55-76
if ($booksellerid && $basketno) {
Link Here
|
55 |
$template->param( booksellerid => $booksellerid, basketno => $basketno ); |
55 |
$template->param( booksellerid => $booksellerid, basketno => $basketno ); |
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
my ( $year, $month, $day ) = Today(); |
58 |
$startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); }; |
59 |
my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day); |
59 |
$enddate = eval { output_pref( { dt => dt_from_string( $enddate ), dateonly => 1, dateformat => 'iso' } ); }; |
60 |
# Find yesterday for the default shelf pull start and end dates |
60 |
|
61 |
# A default of the prior years's holds is a reasonable way to pull holds |
61 |
my $todaysdate_dt = dt_from_string; |
62 |
my $datelastyear = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YM($year, $month, $day, -1, 0)); |
62 |
my $todaysdate = output_pref( { dt => $todaysdate_dt, dateonly => 1, dateformat => 'iso' } ); |
|
|
63 |
|
64 |
# A default of the prior years's holds is a reasonable way to pull holds |
65 |
my $datelastyear_dt = $todaysdate_dt->subtract( days => 1); |
66 |
my $datelastyear = output_pref( { dt => $datelastyear_dt, dateonly => 1, dateformat => 'iso' } ); |
67 |
|
68 |
$startdate = $datelastyear unless $startdate; |
69 |
$enddate = $todaysdate unless $enddate; |
63 |
|
70 |
|
64 |
# Predefine the start and end dates if they are not already defined |
|
|
65 |
# Check if null, should string match, if so set start and end date to yesterday |
66 |
if (!defined($startdate) or $startdate !~ s/^\s*(\S+)\s*$/$1/) { # strip spaces, remove Taint |
67 |
$startdate = format_date($datelastyear); |
68 |
} |
69 |
if (!defined($enddate) or $enddate !~ s/^\s*(\S+)\s*$/$1/) { # strip spaces, remove Taint |
70 |
$enddate = format_date($todaysdate); |
71 |
} |
72 |
if (!defined($ratio)) { |
71 |
if (!defined($ratio)) { |
73 |
$ratio = 3; |
72 |
$ratio = 3; |
74 |
} |
73 |
} |
75 |
# Force to be a number |
74 |
# Force to be a number |
76 |
$ratio += 0; |
75 |
$ratio += 0; |
Lines 80-94
if ($ratio <= 0) {
Link Here
|
80 |
|
79 |
|
81 |
my $dbh = C4::Context->dbh; |
80 |
my $dbh = C4::Context->dbh; |
82 |
my $sqldatewhere = ""; |
81 |
my $sqldatewhere = ""; |
83 |
$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); |
82 |
$debug and warn output_pref({ dt => dt_from_string( $startdate ), dateformat => 'iso', dateonly => 1 }) . "\n" . output_pref({ dt => dt_from_string( $enddate ), dateformat => 'iso', dateonly => 1 }); |
84 |
my @query_params = (); |
83 |
my @query_params = (); |
85 |
if ($startdate) { |
84 |
if ($startdate) { |
86 |
$sqldatewhere .= " AND reservedate >= ?"; |
85 |
$sqldatewhere .= " AND reservedate >= ?"; |
87 |
push @query_params, format_date_in_iso($startdate); |
86 |
push @query_params, $startdate ; |
88 |
} |
87 |
} |
89 |
if ($enddate) { |
88 |
if ($enddate) { |
90 |
$sqldatewhere .= " AND reservedate <= ?"; |
89 |
$sqldatewhere .= " AND reservedate <= ?"; |
91 |
push @query_params, format_date_in_iso($enddate); |
90 |
push @query_params, $enddate; |
92 |
} |
91 |
} |
93 |
|
92 |
|
94 |
my $nfl_comparison = $include_ordered ? '<=' : '='; |
93 |
my $nfl_comparison = $include_ordered ? '<=' : '='; |
Lines 146-152
while ( my $data = $sth->fetchrow_hashref ) {
Link Here
|
146 |
push( |
145 |
push( |
147 |
@reservedata, |
146 |
@reservedata, |
148 |
{ |
147 |
{ |
149 |
reservedate => format_date( $data->{reservedate} ), |
148 |
reservedate => $data->{reservedate}, |
150 |
priority => $data->{priority}, |
149 |
priority => $data->{priority}, |
151 |
name => $data->{borrower}, |
150 |
name => $data->{borrower}, |
152 |
title => $data->{title}, |
151 |
title => $data->{title}, |
Lines 178-184
for my $rd ( @reservedata ) {
Link Here
|
178 |
|
177 |
|
179 |
$template->param( |
178 |
$template->param( |
180 |
ratio_atleast1 => $ratio_atleast1, |
179 |
ratio_atleast1 => $ratio_atleast1, |
181 |
todaysdate => format_date($todaysdate), |
180 |
todaysdate => $todaysdate, |
182 |
from => $startdate, |
181 |
from => $startdate, |
183 |
to => $enddate, |
182 |
to => $enddate, |
184 |
ratio => $ratio, |
183 |
ratio => $ratio, |