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

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

Return to bug 19198