From 061c9b07ec9ae8606b0c07fb8bb590cae412baa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Tue, 6 Oct 2015 14:39:38 +0200 Subject: [PATCH] Remove C4::Dates from 'lists' in folder reports Remove C4::Dates from: - reports/bor_issues_top.pl - reports/borrowers_out.pl - reports/cat_issues_top.pl - reports/itemslost.pl To test: - Go to Home > Reports - Verify that following reports behave as before: - 'Patrons with the most checkouts (reports/bor_issues_top.pl) - 'Most circulated items' (reports/cat_issues_top.pl) - 'Patrons who haven't checked out (reports/borrowers_out.pl) - 'Items lost' Amended to fix issue with reports/borrowers_out.pl / see comment #3 Amended to fix issue with reports/bor_issues_top.pl / see comment #7 http://bugs.koha-community.org/show_bug.cgi?id=14965 Signed-off-by: Frederic Demians Code OK. The 4 reports works for me as before (same results). Signed-off-by: Jonathan Druart --- reports/bor_issues_top.pl | 4 ++-- reports/borrowers_out.pl | 8 +++++--- reports/cat_issues_top.pl | 16 +++++++++------- reports/itemslost.pl | 6 ++++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/reports/bor_issues_top.pl b/reports/bor_issues_top.pl index 485095e..e230a10 100755 --- a/reports/bor_issues_top.pl +++ b/reports/bor_issues_top.pl @@ -29,7 +29,7 @@ use C4::Circulation; use C4::Members; use C4::Reports; use C4::Debug; -use C4::Dates qw(format_date format_date_in_iso); +use Koha::DateUtils; =head1 NAME @@ -51,7 +51,7 @@ my $limit = $input->param("Limit"); my $column = $input->param("Criteria"); my @filters = $input->param("Filter"); foreach ( @filters[0..3] ) { - $_ and $_ = format_date_in_iso($_); + $_ and $_ = eval { output_pref( { dt => dt_from_string ( $_ ), dateonly => 1, dateformat => 'iso' }); }; } my $output = $input->param("output"); my $basename = $input->param("basename"); diff --git a/reports/borrowers_out.pl b/reports/borrowers_out.pl index 55f29ef..7b3f68a 100755 --- a/reports/borrowers_out.pl +++ b/reports/borrowers_out.pl @@ -28,7 +28,7 @@ use C4::Output; use C4::Circulation; use C4::Reports; use C4::Members; -use C4::Dates qw/format_date_in_iso/; +use Koha::DateUtils; =head1 NAME @@ -46,7 +46,9 @@ my $fullreportname = "reports/borrowers_out.tt"; my $limit = $input->param("Limit"); my $column = $input->param("Criteria"); my @filters = $input->param("Filter"); -$filters[1] = format_date_in_iso($filters[1]) if $filters[1]; +$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[1] ); + my $output = $input->param("output"); my $basename = $input->param("basename"); our $sep = $input->param("sep") || ''; @@ -230,7 +232,7 @@ sub calculate { } $strcalc .= " AND NOT EXISTS (SELECT * FROM issues WHERE issues.borrowernumber=borrowers.borrowernumber "; if ( @$filters[1] ) { - $strcalc .= " AND issues.timestamap > ?"; + $strcalc .= " AND issues.timestamp > ?"; push @query_args, @$filters[1]; } $strcalc .= ") "; diff --git a/reports/cat_issues_top.pl b/reports/cat_issues_top.pl index f88ff47..3726fe8 100755 --- a/reports/cat_issues_top.pl +++ b/reports/cat_issues_top.pl @@ -28,8 +28,8 @@ use C4::Output; use C4::Koha; use C4::Circulation; use C4::Reports; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Members; +use Koha::DateUtils; =head1 NAME @@ -47,10 +47,10 @@ my $fullreportname = "reports/cat_issues_top.tt"; my $limit = $input->param("Limit"); my $column = $input->param("Criteria"); my @filters = $input->param("Filter"); -$filters[0]=format_date_in_iso($filters[0]); -$filters[1]=format_date_in_iso($filters[1]); -$filters[2]=format_date_in_iso($filters[2]); -$filters[3]=format_date_in_iso($filters[3]); +foreach ( @filters[0..3] ) { + $_ and $_ = eval { output_pref( { dt => dt_from_string ( $_ ), dateonly => 1, dateformat => 'iso' } ); }; +} + my $output = $input->param("output"); my $basename = $input->param("basename"); #warn "calcul : ".$calc; @@ -181,8 +181,10 @@ sub calculate { if ($i>=2) { $cell{filter} .= @$filters[$i]; } else { - $cell{filter} .= format_date(@$filters[$i]); - } $cell{crit} .="Issue From" if ($i==0); + $cell{filter} .= eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } + if ( @$filters[$i] ); + } + $cell{crit} .="Issue From" if ($i==0); $cell{crit} .="Issue To" if ($i==1); $cell{crit} .="Return From" if ($i==2); $cell{crit} .="Return To" if ($i==3); diff --git a/reports/itemslost.pl b/reports/itemslost.pl index e208351..f0f318a 100755 --- a/reports/itemslost.pl +++ b/reports/itemslost.pl @@ -35,7 +35,7 @@ use C4::Biblio; use C4::Items; use C4::Koha; # GetItemTypes use C4::Branch; # GetBranches -use C4::Dates qw/format_date/; +use Koha::DateUtils; my $query = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -68,8 +68,10 @@ if ( $get_items ) { my $items = GetLostItems( \%where ); foreach my $it (@$items) { - $it->{'datelastseen'} = format_date($it->{'datelastseen'}); + $it->{'datelastseen'} = eval { output_pref( { dt => dt_from_string( $it->{'datelastseen'} ), dateonly => 1 }); } + if ( $it->{'datelastseen'} ); } + $template->param( total => scalar @$items, itemsloop => $items, -- 2.1.0