Lines 22-27
use Mojo::Base 'Mojolicious::Controller';
Link Here
|
22 |
use Koha::Database; |
22 |
use Koha::Database; |
23 |
use Koha::Exceptions; |
23 |
use Koha::Exceptions; |
24 |
use Koha::Patrons; |
24 |
use Koha::Patrons; |
|
|
25 |
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); |
25 |
|
26 |
|
26 |
use List::MoreUtils qw(any); |
27 |
use List::MoreUtils qw(any); |
27 |
use Scalar::Util qw( blessed ); |
28 |
use Scalar::Util qw( blessed ); |
Lines 113-118
sub add {
Link Here
|
113 |
my $extended_attributes = delete $body->{extended_attributes} // []; |
114 |
my $extended_attributes = delete $body->{extended_attributes} // []; |
114 |
|
115 |
|
115 |
my $patron = Koha::Patron->new_from_api($body)->store; |
116 |
my $patron = Koha::Patron->new_from_api($body)->store; |
|
|
117 |
|
118 |
if ( $c->req->headers->header('X-Koha-SendWelcomeEmail') ) { |
119 |
|
120 |
# if we manage to find a valid email address, send notice |
121 |
if ( $patron->notice_email_address ) { |
122 |
my $letter = GetPreparedLetter( |
123 |
module => 'members', |
124 |
letter_code => 'WELCOME', |
125 |
branchcode => $patron->branchcode, |
126 |
, |
127 |
lang => $patron->lang || 'default', |
128 |
tables => { |
129 |
'branches' => $patron->branchcode, |
130 |
'borrowers' => $patron->borrowernumber, |
131 |
}, |
132 |
want_librarian => 1, |
133 |
); |
134 |
|
135 |
if ($letter) { |
136 |
my $message_id = EnqueueLetter( |
137 |
{ |
138 |
letter => $letter, |
139 |
borrowernumber => $patron->id, |
140 |
to_address => $patron->notice_email_address, |
141 |
message_transport_type => 'email' |
142 |
} |
143 |
); |
144 |
SendQueuedMessages( { message_id => $message_id } ); |
145 |
} |
146 |
} |
147 |
} |
148 |
|
116 |
$patron->extended_attributes( |
149 |
$patron->extended_attributes( |
117 |
[ |
150 |
[ |
118 |
map { { code => $_->{type}, attribute => $_->{value} } } |
151 |
map { { code => $_->{type}, attribute => $_->{value} } } |
119 |
- |
|
|