Bugzilla – Attachment 21337 Details for
Bug 8868
ILS-DI: CancelHold needs to take a reserve_id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 8868: ILS-DI: CancelHold needs to take a reserve_id
Bug-8868-ILS-DI-CancelHold-needs-to-take-a-reserve.patch (text/plain), 5.59 KB, created by
Julian Maurice
on 2013-09-23 08:24:25 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 8868: ILS-DI: CancelHold needs to take a reserve_id
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2013-09-23 08:24:25 UTC
Size:
5.59 KB
patch
obsolete
>From 4d2a5986aad05996e1b613bcc3996fb0689c5f85 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 3 Oct 2012 13:23:04 +0200 >Subject: [PATCH] Bug 8868: ILS-DI: CancelHold needs to take a reserve_id > >CancelHold takes two parameters: patron_id and item_id. >If item_id is considered as an itemnumber, holds on title can't be >canceled. >If item_id is considered as a biblionumber, all holds on this >biblionumber (for a borrower) will be canceled. > >So CancelHold have to consider item_id as a reserve_id. > >Added subroutines C4::Reserves::GetReserve and >C4::Reserves::CancelReserveFromId >C4::ILSDI::Services::GetRecords now returns the reserve_id > >Signed-off-by: Leila and Sonia <koha.aixmarseille@gmail.com> >--- > C4/ILSDI/Services.pm | 30 ++++++------------- > C4/Reserves.pm | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 89 insertions(+), 21 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 7941a70..3e40b53 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -26,7 +26,7 @@ use C4::Circulation; > use C4::Branch; > use C4::Accounts; > use C4::Biblio; >-use C4::Reserves qw(AddReserve CancelReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved); >+use C4::Reserves qw(AddReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved); > use C4::Context; > use C4::AuthoritiesMarc; > use C4::ILSDI::Utility; >@@ -727,9 +727,9 @@ Cancels an active reserve request for the borrower. > Parameters: > > - patron_id (Required) >- a borrowernumber >+ a borrowernumber > - item_id (Required) >- an itemnumber >+ a reserve_id > > =cut > >@@ -741,25 +741,13 @@ sub CancelHold { > my $borrower = GetMemberDetails( $borrowernumber ); > return { code => 'PatronNotFound' } unless $$borrower{borrowernumber}; > >- # Get the item or return an error code >- my $itemnumber = $cgi->param('item_id'); >- my $item = GetItem( $itemnumber ); >- return { code => 'RecordNotFound' } unless $$item{itemnumber}; >- >- # Get borrower's reserves >- my @reserves = GetReservesFromBorrowernumber( $borrowernumber, undef ); >- my @reserveditems; >- >- # ...and loop over it to build an array of reserved itemnumbers >- foreach my $reserve (@reserves) { >- push @reserveditems, $reserve->{'itemnumber'}; >- } >- >- # if the item was not reserved by the borrower, returns an error code >- return { code => 'NotCanceled' } unless any { $itemnumber eq $_ } @reserveditems; >+ # Get the reserve or return an error code >+ my $reserve_id = $cgi->param('item_id'); >+ my $reserve = C4::Reserves::GetReserve($reserve_id); >+ return { code => 'RecordNotFound' } unless $reserve; >+ return { code => 'RecordNotFound' } unless ($reserve->{borrowernumber} == $borrowernumber); > >- # Cancel the reserve >- CancelReserve({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); >+ C4::Reserves::CancelReserveFromId($reserve_id); > > return { code => 'Canceled' }; > } >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 5514796..2151b4e 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -104,6 +104,7 @@ BEGIN { > &GetReserveFee > &GetReserveInfo > &GetReserveStatus >+ &GetReserve > > &GetOtherReserves > >@@ -119,6 +120,7 @@ BEGIN { > &CanBookBeReserved > &CanItemBeReserved > &CancelReserve >+ &CancelReserveFromId > &CancelExpiredReserves > > &AutoUnsuspendReserves >@@ -808,6 +810,34 @@ sub GetReserveStatus { > #empty string here will remove need for checking undef, or less log lines > } > >+=head2 GetReserve >+ >+ my $reserve = C4::Reserves::GetReserve($reserve_id); >+ >+Take a reserve_id and returns a hashref containing reserve informations. >+Return undef if reserve_id doesn't exist. >+ >+=cut >+ >+sub GetReserve { >+ my ($reserve_id) = @_; >+ >+ return unless $reserve_id; >+ >+ my $dbh = C4::Context->dbh; >+ my $query = qq{ >+ SELECT * >+ FROM reserves >+ WHERE reserve_id = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ >+ $sth->execute($reserve_id); >+ my $reserve = $sth->fetchrow_hashref; >+ >+ return $reserve; >+} >+ > =head2 CheckReserves > > ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber); >@@ -1030,6 +1060,56 @@ sub CancelReserve { > _FixPriority( $reserve_id ); > } > >+=head2 CancelReserveFromId >+ >+ C4::Reserves::CancelReserveFromId($reserve_id); >+ >+Cancel a reserve, given its reserve_id >+ >+=cut >+ >+sub CancelReserveFromId { >+ my ($reserve_id) = @_; >+ >+ my $reserve = GetReserve($reserve_id); >+ if ($reserve) { >+ my $dbh = C4::Context->dbh; >+ >+ # update the database, removing the record... >+ my $query = qq{ >+ UPDATE reserves >+ SET cancellationdate = NOW(), >+ found = NULL, >+ priority = 0 >+ WHERE reserve_id = ? >+ }; >+ my $sth = $dbh->prepare($query); >+ $sth->execute($reserve_id); >+ $sth->finish; >+ >+ $query = qq{ >+ INSERT INTO old_reserves >+ SELECT * FROM reserves >+ WHERE reserve_id = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($reserve_id); >+ >+ $query = qq{ >+ DELETE FROM reserves >+ WHERE reserve_id = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($reserve_id); >+ >+ # now fix the priority on the others... >+ _FixPriority( $reserve->{biblionumber}, $reserve->{borrowernumber} ); >+ } >+ >+ return $reserve; >+} >+ >+ > =head2 ModReserve > > ModReserve({ rank => $rank, >-- >1.7.10.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 8868
:
12657
|
16313
|
16527
|
18921
|
21337
|
21338
|
22723
|
22724
|
24879
|
26150
|
26271
|
26333
|
26645
|
27023
|
27024
|
27771
|
27947
|
30881
|
30908
|
30909