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

(-)a/Koha/Template/Plugin/Branches.pm (+4 lines)
Lines 54-59 sub GetURL { Link Here
54
    return $b->{branchurl};
54
    return $b->{branchurl};
55
}
55
}
56
56
57
sub OnlyMine {
58
    return C4::Branch::onlymine;
59
}
60
57
sub all {
61
sub all {
58
    my ( $self, $params ) = @_;
62
    my ( $self, $params ) = @_;
59
    my $selected = $params->{selected};
63
    my $selected = $params->{selected};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt (-3 / +35 lines)
Lines 1-5 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE Branches %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Tools &rsaquo; Batch patron deletion/anonymization [% IF step == 2 %]&rsaquo; Confirm[% END %][% IF step == 3 %]&rsaquo; Finished[% END %]</title>
5
<title>Koha &rsaquo; Tools &rsaquo; Batch patron deletion/anonymization [% IF step == 2 %]&rsaquo; Confirm[% END %][% IF step == 3 %]&rsaquo; Finished[% END %]</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 37-42 Link Here
37
          function checkForm2(form) {
38
          function checkForm2(form) {
38
              return true;
39
              return true;
39
          }
40
          }
41
42
          $(document).ready(function() {
43
              $('#selectlibrary').find("input:submit").hide();
44
              $('#branch').change(function() {
45
                $('#selectlibrary').submit();
46
              });
47
          });
40
     // ]]>
48
     // ]]>
41
</script>
49
</script>
42
50
Lines 52-64 Link Here
52
   <div id="bd">
60
   <div id="bd">
53
    <div id="yui-main">
61
    <div id="yui-main">
54
    <div class="yui-b">
62
    <div class="yui-b">
63
[% IF !Branches.OnlyMine %]
64
    <form method="get" action="/cgi-bin/koha/tools/cleanborrowers.pl" id="selectlibrary">
65
    Select a library :
66
        <select name="branch" id="branch" style="width:20em;">
67
            <option value="*">All libraries</option>
68
        [% FOREACH branch IN Branches.all( selected => current_branch ) %]
69
          [% IF branch.selected %]
70
            <option value="[% branch.branchcode %]" selected="selected">[% branch.branchname %]</option>
71
          [% ELSE %]
72
            <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
73
          [% END %]
74
        [% END %]
75
        </select>
76
    </form>
77
  [% IF current_branch == '*' %]
78
    <h1>Batch patron deletion/anonymization</h1>
79
  [% ELSE %]
80
    <h1>Batch patron deletion/anonymization for [% Branches.GetName( current_branch ) %]</h1>
81
  [% END %]
82
[% ELSE %]
83
    <h1>Batch patron deletion/anonymization for [% Branches.GetName( Branches.GetLoggedInBranchcode ) %]</h1>
84
[% END %]
85
86
[% IF step == 1 %]
87
<!-- step 1 START -->
55
88
56
<h1>Batch patron deletion/anonymization</h1>
57
<div class="help">
89
<div class="help">
58
    <p>This tool allows you to delete patrons and anonymize checkout history. For deleting patrons, any combination of limits can be used.</p>
90
    <p>This tool allows you to delete patrons and anonymize checkout history. For deleting patrons, any combination of limits can be used.</p>
59
</div>
91
</div>
60
[% IF step == 1 %]
61
<!-- step 1 START -->
62
<div id="step1">
92
<div id="step1">
63
    <form name="f1" onsubmit="return checkForm(this);" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
93
    <form name="f1" onsubmit="return checkForm(this);" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post">
64
    <fieldset>
94
    <fieldset>
Lines 119-124 Link Here
119
149
120
            <!-- hidden here -->
150
            <!-- hidden here -->
121
            <input type="hidden" name="step" value="2" />
151
            <input type="hidden" name="step" value="2" />
152
            <input type="hidden" name="branch" value="[% current_branch %]" />
122
            </fieldset>
153
            </fieldset>
123
            <fieldset class="action"><input type="submit" value="Next &gt;&gt;" /></fieldset>
154
            <fieldset class="action"><input type="submit" value="Next &gt;&gt;" /></fieldset>
124
    </form>
155
    </form>
Lines 162-167 Link Here
162
            <input type="hidden" name="borrower_dateexpiry" value="[% borrower_dateexpiry | $KohaDates %]" />
193
            <input type="hidden" name="borrower_dateexpiry" value="[% borrower_dateexpiry | $KohaDates %]" />
163
            <input type="hidden" name="borrower_categorycode" value="[% borrower_categorycode %]" />
194
            <input type="hidden" name="borrower_categorycode" value="[% borrower_categorycode %]" />
164
            <input type="hidden" name="patron_list_id" value="[% patron_list_id %]" />
195
            <input type="hidden" name="patron_list_id" value="[% patron_list_id %]" />
196
            <input type="hidden" name="branch" value="[% current_branch %]" />
165
    </fieldset>
197
    </fieldset>
166
    <fieldset class="action"><input type="submit" value="Finish" /> <a class="cancel" href="/cgi-bin/koha/tools/cleanborrowers.pl">Cancel</a></fieldset>
198
    <fieldset class="action"><input type="submit" value="Finish" /> <a class="cancel" href="/cgi-bin/koha/tools/cleanborrowers.pl">Cancel</a></fieldset>
167
        </form>
199
        </form>
(-)a/tools/cleanborrowers.pl (-8 / +22 lines)
Lines 31-39 This script allows to do 2 things. Link Here
31
31
32
=cut
32
=cut
33
33
34
use strict;
34
use Modern::Perl;
35
35
36
#use warnings; FIXME - Bug 2505
37
use CGI qw ( -utf8 );
36
use CGI qw ( -utf8 );
38
use C4::Auth;
37
use C4::Auth;
39
use C4::Output;
38
use C4::Output;
Lines 78-83 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
78
    }
77
    }
