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

(-)a/C4/Circulation.pm (-24 / +24 lines)
Lines 382-390 sub TooMany { Link Here
382
    my $switch_onsite_checkout = $params->{switch_onsite_checkout} || 0;
382
    my $switch_onsite_checkout = $params->{switch_onsite_checkout} || 0;
383
    my $cat_borrower    = $borrower->{'categorycode'};
383
    my $cat_borrower    = $borrower->{'categorycode'};
384
    my $dbh             = C4::Context->dbh;
384
    my $dbh             = C4::Context->dbh;
385
	my $branch;
385
    # Get which branchcode we need
386
	# Get which branchcode we need
386
    my $branch = _GetCircControlBranch($item_object->unblessed,$borrower);
387
    $branch = _GetCircControlBranch($item_object->unblessed,$borrower);
388
    my $type = $item_object->effective_itemtype;
387
    my $type = $item_object->effective_itemtype;
389
388
390
    my ($type_object, $parent_type, $parent_maxissueqty_rule);
389
    my ($type_object, $parent_type, $parent_maxissueqty_rule);
Lines 416-422 sub TooMany { Link Here
416
        }
415
        }
417
    );
416
    );
418
417
419
420
    my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule(
418
    my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule(
421
        {
419
        {
422
            categorycode => $cat_borrower,
420
            categorycode => $cat_borrower,
Lines 558-597 sub TooMany { Link Here
558
}
556
}
559
557
560
sub _check_max_qty {
558
sub _check_max_qty {
561
    my $params = shift;
559
    my $params                       = shift;
562
    my $checkout_count = $params->{checkout_count};
560
    my $checkout_count               = $params->{checkout_count};
563
    my $onsite_checkout_count = $params->{onsite_checkout_count};
561
    my $onsite_checkout_count        = $params->{onsite_checkout_count};
564
    my $onsite_checkout = $params->{onsite_checkout};
562
    my $onsite_checkout              = $params->{onsite_checkout};
565
    my $max_checkouts_allowed = $params->{max_checkouts_allowed};
563
    my $max_checkouts_allowed        = $params->{max_checkouts_allowed};
566
    my $max_onsite_checkouts_allowed = $params->{max_onsite_checkouts_allowed};
564
    my $max_onsite_checkouts_allowed = $params->{max_onsite_checkouts_allowed};
567
    my $switch_onsite_checkout = $params->{switch_onsite_checkout};
565
    my $switch_onsite_checkout       = $params->{switch_onsite_checkout};
568
566
569
    if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
567
    if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
570
        if( $max_onsite_checkouts_allowed eq '' ){ return;}
568
        if ( $max_onsite_checkouts_allowed eq '' ) { return; }
571
        if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed )  {
569
        if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) {
572
            return {
570
            return {
573
                reason => 'TOO_MANY_ONSITE_CHECKOUTS',
571
                reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
574
                count => $onsite_checkout_count,
572
                count       => $onsite_checkout_count,
575
                max_allowed => $max_onsite_checkouts_allowed,
573
                max_allowed => $max_onsite_checkouts_allowed,
576
            }
574
            };
577
        }
575
        }
578
    }
576
    }
579
    if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
577
    if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
580
        if( $max_checkouts_allowed eq '' ){ return;}
578
        if ( $max_checkouts_allowed eq '' ) { return; }
581
        my $delta = $switch_onsite_checkout ? 1 : 0;
579
        my $delta = $switch_onsite_checkout ? 1 : 0;
582
        if ( $checkout_count >= $max_checkouts_allowed + $delta ) {
580
        if ( $checkout_count >= $max_checkouts_allowed + $delta ) {
583
            return {
581
            return {
584
                reason => 'TOO_MANY_CHECKOUTS',
582
                reason      => 'TOO_MANY_CHECKOUTS',
585
                count => $checkout_count,
583
                count       => $checkout_count,
586
                max_allowed => $max_checkouts_allowed,
584
                max_allowed => $max_checkouts_allowed,
587
            };
585
            };
588
        }
586
        }
589
    } elsif ( not $onsite_checkout ) {
587
    }
590
        if( $max_checkouts_allowed eq '' ){ return;}
588
    elsif ( not $onsite_checkout ) {
591
        if ( $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed ) {
589
        if ( $max_checkouts_allowed eq '' ) { return; }
590
        if (
591
            $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed )
592
        {
592
            return {
593
            return {
593
                reason => 'TOO_MANY_CHECKOUTS',
594
                reason      => 'TOO_MANY_CHECKOUTS',
594
                count => $checkout_count - $onsite_checkout_count,
595
                count       => $checkout_count - $onsite_checkout_count,
595
                max_allowed => $max_checkouts_allowed,
596
                max_allowed => $max_checkouts_allowed,
596
            };
597
            };
597
        }
598
        }
598
- 

Return to bug 26132