use C4::Overdues;
use Koha::DateUtils;
use C4::Log;
+use Koha::Items;
+use Koha::Libraries;
+use Koha::Patrons;
=head1 NAME
comma separated list of fields that get substituted into templates in
places of the E<lt>E<lt>items.contentE<gt>E<gt> placeholder. This
-defaults to due date,title,author,barcode
+defaults to date_due,title,author,barcode
Other possible values come from fields in the biblios, items and
issues tables.
=item E<lt>E<lt>items.contentE<gt>E<gt>
one line for each item, each line containing a tab separated list of
-title, author, barcode, issuedate
+date due, title, author, barcode
=item E<lt>E<lt>borrowers.*E<gt>E<gt>
The F<misc/cronjobs/overdue_notices.pl> program allows you to send
messages to patrons when their messages are overdue.
+
=cut
binmode( STDOUT, ':encoding(UTF-8)' );
'itemscontent=s' => \$itemscontent,
)or pod2usage(2);
pod2usage(1) if $help;
-pod2usage( -verbose => 2 ) if $man;;
+pod2usage( -verbose => 2 ) if $man;
# Since advance notice options are not visible in the web-interface
# unless EnhancedMessagingPreferences is on, let the user know that
$due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
$due_digest->{ $upcoming->{borrowernumber} }->{count}++;
} else {
- my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
+ my $item = Koha::Items->find( $upcoming->{itemnumber} );
my $letter_type = 'DUE';
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0');
my $titles = "";
while ( my $item_info = $sth->fetchrow_hashref()) {
- my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields;
- $titles .= join("\t",@item_info) . "\n";
+ $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields } );
}
## Get branch info for borrowers home library.
my $letter = parse_letter( { letter_code => $letter_type,
borrowernumber => $upcoming->{'borrowernumber'},
branchcode => $upcoming->{'branchcode'},
- biblionumber => $biblio->{'biblionumber'},
+ biblionumber => $item->biblionumber,
itemnumber => $upcoming->{'itemnumber'},
substitute => { 'items.content' => $titles },
message_transport_type => $transport,
$upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address;
$upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++;
} else {
- my $biblio = C4::Biblio::GetBiblioFromItemNumber( $upcoming->{'itemnumber'} );
+ my $item = Koha::Items->find( $upcoming->{itemnumber} );
my $letter_type = 'PREDUE';
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'});
my $titles = "";
while ( my $item_info = $sth->fetchrow_hashref()) {
- my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields;
- $titles .= join("\t",@item_info) . "\n";
+ $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields } );
}
## Get branch info for borrowers home library.
my $letter = parse_letter( { letter_code => $letter_type,
borrowernumber => $upcoming->{'borrowernumber'},
branchcode => $upcoming->{'branchcode'},
- biblionumber => $biblio->{'biblionumber'},
+ biblionumber => $item->biblionumber,
itemnumber => $upcoming->{'itemnumber'},
substitute => { 'items.content' => $titles },
message_transport_type => $transport,
$sth->execute($borrowernumber,$borrower_preferences->{'days_in_advance'});
my $titles = "";
while ( my $item_info = $sth->fetchrow_hashref()) {
- my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields;
- $titles .= join("\t",@item_info) . "\n";
+ $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields } );
}
## Get branch info for borrowers home library.
$sth->execute($borrowernumber,'0');
my $titles = "";
while ( my $item_info = $sth->fetchrow_hashref()) {
- my @item_info = map { $_ =~ /^date|date$/ ? format_date($item_info->{$_}) : $item_info->{$_} || '' } @item_content_fields;
- $titles .= join("\t",@item_info) . "\n";
+ $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields } );
}
## Get branch info for borrowers home library.
foreach my $required ( qw( letter_code borrowernumber ) ) {
return unless exists $params->{$required};
}
+ my $patron = Koha::Patrons->find( $params->{borrowernumber} );
my %table_params = ( 'borrowers' => $params->{'borrowernumber'} );
module => 'circulation',
letter_code => $params->{'letter_code'},
branchcode => $table_params{'branches'},
+ lang => $patron->lang,
substitute => $params->{'substitute'},
tables => \%table_params,
message_transport_type => $params->{message_transport_type},
);
}
-sub format_date {
- my $date_string = shift;
- my $dt=dt_from_string($date_string);
- return output_pref($dt);
-}
-
=head2 get_branch_info
=cut
my ( $borrowernumber ) = @_;
## Get branch info for borrowers home library.
- my $borrower_details = C4::Members::GetMember( borrowernumber => $borrowernumber );
- my $borrower_branchcode = $borrower_details->{'branchcode'};
- my $branch = C4::Branch::GetBranchDetail( $borrower_branchcode );
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ my $branch = $patron->library->unblessed;
my %branch_info;
foreach my $key( keys %$branch ) {
$branch_info{"branches.$key"} = $branch->{$key};