Bugzilla – Attachment 63275 Details for
Bug 17509
Notify patrons to return items requested on hold by another person
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 17509: notify patrons to return an item whenever a hold is placed on it
SIGNED-OFF-Bug-17509-notify-patrons-to-return-an-i.patch (text/plain), 4.88 KB, created by
Josef Moravec
on 2017-05-09 06:27:35 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 17509: notify patrons to return an item whenever a hold is placed on it
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-05-09 06:27:35 UTC
Size:
4.88 KB
patch
obsolete
>From 74302088031049872ec22b2cdee4f22b2915b29b Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Radek=20=C5=A0iman?= <rbit@rbit.cz> >Date: Thu, 3 Nov 2016 04:47:10 +0100 >Subject: [PATCH] [SIGNED-OFF] Bug 17509: notify patrons to return an item > whenever a hold is placed on it > >Test plan: >1) apply patch >2) run database update >3) enable sending an email to the patrons to return an item whenever a > hold request is placed on it >4) place a hold >5) patrons having checked-out the item on hold are notified by email > (see HOLDPLACED_CONTACT letter) > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/Reserves.pm | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 101 insertions(+), 1 deletion(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 3192d50..3d5b371 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -250,12 +250,49 @@ sub AddReserve { > borrowernumber => $borrowernumber, > message_transport_type => 'email', > from_address => $admin_email_address, >- to_address => $admin_email_address, >+ to_address => $admin_email_address, > } > ); > } > } > >+ # Send email to borrowers asking to return item whenever a hold is placed on it >+ if (C4::Context->preference("NotifyToReturnItemWhenHoldIsPlaced")) { >+ my @borrowers = GetBorrowersToSatisfyHold($hold); >+ foreach my $borrower (@borrowers) { >+ if ( !$borrower->{email} ) { >+ next; >+ } >+ >+ my $library = Koha::Libraries->find($borrower->{branchcode})->unblessed; >+ if ( my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'reserves', >+ letter_code => 'HOLDPLACED_CONTACT', >+ branchcode => $branch, >+ tables => { >+ 'branches' => $library, >+ 'borrowers' => $borrower, >+ 'biblio' => $biblionumber, >+ 'biblioitems' => $biblionumber, >+ 'items' => $checkitem, >+ }, >+ ) ) { >+ >+ my $admin_email_address = $library->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); >+ >+ C4::Letters::EnqueueLetter( >+ { letter => $letter, >+ borrowernumber => $borrower->{borrowernumber}, >+ message_transport_type => 'email', >+ from_address => $admin_email_address, >+ to_address => $borrower->{email}, >+ } >+ ); >+ } >+ >+ } >+ } >+ > return $reserve_id; > } > >@@ -2433,6 +2470,69 @@ sub GetHoldRule { > return $sth->fetchrow_hashref(); > } > >+=head2 GetBorrowersToSatisfyHold >+ >+my @borrowers = GetBorrowersToSatisfyHold( $hold ); >+ >+Returns borrowers who can return item to satisfy a given hold. >+ >+=cut >+ >+sub GetBorrowersToSatisfyHold { >+ my ( $hold ) = @_; >+ >+ my $query = ""; >+ >+ if ($hold->item()) { >+ $query = q{ >+ SELECT borrowers.borrowernumber >+ FROM reserves >+ JOIN items ON reserves.itemnumber = items.itemnumber >+ JOIN issues ON issues.itemnumber = items.itemnumber >+ JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber >+ WHERE reserves.reserve_id = ? >+ }; >+ } >+ elsif ($hold->biblio()) { >+ $query = q{ >+ SELECT borrowers.borrowernumber >+ FROM reserves >+ JOIN biblio ON reserves.biblionumber = biblio.biblionumber >+ JOIN items ON items.biblionumber = biblio.biblionumber >+ JOIN issues ON issues.itemnumber = items.itemnumber >+ JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber >+ WHERE reserves.reserve_id = ? >+ }; >+ } >+ >+ my $library = C4::Context->preference("NotifyToReturnItemFromLibrary"); >+ my $dbh = C4::Context->dbh; >+ my $sth; >+ >+ if ($library eq 'RequestorLibrary') { >+ $query .= " AND borrowers.branchcode = ?"; >+ $sth = $dbh->prepare( $query ); >+ $sth->execute( $hold->id(), $hold->borrower()->branchcode ); >+ } >+ elsif ($library eq 'ItemHomeLibrary') { >+ $query .= " AND items.homebranch = ?"; >+ $sth = $dbh->prepare( $query ); >+ $sth->execute( $hold->id(), $hold->borrower()->branchcode ); >+ } >+ else { >+ $sth = $dbh->prepare( $query ); >+ $sth->execute( $hold->id() ); >+ } >+ >+ my @results = (); >+ while ( my $data = $sth->fetchrow_hashref ) { >+ my $borrower = C4::Members::GetMember(borrowernumber => $data->{borrowernumber}); >+ push( @results, $borrower ); >+ } >+ >+ return @results; >+} >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >-- >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 17509
:
57143
|
57144
|
57145
|
57146
|
57147
|
57148
|
57149
|
57150
|
57157
|
57159
|
57160
|
57161
|
57162
|
57163
|
57164
|
57165
|
63258
|
63269
|
63270
|
63271
|
63272
|
63273
|
63274
|
63275
|
63276
|
63277
|
67982
|
80452
|
80453
|
80454
|
80455
|
80456
|
80457
|
80458
|
80459
|
80460
|
80461
|
86365
|
86366
|
86367
|
86368
|
86369