use C4::Members;
use C4::Log;
use C4::SMS;
+use C4::Templates;
use C4::Debug;
use Koha::DateUtils;
use Koha::SMS::Providers;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
- &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &SendAlerts &GetPrintMessages &GetMessageTransportTypes
+ &EnqueueLetter &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &SendAlerts &GetPrintMessages &GetMessageTransportTypes
);
}
sub SendAlerts {
my ( $type, $externalid, $letter_code ) = @_;
my $dbh = C4::Context->dbh;
+ my $error;
+
if ( $type eq 'issue' ) {
# prepare the letter...
$mail->text_body( $letter->{content} );
}
- try {
+ my $success = try {
$mail->send_or_die({ transport => $library->smtp_server->transport });
}
catch {
+ # We expect ref($_) eq 'Email::Sender::Failure'
+ $error = $_->message;
+
carp "$_";
- return { error => "$_" };
+ return;
};
+
+ return { error => $error }
+ unless $success;
}
}
elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' or $type eq 'orderacquisition' ) {
$mail->text_body( "" . $letter->{content} );
}
- try {
+ my $success = try {
$mail->send_or_die({ transport => $library->smtp_server->transport });
}
catch {
+ # We expect ref($_) eq 'Email::Sender::Failure'
+ $error = $_->message;
+
carp "$_";
- return { error => "$_" };
+ return;
};
+ return { error => $error }
+ unless $success;
+
logaction(
"ACQUISITION",
$action,
want_librarian => 1,
) or return;
return { error => "no_email" } unless $externalid->{'emailaddr'};
- try {
+
+ my $success = try {
# FIXME: This 'default' behaviour should be moved to Koha::Email
my $mail = Koha::Email->create(
$mail->send_or_die({ transport => $library->smtp_server->transport });
}
catch {
+ # We expect ref($_) eq 'Email::Sender::Failure'
+ $error = $_->message;
+
carp "$_";
- return { error => "$_" };
+ return;
};
+
+ return { error => $error }
+ unless $success;
}
# If we come here, return an OK status
my %params = @_;
my $letter = $params{letter};
+ my $lang = $params{lang} || 'default';
unless ( $letter ) {
my $module = $params{module} or croak "No module";
my $letter_code = $params{letter_code} or croak "No letter_code";
my $branchcode = $params{branchcode} || '';
my $mtt = $params{message_transport_type} || 'email';
- my $lang = $params{lang} || 'default';
$letter = getletter( $module, $letter_code, $branchcode, $mtt, $lang );
tables => $tables,
loops => $loops,
substitute => $substitute,
+ lang => $lang
}
);
# broke things for the rest of us. prepare_cached is a better
# way to cache statement handles anyway.
my $query =
+ ($table eq 'accountlines' ) ? "SELECT * FROM $table WHERE accountlines_id = ?" :
($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" :
($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" :
+ ($table eq 'credits' ) ? "SELECT * FROM accountlines WHERE accountlines_id = ?" :
+ ($table eq 'debits' ) ? "SELECT * FROM accountlines WHERE accountlines_id = ?" :
($table eq 'items' ) ? "SELECT * FROM $table WHERE itemnumber = ?" :
($table eq 'issues' ) ? "SELECT * FROM $table WHERE itemnumber = ?" :
($table eq 'old_issues' ) ? "SELECT * FROM $table WHERE itemnumber = ? ORDER BY timestamp DESC LIMIT 1" :
# Dates replacement
my $replacedby = defined ($val) ? $val : '';
if ( $replacedby
- and not $replacedby =~ m|0000-00-00|
and not $replacedby =~ m|9999-12-31|
and $replacedby =~ m|^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$| )
{
my $params = shift;
my $which_unsent_messages = {
+ 'message_id' => $params->{'message_id'},
'limit' => $params->{'limit'} // 0,
'borrowernumber' => $params->{'borrowernumber'} // q{},
'letter_code' => $params->{'letter_code'} // q{},
message_transport_type: method of message sending (e.g. email, sms, etc.)
borrowernumber : who the message is to be sent
letter_code : type of message being sent (e.g. PASSWORD_RESET)
+ message_id : the message_id of the message. In that case the sub will return only 1 result
limit : maximum number of messages to send
This function returns an array of matching hash referenced rows from
$statement .= ' AND message_transport_type = ? ';
push @query_params, $params->{'type'};
}
+ if ( $params->{message_id} ) {
+ $statement .= ' AND message_id = ?';
+ push @query_params, $params->{message_id};
+ }
if ( $params->{'limit'} ) {
$statement .= ' limit ? ';
push @query_params, $params->{'limit'};
my $tables = $params->{tables};
my $loops = $params->{loops};
my $substitute = $params->{substitute} || {};
+ my $lang = defined($params->{lang}) && $params->{lang} ne 'default' ? $params->{lang} : 'en';
+ my ($theme, $activethemes);
+
+ my $htdocs = C4::Context->config('intrahtdocs');
+ ($theme, $lang, $activethemes)= C4::Templates::activethemes( $htdocs, 'about.tt', 'intranet', $lang);
+ my @includes;
+ foreach (@$activethemes) {
+ push @includes, "$htdocs/$_/$lang/includes";
+ push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en';
+ }
my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
my $template = Template->new(
PLUGIN_BASE => 'Koha::Template::Plugin',
COMPILE_EXT => $use_template_cache ? '.ttc' : '',
COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '',
+ INCLUDE_PATH => \@includes,
FILTERS => {},
ENCODING => 'UTF-8',
}
plural => 'branches',
pk => 'branchcode',
},
+ credits => {
+ module => 'Koha::Account::Lines',
+ singular => 'credit',
+ plural => 'credits',
+ pk => 'accountlines_id',
+ },
+ debits => {
+ module => 'Koha::Account::Lines',
+ singular => 'debit',
+ plural => 'debits',
+ pk => 'accountlines_id',
+ },
items => {
module => 'Koha::Items',
singular => 'item',