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