From 3c579ed7f1ef36b4a2a647d3bdae816375fc75a4 Mon Sep 17 00:00:00 2001 From: Maxime Pelletier Date: Mon, 11 Aug 2014 10:53:01 -0400 Subject: [PATCH] Bug 23243: Restore filtering out historic expired subscriptions The 'Check Expiration' page in Serials is now hardcoded to display all expired subscriptions before the entered date. This patch restores the ability to limit the results to just those expiring between 'today' and the date entered. Original code taken from bug 6968 autored by Maxime Pelletier, rebased by Charles Farmer and then moved to a new report and rebased again by Martin Renvoize. Test plan: 1) Without the patch any results after a search from this page will result in matches both before after todays date (but before the date you entered). 2) With the patch you should see a 'Show historic expirations' checkbox which will allow you to limit the results to just those that expire between the date you enter and today. Sponsored-by: CCSR Rescued-by: Charles Farmer Rescued-by: Martin Renvoize Signed-off-by: Martin Renvoize --- .../en/modules/serials/checkexpiration.tt | 9 ++++++++- serials/checkexpiration.pl | 20 +++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt index 091451c2a7..79ddb06aba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt @@ -24,6 +24,7 @@ Filter results:
    +
    1. @@ -43,7 +44,13 @@ Required
      [% INCLUDE 'date-format.inc' %]
    - + +
  1. + + +
  2. +
diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl index ae88841444..da865a7ae8 100755 --- a/serials/checkexpiration.pl +++ b/serials/checkexpiration.pl @@ -70,6 +70,7 @@ my $issn = $query->param('issn'); my $branch = $query->param('branch'); my $date = $query->param('date'); $date = eval { dt_from_string( scalar $query->param('date') ) } if $date; +my $showhistoricexpired = $query->param('showhistoryexpired'); if ($date) { my @subscriptions = SearchSubscriptions({ title => $title, issn => $issn, orderby => 'title' }); @@ -94,20 +95,23 @@ if ($date) { next if $subscription->{cannotedit}; my $expirationdate_dt = dt_from_string( $expirationdate, 'iso' ); + my $today_dt = dt_from_string(); if ( DateTime->compare( $date, $expirationdate_dt ) == 1 + && ( $showhistoricexpired || DateTime->compare( $expiration_dt, $today_dt ) == 1 ) && ( !$branch || ( $subscription->{'branchcode'} eq $branch ) ) ) { push @subscriptions_loop, $subscription; } } - $template->param ( - title => $title, - issn => $issn, - numsubscription => scalar @subscriptions_loop, - date => $date, - subscriptions_loop => \@subscriptions_loop, - "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, - searched => 1, + $template->param( + title => $title, + issn => $issn, + showhistoricexpired => $showhistoricexpired, + numsubscription => scalar @subscriptions_loop, + date => $date, + subscriptions_loop => \@subscriptions_loop, + "BiblioDefaultView" . C4::Context->preference("BiblioDefaultView") => 1, + searched => 1, ); } -- 2.20.1