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

(-)a/C4/Circulation.pm (-52 / +51 lines)
Lines 834-839 sub CanBookBeIssued { Link Here
834
        }
834
        }
835
    }
835
    }
836
836
837
    #
838
    # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
839
    #
840
    if ( $issue && $issue->borrowernumber eq $borrower->{'borrowernumber'} ){
841
842
        # Already issued to current borrower.
843
        # If it is an on-site checkout if it can be switched to a normal checkout
844
        # or ask whether the loan should be renewed
845
846
        if ( $issue->onsite_checkout
847
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
848
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
849
        } else {
850
            my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed(
851
                $borrower->{'borrowernumber'},
852
                $item->{'itemnumber'},
853
            );
854
            if ( $CanBookBeRenewed == 0 ) {    # no more renewals allowed
855
                if ( $renewerror eq 'onsite_checkout' ) {
856
                    $issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1;
857
                }
858
                else {
859
                    $issuingimpossible{NO_MORE_RENEWALS} = 1;
860
                }
861
            }
862
            else {
863
                $needsconfirmation{RENEW_ISSUE} = 1;
864
            }
865
        }
866
    }
867
    elsif ( $issue ) {
868
869
        # issued to someone else
870
871
        my $patron = Koha::Patrons->find( $issue->borrowernumber );
872
873
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
874
875
        unless ( $can_be_returned ) {
876
            $issuingimpossible{RETURN_IMPOSSIBLE} = 1;
877
            $issuingimpossible{branch_to_return} = $message;
878
        } else {
879
            $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
880
            $needsconfirmation{issued_firstname} = $patron->firstname;
881
            $needsconfirmation{issued_surname} = $patron->surname;
882
            $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
883
            $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
884
        }
885
    }
886
837
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
887
    # JB34 CHECKS IF BORROWERS DON'T HAVE ISSUE TOO MANY BOOKS
838
    #
888
    #
839
    my $switch_onsite_checkout = (
889
    my $switch_onsite_checkout = (
Lines 843-849 sub CanBookBeIssued { Link Here
843
      and $issue->borrowernumber == $borrower->{'borrowernumber'} ? 1 : 0 );
893
      and $issue->borrowernumber == $borrower->{'borrowernumber'} ? 1 : 0 );
844
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
894
    my $toomany = TooMany( $borrower, $item->{biblionumber}, $item, { onsite_checkout => $onsite_checkout, switch_onsite_checkout => $switch_onsite_checkout, } );
845
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
895
    # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book
846
    if ( $toomany ) {
896
    if ( $toomany  & !$needsconfirmation{RENEW_ISSUE} ) {
847
        if ( $toomany->{max_allowed} == 0 ) {
897
        if ( $toomany->{max_allowed} == 0 ) {
848
            $needsconfirmation{PATRON_CANT} = 1;
898
            $needsconfirmation{PATRON_CANT} = 1;
849
        }
899
        }
Lines 944-999 sub CanBookBeIssued { Link Here
944
        }
994
        }
945
    }
995
    }
946
996
947
    #
948
    # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
949
    #
950
    if ( $issue && $issue->borrowernumber eq $borrower->{'borrowernumber'} ){
951
952
        # Already issued to current borrower.
953
        # If it is an on-site checkout if it can be switched to a normal checkout
954
        # or ask whether the loan should be renewed
955
956
        if ( $issue->onsite_checkout
957
                and C4::Context->preference('SwitchOnSiteCheckouts') ) {
958
            $messages{ONSITE_CHECKOUT_WILL_BE_SWITCHED} = 1;
959
        } else {
960
            my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed(
961
                $borrower->{'borrowernumber'},
962
                $item->{'itemnumber'},
963
            );
964
            if ( $CanBookBeRenewed == 0 ) {    # no more renewals allowed
965
                if ( $renewerror eq 'onsite_checkout' ) {
966
                    $issuingimpossible{NO_RENEWAL_FOR_ONSITE_CHECKOUTS} = 1;
967
                }
968
                else {
969
                    $issuingimpossible{NO_MORE_RENEWALS} = 1;
970
                }
971
            }
972
            else {
973
                $needsconfirmation{RENEW_ISSUE} = 1;
974
            }
975
        }
976
    }
977
    elsif ( $issue ) {
978
979
        # issued to someone else
980
981
        my $patron = Koha::Patrons->find( $issue->borrowernumber );
982
983
        my ( $can_be_returned, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
984
985
        unless ( $can_be_returned ) {
986
            $issuingimpossible{RETURN_IMPOSSIBLE} = 1;
987
            $issuingimpossible{branch_to_return} = $message;
988
        } else {
989
            $needsconfirmation{ISSUED_TO_ANOTHER} = 1;
990
            $needsconfirmation{issued_firstname} = $patron->firstname;
991
            $needsconfirmation{issued_surname} = $patron->surname;
992
            $needsconfirmation{issued_cardnumber} = $patron->cardnumber;
993
            $needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
994
        }
995
    }
996
997
    unless ( $ignore_reserves ) {
997
    unless ( $ignore_reserves ) {
998
        # See if the item is on reserve.
998
        # See if the item is on reserve.
999
        my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} );
999
        my ( $restype, $res ) = C4::Reserves::CheckReserves( $item->{'itemnumber'} );
1000
- 

Return to bug 19198