From fe2eb7c9fd6bcfd523ac2520d5354f614999102d Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Fri, 25 Sep 2009 16:32:41 +0200 Subject: [PATCH] (bug #3667) fix borrowers cleanup This add a check of borrower expiry date, and don't delete the borrower if he's still active. --- C4/Members.pm | 10 ++++++---- tools/cleanborrowers.pl | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 26f1273cec..4ac99177c7 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1858,9 +1858,8 @@ this function get all borrowers who haven't borrowed since the date given on inp =cut sub GetBorrowersWhoHaveNotBorrowedSince { -### TODO : It could be dangerous to delete Borrowers who have just been entered and who have not yet borrowed any book. May be good to add a dateexpiry or dateenrolled filter. - - my $filterdate = shift||POSIX::strftime("%Y-%m-%d",localtime()); + my $filterdate = shift||POSIX::strftime("%Y-%m-%d",localtime()); + my $filterexpiry = shift; my $filterbranch = shift || ((C4::Context->preference('IndependantBranches') && C4::Context->userenv @@ -1880,7 +1879,10 @@ sub GetBorrowersWhoHaveNotBorrowedSince { if ($filterbranch && $filterbranch ne ""){ $query.=" AND borrowers.branchcode= ?"; push @query_params,$filterbranch; - } + } + if($filterexpiry){ + $query .= " AND dateexpiry < NOW() "; + } $query.=" GROUP BY borrowers.borrowernumber"; if ($filterdate){ $query.=" HAVING latestissue {'step2'} ) { my $totalDel; my $membersToDelete; if ($checkboxes{borrower}) { - $membersToDelete = GetBorrowersWhoHaveNotBorrowedSince($filterdate1); + $membersToDelete = GetBorrowersWhoHaveNotBorrowedSince($filterdate1, 1); $totalDel = scalar @$membersToDelete; } @@ -109,7 +109,7 @@ if ( $params->{'step3'} ) { # delete members if ($do_delete) { - my $membersToDelete = GetBorrowersWhoHaveNotBorrowedSince($filterdate1); + my $membersToDelete = GetBorrowersWhoHaveNotBorrowedSince($filterdate1, 1); $totalDel = scalar(@$membersToDelete); $radio = $params->{'radio'}; if ( $radio eq 'trash' ) { -- 2.39.5