From 0dca3e58a77fc18e2424066e23af42b440be11f5 Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Fri, 28 Dec 2012 16:37:59 +0100 Subject: [PATCH] Bug 9329: Wrong message for already expired cards Previously users would see the same message whether their card was about to expire or was already expired. This patch adds a new message to handle cards which are about to expire, following the NotifyBorrowerDeparture system preference. TEST PLAN : The best way to test would to have at the same time : - a SQL client to change the expiry date of a borrower - an OPAC session opened for the same patron. Case 1: expiry date is set in the future -> no warning Case 2: expiry date is set in the near future (within the "NotifyBorrowerDeparture" system preference range) -> a warning says the card will expire on **date** Case 3: expiry date is set in the past -> before patch, same warning as Case 2 -> after patch, new warning indicating that the card has expired Signed-off-by: Owen Leonard Added description to the patch and copied test plan from the bug report. Patch passes test plan. Signed-off-by: Jonathan Druart Signed-off-by: Jared Camins-Esakov --- .../opac-tmpl/prog/en/modules/opac-user.tt | 6 ++++++ opac/opac-user.pl | 21 +++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) 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 f9b7ba53b5..96f6e8d35d 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt @@ -92,6 +92,12 @@ $.tablesorter.addParser({ [% END %] + [% IF ( BORROWER_INF.warnexpired ) %] +
+ Please note: Your card has expired. Please contact the library for more information. +
+ [% END %] + [% IF ( patron_flagged ) %]
    diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 2b8563c143..c5a7f5afe6 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -125,17 +125,20 @@ my @bordat; $bordat[0] = $borr; # Warningdate is the date that the warning starts appearing -if ( $borr->{dateexpiry} && 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; - } +if ( $borr->{dateexpiry} && Date_to_Days( $today_year, $today_month, $today_day ) > Date_to_Days( $warning_year, $warning_month, $warning_day ) ) { + $borr->{'warnexpired'} = 1; +} +elsif ( $borr->{dateexpiry} && 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}, -- 2.39.5