Bugzilla – Attachment 57267 Details for
Bug 17569
Move GetUpcomingMembershipExpires to Koha::Patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17569: Koha::Patrons - Move GetUpcomingMembershipExpires to search_upcoming_membership_expires
Bug-17569-KohaPatrons---Move-GetUpcomingMembership.patch (text/plain), 4.41 KB, created by
Jonathan Druart
on 2016-11-07 14:53:14 UTC
(
hide
)
Description:
Bug 17569: Koha::Patrons - Move GetUpcomingMembershipExpires to search_upcoming_membership_expires
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-11-07 14:53:14 UTC
Size:
4.41 KB
patch
obsolete
>From 8184bca448c989c3ab38d8b308508ab96e796fac Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 7 Nov 2016 14:38:17 +0000 >Subject: [PATCH] Bug 17569: Koha::Patrons - Move GetUpcomingMembershipExpires > to search_upcoming_membership_expires > >This patchset moves the C4::Members::GetUpcomingMembershipExpires >subroutine code to the Koha::Patrons->search_upcoming_membership_expires >method. >This subroutine was used from only 1 place, so it's an easier to move. > >Test plan: >Use the membership_expiry.pl cronjob script using the different >options. >The behavior should be the same as prior to this patch. > > prove t/db_dependent/Koha/Patrons.t >should return green >--- > Koha/Patrons.pm | 33 +++++++++++++++++++++++++++++++++ > misc/cronjobs/membership_expiry.pl | 16 ++++++++-------- > 2 files changed, 41 insertions(+), 8 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 4318179..d079df0 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use Carp; > > use Koha::Database; >+use Koha::DateUtils; > > use Koha::ArticleRequests; > use Koha::ArticleRequest::Status; >@@ -69,6 +70,38 @@ sub search_housebound_deliverers { > return Koha::Patrons->_new_from_dbic($del); > } > >+=head3 >+ >+my $patrons = Koha::Patrons->search_upcoming_membership_expires(); >+ >+The 'before' and 'after' represent the number of days before/after the date >+that is set by the preference MembershipExpiryDaysNotice. >+If the pref is 14, before 2 and after 3 then you will get all expires >+from 12 to 17 days. >+ >+=cut >+ >+sub search_upcoming_membership_expires { >+ my ( $self, $params ) = @_; >+ my $before = $params->{before} || 0; >+ my $after = $params->{after} || 0; >+ delete $params->{before}; >+ delete $params->{after}; >+ >+ my $days = C4::Context->preference("MembershipExpiryDaysNotice") || 0; >+ my $date_before = dt_from_string->add( days => $days - $before ); >+ my $date_after = dt_from_string->add( days => $days + $after ); >+ my $dtf = Koha::Database->new->schema->storage->datetime_parser; >+ >+ $params->{dateexpiry} = { >+ ">=" => $dtf->format_date( $date_before ), >+ "<=" => $dtf->format_date( $date_after ), >+ }; >+ return $self->SUPER::search( >+ $params, { join => ['branchcode', 'categorycode'] } >+ ); >+} >+ > =head3 guarantor > > Returns a Koha::Patron object for this borrower's guarantor >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index 36c0329..3b4b885 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -167,21 +167,21 @@ if( !$expdays ) { > > my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); > warn 'getting upcoming membership expires' if $verbose; >-my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires({ branch => $branch, before => $before, after => $after }); >-warn 'found ' . scalar( @$upcoming_mem_expires ) . ' soon expiring members' >+my $upcoming_mem_expires = Koha::Patrons->search_upcoming_membership_expires({ 'me.branchcode' => $branch, before => $before, after => $after }); >+warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members' > if $verbose; > > # main loop > $letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; >-foreach my $recent ( @$upcoming_mem_expires ) { >- my $from_address = $recent->{'branchemail'} || $admin_adress; >+while ( my $recent = $upcoming_mem_expires->next ) { >+ my $from_address = $recent->library->branchemail || $admin_adress; > my $letter = C4::Letters::GetPreparedLetter( > module => 'members', > letter_code => $letter_type, >- branchcode => $recent->{'branchcode'}, >+ branchcode => $recent->branchcode, > tables => { >- borrowers => $recent->{'borrowernumber'}, >- branches => $recent->{'branchcode'}, >+ borrowers => $recent->borrowernumber, >+ branches => $recent->branchcode, > }, > ); > last if !$letter; # Letters.pm already warned, just exit >@@ -190,7 +190,7 @@ foreach my $recent ( @$upcoming_mem_expires ) { > } else { > C4::Letters::EnqueueLetter({ > letter => $letter, >- borrowernumber => $recent->{'borrowernumber'}, >+ borrowernumber => $recent->borrowernumber, > from_address => $from_address, > message_transport_type => 'email', > }); >-- >2.1.4
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 17569
:
57265
|
57266
|
57267
|
57294
|
57295
|
57315
|
57316
|
57317
|
57318
|
57319
|
57894
|
57895
|
57896
|
57897
|
57898
|
57908
|
57909
|
57910
|
57911
|
57912
|
57913
|
58478
|
58479
|
58480
|
58481
|
58482
|
58483