From b7e35a37256054c2a1d07a4fcd965283aa91968e Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Thu, 11 Jun 2009 11:40:01 -0600 Subject: [PATCH] Add expiration date, today to hold notices This adds the new, virtual placeholders <> and < that can be used in letter templates. --- C4/Letters.pm | 16 ++++++++++++++++ C4/Reserves.pm | 3 +++ 2 files changed, 19 insertions(+) diff --git a/C4/Letters.pm b/C4/Letters.pm index fb8de5474b..3c6ff15196 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -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 diff --git a/C4/Reserves.pm b/C4/Reserves.pm index b10d6b4b18..f25764cb72 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -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/g; + $letter->{'content'} =~ s/<>/$today/g; $letter->{'content'} =~ s/<<[a-z0-9_]+\.[a-z0-9]+>>//g; #remove any stragglers if ( -1 != firstidx { $_ eq 'email' } @{$messagingprefs->{transports}} ) { -- 2.39.5