Lines 925-954
sub EnqueueLetter {
Link Here
|
925 |
); |
925 |
); |
926 |
} |
926 |
} |
927 |
|
927 |
|
928 |
my $dbh = C4::Context->dbh(); |
928 |
my $message = Koha::Notice::Message->new( |
929 |
my $statement = << 'ENDSQL'; |
929 |
{ |
930 |
INSERT INTO message_queue |
930 |
letter_id => $params->{letter}->{id} || undef, |
931 |
( letter_id, borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type, failure_code ) |
931 |
borrowernumber => $params->{borrowernumber}, |
932 |
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, CAST(NOW() AS DATETIME), ?, ?, ?, ?, ? ) |
932 |
subject => $params->{letter}->{title}, |
933 |
ENDSQL |
933 |
content => $params->{letter}->{content}, |
934 |
|
934 |
metadata => $params->{letter}->{metadata} || q{}, |
935 |
my $sth = $dbh->prepare($statement); |
935 |
letter_code => $params->{letter}->{code} || q{}, |
936 |
my $result = $sth->execute( |
936 |
message_transport_type => $params->{message_transport_type}, |
937 |
$params->{letter}->{id} || undef, # letter.id |
937 |
status => 'pending', |
938 |
$params->{'borrowernumber'}, # borrowernumber |
938 |
time_queued => dt_from_string(), |
939 |
$params->{'letter'}->{'title'}, # subject |
939 |
to_address => $params->{to_address}, |
940 |
$params->{'letter'}->{'content'}, # content |
940 |
from_address => $params->{from_address}, |
941 |
$params->{'letter'}->{'metadata'} || '', # metadata |
941 |
reply_address => $params->{reply_address}, |
942 |
$params->{'letter'}->{'code'} || '', # letter_code |
942 |
content_type => $params->{letter}->{'content-type'}, |
943 |
$params->{'message_transport_type'}, # message_transport_type |
943 |
failure_code => $params->{failure_code} || q{}, |
944 |
'pending', # status |
944 |
} |
945 |
$params->{'to_address'}, # to_address |
945 |
)->store(); |
946 |
$params->{'from_address'}, # from_address |
946 |
return $message->id; |
947 |
$params->{'reply_address'}, # reply_address |
|
|
948 |
$params->{'letter'}->{'content-type'}, # content_type |
949 |
$params->{'failure_code'} || '', # failure_code |
950 |
); |
951 |
return $dbh->last_insert_id(undef,undef,'message_queue', undef); |
952 |
} |
947 |
} |
953 |
|
948 |
|
954 |
=head2 SendQueuedMessages ([$hashref]) |
949 |
=head2 SendQueuedMessages ([$hashref]) |
955 |
- |
|
|