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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt (-7 / +7 lines)
Lines 130-141 Link Here
130
    <fieldset>
130
    <fieldset>
131
        <legend>Warnings</legend>
131
        <legend>Warnings</legend>
132
        <ul>
132
        <ul>
133
            <li>[% memberstodelete_list.size || 0 %] patrons will be deleted</li>
133
            <li>[% patrons_to_delete.size || 0 %] patrons will be deleted</li>
134
            <li>[% memberstoanonymize_list.size || 0 %] patron's checkout histories will be anonymized</li>
134
            <li>[% patrons_to_anonymize.size || 0 %] patron's checkout histories will be anonymized</li>
135
        </ul>
135
        </ul>
136
136
137
        <br />
137
        <br />
138
            [% IF memberstodelete_list.size %]
138
            [% IF patrons_to_delete.size %]
139
                <fieldset><legend>What do you want to do for deleted patrons?</legend>
139
                <fieldset><legend>What do you want to do for deleted patrons?</legend>
140
                <input id="delete" type="radio" name="radio" value="delete" />
140
                <input id="delete" type="radio" name="radio" value="delete" />
141
                <label for="delete">Permanently delete these patrons</label>
141
                <label for="delete">Permanently delete these patrons</label>
Lines 145-156 Link Here
145
145
146
                <br /><input id="testrun" type="radio" name="radio" value="testrun" checked="checked" />
146
                <br /><input id="testrun" type="radio" name="radio" value="testrun" checked="checked" />
147
                <label for="testrun">Do not remove any patrons (test run)</label>
147
                <label for="testrun">Do not remove any patrons (test run)</label>
148
                <input type="hidden" name="do_delete" value="[% memberstodelete_list.size %]" /></fieldset>
148
                <input type="hidden" name="do_delete" value="[% patrons_to_delete.size %]" /></fieldset>
149
149
150
            [% END %]
150
            [% END %]
151
            [% IF memberstoanonymize_list.size %]
151
            [% IF patrons_to_anonymize.size %]
152
                Checkout history for [% memberstoanonymize_list.size %] patrons will be anonymized
152
                Checkout history for [% patrons_to_anonymize.size %] patrons will be anonymized
153
                <input type="hidden" name="do_anonym" value="[% memberstoanonymize_list.size %]" />
153
                <input type="hidden" name="do_anonym" value="[% patrons_to_anonymize.size %]" />
154
            [% END %]
154
            [% END %]
155
155
156
            <input type="hidden" name="step" value="3" />
156
            <input type="hidden" name="step" value="3" />
(-)a/tools/cleanborrowers.pl (-16 / +15 lines)
Lines 84-99 if ( $step == 2 ) { Link Here
84
84
85
    my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'};
85
    my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'};
86
86
87
    my $membersToDelete;
87
    my $patrons_to_delete;
88
    if ($patron_list_id) {
88
    if ($patron_list_id) {
89
        my @patron_list_patrons =
89
        my @patron_list_patrons =
90
          Koha::Database->new()->schema()->resultset('PatronListPatron')
90
          Koha::Database->new()->schema()->resultset('PatronListPatron')
91
          ->search( { patron_list_id => $patron_list_id } );
91
          ->search( { patron_list_id => $patron_list_id } );
92
        $membersToDelete = \@patron_list_patrons;
92
        $patrons_to_delete = \@patron_list_patrons;
93
    }
93
    }
94
    else {
94
    else {
95
        if ( $checkboxes{borrower} ) {
95
        if ( $checkboxes{borrower} ) {
96
            $membersToDelete = GetBorrowersToExpunge(
96
            $patrons_to_delete = GetBorrowersToExpunge(
97
                _get_selection_params(
97
                _get_selection_params(
98
                    $not_borrowered_since,
98
                    $not_borrowered_since,
99
                    $borrower_dateexpiry,
99
                    $borrower_dateexpiry,
Lines 102-117 if ( $step == 2 ) { Link Here
102
            );
102
            );
103
        }
103
        }
104
    }
104
    }
105
    _skip_borrowers_with_nonzero_balance($membersToDelete);
105
    _skip_borrowers_with_nonzero_balance($patrons_to_delete);
106
106
107
    my $membersToAnonymize;
107
    my $members_to_anonymize;
108
    if ( $checkboxes{issue} ) {
108
    if ( $checkboxes{issue} ) {
109
        $membersToAnonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date);
109
        $members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date);
110
    }
110
    }
111
111
112
    $template->param(
112
    $template->param(
113
        memberstodelete_list    => $membersToDelete,
113
        patrons_to_delete    => $patrons_to_delete,
114
        memberstoanonymize_list => $membersToAnonymize,
114
        patrons_to_anonymize => $members_to_anonymize,
115
        patron_list_id          => $patron_list_id,
115
        patron_list_id          => $patron_list_id,
116
    );
116
    );
117
}
117
}
Lines 124-152 elsif ( $step == 3 ) { Link Here
124
124
125
    # delete members
125
    # delete members
126
    if ($do_delete) {
126
    if ($do_delete) {
127
        my $membersToDelete;
127
        my $patrons_to_delete;
128
        if ($patron_list_id) {
128
        if ($patron_list_id) {
129
            my @patron_list_patrons =
129
            my @patron_list_patrons =
130
              Koha::Database->new()->schema()->resultset('PatronListPatron')
130
              Koha::Database->new()->schema()->resultset('PatronListPatron')
131
              ->search( { patron_list_id => $patron_list_id } );
131
              ->search( { patron_list_id => $patron_list_id } );
132
            $membersToDelete = \@patron_list_patrons;
132
            $patrons_to_delete = \@patron_list_patrons;
133
        }
133
        }
134
        else {
134
        else {
135
            $membersToDelete = GetBorrowersToExpunge(
135
            $patrons_to_delete = GetBorrowersToExpunge(
136
                _get_selection_params(
136
                _get_selection_params(
137
                    $not_borrowered_since, $borrower_dateexpiry,
137
                    $not_borrowered_since, $borrower_dateexpiry,
138
                    $borrower_categorycode
138
                    $borrower_categorycode
139
                )
139
                )
140
            );
140
            );
141
        }
141
        }
142
        _skip_borrowers_with_nonzero_balance($membersToDelete);
142
        _skip_borrowers_with_nonzero_balance($patrons_to_delete);
143
143
144
        $totalDel = scalar(@$membersToDelete);
144
        $totalDel = scalar(@$patrons_to_delete);
145
        $radio    = $params->{'radio'};
145
        $radio    = $params->{'radio'};
146
        for ( my $i = 0 ; $i < $totalDel ; $i++ ) {
146
        for ( my $i = 0 ; $i < $totalDel ; $i++ ) {
147
            $radio eq 'testrun' && last;
147
            $radio eq 'testrun' && last;
148
            my $borrowernumber = $membersToDelete->[$i]->{'borrowernumber'}
148
            my $borrowernumber = $patrons_to_delete->[$i]->{'borrowernumber'}
149
              || $membersToDelete->[$i]->get_column('borrowernumber');
149
              || $patrons_to_delete->[$i]->get_column('borrowernumber');
150
            $radio eq 'trash' && MoveMemberToDeleted($borrowernumber);
150
            $radio eq 'trash' && MoveMemberToDeleted($borrowernumber);
151
            C4::VirtualShelves::HandleDelBorrower($borrowernumber);
151
            C4::VirtualShelves::HandleDelBorrower($borrowernumber);
152
            DelMember($borrowernumber);
152
            DelMember($borrowernumber);
153
- 

Return to bug 10612