From dc18719e3a46a30111de43f8b3a510649a678a36 Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Thu, 15 Mar 2012 14:59:24 +0100 Subject: [PATCH] Bug 7086 : "suggested by" fixed for staff members Now: - suggested by is stored when a staff member makes a suggestion - managed by is only updated when a suggestion is edited (not when it is created) Signed-off-by: Jared Camins-Esakov Signed-off-by: Paul Poulain --- suggestion/suggestion.pl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 64f00d49d3..c0dc72f8be 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -34,20 +34,26 @@ use C4::Debug; sub Init{ my $suggestion= shift @_; - foreach my $date ( qw(suggesteddate manageddate) ){ - $suggestion->{$date}=(($suggestion->{$date} eq "0000-00-00" ||$suggestion->{$date} eq "")? - $suggestion->{$date}=C4::Dates->today: - format_date($suggestion->{$date}) - ); - } + # "Managed by" is used only when a suggestion is being edited (not when created) + if ($suggestion->{'suggesteddate'} eq "0000-00-00" ||$suggestion->{'suggesteddate'} eq "") { + # new suggestion + $suggestion->{'suggesteddate'} = C4::Dates->today; + $suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'}); + } + else { + # editing of an existing suggestion + $suggestion->{'manageddate'} = C4::Dates->today; + warn $suggestion->{'manageddate'}; + $suggestion->{'managedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'managedby'}); + # suggesteddate, when coming from the DB, needs to be formated + $suggestion->{'suggesteddate'} = format_date($suggestion->{'suggesteddate'}); + } foreach my $date ( qw(rejecteddate accepteddate) ){ $suggestion->{$date}=(($suggestion->{$date} eq "0000-00-00" ||$suggestion->{$date} eq "")? "": format_date($suggestion->{$date}) ); - } - $suggestion->{'managedby'}=C4::Context->userenv->{"number"} unless ($suggestion->{'managedby'}); - $suggestion->{'createdby'}=C4::Context->userenv->{"number"} unless ($suggestion->{'createdby'}); + } $suggestion->{'branchcode'}=C4::Context->userenv->{"branch"} unless ($suggestion->{'branchcode'}); } -- 2.39.5