Bugzilla – Attachment 71805 Details for
Bug 19933
Move C4::Members::patronflags to the Koha namespace - part 1
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19933: Remove patronflags - easy ones
Bug-19933-Remove-patronflags---easy-ones.patch (text/plain), 6.21 KB, created by
Jonathan Druart
on 2018-02-16 14:44:47 UTC
(
hide
)
Description:
Bug 19933: Remove patronflags - easy ones
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-02-16 14:44:47 UTC
Size:
6.21 KB
patch
obsolete
>From 2a1f5b4430d6e084120af19eb85f1bb3d545395d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 7 Jan 2018 14:42:00 -0300 >Subject: [PATCH] Bug 19933: Remove patronflags - easy ones > >This patch replaces the easy occurrences of patronflags. > >These calls only need the CHARGES->amount value, that is the non issues >charges. Luckily we now have a Koha::Account->non_issues_charges that >deal with that. >--- > C4/ILSDI/Services.pm | 3 +-- > koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt | 3 ++- > members/deletemem.pl | 11 ++++++----- > members/member-flags.pl | 1 - > misc/cronjobs/delete_patrons.pl | 9 ++++++--- > 5 files changed, 15 insertions(+), 12 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index c9069af1a6..7e021a5856 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -393,8 +393,7 @@ sub GetPatronInfo { > > # Cleaning the borrower hashref > my $borrower = $patron->unblessed; >- my $flags = C4::Members::patronflags( $borrower ); >- $borrower->{'charges'} = $flags->{'CHARGES'}->{'amount'}; >+ $borrower->{charges} = sprintf "%.02f", $patron->account->non_issues_charges; # FIXME Formatting should not be done here > my $library = Koha::Libraries->find( $borrower->{branchcode} ); > $borrower->{'branchname'} = $library ? $library->branchname : ''; > delete $borrower->{'userid'}; >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 660fd93a7b..c3d8a83268 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt >@@ -1,3 +1,4 @@ >+[% USE Price %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Delete patron [% firstname %] [% surname %]</title> >@@ -22,7 +23,7 @@ > <li>Patron has [% ItemsOnIssues %] item(s) checked out.</li> > [% END %] > [% IF ( charges ) %] >- <li>Patron has [% charges %] in fines.</li> >+ <li>Patron has [% charges | $Prices %] in fines.</li> > [% END %] > [% IF ( guarantees ) %] > <li>Patron's record has guaranteed accounts attached.</li> >diff --git a/members/deletemem.pl b/members/deletemem.pl >index 5a1e3f5cb7..57cecae8ab 100755 >--- a/members/deletemem.pl >+++ b/members/deletemem.pl >@@ -77,7 +77,8 @@ if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen > my $issues = GetPendingIssues($member); # FIXME: wasteful call when really, we only want the count > my $countissues = scalar(@$issues); > >-my $flags = C4::Members::patronflags( $patron->unblessed ); >+my $patron = Koha::Patrons->find( $member ); >+my $charges = $patron->account->non_issues_charges; > my $userenv = C4::Context->userenv; > > >@@ -107,7 +108,7 @@ if (C4::Context->preference("IndependentBranches")) { > my $op = $input->param('op') || 'delete_confirm'; > my $dbh = C4::Context->dbh; > my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member); >-if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_guarantor or $deletelocal == 0) { >+if ( $op eq 'delete_confirm' or $countissues > 0 or $charges or $is_guarantor or $deletelocal == 0) { > $template->param( picture => 1 ) if $patron->image; > > $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/; >@@ -134,8 +135,8 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_ > if ($countissues >0) { > $template->param(ItemsOnIssues => $countissues); > } >- if ($flags->{'CHARGES'} ne '') { >- $template->param(charges => $flags->{'CHARGES'}->{'amount'}); >+ if ( $charges > 0 ) { >+ $template->param(charges => $charges); > } > if ($is_guarantor) { > $template->param(guarantees => 1); >@@ -144,7 +145,7 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_ > $template->param(keeplocal => 1); > } > # This is silly written but reflect the same conditions as above >- if ( not $countissues > 0 and not $flags->{CHARGES} ne '' and not $is_guarantor and not $deletelocal == 0 ) { >+ if ( not $countissues > 0 and not $charges and not $is_guarantor and not $deletelocal == 0 ) { > $template->param( > op => 'delete_confirm', > csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }), >diff --git a/members/member-flags.pl b/members/member-flags.pl >index 178415fb61..9cd4fd6dbe 100755 >--- a/members/member-flags.pl >+++ b/members/member-flags.pl >@@ -107,7 +107,6 @@ if ($input->param('newflags')) { > print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member"); > } else { > >- my $flags = C4::Members::patronflags( $bor ); > my $accessflags; > my $dbh = C4::Context->dbh(); > # FIXME This needs to be improved to avoid doing the same query >diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl >index ee015a6856..4470746a96 100755 >--- a/misc/cronjobs/delete_patrons.pl >+++ b/misc/cronjobs/delete_patrons.pl >@@ -66,14 +66,17 @@ for my $member (@$members) { > if $verbose; > > my $borrowernumber = $member->{borrowernumber}; >- my $flags = C4::Members::patronflags( $member ); >- if ( my $charges = $flags->{CHARGES}{amount} ) { >+ my $patron = Koha::Patrons->find( $borrowernumber ); >+ unless ( $patron ) { >+ say "Patron with borrowernumber $borrowernumber does not exist"; >+ next; >+ } >+ if ( my $charges = $patron->account->non_issues_charges ) { # And what if we owe to this patron? > say "Failed to delete patron $borrowernumber: patron has $charges in fines"; > next; > } > > if ( $confirm ) { >- my $patron = Koha::Patrons->find( $borrowernumber ); > my $deleted = eval { $patron->move_to_deleted; }; > if ($@ or not $deleted) { > say "Failed to delete patron $borrowernumber, cannot move it" . ( $@ ? ": ($@)" : "" ); >-- >2.11.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 19933
:
70347
|
70348
|
70349
|
70350
|
71803
|
71804
|
71805
|
71806
|
72004
|
72005
|
72006
|
72007
|
72094
|
72095
|
72350
|
72351
|
72352
|
72353
|
72354
|
72355
|
72356
|
72472
|
72473
|
72474
|
72475
|
72476
|
72477
|
72478