sub GetReserve {
my ($reserve_id) = @_;
- #warn "C4::Reserves::GetReserve( $reserve_id )";
my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM reserves WHERE reserve_id = ?";
}
# we check if it's ok or not
- if( $reservecount < $allowedreserves ){
- return 1;
- }else{
+ if( $reservecount >= $allowedreserves ){
return 0;
}
+
+ # If reservecount is ok, we check item branch if IndependentBranches is ON
+ # and canreservefromotherbranches is OFF
+ if ( C4::Context->preference('IndependentBranches')
+ and !C4::Context->preference('canreservefromotherbranches') )
+ {
+ my $itembranch = $item->{homebranch};
+ if ($itembranch ne $borrower->{branchcode}) {
+ return 0;
+ }
+ }
+
+ return 1;
}
#--------------------------------------------------------------------------------
=head2 GetReserveCount
my $reserve = GetReserve( $reserve_id );
+ if ( $reserve->{cancellationdate} ) {
+ warn "I cannot alter the priority for reserve_id $reserve_id, the reserve has been cancelled (".$reserve->{cancellationdate}.')';
+ return;
+ }
+
if ( $where eq 'up' || $where eq 'down' ) {
-
- my $priority = $reserve->{'priority'};
+
+ my $priority = $reserve->{'priority'};
$priority = $where eq 'up' ? $priority - 1 : $priority + 1;
_FixPriority( $reserve_id, $priority )
$sth->execute( $reserve_id );
}
my @priority;
- my @reservedates;
# get whats left
my $query = "
my $sth = $dbh->prepare($query);
$sth->execute( $res->{'biblionumber'} );
while ( my $line = $sth->fetchrow_hashref ) {
- push( @reservedates, $line );
push( @priority, $line );
}
sub MergeHolds {
my ( $dbh, $to_biblio, $from_biblio ) = @_;
my $sth = $dbh->prepare(
- "SELECT count(*) as reserve_id FROM reserves WHERE biblionumber = ?"
+ "SELECT count(*) as reserve_count FROM reserves WHERE biblionumber = ?"
);
$sth->execute($from_biblio);
if ( my $data = $sth->fetchrow_hashref() ) {