| Lines 418-424
          sub GetReservesFromBorrowernumber {
      
      
        Link Here | 
        
          | 418 |  | 418 |  | 
        
          | 419 | =head2 CanBookBeReserved | 419 | =head2 CanBookBeReserved | 
        
          | 420 |  | 420 |  | 
          
            
              | 421 |   $canReserve = &CanBookBeReserved($borrowernumber, $biblionumber) | 421 |   $canReserve = &CanBookBeReserved($borrowernumber, $biblionumber, $branchcode) | 
        
          | 422 |   if ($canReserve eq 'OK') { #We can reserve this Item! } | 422 |   if ($canReserve eq 'OK') { #We can reserve this Item! } | 
        
          | 423 |  | 423 |  | 
        
          | 424 | See CanItemBeReserved() for possible return values. | 424 | See CanItemBeReserved() for possible return values. | 
  
    | Lines 426-432
          See CanItemBeReserved() for possible return values.
      
      
        Link Here | 
        
          | 426 | =cut | 426 | =cut | 
        
          | 427 |  | 427 |  | 
        
          | 428 | sub CanBookBeReserved{ | 428 | sub CanBookBeReserved{ | 
          
            
              | 429 |     my ($borrowernumber, $biblionumber) = @_; | 429 |     my ($borrowernumber, $biblionumber, $branchcode) = @_; | 
        
          | 430 |  | 430 |  | 
        
          | 431 |     my $items = GetItemnumbersForBiblio($biblionumber); | 431 |     my $items = GetItemnumbersForBiblio($biblionumber); | 
        
          | 432 |     #get items linked via host records | 432 |     #get items linked via host records | 
  
    | Lines 437-443
          sub CanBookBeReserved{
      
      
        Link Here | 
        
          | 437 |  | 437 |  | 
        
          | 438 |     my $canReserve; | 438 |     my $canReserve; | 
        
          | 439 |     foreach my $item (@$items) { | 439 |     foreach my $item (@$items) { | 
          
            
              | 440 |         $canReserve = CanItemBeReserved( $borrowernumber, $item ); | 440 |         $canReserve = CanItemBeReserved( $borrowernumber, $item, $branchcode ); | 
        
          | 441 |         return 'OK' if $canReserve eq 'OK'; | 441 |         return 'OK' if $canReserve eq 'OK'; | 
        
          | 442 |     } | 442 |     } | 
        
          | 443 |     return $canReserve; | 443 |     return $canReserve; | 
  
    | Lines 445-451
          sub CanBookBeReserved{
      
      
        Link Here | 
        
          | 445 |  | 445 |  | 
        
          | 446 | =head2 CanItemBeReserved | 446 | =head2 CanItemBeReserved | 
        
          | 447 |  | 447 |  | 
          
            
              | 448 |   $canReserve = &CanItemBeReserved($borrowernumber, $itemnumber) | 448 |   $canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode) | 
        
          | 449 |   if ($canReserve eq 'OK') { #We can reserve this Item! } | 449 |   if ($canReserve eq 'OK') { #We can reserve this Item! } | 
        
          | 450 |  | 450 |  | 
        
          | 451 | @RETURNS OK,              if the Item can be reserved. | 451 | @RETURNS OK,              if the Item can be reserved. | 
  
    | Lines 454-464
          sub CanBookBeReserved{
      
      
        Link Here | 
        
          | 454 |          cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK. | 454 |          cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK. | 
        
          | 455 |          tooManyReserves, if the borrower has exceeded his maximum reserve amount. | 455 |          tooManyReserves, if the borrower has exceeded his maximum reserve amount. | 
        
          | 456 |          notReservable,   if holds on this item are not allowed | 456 |          notReservable,   if holds on this item are not allowed | 
            
              |  |  | 457 |          libraryNotFound  if given branchcode is not an existing library | 
            
              | 458 |          libraryNotPickupLocation if given branchcode is not configured to be a pickup location | 
        
          | 457 |  | 459 |  | 
        
          | 458 | =cut | 460 | =cut | 
        
          | 459 |  | 461 |  | 
        
          | 460 | sub CanItemBeReserved { | 462 | sub CanItemBeReserved { | 
          
            
              | 461 |     my ( $borrowernumber, $itemnumber ) = @_; | 463 |     my ( $borrowernumber, $itemnumber, $branchcode_to ) = @_; | 
        
          | 462 |  | 464 |  | 
        
          | 463 |     my $dbh = C4::Context->dbh; | 465 |     my $dbh = C4::Context->dbh; | 
        
          | 464 |     my $ruleitemtype;    # itemtype of the matching issuing rule | 466 |     my $ruleitemtype;    # itemtype of the matching issuing rule | 
  
    | Lines 587-592
          sub CanItemBeReserved {
      
      
        Link Here | 
        
          | 587 |         } | 589 |         } | 
        
          | 588 |     } | 590 |     } | 
        
          | 589 |  | 591 |  | 
            
              |  |  | 592 |     if ($branchcode_to) { | 
            
              | 593 |         my $destination = Koha::Libraries->find({ | 
            
              | 594 |             branchcode => $branchcode_to, | 
            
              | 595 |         }); | 
            
              | 596 |         unless ($destination) { | 
            
              | 597 |             return 'libraryNotFound'; | 
            
              | 598 |         } | 
            
              | 599 |         unless ($destination->pickup_location) { | 
            
              | 600 |             return 'libraryNotPickupLocation'; | 
            
              | 601 |         } | 
            
              | 602 |     } | 
            
              | 603 |  | 
        
          | 590 |     return 'OK'; | 604 |     return 'OK'; | 
        
          | 591 | } | 605 | } | 
        
          | 592 |  | 606 |  |