From 6f5286c7f049a58b4588e1101675a9f5b6a4113a Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Tue, 29 Jun 2010 11:23:39 +0200 Subject: [PATCH] (bug #4916) permit tools/cleanborrowers.pl to be used by command line This patchs adds the possibility to run the script by command line. Signed-off-by: Henri-Damien LAURENT --- tools/cleanborrowers.pl | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl index 1a6c9bc251..8cdea2bd0a 100755 --- a/tools/cleanborrowers.pl +++ b/tools/cleanborrowers.pl @@ -40,6 +40,75 @@ use C4::Dates qw/format_date format_date_in_iso/; use C4::Members; # GetBorrowersWhoHavexxxBorrowed. use C4::Circulation; # AnonymiseIssueHistory. use Date::Calc qw/Today Add_Delta_YM/; +use Getopt::Long; + +if ( scalar @ARGV > 0 ) { + my ($untildate, $delete, $full, $anonymize, $help, $test); + my ($totalDel, $totalAno, $membersToDelete, $membersToAnonymize) = (0,0,0,0); + GetOptions( 'until=s' => \$untildate, + 'delete' => \$delete, + 'anonymize' => \$anonymize, + 'full' => \$full, + 'help|h' => \$help, + 'test|t' => \$test, + ); + + if($help or not $untildate){ + print <{'borrowernumber'} ); + } + }else{ + foreach my $member (@$membersToDelete){ + MoveMemberToDeleted( $member->{'borrowernumber'} ); + DelMember( $member->{'borrowernumber'} ); + } + } + } + + if($anonymize){ + print "Anonimyzing check-out history...\n"; + AnonymiseIssueHistory($untildate); + } + + print "Cleaning borrowers successfully finished.\n"; + exit; +} my $cgi = new CGI; -- 2.39.5