From d3df54d05245b3fa11f052b4c09104bdd2531e31 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 13 Nov 2010 16:27:47 -0500 Subject: [PATCH] bug 4211: ensure that suggestion emails have full details Because of how the ModFoo routines work, if you are only changing selected columns but are also using the change as a trigger to place a message in the queue, you need to fetch the full row before generating the message. Signed-off-by: Galen Charlton --- C4/Suggestions.pm | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index d4529cb820..5ea6c77a9c 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -379,20 +379,22 @@ Note that there is no function to modify a suggestion. sub ModSuggestion { my ($suggestion)=@_; my $status_update_table=UpdateInTable("suggestions", $suggestion); -# check mail sending. - if ($$suggestion{STATUS}){ - my $letter=C4::Letters::getletter('suggestions',$suggestion->{STATUS}); - if ($letter){ - C4::Letters::parseletter($letter, 'branches', $suggestion->{branchcode}); - C4::Letters::parseletter($letter, 'borrowers', $suggestion->{suggestedby}); - C4::Letters::parseletter($letter, 'suggestions', $suggestion->{suggestionid}); - C4::Letters::parseletter($letter, 'biblio', $suggestion->{biblionumber}); + + if ($suggestion->{STATUS}) { + # fetch the entire updated suggestion so that we can populate the letter + my $full_suggestion = GetSuggestion($suggestion->{suggestionid}); + my $letter = C4::Letters::getletter('suggestions', $full_suggestion->{STATUS}); + if ($letter) { + C4::Letters::parseletter($letter, 'branches', $full_suggestion->{branchcode}); + C4::Letters::parseletter($letter, 'borrowers', $full_suggestion->{suggestedby}); + C4::Letters::parseletter($letter, 'suggestions', $full_suggestion->{suggestionid}); + C4::Letters::parseletter($letter, 'biblio', $full_suggestion->{biblionumber}); my $enqueued = C4::Letters::EnqueueLetter({ - letter=>$letter, - borrowernumber=>$suggestion->{suggestedby}, - suggestionid=>$suggestion->{suggestionid}, - LibraryName => C4::Context->preference("LibraryName"), - message_transport_type=>'email' + letter => $letter, + borrowernumber => $full_suggestion->{suggestedby}, + suggestionid => $full_suggestion->{suggestionid}, + LibraryName => C4::Context->preference("LibraryName"), + message_transport_type => 'email', }); if (!$enqueued){warn "can't enqueue letter $letter";} } -- 2.39.5