From 608db665e9694e6d5559761aae45c2893bcc940b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sun, 24 Apr 2016 17:51:56 +0100 Subject: [PATCH] Bug 16276: Make the batch patron deletion tool deal with last_seen Content-Type: text/plain; charset=utf-8 This patch adds the same change as the previous one to the batch patron deletion tool. If the pref TrackLastPatronActivity is enabled, the librarians will be able to delete patrons who do not have been connected since a given time. Test plan: Define a date for the "who have not been connected since" options and confirm that it works as expected. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Nicolas Legrand https://bugs.koha-community.org/show_bug.cgi?id=12276 --- .../prog/en/modules/tools/cleanborrowers.tt | 12 +++++++++++- tools/cleanborrowers.pl | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt index 9e68141..ac65949 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt @@ -12,7 +12,7 @@ */ function checkForm(form) { if((form.checkbox[0].checked)){ - if ( (!form.date1.value) && (!form.borrower_dateexpiry.value) && (!form.borrower_categorycode.value) && (!form.patron_list_id.value)){ + if ( (!form.date1.value) && (!form.borrower_dateexpiry.value) [% IF Koha.Preference('TrackLastPatronActivity') %]&& (!form.borrower_lastseen.value) [% END %]&& (!form.borrower_categorycode.value) && (!form.patron_list_id.value)){ alert(_("Please enter at least one criterion for deletion!")); return false; } @@ -77,6 +77,13 @@ [% INCLUDE 'date-format.inc' %] + [% IF Koha.Preference('TrackLastPatronActivity') %] +
  • + + + [% INCLUDE 'date-format.inc' %] +
  • + [% END %]
  • + [% IF Koha.Preference('TrackLastPatronActivity') %] + + [% END %] diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl index d108d53..cc2c3bc 100755 --- a/tools/cleanborrowers.pl +++ b/tools/cleanborrowers.pl @@ -64,6 +64,10 @@ my $borrower_dateexpiry = $params->{borrower_dateexpiry} ? dt_from_string $params->{borrower_dateexpiry} : undef; +my $borrower_lastseen = + $params->{borrower_lastseen} + ? dt_from_string $params->{borrower_lastseen} + : undef; my $patron_list_id = $params->{patron_list_id}; my $borrower_categorycode = $params->{'borrower_categorycode'} || q{}; @@ -88,6 +92,7 @@ if ( $step == 2 ) { _get_selection_params( $not_borrowed_since, $borrower_dateexpiry, + $borrower_lastseen, $borrower_categorycode, $patron_list_id, ) @@ -117,7 +122,7 @@ elsif ( $step == 3 ) { if ($do_delete) { my $patrons_to_delete = GetBorrowersToExpunge( _get_selection_params( - $not_borrowed_since, $borrower_dateexpiry, + $not_borrowed_since, $borrower_dateexpiry, $borrower_lastseen, $borrower_categorycode, $patron_list_id ) ); @@ -165,6 +170,7 @@ $template->param( step => $step, not_borrowed_since => $not_borrowed_since, borrower_dateexpiry => $borrower_dateexpiry, + borrower_lastseen => $borrower_lastseen, last_issue_date => $last_issue_date, borrower_categorycodes => GetBorrowercategoryList(), borrower_categorycode => $borrower_categorycode, @@ -183,7 +189,7 @@ sub _skip_borrowers_with_nonzero_balance { } sub _get_selection_params { - my ($not_borrowed_since, $borrower_dateexpiry, $borrower_categorycode, $patron_list_id) = @_; + my ($not_borrowed_since, $borrower_dateexpiry, $borrower_lastseen, $borrower_categorycode, $patron_list_id) = @_; my $params = {}; $params->{not_borrowed_since} = output_pref({ @@ -196,6 +202,11 @@ sub _get_selection_params { dateformat => 'iso', dateonly => 1 }) if $borrower_dateexpiry; + $params->{last_seen} = output_pref({ + dt => $borrower_lastseen, + dateformat => 'iso', + dateonly => 1 + }) if $borrower_lastseen; $params->{category_code} = $borrower_categorycode if $borrower_categorycode; $params->{patron_list_id} = $patron_list_id if $patron_list_id; -- 1.7.10.4