Lines 41-46
use C4::Members; # GetBorrowersWhoHavexxxBorrowed.
Link Here
|
41 |
use C4::Circulation; # AnonymiseIssueHistory. |
41 |
use C4::Circulation; # AnonymiseIssueHistory. |
42 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
42 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
43 |
use Date::Calc qw/Today Add_Delta_YM/; |
43 |
use Date::Calc qw/Today Add_Delta_YM/; |
|
|
44 |
use Koha::List::Patron; |
44 |
|
45 |
|
45 |
my $cgi = new CGI; |
46 |
my $cgi = new CGI; |
46 |
|
47 |
|
Lines 63-68
my $borrower_dateexpiry =
Link Here
|
63 |
$params->{borrower_dateexpiry} |
64 |
$params->{borrower_dateexpiry} |
64 |
? dt_from_string $params->{borrower_dateexpiry} |
65 |
? dt_from_string $params->{borrower_dateexpiry} |
65 |
: undef; |
66 |
: undef; |
|
|
67 |
my $patron_list_id = $params->{patron_list_id}; |
66 |
|
68 |
|
67 |
my $borrower_categorycode = $params->{'borrower_categorycode'} || q{}; |
69 |
my $borrower_categorycode = $params->{'borrower_categorycode'} || q{}; |
68 |
|
70 |
|
Lines 80-107
if ( $step == 2 ) {
Link Here
|
80 |
|
82 |
|
81 |
my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'}; |
83 |
my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'}; |
82 |
|
84 |
|
83 |
my $totalDel; |
85 |
my $patrons_to_delete; |
84 |
my $membersToDelete; |
|
|
85 |
if ( $checkboxes{borrower} ) { |
86 |
if ( $checkboxes{borrower} ) { |
86 |
$membersToDelete = GetBorrowersToExpunge( |
87 |
$patrons_to_delete = GetBorrowersToExpunge( |
87 |
_get_selection_params($not_borrowered_since, $borrower_dateexpiry, $borrower_categorycode) |
88 |
_get_selection_params( |
|
|
89 |
$not_borrowered_since, |
90 |
$borrower_dateexpiry, |
91 |
$borrower_categorycode, |
92 |
$patron_list_id, |
93 |
) |
88 |
); |
94 |
); |
89 |
_skip_borrowers_with_nonzero_balance( $membersToDelete ); |
|
|
90 |
$totalDel = scalar @$membersToDelete; |
91 |
|
92 |
} |
95 |
} |
93 |
my $totalAno; |
96 |
_skip_borrowers_with_nonzero_balance($patrons_to_delete); |
94 |
my $membersToAnonymize; |
97 |
|
|
|
98 |
my $members_to_anonymize; |
95 |
if ( $checkboxes{issue} ) { |
99 |
if ( $checkboxes{issue} ) { |
96 |
$membersToAnonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date); |
100 |
$members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date); |
97 |
$totalAno = scalar @$membersToAnonymize; |
|
|
98 |
} |
101 |
} |
99 |
|
102 |
|
100 |
$template->param( |
103 |
$template->param( |
101 |
totalToDelete => $totalDel, |
104 |
patrons_to_delete => $patrons_to_delete, |
102 |
totalToAnonymize => $totalAno, |
105 |
patrons_to_anonymize => $members_to_anonymize, |
103 |
memberstodelete_list => $membersToDelete, |
106 |
patron_list_id => $patron_list_id, |
104 |
memberstoanonymize_list => $membersToAnonymize, |
|
|
105 |
); |
107 |
); |
106 |
} |
108 |
} |
107 |
|
109 |
|
Lines 113-130
elsif ( $step == 3 ) {
Link Here
|
113 |
|
115 |
|
114 |
# delete members |
116 |
# delete members |
115 |
if ($do_delete) { |
117 |
if ($do_delete) { |
116 |
my $membersToDelete = GetBorrowersToExpunge( |
118 |
my $patrons_to_delete = GetBorrowersToExpunge( |
117 |
_get_selection_params($not_borrowered_since, $borrower_dateexpiry, $borrower_categorycode) |
119 |
_get_selection_params( |
118 |
); |
120 |
$not_borrowered_since, $borrower_dateexpiry, |
119 |
_skip_borrowers_with_nonzero_balance( $membersToDelete ); |
121 |
$borrower_categorycode, $patron_list_id |
120 |
$totalDel = scalar(@$membersToDelete); |
122 |
) |
|
|
123 |
); |
124 |
_skip_borrowers_with_nonzero_balance($patrons_to_delete); |
125 |
|
126 |
$totalDel = scalar(@$patrons_to_delete); |
121 |
$radio = $params->{'radio'}; |
127 |
$radio = $params->{'radio'}; |
122 |
for ( my $i = 0 ; $i < $totalDel ; $i++ ) { |
128 |
for ( my $i = 0 ; $i < $totalDel ; $i++ ) { |
123 |
$radio eq 'testrun' && last; |
129 |
$radio eq 'testrun' && last; |
124 |
my $borrowernumber = $membersToDelete->[$i]->{'borrowernumber'}; |
130 |
my $borrowernumber = $patrons_to_delete->[$i]->{'borrowernumber'}; |
125 |
$radio eq 'trash' && MoveMemberToDeleted( $borrowernumber ); |
131 |
$radio eq 'trash' && MoveMemberToDeleted($borrowernumber); |
126 |
C4::Members::HandleDelBorrower( $borrowernumber ); |
132 |
C4::Members::HandleDelBorrower($borrowernumber); |
127 |
DelMember( $borrowernumber ); |
133 |
DelMember($borrowernumber); |
128 |
} |
134 |
} |
129 |
$template->param( |
135 |
$template->param( |
130 |
do_delete => '1', |
136 |
do_delete => '1', |
Lines 145-150
elsif ( $step == 3 ) {
Link Here
|
145 |
trash => ( $radio eq "trash" ) ? (1) : (0), |
151 |
trash => ( $radio eq "trash" ) ? (1) : (0), |
146 |
testrun => ( $radio eq "testrun" ) ? 1: 0, |
152 |
testrun => ( $radio eq "testrun" ) ? 1: 0, |
147 |
); |
153 |
); |
|
|
154 |
} else { # $step == 1 |
155 |
my @all_lists = GetPatronLists(); |
156 |
my @non_empty_lists; |
157 |
foreach my $list (@all_lists){ |
158 |
my @patrons = $list->patron_list_patrons(); |
159 |
if( scalar @patrons ) { push(@non_empty_lists,$list) } |
160 |
} |
161 |
$template->param( patron_lists => [ @non_empty_lists ] ); |
148 |
} |
162 |
} |
149 |
|
163 |
|
150 |
$template->param( |
164 |
$template->param( |
Lines 169-175
sub _skip_borrowers_with_nonzero_balance {
Link Here
|
169 |
} |
183 |
} |
170 |
|
184 |
|
171 |
sub _get_selection_params { |
185 |
sub _get_selection_params { |
172 |
my ($not_borrowered_since, $borrower_dateexpiry, $borrower_categorycode) = @_; |
186 |
my ($not_borrowered_since, $borrower_dateexpiry, $borrower_categorycode, $patron_list_id) = @_; |
173 |
|
187 |
|
174 |
my $params = {}; |
188 |
my $params = {}; |
175 |
$params->{not_borrowered_since} = output_pref({ |
189 |
$params->{not_borrowered_since} = output_pref({ |
Lines 183-188
sub _get_selection_params {
Link Here
|
183 |
dateonly => 1 |
197 |
dateonly => 1 |
184 |
}) if $borrower_dateexpiry; |
198 |
}) if $borrower_dateexpiry; |
185 |
$params->{category_code} = $borrower_categorycode if $borrower_categorycode; |
199 |
$params->{category_code} = $borrower_categorycode if $borrower_categorycode; |
|
|
200 |
$params->{patron_list_id} = $patron_list_id if $patron_list_id; |
186 |
|
201 |
|
187 |
return $params; |
202 |
return $params; |
188 |
}; |
203 |
}; |
189 |
- |
|
|