View | Details | Raw Unified | Return to bug 10612
Collapse All | Expand All

(-)a/C4/Members.pm (-2 / +2 lines)
Lines 1738-1744 sub GetHideLostItemsPreference { Link Here
1738
=head2 GetBorrowersToExpunge
1738
=head2 GetBorrowersToExpunge
1739
1739
1740
  $borrowers = &GetBorrowersToExpunge(
1740
  $borrowers = &GetBorrowersToExpunge(
1741
      not_borrowered_since => $not_borrowered_since,
1741
      not_borrowed_since => $not_borrowed_since,
1742
      expired_before       => $expired_before,
1742
      expired_before       => $expired_before,
1743
      category_code        => $category_code,
1743
      category_code        => $category_code,
1744
      patron_list_id       => $patron_list_id,
1744
      patron_list_id       => $patron_list_id,
Lines 1752-1758 sub GetHideLostItemsPreference { Link Here
1752
sub GetBorrowersToExpunge {
1752
sub GetBorrowersToExpunge {
1753
1753
1754
    my $params = shift;
1754
    my $params = shift;
1755
    my $filterdate       = $params->{'not_borrowered_since'};
1755
    my $filterdate       = $params->{'not_borrowed_since'};
1756
    my $filterexpiry     = $params->{'expired_before'};
1756
    my $filterexpiry     = $params->{'expired_before'};
1757
    my $filtercategory   = $params->{'category_code'};
1757
    my $filtercategory   = $params->{'category_code'};
1758
    my $filterbranch     = $params->{'branchcode'} ||
1758
    my $filterbranch     = $params->{'branchcode'} ||
(-)a/misc/cronjobs/delete_patrons.pl (-1 / +1 lines)
Lines 40-46 cronlogaction(); Link Here
40
40
41
my $members = GetBorrowersToExpunge(
41
my $members = GetBorrowersToExpunge(
42
    {
42
    {
43
        not_borrowered_since => $not_borrowed_since,
43
        not_borrowed_since => $not_borrowed_since,
44
        expired_before       => $expired_before,
44
        expired_before       => $expired_before,
45
        category_code        => $category_code,
45
        category_code        => $category_code,
46
        branchcode           => $branchcode,
46
        branchcode           => $branchcode,
(-)a/t/db_dependent/Members.t (-3 / +3 lines)
Lines 313-319 $patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patro Link Here
313
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by branchcode and list');
313
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by branchcode and list');
314
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } );
314
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } );
315
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by expirationdate and list');
315
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by expirationdate and list');
316
$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
316
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
317
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date');
317
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date');
318
318
319
ModMember( borrowernumber => $bor1inlist, categorycode => 'CIVILIAN' );
319
ModMember( borrowernumber => $bor1inlist, categorycode => 'CIVILIAN' );
Lines 325-331 $patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patro Link Here
325
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by branchcode and list');
325
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by branchcode and list');
326
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } );
326
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } );
327
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list');
327
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list');
328
$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
328
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
329
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date');
329
ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date');
330
ModMember( borrowernumber => $guarantee->{borrowernumber}, guarantorid=>'' );
330
ModMember( borrowernumber => $guarantee->{borrowernumber}, guarantorid=>'' );
331
331
Lines 350-356 $patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id Link Here
350
is( scalar(@$patstodel),2,'Borrowers without issues deleted by category_code and list');
350
is( scalar(@$patstodel),2,'Borrowers without issues deleted by category_code and list');
351
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } );
351
$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } );
352
is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date and list');
352
is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date and list');
353
$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
353
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
354
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
354
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
355
355
356
356
(-)a/tools/cleanborrowers.pl (-12 / +11 lines)
Lines 25-31 This script allows to do 2 things. Link Here
25
25
26
=item * Anonymise the borrowers' issues if issue is older than a given date. see C<datefilter1>.
26
=item * Anonymise the borrowers' issues if issue is older than a given date. see C<datefilter1>.
27
27
28
=item * Delete the borrowers who has not borrowered since a given date. see C<datefilter2>.
28
=item * Delete the borrowers who has not borrowed since a given date. see C<datefilter2>.
29
29
30
=back
30
=back
31
31
Lines 52-60 my $cgi = new CGI; Link Here
52
my $params = $cgi->Vars;
52
my $params = $cgi->Vars;
53
53
54
my $step = $params->{step} || 1;
54
my $step = $params->{step} || 1;
55
my $not_borrowered_since =    # the date which filter on issue history.
55
my $not_borrowed_since =    # the date which filter on issue history.
56
  $params->{not_borrowered_since}
