Add expiration date, today to hold notices

This adds the new, virtual placeholders <<today>> and
<<reserves.expirationdate> that can be used in letter templates.
This commit is contained in:
Jesse Weaver 2009-06-11 11:40:01 -06:00 committed by J. David Bavousett
parent 68bbe0d596
commit b7e35a3725
2 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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}} ) {