From d9b0c46d2ee7c11c664ee84dad67bfd1951f8efa Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 14 Nov 2012 11:41:07 -0500 Subject: [PATCH] Bug 9076 - Followup - Perltidy cleanborrowers.pl Signed-off-by: Liz Rea Signed-off-by: Jonathan Druart Signed-off-by: Jared Camins-Esakov --- tools/cleanborrowers.pl | 81 ++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl index 6a9729c041..6a303267bd 100755 --- a/tools/cleanborrowers.pl +++ b/tools/cleanborrowers.pl @@ -17,7 +17,6 @@ # # Written by Antoine Farnault antoine@koha-fr.org on Nov. 2006. - =head1 cleanborrowers.pl This script allows to do 2 things. @@ -33,6 +32,7 @@ This script allows to do 2 things. =cut use strict; + #use warnings; FIXME - Bug 2505 use CGI; use C4::Auth; @@ -40,7 +40,7 @@ use C4::Output; use C4::Dates qw/format_date format_date_in_iso/; use C4::Members; # GetBorrowersWhoHavexxxBorrowed. use C4::Circulation; # AnonymiseIssueHistory. -use C4::VirtualShelves (); #no import +use C4::VirtualShelves (); #no import use Date::Calc qw/Today Add_Delta_YM/; my $cgi = new CGI; @@ -51,15 +51,14 @@ my $cgi = new CGI; # * multivalued CGI paramaters are returned as a packaged string separated by "\0" (null) my $params = $cgi->Vars; -my $filterdate1; # the date which filter on issue history. -my $filterdate2; # the date which filter on borrowers last issue. +my $filterdate1; # the date which filter on issue history. +my $filterdate2; # the date which filter on borrowers last issue. my $borrower_dateexpiry; my $borrower_categorycode; # getting the template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "tools/cleanborrowers.tmpl", + { template_name => "tools/cleanborrowers.tmpl", query => $cgi, type => "intranet", authnotrequired => 0, @@ -68,38 +67,38 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); if ( $params->{'step2'} ) { - $filterdate1 = format_date_in_iso($params->{'filterdate1'}); - $filterdate2 = format_date_in_iso($params->{'filterdate2'}); - $borrower_dateexpiry = format_date_in_iso($params->{'borrower_dateexpiry'}); + $filterdate1 = format_date_in_iso( $params->{'filterdate1'} ); + $filterdate2 = format_date_in_iso( $params->{'filterdate2'} ); + $borrower_dateexpiry = format_date_in_iso( $params->{'borrower_dateexpiry'} ); $borrower_categorycode = $params->{'borrower_categorycode'}; my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'}; my $totalDel; my $membersToDelete; - if ($checkboxes{borrower}) { - $membersToDelete = GetBorrowersWhoHaveNotBorrowedSince({ not_borrowered_since => $filterdate1, expired_before => $borrower_dateexpiry, category_code => $borrower_categorycode }); + if ( $checkboxes{borrower} ) { + $membersToDelete = + GetBorrowersWhoHaveNotBorrowedSince( { not_borrowered_since => $filterdate1, expired_before => $borrower_dateexpiry, category_code => $borrower_categorycode } ); $totalDel = scalar @$membersToDelete; - + } my $totalAno; my $membersToAnonymize; - if ($checkboxes{issue}) { - $membersToAnonymize = - GetBorrowersWithIssuesHistoryOlderThan($filterdate2); - $totalAno = scalar @$membersToAnonymize; + if ( $checkboxes{issue} ) { + $membersToAnonymize = GetBorrowersWithIssuesHistoryOlderThan($filterdate2); + $totalAno = scalar @$membersToAnonymize; } $template->param( - step2 => 1, - totalToDelete => $totalDel, - totalToAnonymize => $totalAno, - memberstodelete_list => $membersToDelete, - memberstoanonymize_list => $membersToAnonymize, - filterdate1 => format_date($filterdate1), - filterdate2 => format_date($filterdate2), - borrower_dateexpiry => $borrower_dateexpiry, - borrower_categorycode => $borrower_categorycode, + step2 => 1, + totalToDelete => $totalDel, + totalToAnonymize => $totalAno, + memberstodelete_list => $membersToDelete, + memberstoanonymize_list => $membersToAnonymize, + filterdate1 => format_date($filterdate1), + filterdate2 => format_date($filterdate2), + borrower_dateexpiry => $borrower_dateexpiry, + borrower_categorycode => $borrower_categorycode, ); ### TODO : Use GetBorrowersNamesAndLatestIssue function in order to get the borrowers to delete or anonymize. @@ -108,34 +107,34 @@ if ( $params->{'step2'} ) { } if ( $params->{'step3'} ) { - $filterdate1 = format_date_in_iso($params->{'filterdate1'}); - $filterdate2 = format_date_in_iso($params->{'filterdate2'}); - $borrower_dateexpiry = format_date_in_iso($params->{'borrower_dateexpiry'}); + $filterdate1 = format_date_in_iso( $params->{'filterdate1'} ); + $filterdate2 = format_date_in_iso( $params->{'filterdate2'} ); + $borrower_dateexpiry = format_date_in_iso( $params->{'borrower_dateexpiry'} ); $borrower_categorycode = $params->{'borrower_categorycode'}; my $do_delete = $params->{'do_delete'}; my $do_anonym = $params->{'do_anonym'}; my ( $totalDel, $totalAno, $radio ) = ( 0, 0, 0 ); - + # delete members if ($do_delete) { - my $membersToDelete = GetBorrowersWhoHaveNotBorrowedSince({ not_borrowered_since => $filterdate1, expired_before => $borrower_dateexpiry, category_code => $borrower_categorycode }); + my $membersToDelete = + GetBorrowersWhoHaveNotBorrowedSince( { not_borrowered_since => $filterdate1, expired_before => $borrower_dateexpiry, category_code => $borrower_categorycode } ); $totalDel = scalar(@$membersToDelete); $radio = $params->{'radio'}; if ( $radio eq 'trash' ) { my $i; for ( $i = 0 ; $i < $totalDel ; $i++ ) { MoveMemberToDeleted( $membersToDelete->[$i]->{'borrowernumber'} ); - C4::VirtualShelves::HandleDelBorrower($membersToDelete->[$i]->{'borrowernumber'}); + C4::VirtualShelves::HandleDelBorrower( $membersToDelete->[$i]->{'borrowernumber'} ); DelMember( $membersToDelete->[$i]->{'borrowernumber'} ); } - } - else { # delete completly. + } else { # delete completly. my $i; for ( $i = 0 ; $i < $totalDel ; $i++ ) { - C4::VirtualShelves::HandleDelBorrower($membersToDelete->[$i]->{'borrowernumber'}); - DelMember($membersToDelete->[$i]->{'borrowernumber'}); + C4::VirtualShelves::HandleDelBorrower( $membersToDelete->[$i]->{'borrowernumber'} ); + DelMember( $membersToDelete->[$i]->{'borrowernumber'} ); } } $template->param( @@ -143,7 +142,7 @@ if ( $params->{'step3'} ) { TotalDel => $totalDel ); } - + # Anonymising all members if ($do_anonym) { $totalAno = AnonymiseIssueHistory($filterdate2); @@ -152,7 +151,7 @@ if ( $params->{'step3'} ) { do_anonym => '1', ); } - + $template->param( step3 => '1', trash => ( $radio eq "trash" ) ? (1) : (0), @@ -164,11 +163,11 @@ if ( $params->{'step3'} ) { } $template->param( - step1 => '1', - filterdate1 => $filterdate1, - filterdate2 => $filterdate2, + step1 => '1', + filterdate1 => $filterdate1, + filterdate2 => $filterdate2, DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), - borrower_categorycodes => GetBorrowercategoryList(), + borrower_categorycodes => GetBorrowercategoryList(), ); #writing the template -- 2.39.5