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 |
- |
|
|