From e676e117fccfaa8208742c17a08cb92056286f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick=20Capovilla?= Date: Wed, 5 Oct 2011 15:12:04 -0400 Subject: [PATCH] Notify the user on his account page when his account is almost expired New feature : If the "NotifyBorrowerDeparture" system preference is defined, a notification appears in the user's account page if his subscription is almost expired. http://bugs.koha-community.org/show_bug.cgi?id=6978 Signed-off-by: Owen Leonard Signed-off-by: Paul Poulain works perfectly with date formatted DD/MM/YYYY as well --- .../opac-tmpl/prog/en/modules/opac-user.tt | 6 ++++++ opac/opac-user.pl | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt index d9417ec5b9..f460b406bf 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt @@ -79,6 +79,12 @@ $.tablesorter.addParser({ [% IF ( patronupdate ) %]

Thank you!

Your corrections have been submitted to the library, and a staff member will update your record as soon as possible.

[% END %] + [% IF ( BORROWER_INF.warndeparture ) %] +
+ Please note: Your card will expire on [% BORROWER_INF.warndeparture %]. Please contact the library if you wish to renew your subscription. + [% IF ( BORROWER_INF.returnbeforeexpiry ) %] Also note that you must return all checked out items before your card expires.[% END %] +
+ [% END %] [% IF ( BORROWER_INF.flagged ) %]
diff --git a/opac/opac-user.pl b/opac/opac-user.pl index e99e557656..03c9e810fb 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -38,6 +38,12 @@ use C4::Branch; # GetBranches use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; +use Date::Calc qw( + Today + Add_Delta_Days + Date_to_Days +); + my $query = new CGI; BEGIN { @@ -64,6 +70,9 @@ my $patronupdate = $query->param('patronupdate'); # get borrower information .... my ( $borr ) = GetMemberDetails( $borrowernumber ); +my ( $today_year, $today_month, $today_day) = Today(); +my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'}; + for (qw(dateenrolled dateexpiry dateofbirth)) { ($borr->{$_}) and $borr->{$_} = format_date($borr->{$_}); } @@ -99,6 +108,18 @@ $borr->{'amountoutstanding'} = sprintf "%.02f", $borr->{'amountoutstanding'}; my @bordat; $bordat[0] = $borr; +# Warningdate is the date that the warning starts appearing +if ( C4::Context->preference('NotifyBorrowerDeparture') && + Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) < + Date_to_Days( $today_year, $today_month, $today_day ) ) +{ + # borrower card soon to expire, warn the borrower + $borr->{'warndeparture'} = $borr->{dateexpiry}; + if (C4::Context->preference('ReturnBeforeExpiry')){ + $borr->{'returnbeforeexpiry'} = 1; + } +} + $template->param( BORROWER_INFO => \@bordat, borrowernumber => $borrowernumber, patron_flagged => $borr->{flagged},