Bugzilla – Attachment 50336 Details for
Bug 15705
Notify the user on auto renewing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15705: Notify the user on auto renewing
Bug-15705-Notify-the-user-on-auto-renewing.patch (text/plain), 4.21 KB, created by
Jonathan Druart
on 2016-04-18 15:05:13 UTC
(
hide
)
Description:
Bug 15705: Notify the user on auto renewing
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-04-18 15:05:13 UTC
Size:
4.21 KB
patch
obsolete
>From 8f9e84fda202add142ba7720ef7d7c990fbfb95f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 29 Jan 2016 16:57:21 +0000 >Subject: [PATCH] Bug 15705: Notify the user on auto renewing > >When an issue is auto renewed, a notice will be sent to the patron. >The notice will tell if the renewed has been successfully done. > >Note that this patch is not ready to be pushed yet, as it has some >defects: >- 1 notice per issue >- no way to disable the notice generation >- no way to specify patron categories to enable/disable the > notifications > >Test plan: >Use the automatic_renewals.pl script to auto renew issues. >If the auto renew has failed or succeeded, a notice will be generated in the >message_queue table. >If the error is "too_soon" or is the same as the previous error, the >notice won't be generated (we do not want to spam the patron). >--- > misc/cronjobs/automatic_renewals.pl | 68 ++++++++++++++++++++++++++++++------- > 1 file changed, 55 insertions(+), 13 deletions(-) > >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >index 73aad5f..59238d7 100755 >--- a/misc/cronjobs/automatic_renewals.pl >+++ b/misc/cronjobs/automatic_renewals.pl >@@ -42,24 +42,66 @@ No options. > > use Modern::Perl; > >+use C4::Branch; > use C4::Circulation; > use C4::Context; > use C4::Log; >+use C4::Letters; >+use Koha::Checkouts; >+use Koha::Borrowers; > > cronlogaction(); > >-my $dbh = C4::Context->dbh; >-my ( $borrowernumber, $itemnumber, $branch, $ok, $error ); >- >-my $query = >-"SELECT borrowernumber, itemnumber, branchcode FROM issues WHERE auto_renew = 1"; >-my $sth = $dbh->prepare($query); >-$sth->execute(); >- >-while ( ( $borrowernumber, $itemnumber, $branch ) = $sth->fetchrow_array ) { >+my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 }); >+ >+my %report; >+while ( my $auto_renew = $auto_renews->next ) { >+ >+ # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script >+ my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber ); >+ if ( $error eq 'auto_renew' ) { >+ my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode ); >+ push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew; >+ } elsif ( $error eq 'too_many' >+ or $error eq 'on_reserve' >+ or $error eq 'restriction' >+ or $error eq 'overdue' >+ or $error eq 'auto_too_late' >+ or $error eq 'auto_too_much_oweing' >+ or $error eq 'auto_too_soon' ) { >+ if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { >+ $auto_renew->auto_renew_error($error)->store; >+ push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew >+ if $error ne 'auto_too_soon'; # Do not notify if it's too soon >+ } >+ } >+} > >-# CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script >- ( $ok, $error ) = CanBookBeRenewed( $borrowernumber, $itemnumber ); >- AddRenewal( $borrowernumber, $itemnumber, $branch ) >- if ( $error eq "auto_renew" ); >+for my $borrowernumber ( keys %report ) { >+ my $patron = Koha::Borrowers->find($borrowernumber); >+ my @issues; >+ for my $issue ( @{ $report{$borrowernumber} } ) { >+ my $item = Koha::Items->find( $issue->itemnumber ); >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'circulation', >+ letter_code => 'AUTO_RENEWALS', >+ tables => { >+ borrowers => $patron->borrowernumber, >+ issues => $issue->itemnumber, >+ items => $issue->itemnumber, >+ biblio => $item->biblionumber, >+ }, >+ ); >+ >+ my $branch_details = C4::Branch::GetBranchDetail( $patron->branchcode ); >+ my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); >+ >+ C4::Letters::EnqueueLetter( >+ { letter => $letter, >+ borrowernumber => $borrowernumber, >+ message_transport_type => 'email', >+ from_address => $admin_email_address, >+ } >+ ); >+ } > } >-- >2.7.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 15705
:
47470
|
47471
|
47472
|
50336
|
50337
|
50338
|
50341
|
50342
|
50344
|
50345
|
50346
|
50680
|
50681
|
50682
|
50683
|
50732
|
50733
|
56756
|
56757
|
56758
|
56759
|
56760
|
56798
|
56799
|
56981
|
56983
|
57741
|
57742
|
57743
|
57744
|
57745
|
57746
|
57747
|
61080
|
61081
|
61082
|
61083
|
61084
|
61085
|
61086
|
61495
|
61496
|
61497
|
61498
|
61499
|
61500
|
61501
|
61739
|
62072
|
63036
|
63037
|
63138
|
63139
|
63140
|
63141
|
63142
|
63143
|
63144