56
  $params->{not_borrowed_since}
57
  ? dt_from_string $params->{not_borrowered_since}
57
  ? dt_from_string $params->{not_borrowed_since}
58
  : undef;
58
  : undef;
59
my $last_issue_date =         # the date which filter on borrowers last issue.
59
my $last_issue_date =         # the date which filter on borrowers last issue.
60
  $params->{last_issue_date}
60
  $params->{last_issue_date}
Lines 86-92 if ( $step == 2 ) { Link Here
86
    if ( $checkboxes{borrower} ) {
86
    if ( $checkboxes{borrower} ) {
87
        $patrons_to_delete = GetBorrowersToExpunge(
87
        $patrons_to_delete = GetBorrowersToExpunge(
88
             _get_selection_params(
88
             _get_selection_params(
89
                  $not_borrowered_since,
89
                  $not_borrowed_since,
90
                  $borrower_dateexpiry,
90
                  $borrower_dateexpiry,
91
                  $borrower_categorycode,
91
                  $borrower_categorycode,
92
                  $patron_list_id,
92
                  $patron_list_id,
Lines 117-123 elsif ( $step == 3 ) { Link Here
117
    if ($do_delete) {
117
    if ($do_delete) {
118
        my $patrons_to_delete = GetBorrowersToExpunge(
118
        my $patrons_to_delete = GetBorrowersToExpunge(
119
                _get_selection_params(
119
                _get_selection_params(
120
                    $not_borrowered_since, $borrower_dateexpiry,
120
                    $not_borrowed_since, $borrower_dateexpiry,
121
                    $borrower_categorycode, $patron_list_id
121
                    $borrower_categorycode, $patron_list_id
122
                )
122
                )
123
            );
123
            );
Lines 163-169 elsif ( $step == 3 ) { Link Here
163
163
164
$template->param(
164
$template->param(
165
    step                   => $step,
165
    step                   => $step,
166
    not_borrowered_since   => $not_borrowered_since,
166
    not_borrowed_since   => $not_borrowed_since,
167
    borrower_dateexpiry    => $borrower_dateexpiry,
167
    borrower_dateexpiry    => $borrower_dateexpiry,
168
    last_issue_date        => $last_issue_date,
168
    last_issue_date        => $last_issue_date,
169
    borrower_categorycodes => GetBorrowercategoryList(),
169
    borrower_categorycodes => GetBorrowercategoryList(),
Lines 183-196 sub _skip_borrowers_with_nonzero_balance { Link Here
183
}
183
}
184
184
185
sub _get_selection_params {
185
sub _get_selection_params {
186
    my ($not_borrowered_since, $borrower_dateexpiry, $borrower_categorycode, $patron_list_id) = @_;
186
    my ($not_borrowed_since, $borrower_dateexpiry, $borrower_categorycode, $patron_list_id) = @_;
187
187
188
    my $params = {};
188
    my $params = {};
189
    $params->{not_borrowered_since} = output_pref({
189
    $params->{not_borrowed_since} = output_pref({
190
        dt         => $not_borrowered_since,
190
        dt         => $not_borrowed_since,
191
        dateformat => 'iso',
191
        dateformat => 'iso',
192
        dateonly   => 1
192
        dateonly   => 1
193
    }) if $not_borrowered_since;
193
    }) if $not_borrowed_since;
194
    $params->{expired_before} = output_pref({
194
    $params->{expired_before} = output_pref({
195
        dt         => $borrower_dateexpiry,
195
        dt         => $borrower_dateexpiry,
196
        dateformat => 'iso',
196
        dateformat => 'iso',
197
- 

Return to bug 10612