|
Lines 454-460
sub NewSuggestion {
Link Here
|
| 454 |
$suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; |
454 |
$suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; |
| 455 |
|
455 |
|
| 456 |
my $rs = Koha::Database->new->schema->resultset('Suggestion'); |
456 |
my $rs = Koha::Database->new->schema->resultset('Suggestion'); |
| 457 |
return $rs->create($suggestion)->id; |
457 |
my $new_id = $rs->create($suggestion)->id; |
|
|
458 |
|
| 459 |
my $full_suggestion = GetSuggestion( $new_id ); |
| 460 |
if ( |
| 461 |
my $letter = C4::Letters::GetPreparedLetter( |
| 462 |
module => 'suggestions', |
| 463 |
letter_code => 'NEW_SUGGESTION', |
| 464 |
tables => { |
| 465 |
'branches' => $full_suggestion->{branchcode}, |
| 466 |
'borrowers' => $full_suggestion->{suggestedby}, |
| 467 |
'suggestions' => $full_suggestion, |
| 468 |
}, |
| 469 |
) |
| 470 |
){ |
| 471 |
my $emailpurchasesuggestions = C4::Context->preference("EmailPurchaseSuggestions"); |
| 472 |
|
| 473 |
my $toaddress = ( $emailpurchasesuggestions eq "BranchEmailAddress" ) |
| 474 |
? Koha::Libraries->find($full_suggestion->{branchcode})->branchemail |
| 475 |
: C4::Context->preference( $emailpurchasesuggestions ) ; |
| 476 |
|
| 477 |
C4::Letters::EnqueueLetter( |
| 478 |
{ |
| 479 |
letter => $letter, |
| 480 |
borrowernumber => $full_suggestion->{suggestedby}, |
| 481 |
suggestionid => $full_suggestion->{suggestionid}, |
| 482 |
to_address => $toaddress, |
| 483 |
message_transport_type => 'email', |
| 484 |
} |
| 485 |
) or warn "can't enqueue letter $letter"; |
| 486 |
} |
| 487 |
|
| 488 |
return $new_id; |
| 458 |
} |
489 |
} |
| 459 |
|
490 |
|
| 460 |
=head2 ModSuggestion |
491 |
=head2 ModSuggestion |