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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt (-11 / +9 lines)
Lines 33-49 Link Here
33
            <main>
33
            <main>
34
34
35
    [% INCLUDE 'members-toolbar.inc' %]
35
    [% INCLUDE 'members-toolbar.inc' %]
36
    [% IF ItemsOnIssues || debits || is_guarantor %]
36
    [% IF safe_to_delete != 'ok' %]
37
        <div class="dialog alert">
37
        <div class="dialog alert">
38
        <h3>Cannot delete patron</h3>
38
        <h3>Cannot delete patron</h3>
39
            <ul>
39
            <ul>
40
            [% IF ( ItemsOnIssues ) %]
40
            [% IF safe_to_delete == 'has_checkouts' %]
41
                <li>Patron has [% ItemsOnIssues | html %] item(s) checked out.</li>
41
                <li>Patron has [% checkouts_count | html %] item(s) checked out.</li>
42
            [% END %]
42
            [% ELSIF safe_to_delete == 'has_debt' %]
43
            [% IF debits %]
43
                <li>Patron has [% charges | $Price %] in outstanding charges.</li>
44
                <li>Patron has [% debits | $Price %] in fines.</li>
44
            [% ELSIF safe_to_delete == 'has_guarantees' %]
45
            [% END %]
46
            [% IF is_guarantor %]
47
                <li>Patron's record has guaranteed accounts attached.</li>
45
                <li>Patron's record has guaranteed accounts attached.</li>
48
            [% END %]
46
            [% END %]
49
            </ul>
47
            </ul>
Lines 51-60 Link Here
51
    [% ELSIF op == 'delete_confirm' and patron %]
49
    [% ELSIF op == 'delete_confirm' and patron %]
52
        [%# TODO add "patron does not exist" unless patron %]
50
        [%# TODO add "patron does not exist" unless patron %]
53
        <div class="dialog alert">
51
        <div class="dialog alert">
54
            [% IF ItemsOnHold or credits or pending_suggestions > 0 %]
52
            [% IF holds_count or credits or pending_suggestions > 0 %]
55
                <ul>
53
                <ul>
56
                    [% IF ItemsOnHold %]
54
                    [% IF holds_count %]
57
                        <li>Patron has [% ItemsOnHold | html %] hold(s). Deleting patron cancels all their holds.</li>
55
                        <li>Patron has [% holds_count | html %] hold(s). Deleting patron cancels all their holds.</li>
58
                    [% END %]
56
                    [% END %]
59
                    [% IF credits %]
57
                    [% IF credits %]
60
                        <li>Patron has a [% credits | $Price %] credit.</li>
58
                        <li>Patron has a [% credits | $Price %] credit.</li>
(-)a/members/deletemem.pl (-21 / +21 lines)
Lines 45-52 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
45
    }
45
    }
46
);
46
);
47
47
48
#print $input->header;
48
my $member = $input->param('member');
49
my $member       = $input->param('member');
50
49
51
#Do not delete yourself...
50
#Do not delete yourself...
52
if ( $loggedinuser == $member ) {
51
if ( $loggedinuser == $member ) {
Lines 58-66 my $logged_in_user = Koha::Patrons->find( $loggedinuser ); Link Here
58
my $patron         = Koha::Patrons->find( $member );
57
my $patron         = Koha::Patrons->find( $member );
59
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
58
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
60
59
61
my $debits = $patron->account->outstanding_debits->total_outstanding;
62
my $credits = abs $patron->account->outstanding_credits->total_outstanding;
63
my $countissues = $patron->checkouts->count;
64
my $userenv = C4::Context->userenv;
60
my $userenv = C4::Context->userenv;
65
61
66
if ($patron->category->category_type eq "S") {
62
if ($patron->category->category_type eq "S") {
Lines 85-101 if (C4::Context->preference("IndependentBranches")) { Link Here
85
    }
81
    }
86
}
82
}
87
83
88
if ( my $anonymous_patron = C4::Context->preference("AnonymousPatron") ) {
84
my $safe_to_delete = $patron->safe_to_delete;
89
    if ( $patron->id eq $anonymous_patron ) {
85
90
        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON");
86
if ( $safe_to_delete eq 'is_anonymous_patron' ) {
91
        exit 0;    # Exit without error
87
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON");
92
    }
88
    exit 0;    # Exit without error
93
}
89
}
94
90
95
my $op = $input->param('op') || 'delete_confirm';
91
my $op = $input->param('op') || 'delete_confirm';
96
my $dbh = C4::Context->dbh;
97
my $is_guarantor = $patron->guarantee_relationships->count;
98
my $countholds = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE borrowernumber=?", undef, $member);
99
92
100
# Add warning if patron has pending suggestions
93
# Add warning if patron has pending suggestions
101
$template->param(
94
$template->param(
Lines 106-121 $template->param( Link Here
106
    }
99
    }
107
);
100
);
108
101
102
my $account = $patron->account;
103
my $credits = abs $account->outstanding_credits->total_outstanding;
104
109
$template->param(
105
$template->param(
110
    patron        => $patron,
106
    credits        => $credits,
111
    ItemsOnIssues => $countissues,
107
    holds_count    => $patron->holds->count,
112
    debits        => $debits,
108
    patron         => $patron,
113
    credits       => $credits,
109
    safe_to_delete => $safe_to_delete,
114
    is_guarantor  => $is_guarantor,
115
    ItemsOnHold   => $countholds,
116
);
110
);
117
111
118
if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) {
112
if ( $safe_to_delete eq 'has_checkouts' ) {
113
    $template->param( checkouts_count => $patron->checkouts->count, );
114
}
115
elsif ( $safe_to_delete eq 'has_debt' ) {
116
    $template->param( charges => $account->outstanding_debits->total_outstanding, );
117
}
118
119
if ( $op eq 'delete_confirm' or $safe_to_delete ne 'ok' ) {
119
    $template->param(
120
    $template->param(
120
        op         => 'delete_confirm',
121
        op         => 'delete_confirm',
121
        csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
122
        csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
122
- 

Return to bug 29742