79
);
78
);
80
79
80
my $branch = $params->{ branch } || '*';
81
$template->param( current_branch => $branch );
82
81
if ( $step == 2 ) {
83
if ( $step == 2 ) {
82
84
83
    my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'};
85
    my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'};
Lines 90-95 if ( $step == 2 ) { Link Here
90
                  $borrower_dateexpiry,
92
                  $borrower_dateexpiry,
91
                  $borrower_categorycode,
93
                  $borrower_categorycode,
92
                  $patron_list_id,
94
                  $patron_list_id,
95
                  $branch
93
             )
96
             )
94
        );
97
        );
95
    }
98
    }
Lines 97-109 if ( $step == 2 ) { Link Here
97
100
98
    my $members_to_anonymize;
101
    my $members_to_anonymize;
99
    if ( $checkboxes{issue} ) {
102
    if ( $checkboxes{issue} ) {
100
        $members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date);
103
        if ( $branch eq '*' ) {
104
            $members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date);
105
        } else {
106
            $members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date, $branch);
107
        }
101
    }
108
    }
102
109
103
    $template->param(
110
    $template->param(
104
        patrons_to_delete    => $patrons_to_delete,
111
        patrons_to_delete    => $patrons_to_delete,
105
        patrons_to_anonymize => $members_to_anonymize,
112
        patrons_to_anonymize => $members_to_anonymize,
106
        patron_list_id          => $patron_list_id,
113
        patron_list_id       => $patron_list_id
107
    );
114
    );
108
}
115
}
109
116
Lines 117-124 elsif ( $step == 3 ) { Link Here
117
    if ($do_delete) {
124
    if ($do_delete) {
118
        my $patrons_to_delete = GetBorrowersToExpunge(
125
        my $patrons_to_delete = GetBorrowersToExpunge(
119
                _get_selection_params(
126
                _get_selection_params(
120
                    $not_borrowed_since, $borrower_dateexpiry,
127
                    $not_borrowed_since,
121
                    $borrower_categorycode, $patron_list_id
128
                    $borrower_dateexpiry,
129
                    $borrower_categorycode,
130
                    $patron_list_id,
131
                    $branch
122
                )
132
                )
123
            );
133
            );
124
        _skip_borrowers_with_nonzero_balance($patrons_to_delete);
134
        _skip_borrowers_with_nonzero_balance($patrons_to_delete);
Lines 183-189 sub _skip_borrowers_with_nonzero_balance { Link Here
183
}
193
}
184
194
185
sub _get_selection_params {
195
sub _get_selection_params {
186
    my ($not_borrowed_since, $borrower_dateexpiry, $borrower_categorycode, $patron_list_id) = @_;
196
    my ($not_borrowed_since, $borrower_dateexpiry,
197
        $borrower_categorycode, $patron_list_id, $branch) = @_;
187
198
188
    my $params = {};
199
    my $params = {};
189
    $params->{not_borrowed_since} = output_pref({
200
    $params->{not_borrowed_since} = output_pref({
Lines 199-203 sub _get_selection_params { Link Here
199
    $params->{category_code} = $borrower_categorycode if $borrower_categorycode;
210
    $params->{category_code} = $borrower_categorycode if $borrower_categorycode;
200
    $params->{patron_list_id} = $patron_list_id if $patron_list_id;
211
    $params->{patron_list_id} = $patron_list_id if $patron_list_id;
201
212
213
    if ( defined $branch and $branch ne '*' ) {
214
        $params->{ branchcode } = $branch;
215
    }
216
202
    return $params;
217
    return $params;
203
};
218
};
204
- 

Return to bug 15023