Bug 14695 [QA Followup] - Fix clearing of all holds by patron at checkout
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jason M. Burds <JBurds@dubuque.lib.ia.us> Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
This commit is contained in:
parent
8e338c3ae1
commit
e1b1a67fdd
|
|
@ -40,6 +40,7 @@ use Koha::DateUtils;
|
|||
use Koha::Calendar;
|
||||
use Koha::Database;
|
||||
use Koha::Hold;
|
||||
use Koha::Old::Hold;
|
||||
use Koha::Holds;
|
||||
use Koha::Libraries;
|
||||
use Koha::Items;
|
||||
|
|
@ -1228,56 +1229,31 @@ whose keys are fields from the reserves table in the Koha database.
|
|||
|
||||
sub ModReserveFill {
|
||||
my ($res) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
# fill in a reserve record....
|
||||
my $reserve_id = $res->{'reserve_id'};
|
||||
my $biblionumber = $res->{'biblionumber'};
|
||||
my $borrowernumber = $res->{'borrowernumber'};
|
||||
my $resdate = $res->{'reservedate'};
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $hold = Koha::Holds->find($reserve_id);
|
||||
|
||||
# get the priority on this record....
|
||||
my $priority;
|
||||
my $query = "SELECT priority
|
||||
FROM reserves
|
||||
WHERE biblionumber = ?
|
||||
AND borrowernumber = ?
|
||||
AND reservedate = ?";
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute( $biblionumber, $borrowernumber, $resdate );
|
||||
($priority) = $sth->fetchrow_array;
|
||||
my $priority = $hold->priority;
|
||||
|
||||
# update the database...
|
||||
$query = "UPDATE reserves
|
||||
SET found = 'F',
|
||||
priority = 0
|
||||
WHERE biblionumber = ?
|
||||
AND reservedate = ?
|
||||
AND borrowernumber = ?
|
||||
";
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute( $biblionumber, $resdate, $borrowernumber );
|
||||
# update the hold statuses, no need to store it though, we will be deleting it anyway
|
||||
$hold->set(
|
||||
{
|
||||
found => 'F',
|
||||
priority => 0,
|
||||
}
|
||||
);
|
||||
|
||||
# move to old_reserves
|
||||
$query = "INSERT INTO old_reserves
|
||||
SELECT * FROM reserves
|
||||
WHERE biblionumber = ?
|
||||
AND reservedate = ?
|
||||
AND borrowernumber = ?
|
||||
";
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute( $biblionumber, $resdate, $borrowernumber );
|
||||
$query = "DELETE FROM reserves
|
||||
WHERE biblionumber = ?
|
||||
AND reservedate = ?
|
||||
AND borrowernumber = ?
|
||||
";
|
||||
$sth = $dbh->prepare($query);
|
||||
$sth->execute( $biblionumber, $resdate, $borrowernumber );
|
||||
my $old_hold = Koha::Old::Hold->new( $hold->unblessed() )->store();
|
||||
|
||||
$hold->delete();
|
||||
|
||||
# now fix the priority on the others (if the priority wasn't
|
||||
# already sorted!)....
|
||||
unless ( $priority == 0 ) {
|
||||
_FixPriority({ reserve_id => $reserve_id, biblionumber => $biblionumber });
|
||||
_FixPriority( { reserve_id => $reserve_id, biblionumber => $hold->biblionumber } );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
package Koha::Old::Hold;
|
||||
|
||||
# Copyright ByWater Solutions 2014
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use base qw(Koha::Hold);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Old::Hold - Koha Old Hold object class
|
||||
|
||||
This object represents a hold that has been filled or canceled
|
||||
|
||||
=head1 API
|
||||
|
||||
=head2 Class Methods
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
=head3 type
|
||||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
return 'OldReserve';
|
||||
}
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Kyle M Hall <kyle@bywatersolutions.com>
|
||||
|
||||
=cut
|
||||
|
||||
1;
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package Koha::Old::Holds;
|
||||
|
||||
# Copyright ByWater Solutions 2014
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Carp;
|
||||
|
||||
use Koha::Database;
|
||||
|
||||
use Koha::Old::Hold;
|
||||
|
||||
use base qw(Koha::Holds);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Old::Holds - Koha Old Hold object set class
|
||||
|
||||
This object represents a set of holds that have been filled or canceled
|
||||
|
||||
=head1 API
|
||||
|
||||
=head2 Class Methods
|
||||
|
||||
=cut
|
||||
|
||||
=head3 type
|
||||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
return 'OldReserve';
|
||||
}
|
||||
|
||||
=head3 object_class
|
||||
|
||||
=cut
|
||||
|
||||
sub object_class {
|
||||
return 'Koha::Old::Hold';
|
||||
}
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Kyle M Hall <kyle@bywatersolutions.com>
|
||||
|
||||
=cut
|
||||
|
||||
1;
|
||||
Loading…
Reference in New Issue