From d331bcfbee31c623761dacdd851d7b042ad368ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Thu, 8 Oct 2015 19:34:56 +0200 Subject: [PATCH] Bug 14982: Remove C4::Dates from guided report wizard and dictionary This patch removes C4::Dates from files: - reports/guided_reports.pl - reports/dictionary.pl - C4/Reports/Guided.pm To test: - Go to Home > Reports > Guided reports wizard - Then go to 'View Dictionary' (menue at teh left) - Click 'New definition' and step through - In step 2. select e.g. borrowers - In step 3 select a date field - In step 4, select date range and test start / end dates - In step 5, verify that dates display properly - Save and verify that dates are insertet properly in sql definition - Go back to Home > Reports > Guided reports wizard - Step through the wizard and verify that it works as before. http://bugs.koha-community.org/show_bug.cgi?id=14982 Signed-off-by: Josef Moravec Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/Reports/Guided.pm | 4 ++-- reports/dictionary.pl | 28 +++++++++++++++------------- reports/guided_reports.pl | 1 - 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index cb09651a85..37eaf989b3 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -23,9 +23,9 @@ use Carp; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); use C4::Context; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Templates qw/themelanguage/; use C4::Koha; +use Koha::DateUtils; use C4::Output; use XML::Simple; use XML::Dumper; @@ -675,7 +675,7 @@ sub get_saved_reports { my (@cond,@args); if ($filter) { if (my $date = $filter->{date}) { - $date = format_date_in_iso($date); + $date = eval { output_pref( { dt => dt_from_string( $date ), dateonly => 1, dateformat => 'iso' }); }; push @cond, "DATE(date_run) = ? OR DATE(date_created) = ? OR DATE(last_modified) = ? OR diff --git a/reports/dictionary.pl b/reports/dictionary.pl index 400790c65c..964f76f581 100755 --- a/reports/dictionary.pl +++ b/reports/dictionary.pl @@ -23,7 +23,7 @@ use C4::Auth; use CGI qw ( -utf8 ); use C4::Output; use C4::Reports::Guided; -use C4::Dates; +use Koha::DateUtils; =head1 NAME @@ -141,34 +141,36 @@ elsif ( $phase eq 'New Term step 5' ) { $tmp_hash{'name'} = $crit; $tmp_hash{'value'} = $value; push @criteria_loop, \%tmp_hash; - if ( $value =~ C4::Dates->regexp( C4::Context->preference('dateformat') ) ) { - my $date = C4::Dates->new($value); - $value = $date->output("iso"); - } + my $value_dt = eval { dt_from_string( $value ) }; + $value = output_pref( { dt => $value_dt, dateonly => 1, dateformat => 'iso' } ) + if ( $value_dt ); + $query_criteria .= " AND $crit='$value'"; } $value = $input->param( $crit . "_start_value" ); + if ($value) { my %tmp_hash; $tmp_hash{'name'} = "$crit Start"; $tmp_hash{'value'} = $value; push @criteria_loop, \%tmp_hash; - if ( $value =~ C4::Dates->regexp( C4::Context->preference('dateformat') ) ) { - my $date = C4::Dates->new($value); - $value = $date->output("iso"); - } + my $value_dt = eval { dt_from_string( $value ) }; + $value = output_pref( { dt => $value_dt, dateonly => 1, dateformat => 'iso' } ) + if ( $value_dt ); + $query_criteria .= " AND $crit >= '$value'"; } + $value = $input->param( $crit . "_end_value" ); if ($value) { my %tmp_hash; $tmp_hash{'name'} = "$crit End"; $tmp_hash{'value'} = $value; push @criteria_loop, \%tmp_hash; - if ( $value =~ C4::Dates->regexp( C4::Context->preference('dateformat') ) ) { - my $date = C4::Dates->new($value); - $value = $date->output("iso"); - } + my $value_dt = eval { dt_from_string( $value ) }; + $value = output_pref( { dt => $value_dt, dateonly => 1, dateformat => 'iso' } ) + if ( $value_dt ); + $query_criteria .= " AND $crit <= '$value'"; } } diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 0cee490fbe..71b9253b55 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -27,7 +27,6 @@ use File::Basename qw( dirname ); use C4::Reports::Guided; use C4::Auth qw/:DEFAULT get_session/; use C4::Output; -use C4::Dates qw/format_date/; use C4::Debug; use C4::Branch; # XXX subfield_is_koha_internal_p use C4::Koha qw/IsAuthorisedValueCategory GetFrameworksLoop/; -- 2.39.5