827ef0e83c
All the modules in the SIP/ILS tree are objects The addition of calls to Exporter or hand manipulation of @ISA added unnecessary bloat Removed the "self = shift or return" idiom as it is nonsensical if the method can only be called via an object. standardized inheritance via use parent added a $self = shift in a couple of places where it was not strictly necessary as its absence seemed to have misled readers in the past Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Passed-QA-by: Mason James <mtj@kohaaloha.com> Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
135 lines
3.7 KiB
Perl
135 lines
3.7 KiB
Perl
#
|
|
# status of a Hold transaction
|
|
|
|
package ILS::Transaction::Hold;
|
|
|
|
use warnings;
|
|
use strict;
|
|
|
|
use ILS;
|
|
use ILS::Transaction;
|
|
|
|
use C4::Reserves; # AddReserve
|
|
use C4::Members; # GetMember
|
|
use C4::Biblio; # GetBiblioFromItemNumber GetBiblioItemByBiblioNumber
|
|
use parent qw(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, 'a', 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);
|
|
# FIXME: figure out if it is a item or title hold. Till then, cancel both.
|
|
CancelReserve($bib->{biblionumber}, undef, $borrower->{borrowernumber});
|
|
CancelReserve(undef, $self->{item}->id, $borrower->{borrowernumber});
|
|
# unfortunately no meaningful return value here either
|
|
$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($bibno, $borrower->{borrowernumber}, $branch, GetBiblioItemByBiblioNumber($bibno));
|
|
# unfortunately no meaningful return value
|
|
# ModReserve needs to be fixed to maintain priority by iteself (Feb 2008)
|
|
$self->ok(1);
|
|
return $self;
|
|
}
|
|
1;
|
|
__END__
|
|
|
|
# 11 friggin arguments
|
|
AddReserve($branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$startdate,$notes,$title,$checkitem,$found)
|
|
|
|
ModReserve($rank, $biblio, $borrower, $branch , $itemnumber)
|
|
|