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

(-)a/basket/sendbasket.pl (-19 / +2 lines)
Lines 17-24 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use CGI qw ( -utf8 );
20
use CGI       qw ( -utf8 );
21
use Encode;
22
use Carp      qw( carp );
21
use Carp      qw( carp );
23
use Try::Tiny qw( catch try );
22
use Try::Tiny qw( catch try );
24
23
Lines 56-72 if ( $op eq "cud-send" && $email_add ) { Link Here
56
    my $comment = $query->param('comment');
55
    my $comment = $query->param('comment');
57
56
58
    my @bibs = split( /\//, $bib_list );
57
    my @bibs = split( /\//, $bib_list );
59
    my $iso2709;
60
58
61
    foreach my $bib (@bibs) {
59
    if ( !defined $user_email or $user_email eq '' ) {
62
        my $biblio = Koha::Biblios->find($bib) or next;
63
        $iso2709 .= $biblio->metadata_record()->as_usmarc();
64
    }
65
66
    if ( !defined $iso2709 ) {
67
        carp "Error sending mail: empty basket";
68
        $template->param( error => 1 );
69
    } elsif ( !defined $user_email or $user_email eq '' ) {
70
        carp "Error sending mail: sender's email address is invalid";
60
        carp "Error sending mail: sender's email address is invalid";
71
        $template->param( error => 1 );
61
        $template->param( error => 1 );
72
    } else {
62
    } else {
Lines 86-104 if ( $op eq "cud-send" && $email_add ) { Link Here
86
            substitute             => \%substitute,
76
            substitute             => \%substitute,
87
        );
77
        );
88
78
89
        my $attachment = {
90
            filename => 'basket.iso2709',
91
            type     => 'application/octet-stream',
92
            content  => Encode::encode( "UTF-8", $iso2709 ),
93
        };
94
95
        my $message_id = C4::Letters::EnqueueLetter(
79
        my $message_id = C4::Letters::EnqueueLetter(
96
            {
80
            {
97
                letter                 => $letter,
81
                letter                 => $letter,
98
                message_transport_type => 'email',
82
                message_transport_type => 'email',
99
                to_address             => $email_add,
83
                to_address             => $email_add,
100
                reply_address          => $user_email,
84
                reply_address          => $user_email,
101
                attachments            => [$attachment],
102
            }
85
            }
103
        );
86
        );
104
87
(-)a/opac/opac-sendbasket.pl (-44 / +25 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use Encode;
24
23
25
use C4::Auth   qw( get_template_and_user );
24
use C4::Auth   qw( get_template_and_user );
26
use C4::Biblio qw(GetMarcSubjects);
25
use C4::Biblio qw(GetMarcSubjects);
Lines 50-101 if ( $op eq "cud-send" && $email_add && $user_email ) { Link Here
50
    my $comment = $query->param('comment');
49
    my $comment = $query->param('comment');
51
50
52
    my @bibs = split( /\//, $bib_list );
51
    my @bibs = split( /\//, $bib_list );
53
    my $iso2709;
54
    foreach my $bib (@bibs) {
55
        $bib = int($bib);
56
        my $biblio = Koha::Biblios->find($bib) or next;
57
        $iso2709 .= $biblio->metadata_record( { interface => 'opac' } )->as_usmarc();
58
    }
59
52
60
    if ( !defined $iso2709 ) {
53
    my %loops = ( biblio => \@bibs, );
61
        $template->param( error => 'NO_BODY' );
54
62
    } else {
55
    my %substitute = ( comment => $comment, );
63
        my %loops = ( biblio => \@bibs, );
64
56
65
        my %substitute = ( comment => $comment, );
57
    my $letter = C4::Letters::GetPreparedLetter(
58
        module      => 'catalogue',
59
        letter_code => 'CART',
60
        lang        => $patron->lang,
61
        tables      => {
62
            borrowers => $borrowernumber,
63
        },
64
        message_transport_type => 'email',
65
        loops                  => \%loops,
66
        substitute             => \%substitute,
67
    );
66
68
67
        my $letter = C4::Letters::GetPreparedLetter(
69
    my $message_id = C4::Letters::EnqueueLetter(
68
            module      => 'catalogue',
70
        {
69
            letter_code => 'CART',
71
            letter                 => $letter,
70
            lang        => $patron->lang,
71
            tables      => {
72
                borrowers => $borrowernumber,
73
            },
74
            message_transport_type => 'email',
72
            message_transport_type => 'email',
75
            loops                  => \%loops,
73
            to_address             => $email_add,
76
            substitute             => \%substitute,
74
            reply_address          => $user_email,
77
        );
75
        }
78
76
    );
79
        my $attachment = {
77
80
            filename => 'basket.iso2709',
78
    C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id;
81
            type     => 'application/octet-stream',
79
82
            content  => Encode::encode( "UTF-8", $iso2709 ),
80
    $template->param( SENT => 1 );
83
        };
84
85
        my $message_id = C4::Letters::EnqueueLetter(
86
            {
87
                letter                 => $letter,
88
                message_transport_type => 'email',
89
                to_address             => $email_add,
90
                reply_address          => $user_email,
91
                attachments            => [$attachment],
92
            }
93
        );
94
95
        C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id;
96
97
        $template->param( SENT => 1 );
98
    }
99
81
100
    $template->param( email_add => $email_add );
82
    $template->param( email_add => $email_add );
101
    output_html_with_http_headers $query, $cookie, $template->output, undef,
83
    output_html_with_http_headers $query, $cookie, $template->output, undef,
102
- 

Return to bug 2172