# $constraint, $bibitems, $priority, $resdate, $expdate, $notes,
# $title, $checkitem, $found
my $priority= C4::Reserves::CalculatePriority( $biblionumber );
- AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $priority, undef, undef, undef, $title, undef, undef );
+ AddReserve( $branch, $borrowernumber, $biblionumber, undef, $priority, undef, undef, undef, $title, undef, undef );
# Hashref building
my $out;
# $constraint, $bibitems, $priority, $resdate, $expdate, $notes,
# $title, $checkitem, $found
my $priority= C4::Reserves::CalculatePriority( $biblionumber );
- AddReserve( $branch, $borrowernumber, $biblionumber, 'a', undef, $priority, undef, undef, undef, $title, $itemnumber, undef );
+ AddReserve( $branch, $borrowernumber, $biblionumber, undef, $priority, undef, undef, undef, $title, $itemnumber, undef );
# Hashref building
my $out;
=head2 AddReserve
- AddReserve($branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found)
+ AddReserve($branch,$borrowernumber,$biblionumber,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found)
=cut
sub AddReserve {
my (
$branch, $borrowernumber, $biblionumber,
- $constraint, $bibitems, $priority, $resdate, $expdate, $notes,
+ $bibitems, $priority, $resdate, $expdate, $notes,
$title, $checkitem, $found
) = @_;
my $fee =
- GetReserveFee($borrowernumber, $biblionumber, $constraint,
+ GetReserveFee($borrowernumber, $biblionumber,
$bibitems );
my $dbh = C4::Context->dbh;
- my $const = lc substr( $constraint, 0, 1 );
$resdate = format_date_in_iso( $resdate ) if ( $resdate );
$resdate = C4::Dates->today( 'iso' ) unless ( $resdate );
if ($expdate) {
"Reserve Charge - $title", $fee );
}
- #if ($const eq 'a'){
my $query = qq{
INSERT INTO reserves
- (borrowernumber,biblionumber,reservedate,branchcode,constrainttype,
+ (borrowernumber,biblionumber,reservedate,branchcode,
priority,reservenotes,itemnumber,found,waitingdate,expirationdate)
VALUES
(?,?,?,?,?,
- ?,?,?,?,?,?)
+ ?,?,?,?,?)
};
my $sth = $dbh->prepare($query);
$sth->execute(
- $borrowernumber, $biblionumber, $resdate, $branch,
- $const, $priority, $notes, $checkitem,
- $found, $waitingdate, $expdate
+ $borrowernumber, $biblionumber, $resdate, $branch, $priority,
+ $notes, $checkitem, $found, $waitingdate, $expdate
);
my $reserve_id = $sth->{mysql_insertid};
}
}
- #}
- ($const eq "o" || $const eq "e") or return $reserve_id;
-
return $reserve_id;
}
biblionumber,
borrowernumber,
reservedate,
- constrainttype,
found,
itemnumber,
reservenotes,
=head2 GetReserveFee
- $fee = GetReserveFee($borrowernumber,$biblionumber,$constraint,$biblionumber);
+ $fee = GetReserveFee($borrowernumber,$biblionumber,$biblionumber);
Calculate the fee for a reserve
=cut
sub GetReserveFee {
- my ($borrowernumber, $biblionumber, $constraint, $bibitems ) = @_;
+ my ($borrowernumber, $biblionumber, $bibitems ) = @_;
#check for issues;
my $dbh = C4::Context->dbh;
- my $const = lc substr( $constraint, 0, 1 );
my $query = qq{
SELECT * FROM borrowers
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode
);
$sth1->execute($biblionumber);
while ( my $data1 = $sth1->fetchrow_hashref ) {
- if ( $const eq "a" ) {
- push @biblioitems, $data1;
- }
- else {
- my $found = 0;
- my $x = 0;
- while ( $x < $cntitems ) {
- if ( @$bibitems->{'biblioitemnumber'} ==
- $data->{'biblioitemnumber'} )
- {
- $found = 1;
- }
- $x++;
- }
- if ( $const eq 'o' ) {
- if ( $found == 1 ) {
- push @biblioitems, $data1;
- }
- }
- else {
- if ( $found == 0 ) {
- push @biblioitems, $data1;
- }
+ my $found = 0;
+ my $x = 0;
+ while ( $x < $cntitems ) {
+ if ( @$bibitems->{'biblioitemnumber'} ==
+ $data->{'biblioitemnumber'} )
+ {
+ $found = 1;
}
+ $x++;
+ }
+
+ if ( $found == 0 ) {
+ push @biblioitems, $data1;
}
}
my $cntitemsfound = @biblioitems;
# get whats left
my $query = "
- SELECT reserve_id, borrowernumber, reservedate, constrainttype
+ SELECT reserve_id, borrowernumber, reservedate
FROM reserves
WHERE biblionumber = ?
AND ((found <> 'W' AND found <> 'T') OR found IS NULL)
@results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead, $ignore_borrowers);
-Looks for an item-specific match first, then for a title-level match, returning the
-first match found. If neither, then we look for a 3rd kind of match based on
-reserve constraints.
+Looks for a holds-queue based item-specific match first, then for a holds-queue title-level match, returning the
+first match found. If neither, then we look for non-holds-queue based holds.
Lookahead is the number of days to look in advance.
-TODO: add more explanation about reserve constraints
-
C<&_Findgroupreserve> returns :
C<@results> is an array of references-to-hash whose keys are mostly
fields from the reserves table of the Koha database, plus
);
my $upd_sth = $dbh->prepare(
"UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ?
- AND reservedate = ? AND constrainttype = ? AND (itemnumber = ? or itemnumber is NULL) "
+ AND reservedate = ? AND (itemnumber = ? or itemnumber is NULL) "
);
$sth->execute( $to_biblio, 'W', 'T' );
my $priority = 1;
$upd_sth->execute(
$priority, $to_biblio,
$reserve->{'borrowernumber'}, $reserve->{'reservedate'},
- $reserve->{'constrainttype'}, $reserve->{'itemnumber'}
+ $reserve->{'itemnumber'}
);
$priority++;
}
}
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;
+ 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 {
if ($canreserve) {
AddReserve(
$branch, $borrowernumber,
- $biblioNum, 'a',
+ $biblioNum,
[$biblioNum], $rank,
$startdate, $expiration_date,
$notes, $biblioData->{title},
checkauth($input, 0, { reserveforothers => 'place_holds' }, 'intranet');
my @bibitems=$input->param('biblioitem');
-# FIXME I think reqbib does not exist anymore, it's used in line 82, to AddReserve of contraint type 'o'
-# I bet it's a 2.x feature, reserving a given biblioitem, that is useless in Koha 3.0
-# we can remove this line, the AddReserve of constrainttype 'o',
-# and probably remove the reserveconstraint table as well, I never could fill anything in this table.
my @reqbib=$input->param('reqbib');
my $biblionumber=$input->param('biblionumber');
my $borrowernumber=$input->param('borrowernumber');
if ($multi_hold) {
my $bibinfo = $bibinfos{$biblionumber};
- AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',[$biblionumber],
+ AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,[$biblionumber],
$bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found);
} else {
- if ($input->param('request') eq 'any'){
- # place a request on 1st available
- AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem,$found);
- } elsif ($reqbib[0] ne ''){
- # FIXME : elsif probably never reached, (see top of the script)
- # place a request on a given item
- AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
- } else {
- AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
- }
+ # place a request on 1st available
+ AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem,$found);
}
}
$count--;
}
}
- my $const = 'o';
my $notes;
my $title = $subs->{'bibliotitle'};
for my $routing ( @routinglist ) {
branchcode => $branch
});
} else {
- AddReserve($branch,$routing->{borrowernumber},$biblio,$const,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title);
+ AddReserve($branch,$routing->{borrowernumber},$biblio,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title);
}
}
}