From e75d26e79474073299b1d1ce2ddd5b56b0f834a1 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 bed69abc4c..96c7b472a8 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1827,9 +1827,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 @@ -1849,7 +1848,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