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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt (-4 / +8 lines)
Lines 19-35 Link Here
19
            <main>
19
            <main>
20
20
21
    [% INCLUDE 'members-toolbar.inc' %]
21
    [% INCLUDE 'members-toolbar.inc' %]
22
    [% IF ( ItemsOnIssues || charges || guarantees ) %]
22
    [% IF ItemsOnIssues || debits || is_guarantor %]
23
        <div class="dialog alert">
23
        <div class="dialog alert">
24
        <h3>Cannot delete patron</h3>
24
        <h3>Cannot delete patron</h3>
25
            <ul>
25
            <ul>
26
            [% IF ( ItemsOnIssues ) %]
26
            [% IF ( ItemsOnIssues ) %]
27
                <li>Patron has [% ItemsOnIssues | html %] item(s) checked out.</li>
27
                <li>Patron has [% ItemsOnIssues | html %] item(s) checked out.</li>
28
            [% END %]
28
            [% END %]
29
            [% IF ( charges ) %]
29
            [% IF debits %]
30
                <li>Patron has [% charges | $Price %] in fines.</li>
30
                <li>Patron has [% debits | $Price %] in fines.</li>
31
            [% END %]
31
            [% END %]
32
            [% IF ( guarantees ) %]
32
            [% IF is_guarantor %]
33
                <li>Patron's record has guaranteed accounts attached.</li>
33
                <li>Patron's record has guaranteed accounts attached.</li>
34
            [% END %]
34
            [% END %]
35
            </ul>
35
            </ul>
Lines 41-46 Link Here
41
            <h3>Patron has [% ItemsOnHold | html %] hold(s). Deleting patron cancels all their holds.</h3></br>
41
            <h3>Patron has [% ItemsOnHold | html %] hold(s). Deleting patron cancels all their holds.</h3></br>
42
            [% END %]
42
            [% END %]
43
            <h3>Are you sure you want to delete the patron [% patron.firstname | html %] [% patron.surname | html %]? This cannot be undone.</h3>
43
            <h3>Are you sure you want to delete the patron [% patron.firstname | html %] [% patron.surname | html %]? This cannot be undone.</h3>
44
45
            [% IF credits %]
46
                <h4>Patron has a [% credits | $Price %] credit.</h4>
47
            [% END %]
44
            <form action="/cgi-bin/koha/members/deletemem.pl">
48
            <form action="/cgi-bin/koha/members/deletemem.pl">
45
                <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
49
                <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
46
                <input type="hidden" name="member" value="[% patron.borrowernumber | html %]"/>
50
                <input type="hidden" name="member" value="[% patron.borrowernumber | html %]"/>
(-)a/members/deletemem.pl (-24 / +14 lines)
Lines 56-62 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" Link Here
56
my $patron         = Koha::Patrons->find( $member );
56
my $patron         = Koha::Patrons->find( $member );
57
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
57
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
58
58
59
my $charges = $patron->account->non_issues_charges;
59
my $debits = $patron->account->outstanding_debits->total_outstanding;
60
my $credits = $patron->account->outstanding_credits->total_outstanding;
60
my $countissues = $patron->checkouts->count;
61
my $countissues = $patron->checkouts->count;
61
my $userenv = C4::Context->userenv;
62
my $userenv = C4::Context->userenv;
62
63
Lines 86-117 my $op = $input->param('op') || 'delete_confirm'; Link Here
86
my $dbh = C4::Context->dbh;
87
my $dbh = C4::Context->dbh;
87
my $is_guarantor = $patron->guarantee_relationships->count;
88
my $is_guarantor = $patron->guarantee_relationships->count;
88
my $countholds = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE borrowernumber=?", undef, $member);
89
my $countholds = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE borrowernumber=?", undef, $member);
89
if ( $op eq 'delete_confirm' or $countissues > 0 or $charges or $is_guarantor ) {
90
90
91
$template->param(
92
    patron        => $patron,
93
    ItemsOnIssues => $countissues,
94
    debits        => $debits,
95
    credits       => $credits,
96
    is_guarantor  => $is_guarantor,
97
    ItemsOnHold   => $countholds,
98
);
99
100
if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) {
91
    $template->param(
101
    $template->param(
92
        patron => $patron,
102
        op         => 'delete_confirm',
103
        csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
93
    );
104
    );
94
    if ($countissues >0) {
95
        $template->param(ItemsOnIssues => $countissues);
96
    }
97
    if ( $charges > 0 ) {
98
        $template->param(charges => $charges);
99
    }
100
    if ( $is_guarantor ) {
101
        $template->param( guarantees => 1 );
102
    }
103
    if($countholds > 0){
104
        $template->param(ItemsOnHold => $countholds);
105
    }
106
    # This is silly written but reflect the same conditions as above
107
    if ( not $countissues > 0 and not $charges > 0 and not $is_guarantor ) {
108
        $template->param(
109
            op         => 'delete_confirm',
110
            csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
111
        );
112
    }
113
} elsif ( $op eq 'delete_confirmed' ) {
105
} elsif ( $op eq 'delete_confirmed' ) {
114
115
    output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )
106
    output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )
116
        unless Koha::Token->new->check_csrf( {
107
        unless Koha::Token->new->check_csrf( {
117
            session_id => $input->cookie('CGISESSID'),
108
            session_id => $input->cookie('CGISESSID'),
118
- 

Return to bug 24008