Lines 455-466
sub NewSuggestion {
Link Here
|
455 |
|
455 |
|
456 |
$suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; |
456 |
$suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; |
457 |
|
457 |
|
458 |
my $rs = Koha::Database->new->schema->resultset('Suggestion'); |
458 |
my $suggestion_object = Koha::Suggestion->new( $suggestion )->store; |
459 |
my $new_id = $rs->create($suggestion)->id; |
459 |
my $suggestion_id = $suggestion_object->suggestionid; |
460 |
|
460 |
|
461 |
my $emailpurchasesuggestions = C4::Context->preference("EmailPurchaseSuggestions"); |
461 |
my $emailpurchasesuggestions = C4::Context->preference("EmailPurchaseSuggestions"); |
462 |
if ($emailpurchasesuggestions) { |
462 |
if ($emailpurchasesuggestions) { |
463 |
my $full_suggestion = GetSuggestion( $new_id ); |
463 |
my $full_suggestion = GetSuggestion( $suggestion_id); # We should not need to refetch it! |
464 |
if ( |
464 |
if ( |
465 |
my $letter = C4::Letters::GetPreparedLetter( |
465 |
my $letter = C4::Letters::GetPreparedLetter( |
466 |
module => 'suggestions', |
466 |
module => 'suggestions', |
Lines 506-512
sub NewSuggestion {
Link Here
|
506 |
} |
506 |
} |
507 |
} |
507 |
} |
508 |
|
508 |
|
509 |
return $new_id; |
509 |
return $suggestion_id; |
510 |
} |
510 |
} |
511 |
|
511 |
|
512 |
=head2 ModSuggestion |
512 |
=head2 ModSuggestion |
Lines 543-551
sub ModSuggestion {
Link Here
|
543 |
or $suggestion->{$field} eq '' ); |
543 |
or $suggestion->{$field} eq '' ); |
544 |
} |
544 |
} |
545 |
|
545 |
|
546 |
my $rs = Koha::Database->new->schema->resultset('Suggestion')->find($suggestion->{suggestionid}); |
546 |
my $suggestion_object = Koha::Suggestions->find( $suggestion->{suggestionid} ); |
547 |
eval { # FIXME Must raise an exception instead |
547 |
eval { # FIXME Must raise an exception instead |
548 |
$rs->update($suggestion); |
548 |
$suggestion_object->set($suggestion)->store; |
549 |
}; |
549 |
}; |
550 |
return 0 if $@; |
550 |
return 0 if $@; |
551 |
|
551 |
|
552 |
- |
|
|