From 388f69e5c9f1ca0e7eab38f26afd93821d4287ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Tue, 29 Sep 2015 14:22:33 +0200 Subject: [PATCH] Bug 14920: Remove C4::Dates from circ/reserveratios.pl This patch removes C4::Dates from circ/reserveratios.pl To test: - Make sure you have many holds for biblios with not so much items (e.g. 5 holds, 1 item) or follow hint below - Go to Home > Circulation > Hold ratios - Verify that everything works the same without an dwith patch Hint: To get a big table you can set 'Hod ratio' in the filter to 0.1 (default value is 3). This was will trigger biblios with less holds than items. Signed-off-by: Hector Castro Works as advertised. Tested with dateformat syspref, datepiker Ok Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- circ/reserveratios.pl | 39 +++++++++---------- .../prog/en/modules/circ/reserveratios.tt | 9 +++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl index 96756742b3..27cc86ccad 100755 --- a/circ/reserveratios.pl +++ b/circ/reserveratios.pl @@ -27,10 +27,10 @@ use Date::Calc qw/Today Add_Delta_YM/; 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'); @@ -55,22 +55,21 @@ if ($booksellerid && $basketno) { $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; @@ -80,15 +79,15 @@ if ($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 ? '<=' : '='; @@ -146,7 +145,7 @@ while ( my $data = $sth->fetchrow_hashref ) { push( @reservedata, { - reservedate => format_date( $data->{reservedate} ), + reservedate => $data->{reservedate}, priority => $data->{priority}, name => $data->{borrower}, title => $data->{title}, @@ -178,7 +177,7 @@ for my $rd ( @reservedata ) { $template->param( ratio_atleast1 => $ratio_atleast1, - todaysdate => format_date($todaysdate), + todaysdate => $todaysdate, from => $startdate, to => $enddate, ratio => $ratio, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt index 80fe4aa82c..67f4226e34 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Circulation › Hold ratios [% INCLUDE 'doc-head-close.inc' %] @@ -42,8 +43,8 @@

Hold ratios to calculate items needed

-

Calculated on [% todaysdate %]. From [% from %] - to [% to %]

+

Calculated on [% todaysdate | $KohaDates %]. From [% from | $KohaDates %] + to [% to | $KohaDates %]

These items have a hold ratio ≥ [% ratio %].

[% sql %]
@@ -108,12 +109,12 @@
  • - +
  • - +
  • (inclusive) -- 2.39.5