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

(-)a/Koha/Old/Patron.pm (+8 lines)
Lines 84-89 sub restore_deleted_borrower { Link Here
84
            # Retrive all the data about this patron from deleteborrowers table
84
            # Retrive all the data about this patron from deleteborrowers table
85
            my $patron_data = $self->unblessed;
85
            my $patron_data = $self->unblessed;
86
86
87
            # some fields must be cleared
88
            # borrower_debarments table is cleared on delete, we must also removed the debarment from the patron record
89
            $patron_data->{debarred}        = undef;
90
            $patron_data->{debarredcomment} = undef;
91
92
            #dont restore borrowers with flags, those will have to be re-added
93
            $patron_data->{flags} = undef;
94
87
            # Create the Koha::Patron object
95
            # Create the Koha::Patron object
88
            my $patron = Koha::Patron->new($patron_data);
96
            my $patron = Koha::Patron->new($patron_data);
89
97
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore_deleted_borrowers.tt (-2 / +25 lines)
Lines 77-84 Link Here
77
                                    <li>
77
                                    <li>
78
                                        <label for="branchcode">Library:</label>
78
                                        <label for="branchcode">Library:</label>
79
                                        <select name="branchcode" id="branchcode">
79
                                        <select name="branchcode" id="branchcode">
80
                                            <option value="">All libraries</option>
80
                                            [% IF can_view_all_libraries %]
81
                                            [% PROCESS options_for_libraries libraries => Branches.all() %]
81
                                                <option value="">All libraries</option>
82
                                            [% END %]
83
                                            [% FOREACH lib IN allowed_libraries %]
84
                                                <option value="[% lib.branchcode | html %]" [% IF branchcode == lib.branchcode %]selected="selected"[% END %]> [% lib.branchname | html %] </option>
85
                                            [% END %]
82
                                        </select>
86
                                        </select>
83
                                    </li>
87
                                    </li>
84
                                    <li>
88
                                    <li>
Lines 243-248 Link Here
243
                });
247
                });
244
            [% END %]
248
            [% END %]
245
249
250
            $("#restore_form").on("submit", function(e) {
251
                var checked = $("#deleted_patrons_table tbody input[type='checkbox']:checked").length;
252
253
                if (checked === 0) {
254
                    e.preventDefault();
255
                    alert(_("Please select at least one patron to restore."));
256
                    return false;
257
                }
258
259
                var message = __("Are you sure you want to restore %s patron(s)?").format(checked);
260
261
                if (!confirm(message)) {
262
                    e.preventDefault();
263
                    return false;
264
                }
265
266
                return true;
267
            });
268
246
        });
269
        });
247
    </script>
270
    </script>
248
[% END %]
271
[% END %]
(-)a/tools/restore_deleted_borrowers.pl (-3 / +26 lines)
Lines 23-29 use CGI qw ( -utf8 ); Link Here
23
use Try::Tiny;
23
use Try::Tiny;
24
use Scalar::Util qw( blessed );
24
use Scalar::Util qw( blessed );
25
25
26
use C4::Auth   qw( get_template_and_user );
26
use C4::Auth   qw( get_template_and_user haspermission );
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
28
use C4::Context;
28
use C4::Context;
29
29
Lines 39-48 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
39
        template_name => "tools/restore_deleted_borrowers.tt",
39
        template_name => "tools/restore_deleted_borrowers.tt",
40
        query         => $input,
40
        query         => $input,
41
        type          => "intranet",
41
        type          => "intranet",
42
        flagsrequired => { tools => 'restore_deleted_patrons' },
42
        flagsrequired => { borrowers => 'restore_deleted_borrowers' },
43
    }
43
    }
44
);
44
);
45
45
46
#check if the user can view patrons from any branch, or just thier own
47
my $logged_in_patron = Koha::Patrons->find($loggedinuser);
48
my $can_view_all_libraries =
49
    haspermission( $logged_in_patron->userid, { borrowers => 'view_borrower_infos_from_any_libraries' } );
50
51
my @libraries;
52
if ($can_view_all_libraries) {
53
54
    # User can view all branches, get them all
55
    @libraries = Koha::Libraries->search( {}, { order_by => 'branchname' } )->as_list;
56
} else {
57
58
    # User can only view their branch or branches in the group, get only those
59
    @libraries = Koha::Libraries->search_filtered(
60
        { only_from_group => 1 },
61
        { order_by        => ['branchname'] }
62
    )->as_list;
63
}
64
65
$template->param(
66
    allowed_libraries      => \@libraries,
67
    can_view_all_libraries => $can_view_all_libraries,
68
);
69
46
if ( $op eq 'search' ) {
70
if ( $op eq 'search' ) {
47
71
48
    # Get search parameters
72
    # Get search parameters
49
- 

Return to bug 34069