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 <gmcharlt@gmail.com>
(cherry picked from commit d3df54d052)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Galen Charlton 2010-11-13 16:27:47 -05:00 committed by Chris Nighswonger
parent 38927a4406
commit 19e494bcd5
1 changed files with 15 additions and 13 deletions

View File

@ -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";}
}