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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 3642-3648 sub SendCirculationAlert { Link Here
3642
        my $message = C4::Message->find_last_message($borrower, $type, $mtt);
3642
        my $message = C4::Message->find_last_message($borrower, $type, $mtt);
3643
        unless ( $message ) {
3643
        unless ( $message ) {
3644
            C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3644
            C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3645
            C4::Message->enqueue($letter, $borrower, $mtt);
3645
            my $patron = Koha::Patrons->find($borrower->{borrowernumber});
3646
            C4::Message->enqueue($letter, $patron, $mtt);
3646
        } else {
3647
        } else {
3647
            $message->append($letter);
3648
            $message->append($letter);
3648
            $message->update;
3649
            $message->update;
(-)a/C4/Message.pm (-21 / +24 lines)
Lines 157-197 the message. Link Here
157
157
158
# C4::Message->enqueue($letter, $borrower, $transport)
158
# C4::Message->enqueue($letter, $borrower, $transport)
159
sub enqueue {
159
sub enqueue {
160
    my ($class, $letter, $borrower, $transport) = @_;
160
    my ( $class, $letter, $patron, $transport ) = @_;
161
    my $metadata   = _metadata($letter);
161
    my $metadata   = _metadata($letter);
162
    my $to_address = _to_address($borrower, $transport);
162
    my $to_address = _to_address( $patron, $transport );
163
163
164
    # Same as render_metadata
164
    # Same as render_metadata
165
    my $format ||= sub { $_[0] || "" };
165
    my $format ||= sub { $_[0] || "" };
166
    my $body = join('', map { $format->($_) } @{$metadata->{body}});
166
    my $body = join( '', map { $format->($_) } @{ $metadata->{body} } );
167
    $letter->{content} = $metadata->{header} . $body . $metadata->{footer};
167
    $letter->{content} = $metadata->{header} . $body . $metadata->{footer};
168
168
169
    $letter->{metadata} = Encode::decode_utf8(Dump($metadata));
169
    $letter->{metadata} = Encode::decode_utf8( Dump($metadata) );
170
    C4::Letters::EnqueueLetter({
170
    C4::Letters::EnqueueLetter(
171
        letter                 => $letter,
171
        {
172
        borrowernumber         => $borrower->{borrowernumber},
172
            letter                 => $letter,
173
        message_transport_type => $transport,
173
            borrowernumber         => $patron->id,
174
        to_address             => $to_address,
174
            message_transport_type => $transport,
175
    });
175
            to_address             => $to_address,
176
        }
177
    );
176
}
178
}
177
179
178
# based on message $transport, pick an appropriate address to send to
180
# based on message $transport, pick an appropriate address to send to
179
sub _to_address {
181
sub _to_address {
180
    my ($borrower, $transport) = @_;
182
    my ( $patron, $transport ) = @_;
181
    my $address;
183
    my $address;
182
    if ($transport eq 'email') {
184
    if ( $transport eq 'email' ) {
183
        $address = $borrower->{email}
185
        $address = $patron->notice_email_address;
184
            || $borrower->{emailpro}
186
    }
185
            || $borrower->{B_email};
187
    elsif ( $transport eq 'sms' ) {
186
    } elsif ($transport eq 'sms') {
188
        $address = $patron->smsalertnumber;
187
        $address = $borrower->{smsalertnumber};
189
    }
188
    } else {
190
    else {
189
        warn "'$transport' is an unknown message transport.";
191
        warn "'$transport' is an unknown message transport.";
190
    }
192
    }
191
    if (not defined $address) {
193
    if ( not defined $address ) {
192
        warn "An appropriate $transport address "
194
        warn "An appropriate $transport address "
193
            . "for borrower $borrower->{userid} "
195
          . "for borrower "
194
            . "could not be found.";
196
          . $patron->userid
197
          . "could not be found.";
195
    }
198
    }
196
    return $address;
199
    return $address;
197
}
200
}
(-)a/Koha/Recall.pm (-1 / +1 lines)
Lines 358-364 sub set_waiting { Link Here
358
        },
358
        },
359
    );
359
    );
360
360
361
    C4::Message->enqueue($letter, $self->patron->unblessed, 'email');
361
    C4::Message->enqueue($letter, $self->patron, 'email');
362
362
363
    return $self;
363
    return $self;
364
}
364
}
(-)a/Koha/Recalls.pm (-2 / +1 lines)
Lines 161-167 sub add_recall { Link Here
161
            },
161
            },
162
        );
162
        );
163
163
164
        C4::Message->enqueue( $letter, $checkout->patron->unblessed, 'email' );
164
        C4::Message->enqueue( $letter, $checkout->patron, 'email' );
165
165
166
        $item = Koha::Items->find( $itemnumber );
166
        $item = Koha::Items->find( $itemnumber );
167
        # add to statistics table
167
        # add to statistics table
168
- 

Return to bug 18398