From 17af2c9a1e689ea845c65ffaaa6efaeb49eeec98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Mon, 5 Oct 2015 23:34:38 +0200 Subject: [PATCH] Bug 14961: Remove C4::Dates from files reports/*_stats.pl Remove C4::Dates from following files: - reports/acquisitions_stats.pl - reports/borrowers_stats.pl - reports/reserves_stats.pl - reports/serials_stats.pl - reports/issues_avg_stats.pl - reports/issues_stats.pl To test: - Go to Home > Reports - Verify that following reports work as before: - Other > Average loan time - Statistic wizards - Acquisitions - Patrons - Circulation - Serials - Holds Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- reports/acquisitions_stats.pl | 17 +++++++++++------ reports/borrowers_stats.pl | 11 +++++++---- reports/issues_avg_stats.pl | 19 +++++++++++++------ reports/issues_stats.pl | 15 +++++++++------ reports/reserves_stats.pl | 11 ++++++----- reports/serials_stats.pl | 3 --- 6 files changed, 46 insertions(+), 30 deletions(-) diff --git a/reports/acquisitions_stats.pl b/reports/acquisitions_stats.pl index 0f45989a5e..9bb439f1f4 100755 --- a/reports/acquisitions_stats.pl +++ b/reports/acquisitions_stats.pl @@ -26,9 +26,9 @@ use C4::Reports; use C4::Output; use C4::Koha; use C4::Circulation; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Branch; use C4::Biblio; +use Koha::DateUtils; =head1 NAME @@ -46,10 +46,14 @@ my $fullreportname = "reports/acquisitions_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); 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] ); +$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[0] ); +$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[1] ); +$filters[2] = eval { output_pref( { dt => dt_from_string( $filters[2]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[2] ); +$filters[3] = eval { output_pref( { dt => dt_from_string( $filters[3]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[3] ); my $podsp = $input->param("PlacedOnDisplay"); my $rodsp = $input->param("ReceivedOnDisplay"); my $calc = $input->param("Cellvalue"); @@ -253,7 +257,8 @@ sub calculate { if ($i >= 4) { $cell{filter} = @$filters[$i]; } else { - $cell{filter} = format_date(@$filters[$i]); + $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } + if ( @$filters[$i] ); } $cell{crit} = $i; push @loopfilter, \%cell; diff --git a/reports/borrowers_stats.pl b/reports/borrowers_stats.pl index fc824a92ab..9ac0cac549 100755 --- a/reports/borrowers_stats.pl +++ b/reports/borrowers_stats.pl @@ -25,7 +25,7 @@ use C4::Auth; use C4::Context; use C4::Branch; # GetBranches use C4::Koha; -use C4::Dates; +use Koha::DateUtils; use C4::Acquisition; use C4::Output; use C4::Reports; @@ -53,8 +53,10 @@ my $fullreportname = "reports/borrowers_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); my @filters = $input->param("Filter"); -$filters[3]=format_date_in_iso($filters[3]); -$filters[4]=format_date_in_iso($filters[4]); +$filters[3] = eval { output_pref( { dt => dt_from_string( $filters[3]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[3] ); +$filters[4] = eval { output_pref ({ dt => dt_from_string( $filters[4]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[4] ); my $digits = $input->param("digits"); our $period = $input->param("period"); my $borstat = $input->param("status"); @@ -221,7 +223,8 @@ sub calculate { my %cell; if ( @$filters[$i] ) { if ($i == 3 or $i == 4) { - $cell{filter} = format_date(@$filters[$i]); + $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } + if ( @$filters[$i] ); } else { $cell{filter} = @$filters[$i]; } diff --git a/reports/issues_avg_stats.pl b/reports/issues_avg_stats.pl index 772acd6544..42cce71ac2 100755 --- a/reports/issues_avg_stats.pl +++ b/reports/issues_avg_stats.pl @@ -28,7 +28,7 @@ use C4::Output; use C4::Koha; use C4::Circulation; use C4::Reports; -use C4::Dates qw/format_date format_date_in_iso/; +use Koha::DateUtils; use Date::Calc qw(Delta_Days); =head1 NAME @@ -47,10 +47,16 @@ my $fullreportname = "reports/issues_avg_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); 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]); +$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[0] ); +$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[1] ); +$filters[2] = eval { output_pref( { dt => dt_from_string( $filters[2]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[2] ); +$filters[3] = eval { output_pref( { dt => dt_from_string( $filters[3]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[3] ); + + my $podsp = $input->param("IssueDisplay"); my $rodsp = $input->param("ReturnDisplay"); my $calc = $input->param("Cellvalue"); @@ -213,7 +219,8 @@ sub calculate { if ($i>=4) { $cell{filter} .= @$filters[$i]; } else { - $cell{filter} .= format_date(@$filters[$i]); + $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); diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index 938a8357d7..9b43244c43 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -31,8 +31,8 @@ use C4::Koha; use C4::Output; use C4::Circulation; use C4::Reports; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Members; +use Koha::DateUtils; =head1 NAME @@ -51,8 +51,10 @@ my $do_it = $input->param('do_it'); my $line = $input->param("Line"); my $column = $input->param("Column"); my @filters = $input->param("Filter"); -$filters[0]=format_date_in_iso($filters[0]); -$filters[1]=format_date_in_iso($filters[1]); +$filters[0] = eval { output_pref( { dt => dt_from_string( $filters[0]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[0] ); +$filters[1] = eval { output_pref( { dt => dt_from_string( $filters[1]), dateonly => 1, dateformat => 'iso' } ); } + if ( $filters[1] ); my $podsp = $input->param("DisplayBy"); my $type = $input->param("PeriodTypeSel"); my $daysel = $input->param("PeriodDaySel"); @@ -189,7 +191,8 @@ sub calculate { if ($i>=2) { $cell{filter} = @$filters[$i]; } else { - $cell{filter} = format_date(@$filters[$i]); + $cell{filter} = eval { output_pref( { dt => dt_from_string( @$filters[$i] ), dateonly => 1 }); } + if ( @$filters[$i] ); } $cell{crit} = ( $i == 0 ) ? "Period From" @@ -261,7 +264,7 @@ sub calculate { $linefield = ($dsp == 1) ? " dayname($line)" : ($dsp == 2) ? "monthname($line)" : ($dsp == 3) ? " Year($line)" : - 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through C4::Dates + 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through Koha::DateUtils } else { $linefield = $line; } @@ -336,7 +339,7 @@ sub calculate { $colfield = ($dsp == 1) ? " dayname($column)" : ($dsp == 2) ? "monthname($column)" : ($dsp == 3) ? " Year($column)" : - 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through C4::Dates + 'date_format(`datetime`,"%Y-%m-%d")'; # Probably should be left alone or passed through Koha::DateUtils } else { $colfield = $column; } diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl index df8d6481f6..18449f77d6 100755 --- a/reports/reserves_stats.pl +++ b/reports/reserves_stats.pl @@ -31,8 +31,8 @@ use C4::Koha; use C4::Output; use C4::Reports; use C4::Members; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Category; +use Koha::DateUtils; use List::MoreUtils qw/any/; use YAML; @@ -190,9 +190,10 @@ sub calculate { my @loopfilter; foreach my $filter ( keys %$filters_hashref ) { $filters_hashref->{$filter} =~ s/\*/%/; - $filters_hashref->{$filter} = - format_date_in_iso( $filters_hashref->{$filter} ) - if ( $filter =~ /date/ ); + if ( $filter =~ /date/ ) { + $filters_hashref->{$filter} = + eval { output_pref( { dt => dt_from_string( $filters_hashref->{$filter} ), dateonly => 1, dateformat => 'iso' }); }; + } } #display @@ -201,7 +202,7 @@ sub calculate { crit => $_, filter => ( $_ =~ /date/ - ? format_date( $filters_hashref->{$_} ) + ? eval { output_pref( { dt => dt_from_string( $filters_hashref->{$_} ), dateonly => 1 }); } : $filters_hashref->{$_} ) } diff --git a/reports/serials_stats.pl b/reports/serials_stats.pl index 4ca99c3a63..f6ba4c008c 100755 --- a/reports/serials_stats.pl +++ b/reports/serials_stats.pl @@ -23,7 +23,6 @@ use C4::Auth; use CGI qw ( -utf8 ); use C4::Context; use C4::Branch; # GetBranches -use C4::Dates qw/format_date/; use C4::Output; use C4::Koha; use C4::Reports; @@ -35,8 +34,6 @@ plugin that shows a stats on serials =head1 DESCRIPTION -=over 2 - =cut my $input = new CGI; -- 2.39.5