From ebed532badf4870adde493c108ca1bce8ec0010f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 30 Sep 2014 11:25:27 +0200 Subject: [PATCH] [PASSED QA] Bug 12627: Fix date management C4::Dates->today returns a string formatted depending on the dateformat syspref. Before the original patch, SQLHelper managed both format (string formatted and DateTime. Now DBIX::Class only manages DateTime, so the call to NewSuggestion and ModSuggestion should pass a DateTime object Signed-off-by: Katrin Fischer --- opac/opac-suggestions.pl | 4 +++- suggestion/suggestion.pl | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index 9c74308..d35f715 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -29,6 +29,8 @@ use C4::Koha; use C4::Dates; use C4::Scrubber; +use Koha::DateUtils qw( dt_from_string ); + my $input = new CGI; my $allsuggestions = $input->param('showall'); my $op = $input->param('op'); @@ -91,7 +93,7 @@ if ( $op eq "add_confirm" ) { foreach my $suggest (keys %$suggestion){ $suggestion->{$suggest} = $scrubber->scrub($suggestion->{$suggest}); } - $$suggestion{'suggesteddate'}=C4::Dates->today; + $suggestion->{suggesteddate} = dt_from_string; $$suggestion{'branchcode'}= $input->param('branch') || C4::Context->userenv->{"branch"}; &NewSuggestion($suggestion); diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 211daa8..14c90bd 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -31,6 +31,9 @@ use C4::Search; use C4::Dates qw(format_date); use C4::Members; use C4::Debug; + +use Koha::DateUtils qw( dt_from_string ); + use URI::Escape; sub Init{ @@ -123,10 +126,10 @@ $template->param('borrowernumber' => $borrowernumber); if ( $op =~ /save/i ) { if ( $suggestion_only->{"STATUS"} ) { if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { - $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = C4::Dates->today; + $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string; $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" } = C4::Context->userenv->{number}; } - $suggestion_only->{"manageddate"} = C4::Dates->today; + $suggestion_only->{manageddate} = dt_from_string; $suggestion_only->{"managedby"} = C4::Context->userenv->{number}; } if ( $suggestion_only->{'suggestionid'} > 0 ) { @@ -167,14 +170,14 @@ elsif ($op eq "change" ) { # set accepted/rejected/managed informations if applicable # ie= if the librarian has choosen some action on the suggestions if ($suggestion_only->{"STATUS"} eq "ACCEPTED"){ - $suggestion_only->{"accepteddate"}=C4::Dates->today; + $suggestion_only->{accepteddate} = dt_from_string; $suggestion_only->{"acceptedby"}=C4::Context->userenv->{number}; } elsif ($suggestion_only->{"STATUS"} eq "REJECTED"){ - $suggestion_only->{"rejecteddate"}=C4::Dates->today; + $suggestion_only->{rejecteddate} = dt_from_string; $suggestion_only->{"rejectedby"}=C4::Context->userenv->{number}; } if ($suggestion_only->{"STATUS"}){ - $suggestion_only->{"manageddate"}=C4::Dates->today; + $suggestion_only->{manageddate} = dt_from_string; $suggestion_only->{"managedby"}=C4::Context->userenv->{number}; } if ( my $reason = $$suggestion_ref{"reason$tabcode"}){ -- 1.9.1