View | Details | Raw Unified | Return to bug 33691
Collapse All | Expand All

(-)a/Koha/Patron.pm (-12 / +12 lines)
Lines 726-746 $PATRON, 0 otherwise. Link Here
726
sub do_check_for_previous_checkout {
726
sub do_check_for_previous_checkout {
727
    my ( $self, $item ) = @_;
727
    my ( $self, $item ) = @_;
728
728
729
    my $criteria = { borrowernumber => $self->borrowernumber };
730
731
    my $attrs = {};
732
729
    my @item_nos;
733
    my @item_nos;
730
    my $biblio = Koha::Biblios->find( $item->{biblionumber} );
734
    my $biblio = Koha::Biblios->find( $item->{biblionumber} );
735
    #
736
    # Create (old)issues search criteria
731
    if ( $biblio->is_serial ) {
737
    if ( $biblio->is_serial ) {
732
        push @item_nos, $item->{itemnumber};
738
        $criteria->{itemnumber} = $item->{itemnumber};
733
    } else {
739
    } else {
734
        # Get all itemnumbers for given bibliographic record.
740
        # Get all itemnumbers for given bibliographic record.
735
        @item_nos = $biblio->items->get_column( 'itemnumber' );
741
        @item_nos = $biblio->items->get_column( 'itemnumber' );
742
        $criteria->{'biblio.biblionumber'} = $item->{biblionumber};
743
        $attrs->{join} = { 'item' => 'biblio' };
736
    }
744
    }
737
745
738
    # Create (old)issues search criteria
739
    my $criteria = {
740
        borrowernumber => $self->borrowernumber,
741
        itemnumber => \@item_nos,
742
    };
743
744
    my $delay = C4::Context->preference('CheckPrevCheckoutDelay') || 0;
746
    my $delay = C4::Context->preference('CheckPrevCheckoutDelay') || 0;
745
    if ($delay) {
747
    if ($delay) {
746
        my $dtf = Koha::Database->new->schema->storage->datetime_parser;
748
        my $dtf = Koha::Database->new->schema->storage->datetime_parser;
Lines 749-760 sub do_check_for_previous_checkout { Link Here
749
    }
751
    }
750
752
751
    # Check current issues table
753
    # Check current issues table
752
    my $issues = Koha::Checkouts->search($criteria);
754
    return 1
753
    return 1 if $issues->count; # 0 || N
755
      if Koha::Checkouts->search( $criteria, $attrs )->count;
754
756
755
    # Check old issues table
757
    # Check old issues table
756
    my $old_issues = Koha::Old::Checkouts->search($criteria);
758
    return Koha::Old::Checkouts->search( $criteria, $attrs )->count;
757
    return $old_issues->count;  # 0 || N
758
}
759
}
759
760
760
=head3 is_debarred
761
=head3 is_debarred
761
- 

Return to bug 33691