use C4::Context;
use C4::Output;
use C4::Auth;
-use C4::Dates qw/format_date format_date_in_iso/;
use C4::Debug;
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/;
use C4::Acquisition qw/GetOrdersByBiblionumber/;
+use Koha::DateUtils;
my $input = new CGI;
my $startdate = $input->param('from');
$template->param( booksellerid => $booksellerid, basketno => $basketno );
}
-my ( $year, $month, $day ) = Today();
-my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day);
-# Find yesterday for the default shelf pull start and end dates
-# A default of the prior years's holds is a reasonable way to pull holds
-my $datelastyear = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YM($year, $month, $day, -1, 0));
+$startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); };
+$enddate = eval { output_pref( { dt => dt_from_string( $enddate ), dateonly => 1, dateformat => 'iso' } ); };
+
+my $todaysdate_dt = dt_from_string;
+my $todaysdate = output_pref( { dt => $todaysdate_dt, dateonly => 1, dateformat => 'iso' } );
+
+# A default of the prior years's holds is a reasonable way to pull holds
+my $datelastyear_dt = $todaysdate_dt->subtract( days => 1);
+my $datelastyear = output_pref( { dt => $datelastyear_dt, dateonly => 1, dateformat => 'iso' } );
+
+$startdate = $datelastyear unless $startdate;
+$enddate = $todaysdate unless $enddate;
-# Predefine the start and end dates if they are not already defined
-# Check if null, should string match, if so set start and end date to yesterday
-if (!defined($startdate) or $startdate !~ s/^\s*(\S+)\s*$/$1/) { # strip spaces, remove Taint
- $startdate = format_date($datelastyear);
-}
-if (!defined($enddate) or $enddate !~ s/^\s*(\S+)\s*$/$1/) { # strip spaces, remove Taint
- $enddate = format_date($todaysdate);
-}
if (!defined($ratio)) {
- $ratio = 3;
+ $ratio = 3;
}
# Force to be a number
$ratio += 0;
my $dbh = C4::Context->dbh;
my $sqldatewhere = "";
-$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate);
+$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 });
my @query_params = ();
if ($startdate) {
$sqldatewhere .= " AND reservedate >= ?";
- push @query_params, format_date_in_iso($startdate);
+ push @query_params, $startdate ;
}
if ($enddate) {
$sqldatewhere .= " AND reservedate <= ?";
- push @query_params, format_date_in_iso($enddate);
+ push @query_params, $enddate;
}
my $nfl_comparison = $include_ordered ? '<=' : '=';
push(
@reservedata,
{
- reservedate => format_date( $data->{reservedate} ),
+ reservedate => $data->{reservedate},
priority => $data->{priority},
name => $data->{borrower},
title => $data->{title},
$template->param(
ratio_atleast1 => $ratio_atleast1,
- todaysdate => format_date($todaysdate),
+ todaysdate => $todaysdate,
from => $startdate,
to => $enddate,
ratio => $ratio,
+[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Circulation › Hold ratios</title>
[% INCLUDE 'doc-head-close.inc' %]
<div id="yui-main">
<div class="yui-b">
<h1>Hold ratios to calculate items needed</h1>
- <h3>Calculated on [% todaysdate %]. From [% from %]
- to [% to %]</h3>
+ <h3>Calculated on [% todaysdate | $KohaDates %]. From [% from | $KohaDates %]
+ to [% to | $KohaDates %]</h3>
<p>These items have a hold ratio ≥ [% ratio %].</p>
<div class="sql">[% sql %]</div>
<li>
<label for="from">Start date:</label>
- <input type="text" size="10" id="from" name="from" value="[% from %]" class="datepickerfrom" />
+ <input type="text" size="10" id="from" name="from" value="[% from | $KohaDates %]" class="datepickerfrom" />
</li>
<li>
<label for="to">End date:</label>
- <input size="10" id="to" name="to" value="[% to %]" type="text" class="datepickerto" />
+ <input size="10" id="to" name="to" value="[% to | $KohaDates %]" type="text" class="datepickerto" />
</li>
</ol>
(inclusive)