Lines 22-28
use Modern::Perl;
Link Here
|
22 |
use Clone 'clone'; |
22 |
use Clone 'clone'; |
23 |
use File::Basename qw( basename ); |
23 |
use File::Basename qw( basename ); |
24 |
use Encode qw( encode ); |
24 |
use Encode qw( encode ); |
25 |
use Mail::Sendmail; |
|
|
26 |
use Try::Tiny; |
25 |
use Try::Tiny; |
27 |
use DateTime; |
26 |
use DateTime; |
28 |
|
27 |
|
Lines 40-45
use Koha::Biblios;
Link Here
|
40 |
use Koha::Items; |
39 |
use Koha::Items; |
41 |
use Koha::ItemTypes; |
40 |
use Koha::ItemTypes; |
42 |
use Koha::Libraries; |
41 |
use Koha::Libraries; |
|
|
42 |
|
43 |
use C4::Circulation qw( CanBookBeIssued AddIssue ); |
43 |
use C4::Circulation qw( CanBookBeIssued AddIssue ); |
44 |
|
44 |
|
45 |
use base qw(Koha::Object); |
45 |
use base qw(Koha::Object); |
Lines 1284-1290
attempts to submit the email.
Link Here
|
1284 |
|
1284 |
|
1285 |
sub generic_confirm { |
1285 |
sub generic_confirm { |
1286 |
my ( $self, $params ) = @_; |
1286 |
my ( $self, $params ) = @_; |
1287 |
my $branch = Koha::Libraries->find($params->{current_branchcode}) |
1287 |
my $library = Koha::Libraries->find($params->{current_branchcode}) |
1288 |
|| die "Invalid current branchcode. Are you logged in as the database user?"; |
1288 |
|| die "Invalid current branchcode. Are you logged in as the database user?"; |
1289 |
if ( !$params->{stage}|| $params->{stage} eq 'init' ) { |
1289 |
if ( !$params->{stage}|| $params->{stage} eq 'init' ) { |
1290 |
my $draft->{subject} = "ILL Request"; |
1290 |
my $draft->{subject} = "ILL Request"; |
Lines 1309-1315
Kind Regards
Link Here
|
1309 |
|
1309 |
|
1310 |
EOF |
1310 |
EOF |
1311 |
|
1311 |
|
1312 |
my @address = map { $branch->$_ } |
1312 |
my @address = map { $library->$_ } |
1313 |
qw/ branchname branchaddress1 branchaddress2 branchaddress3 |
1313 |
qw/ branchname branchaddress1 branchaddress2 branchaddress3 |
1314 |
branchzip branchcity branchstate branchcountry branchphone |
1314 |
branchzip branchcity branchstate branchcountry branchphone |
1315 |
branchemail /; |
1315 |
branchemail /; |
Lines 1346-1372
EOF
Link Here
|
1346 |
"No target email addresses found. Either select at least one partner or check your ILL partner library records.") |
1346 |
"No target email addresses found. Either select at least one partner or check your ILL partner library records.") |
1347 |
if ( !$to ); |
1347 |
if ( !$to ); |
1348 |
# Create the from, replyto and sender headers |
1348 |
# Create the from, replyto and sender headers |
1349 |
my $from = $branch->branchemail; |
1349 |
my $from = $library->branchemail; |
1350 |
my $replyto = $branch->branchreplyto || $from; |
1350 |
my $reply_to = $library->branchreplyto || $from; |
1351 |
Koha::Exceptions::Ill::NoLibraryEmail->throw( |
1351 |
Koha::Exceptions::Ill::NoLibraryEmail->throw( |
1352 |
"Your library has no usable email address. Please set it.") |
1352 |
"Your library has no usable email address. Please set it.") |
1353 |
if ( !$from ); |
1353 |
if ( !$from ); |
1354 |
|
1354 |
|
1355 |
# Create the email |
1355 |
# Create the email |
1356 |
my $message = Koha::Email->new; |
1356 |
my $email = Koha::Email->create( |
1357 |
my %mail = $message->create_message_headers( |
|
|
1358 |
{ |
1357 |
{ |
1359 |
to => $to, |
1358 |
to => $to, |
1360 |
from => $from, |
1359 |
from => $from, |
1361 |
replyto => $replyto, |
1360 |
reply_to => $reply_to, |
1362 |
subject => Encode::encode( "utf8", $params->{subject} ), |
1361 |
subject => $params->{subject}, |
1363 |
message => Encode::encode( "utf8", $params->{body} ), |
1362 |
text_body => $params->{body}, |
1364 |
contenttype => 'text/plain', |
|
|
1365 |
} |
1363 |
} |
1366 |
); |
1364 |
); |
|
|
1365 |
|
1367 |
# Send it |
1366 |
# Send it |
1368 |
my $result = sendmail(%mail); |
1367 |
try { |
1369 |
if ( $result ) { |
1368 |
|
|
|
1369 |
$email->send_or_die({ transport => $library->smtp_server->transport }); |
1370 |
|
1370 |
$self->status("GENREQ")->store; |
1371 |
$self->status("GENREQ")->store; |
1371 |
$self->_backend_capability( |
1372 |
$self->_backend_capability( |
1372 |
'set_requested_partners', |
1373 |
'set_requested_partners', |
Lines 1383-1397
EOF
Link Here
|
1383 |
stage => 'commit', |
1384 |
stage => 'commit', |
1384 |
next => 'illview', |
1385 |
next => 'illview', |
1385 |
}; |
1386 |
}; |
1386 |
} else { |
1387 |
} |
|
|
1388 |
catch { |
1387 |
return { |
1389 |
return { |
1388 |
error => 1, |
1390 |
error => 1, |
1389 |
status => 'email_failed', |
1391 |
status => 'email_failed', |
1390 |
message => $Mail::Sendmail::error, |
1392 |
message => "$_", |
1391 |
method => 'generic_confirm', |
1393 |
method => 'generic_confirm', |
1392 |
stage => 'draft', |
1394 |
stage => 'draft', |
1393 |
}; |
1395 |
}; |
1394 |
} |
1396 |
}; |
1395 |
} else { |
1397 |
} else { |
1396 |
die "Unknown stage, should not have happened." |
1398 |
die "Unknown stage, should not have happened." |
1397 |
} |
1399 |
} |
1398 |
- |
|
|