Bugzilla – Attachment 128799 Details for
Bug 29742
Make deletemem.pl use Koha::Patron->safe_to_delete
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29742: Make deletemem.pl use Koha::Patron->safe_to_delete
Bug-29742-Make-deletemempl-use-KohaPatron-safetode.patch (text/plain), 6.19 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-20 18:56:11 UTC
(
hide
)
Description:
Bug 29742: Make deletemem.pl use Koha::Patron->safe_to_delete
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-20 18:56:11 UTC
Size:
6.19 KB
patch
obsolete
>From fbe77e5b52a35d2c2689579da9c6a1b65b29f7bd Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Dec 2021 15:49:30 -0300 >Subject: [PATCH] Bug 29742: Make deletemem.pl use Koha::Patron->safe_to_delete > >This patch makes the deletemem.pl controller script reuse the >safe_to_delete method introduced by bug 29741. > >This way, it will use the same logic as the rest of the Koha pieces, >like the API. > >To test: >1. Verify this conditions make deletion be denied: > - Has a guarantee > - Is the system-defined anonymous patron > - Has outstanding debits > - Has items checked out >2. Verify that this conditions display relevant information when trying > to delete the patron: > - Has outstanding credit > - Has holds placed > - Has pending suggestions >3. Apply this patch >4. Repeat 1 and 2 >=> SUCCESS: Things didn't change! [*] >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../prog/en/modules/members/deletemem.tt | 20 ++++----- > members/deletemem.pl | 41 ++++++++++--------- > 2 files changed, 30 insertions(+), 31 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >index 0b4eb50a32..1e1e01faf0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >@@ -33,17 +33,15 @@ > <main> > > [% INCLUDE 'members-toolbar.inc' %] >- [% IF ItemsOnIssues || debits || is_guarantor %] >+ [% IF safe_to_delete != 'ok' %] > <div class="dialog alert"> > <h3>Cannot delete patron</h3> > <ul> >- [% IF ( ItemsOnIssues ) %] >- <li>Patron has [% ItemsOnIssues | html %] item(s) checked out.</li> >- [% END %] >- [% IF debits %] >- <li>Patron has [% debits | $Price %] in fines.</li> >- [% END %] >- [% IF is_guarantor %] >+ [% IF safe_to_delete == 'has_checkouts' %] >+ <li>Patron has [% checkouts_count | html %] item(s) checked out.</li> >+ [% ELSIF safe_to_delete == 'has_debt' %] >+ <li>Patron has [% charges | $Price %] in outstanding charges.</li> >+ [% ELSIF safe_to_delete == 'has_guarantees' %] > <li>Patron's record has guaranteed accounts attached.</li> > [% END %] > </ul> >@@ -51,10 +49,10 @@ > [% ELSIF op == 'delete_confirm' and patron %] > [%# TODO add "patron does not exist" unless patron %] > <div class="dialog alert"> >- [% IF ItemsOnHold or credits or pending_suggestions > 0 %] >+ [% IF holds_count or credits or pending_suggestions > 0 %] > <ul> >- [% IF ItemsOnHold %] >- <li>Patron has [% ItemsOnHold | html %] hold(s). Deleting patron cancels all their holds.</li> >+ [% IF holds_count %] >+ <li>Patron has [% holds_count | html %] hold(s). Deleting patron cancels all their holds.</li> > [% END %] > [% IF credits %] > <li>Patron has a [% credits | $Price %] credit.</li> >diff --git a/members/deletemem.pl b/members/deletemem.pl >index 5faf87dc47..e7815a6678 100755 >--- a/members/deletemem.pl >+++ b/members/deletemem.pl >@@ -45,8 +45,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-#print $input->header; >-my $member = $input->param('member'); >+my $member = $input->param('member'); > > #Do not delete yourself... > if ( $loggedinuser == $member ) { >@@ -58,9 +57,6 @@ my $logged_in_user = Koha::Patrons->find( $loggedinuser ); > my $patron = Koha::Patrons->find( $member ); > output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); > >-my $debits = $patron->account->outstanding_debits->total_outstanding; >-my $credits = abs $patron->account->outstanding_credits->total_outstanding; >-my $countissues = $patron->checkouts->count; > my $userenv = C4::Context->userenv; > > if ($patron->category->category_type eq "S") { >@@ -85,17 +81,14 @@ if (C4::Context->preference("IndependentBranches")) { > } > } > >-if ( my $anonymous_patron = C4::Context->preference("AnonymousPatron") ) { >- if ( $patron->id eq $anonymous_patron ) { >- print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON"); >- exit 0; # Exit without error >- } >+my $safe_to_delete = $patron->safe_to_delete; >+ >+if ( $safe_to_delete eq 'is_anonymous_patron' ) { >+ print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON"); >+ exit 0; # Exit without error > } > > my $op = $input->param('op') || 'delete_confirm'; >-my $dbh = C4::Context->dbh; >-my $is_guarantor = $patron->guarantee_relationships->count; >-my $countholds = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE borrowernumber=?", undef, $member); > > # Add warning if patron has pending suggestions > $template->param( >@@ -106,16 +99,24 @@ $template->param( > } > ); > >+my $account = $patron->account; >+my $credits = abs $account->outstanding_credits->total_outstanding; >+ > $template->param( >- patron => $patron, >- ItemsOnIssues => $countissues, >- debits => $debits, >- credits => $credits, >- is_guarantor => $is_guarantor, >- ItemsOnHold => $countholds, >+ credits => $credits, >+ holds_count => $patron->holds->count, >+ patron => $patron, >+ safe_to_delete => $safe_to_delete, > ); > >-if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) { >+if ( $safe_to_delete eq 'has_checkouts' ) { >+ $template->param( checkouts_count => $patron->checkouts->count, ); >+} >+elsif ( $safe_to_delete eq 'has_debt' ) { >+ $template->param( charges => $account->outstanding_debits->total_outstanding, ); >+} >+ >+if ( $op eq 'delete_confirm' or $safe_to_delete ne 'ok' ) { > $template->param( > op => 'delete_confirm', > csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }), >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29742
: 128799