Commit b7e35a37 authored by Jesse Weaver's avatar Jesse Weaver Committed by J. David Bavousett

Add expiration date, today to hold notices

This adds the new, virtual placeholders <<today>> and
<<reserves.expirationdate> that can be used in letter templates.
parent 68bbe0d5
......@@ -29,6 +29,9 @@ use C4::Members;
use C4::Log;
use C4::SMS;
use C4::Debug;
use Date::Calc qw( Add_Delta_Days );
use Encode;
use Carp;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
......@@ -519,6 +522,19 @@ sub parseletter {
}
my $values = $sth->fetchrow_hashref;
# TEMPORARY hack until the expirationdate column is added to reserves
if ( $table eq 'reserves' && $values->{'waitingdate'} ) {
my @waitingdate = split /-/, $values->{'waitingdate'};
$values->{'expirationdate'} = C4::Dates->new(
sprintf(
'%04d-%02d-%02d',
Add_Delta_Days( @waitingdate, C4::Context->preference( 'ReservesMaxPickUpDelay' ) )
),
'iso'
)->output();
}
# and get all fields from the table
......
......@@ -1714,6 +1714,9 @@ sub _koha_notify_reserve {
if ( $reserve->{'itemnumber'} ) {
C4::Letters::parseletter( $letter, 'items', $reserve->{'itemnumber'} );
}
my $today = C4::Dates->new()->output();
$letter->{'title'} =~ s/<<today>>/$today/g;
$letter->{'content'} =~ s/<<today>>/$today/g;
$letter->{'content'} =~ s/<<[a-z0-9_]+\.[a-z0-9]+>>//g; #remove any stragglers
if ( -1 != firstidx { $_ eq 'email' } @{$messagingprefs->{transports}} ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment