From 0cdf2ff8be0c7fd0073343f9f52fa40b61733e15 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 28 Sep 2015 16:44:30 +0200 Subject: [PATCH] [PASSED QA] Bug 14916: Display overdues if due on 23:59 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an item is due today 23:59 and the filter is from yesterday to today, the overdue won't appear on the list. Test plan: Be sure you have an item due on DATE 23:59 Search for overdues from DATE-1 to DATE Without this patch, the item won't appear. With this patch, it will. Regression test: test the CSV download. Note: On the way, this patch remove the deps to C4::Dates (which was the original goal of the bug report). Issue reproduced, it's resolved with this patch. Signed-off-by: Marc VĂ©ron Signed-off-by: Katrin Fischer --- circ/overdue.pl | 35 +++++++++++----------- .../intranet-tmpl/prog/en/modules/circ/overdue.tt | 5 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/circ/overdue.pl b/circ/overdue.pl index 01a80d2..4fb046f 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -19,15 +19,13 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; +use Modern::Perl; use C4::Context; use C4::Output; use CGI qw(-oldstyle_urls -utf8); use C4::Auth; use C4::Branch; use C4::Debug; -use C4::Dates qw/format_date format_date_in_iso/; use Text::CSV_XS; use Koha::DateUtils; use DateTime; @@ -43,16 +41,15 @@ my $branchfilter = $input->param('branch') || ''; my $homebranchfilter = $input->param('homebranch') || ''; my $holdingbranchfilter = $input->param('holdingbranch') || ''; my $op = $input->param('op') || ''; -my $dateduefrom = format_date_in_iso($input->param( 'dateduefrom' )) || ''; -my $datedueto = format_date_in_iso($input->param( 'datedueto' )) || ''; -# FIXME This is a kludge to include times -if ($datedueto) { - $datedueto .= ' 23:59'; + +my ($dateduefrom, $datedueto); +if ( $dateduefrom = $input->param('dateduefrom') ) { + $dateduefrom = dt_from_string( $dateduefrom ); } -if ($dateduefrom) { - $dateduefrom .= ' 00:00'; +if ( $datedueto = $input->param('datedueto') ) { + $datedueto = dt_from_string( $datedueto )->set_hour(23)->set_minute(59); } -# kludge end + my $isfiltered = $op =~ /apply/i && $op =~ /filter/i; my $noreport = C4::Context->preference('FilterBeforeOverdueReport') && ! $isfiltered && $op ne "csv"; @@ -228,8 +225,8 @@ $template->param( borname => $bornamefilter, order => $order, showall => $showall, - dateduefrom => $input->param( 'dateduefrom' ) || '', - datedueto => $input->param( 'datedueto' ) || '', + dateduefrom => $dateduefrom, + datedueto => $datedueto, ); if ($noreport) { @@ -307,8 +304,8 @@ if ($noreport) { $strsth.=" AND borrowers.branchcode = '" . $branchfilter . "' " if $branchfilter; $strsth.=" AND items.homebranch = '" . $homebranchfilter . "' " if $homebranchfilter; $strsth.=" AND items.holdingbranch = '" . $holdingbranchfilter . "' " if $holdingbranchfilter; - $strsth.=" AND date_due < '" . $datedueto . "' " if $datedueto; - $strsth.=" AND date_due > '" . $dateduefrom . "' " if $dateduefrom; + $strsth.=" AND date_due >= ?" if $dateduefrom; + $strsth.=" AND date_due <= ?" if $datedueto; # restrict patrons (borrowers) to those matching the patron attribute filter(s), if any my $bnlist = $have_pattr_filter_data ? join(',',keys %borrowernumber_to_attributes) : ''; $strsth =~ s/WHERE 1=1/WHERE 1=1 AND borrowers.borrowernumber IN ($bnlist)/ if $bnlist; @@ -323,8 +320,10 @@ if ($noreport) { ); $template->param(sql=>$strsth); my $sth=$dbh->prepare($strsth); - #warn "overdue.pl : query string ".$strsth; - $sth->execute(); + $sth->execute( + ($dateduefrom ? output_pref({ dt => $dateduefrom, dateformat => 'iso' }) : ()), + ($datedueto ? output_pref({ dt => $datedueto, dateformat => 'iso' }) : ()), + ); my @overduedata; while (my $data = $sth->fetchrow_hashref) { @@ -348,7 +347,7 @@ if ($noreport) { barcode => $data->{barcode}, cardnumber => $data->{cardnumber}, itemnum => $data->{itemnumber}, - issuedate => format_date($data->{issuedate}), + issuedate => output_pref({ dt => dt_from_string( $data->{issuedate} ), dateonly => 1 }), borrowertitle => $data->{borrowertitle}, surname => $data->{surname}, firstname => $data->{firstname}, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt index c1aa428..4ebc7d2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt @@ -1,3 +1,4 @@ +[% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] Koha › Circulation › Items overdue as of [% todaysdate %] [% INCLUDE 'doc-head-close.inc' %] @@ -137,11 +138,11 @@ overdue as of [% todaysdate %][% IF ( isfiltered ) %] From: - +
  • - +
    1. -- 1.9.1