View | Details | Raw Unified | Return to bug 19412
Collapse All | Expand All

(-)a/C4/Letters.pm (+43 lines)
Lines 364-369 sub findrelatedto { Link Here
364
    return $result;
364
    return $result;
365
}
365
}
366
366
367
=head2 SendSuggestionEmail
368
369
370
371
=cut
372
373
sub SendSuggestionEmail {
374
    my ($type, $suggestion, $borrower_email_address, $code, ) = @_;
375
    my $library = Koha::Libraries->find( $_->{branchcode} );
376
    my $userenv = C4::Context->userenv;
377
    my $letter = GetPreparedLetter (
378
        module => 'suggestions',
379
        letter_code => $code,
380
        branchcode => $userenv->{branch},
381
        tables => {
382
            'suggestions' => $suggestion->{suggestionid},
383
        },
384
        want_librarian => 1,
385
    ) or return { error => "no_letter" };
386
387
    my $mail = Koha:;Email->new();
388
    my %mail = $email->create_message_headers (
389
        {
390
            to => $borrower_email_address,
391
            from => $library->{branchemail} || C4::Context->preference('KohaAdminEmailAddress'),
392
            replyto => $library->{branchreplyto},
393
            sender => $library->{branchreturnpath},
394
            Subject => Encode::encode( "UTF-8", "" . $letter->{title} ),
395
            Message => $letter->{'is_html'}
396
                            ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
397
                                          Encode::encode( "UTF-8", "" . $letter->{'title'} ))
398
                            : Encode::encode( "UTF-8", "" . $letter->{'content'} ),
399
            'Content-Type' => $letter->{'is_html'}
400
                              ? 'text/html; charset="utf-8"'
401
                              : 'text/plain; charset="utf-8"',
402
    );
403
    unless ( sendmail(%mail) ) {
404
        carp $Mail::Sendmail::error;
405
        return { error  => $Mail::Sendmail::error };
406
    }
407
}
408
409
367
=head2 SendAlerts
410
=head2 SendAlerts
368
411
369
    my $err = &SendAlerts($type, $externalid, $letter_code);
412
    my $err = &SendAlerts($type, $externalid, $letter_code);
(-)a/Koha/Patron.pm (+17 lines)
Lines 660-665 sub account_locked { Link Here
660
660
661
=cut
661
=cut
662
662
663
=head3 find_borrower_with_borrowernumber
664
my $borrower_email_address = Koha::Patron->find_borrower_with_borrowernumber( $borrower_number );
665
666
This subroutine will return the email address assoicated with the borrower number parameter handed to this subroutine by opac-suggestions.pl
667
=cut
668
669
sub find_borrower_with_borrowernumber {
670
    my ($borrower_number) = @_;
671
    my $dbh = C4::Context->dbh();
672
    my $borrower_email_sth = $dbh->prepare( 'SELECT email FROM borrowers WHERE borrowernumber=?');
673
    $borrower_email_execute = $borrower_email_sth->execute( $borrower_number );
674
    return $borrower_email_execute;
675
}
676
677
678
663
sub _type {
679
sub _type {
664
    return 'Borrower';
680
    return 'Borrower';
665
}
681
}
Lines 668-673 sub _type { Link Here
668
684
669
Kyle M Hall <kyle@bywatersolutions.com>
685
Kyle M Hall <kyle@bywatersolutions.com>
670
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
686
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
687
Alex Buckley <alexbuckley@catalyst.net.nz>
671
688
672
=cut
689
=cut
673
690
(-)a/installer/data/mysql/atomicupdate/bug-19412_-_Add_System_preferences_for_emailing_suggestions.sql (+3 lines)
Line 0 Link Here
1
INSERT INTO systempreferences (variable, explanation, type) VALUES ('EmailSuggestionsToBorrower', 'Input the borrower number of the borrower who will receieve a email for each patron suggestion in the OPAC', 'Free');
2
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('EmailSuggestions', '0', NULL,'If enabled then when a patron submits a suggestion on the OPAC then it will be emailed to the borrower specified in the syspref EmailSuggestionsToBorrower as well as being displayed on the intranet mainpage', 'YesNo');
3
INSERT INTO letter (module, code, name, is_html, title, content, message_transport_type) VALUES ('suggestions', 'SUGGESTION_SUBMITTED', 'Suggestion submitted', 0, 'Purchase suggestion submitted', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nA new purchase suggestion has been made on the OPAC by <<suggester.firstname>><<suggester.surname>> for: <<suggestions.title>> by <<suggestions.author>>,\n\n<<branches.branchname>>', 'email');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (+9 lines)
Lines 75-80 Acquisitions: Link Here
75
                yes: Send
75
                yes: Send
76
                no: Don't send
76
                no: Don't send
77
            - blind copy (BCC) to logged in user when sending serial or acquisitions claims notices.
77
            - blind copy (BCC) to logged in user when sending serial or acquisitions claims notices.
78
        -
79
            - pref: EmailSuggestionsToBorrower
80
            - Input the borrower number of the borrower who will receieve a email for each patron suggestion in the OPAC
81
        -
82
            - pref: EmailSuggestions
83
              choices:
84
                  yes: Do
85
                  no: "Don't"
86
            - If enabled then when a patron submits a suggestion on the OPAC then it will be emailed to the borrower specified in the syspref EmailSuggestionsToBorrower as well as being displayed on the intranet mainpage
78
87
79
    Printing:
88
    Printing:
80
        -
89
        -
(-)a/opac/opac-suggestions.pl (-1 / +9 lines)
Lines 152-157 if ( $op eq "add_confirm" ) { Link Here
152
        &NewSuggestion($suggestion);
152
        &NewSuggestion($suggestion);
153
        $patrons_pending_suggestions_count++;
153
        $patrons_pending_suggestions_count++;
154
154
155
        #If the EmailSuggestions syspref is enabled then retrieve the email address associated with the borrower number stored in the EmailSuggestionsToBorrower syspref, and send the email to that address
156
        if ( C4::Context->preference("EmailSuggestions") == 1) {
157
            my $borrower_number = C4::Context->preference( "EmailSuggestionsToBorrower" );
158
            my $borrower_email_address = Koha::Patron->find_borrower_with_borrowernumber( $borrower_number );
159
            if ( $borrower_email_adddress ) {
160
                C4::Letters->SendSuggestionEmail( 'suggestions', $suggestion, $borrower_email_address,  'SUGGESTION_SUBMITTED');
161
            }
162
        }
163
155
        # delete empty fields, to avoid filter in "SearchSuggestion"
164
        # delete empty fields, to avoid filter in "SearchSuggestion"
156
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
165
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
157
            delete $suggestion->{$field}; #clear search filters (except borrower related) to show all suggestions after placing a new one
166
            delete $suggestion->{$field}; #clear search filters (except borrower related) to show all suggestions after placing a new one
158
- 

Return to bug 19412