Koha/C4/SIP/ILS/Transaction/Hold.pm
Kyle M Hall ad3239479d Bug 9809: Update AddReserve prototype to remove constraint parameter
Test Plan:
1) Apply this patch set
2) prove t/db_dependent/Circulation.t
3) prove t/db_dependent/Holds.t
4) prove t/db_dependent/Holds/LocalHoldsPriority.t
5) prove t/db_dependent/Holds/RevertWaitingStatus.t
6) prove t/db_dependent/HoldsQueue.t
7) prove t/db_dependent/Reserves.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

AMENDED: An else branch in reserve/placerequest.pl was removed. This had
the effect of making it no longer possible to place an any hold in the
staff client.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Verified placing a biblio level and an item level hold.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2015-08-26 10:26:43 -03:00

131 lines
3.4 KiB
Perl

#
# status of a Hold transaction
package C4::SIP::ILS::Transaction::Hold;
use warnings;
use strict;
use C4::SIP::ILS::Transaction;
use C4::Reserves; # AddReserve
use C4::Members; # GetMember
use C4::Biblio; # GetBiblioFromItemNumber GetBiblioItemByBiblioNumber
use parent qw(C4::SIP::ILS::Transaction);
our $VERSION = 3.07.00.049;
my %fields = (
expiration_date => 0,
pickup_location => undef,
constraint_type => undef,
);
sub new {
my $class = shift;
my $self = $class->SUPER::new();
foreach my $element (keys %fields) {
$self->{_permitted}->{$element} = $fields{$element};
}
@{$self}{keys %fields} = values %fields;
return bless $self, $class;
}
sub queue_position {
my $self = shift;
return $self->item->hold_queue_position($self->patron->id);
}
sub do_hold {
my $self = shift;
unless ( $self->{patron} ) {
$self->screen_msg('do_hold called with undefined patron');
$self->ok(0);
return $self;
}
my $borrower = GetMember( 'cardnumber' => $self->{patron}->id );
unless ($borrower) {
$self->screen_msg( 'No borrower matches cardnumber "' . $self->{patron}->id . '".' );
$self->ok(0);
return $self;
}
my $bib = GetBiblioFromItemNumber( undef, $self->{item}->id );
unless ($bib) {
$self->screen_msg( 'No biblio record matches barcode "' . $self->{item}->id . '".' );
$self->ok(0);
return $self;
}
my $branch = ( $self->pickup_location || $self->{patron}->branchcode );
unless ($branch) {
$self->screen_msg('No branch specified (or found w/ patron).');
$self->ok(0);
return $self;
}
my $bibno = $bib->{biblionumber};
AddReserve( $branch, $borrower->{borrowernumber}, $bibno, GetBiblioItemByBiblioNumber($bibno) );
# unfortunately no meaningful return value
$self->ok(1);
return $self;
}
sub drop_hold {
my $self = shift;
unless ($self->{patron}) {
$self->screen_msg('drop_hold called with undefined patron');
$self->ok(0);
return $self;
}
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
unless ($borrower) {
$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
$self->ok(0);
return $self;
}
my $bib = GetBiblioFromItemNumber(undef, $self->{item}->id);
CancelReserve({
biblionumber => $bib->{biblionumber},
itemnumber => $self->{item}->id,
borrowernumber => $borrower->{borrowernumber}
});
$self->ok(1);
return $self;
}
sub change_hold {
my $self = shift;
unless ($self->{patron}) {
$self->screen_msg('change_hold called with undefined patron');
$self->ok(0);
return $self;
}
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
unless ($borrower) {
$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
$self->ok(0);
return $self;
}
my $bib = GetBiblioFromItemNumber(undef, $self->{item}->id);
unless ($bib) {
$self->screen_msg('No biblio record matches barcode "' . $self->{item}->id . '".');
$self->ok(0);
return $self;
}
my $branch = ($self->pickup_location || $self->{patron}->branchcode);
unless ($branch) {
$self->screen_msg('No branch specified (or found w/ patron).');
$self->ok(0);
return $self;
}
my $bibno = $bib->{biblionumber};
ModReserve({ biblionumber => $bibno, borrowernumber => $borrower->{borrowernumber}, branchcode => $branch });
$self->ok(1);
return $self;
}
1;
__END__