Lines 1889-1911
sub _koha_notify_reserve {
Link Here
|
1889 |
); |
1889 |
); |
1890 |
|
1890 |
|
1891 |
my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message. |
1891 |
my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message. |
|
|
1892 |
my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_TESTING}; |
1892 |
my $send_notification = sub { |
1893 |
my $send_notification = sub { |
1893 |
my ( $mtt, $letter_code ) = (@_); |
1894 |
my ( $mtt, $letter_code, $wants_digest ) = (@_); |
1894 |
return unless defined $letter_code; |
1895 |
return unless defined $letter_code; |
1895 |
$letter_params{letter_code} = $letter_code; |
1896 |
$letter_params{letter_code} = $letter_code; |
1896 |
$letter_params{message_transport_type} = $mtt; |
1897 |
$letter_params{message_transport_type} = $mtt; |
1897 |
my $letter = C4::Letters::GetPreparedLetter ( %letter_params ); |
1898 |
my $letter = C4::Letters::GetPreparedLetter(%letter_params); |
1898 |
unless ($letter) { |
1899 |
unless ($letter) { |
1899 |
warn "Could not find a letter called '$letter_params{'letter_code'}' for $mtt in the 'reserves' module"; |
1900 |
warn "Could not find a letter called '$letter_params{'letter_code'}' for $mtt in the 'reserves' module"; |
1900 |
return; |
1901 |
return; |
1901 |
} |
1902 |
} |
1902 |
|
1903 |
|
1903 |
C4::Letters::EnqueueLetter( { |
1904 |
unless ($wants_digest) { |
1904 |
letter => $letter, |
1905 |
C4::Letters::EnqueueLetter( |
1905 |
borrowernumber => $borrowernumber, |
1906 |
{ |
1906 |
from_address => $from_email_address, |
1907 |
letter => $letter, |
1907 |
message_transport_type => $mtt, |
1908 |
borrowernumber => $borrowernumber, |
1908 |
} ); |
1909 |
from_address => $from_email_address, |
|
|
1910 |
message_transport_type => $mtt, |
1911 |
} |
1912 |
); |
1913 |
} else { |
1914 |
C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $do_not_lock; |
1915 |
C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock; |
1916 |
my $message = C4::Message->find_last_message( $patron->unblessed, $letter_code, $mtt ); |
1917 |
unless ($message) { |
1918 |
C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; |
1919 |
C4::Message->enqueue( $letter, $patron, $mtt ); |
1920 |
} else { |
1921 |
$message->append($letter); |
1922 |
$message->update; |
1923 |
} |
1924 |
C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; |
1925 |
} |
1909 |
}; |
1926 |
}; |
1910 |
|
1927 |
|
1911 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
1928 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
Lines 1916-1922
sub _koha_notify_reserve {
Link Here
|
1916 |
or ( $mtt eq 'phone' and not $patron->phone ) # No phone number to call |
1933 |
or ( $mtt eq 'phone' and not $patron->phone ) # No phone number to call |
1917 |
); |
1934 |
); |
1918 |
|
1935 |
|
1919 |
&$send_notification($mtt, $letter_code); |
1936 |
&$send_notification($mtt, $letter_code, $messagingprefs->{wants_digest}); |
1920 |
$notification_sent++; |
1937 |
$notification_sent++; |
1921 |
} |
1938 |
} |
1922 |
#Making sure that a print notification is sent if no other transport types can be utilized. |
1939 |
#Making sure that a print notification is sent if no other transport types can be utilized. |