Lines 418-423
sub TooMany {
Link Here
|
418 |
categorycode => $cat_borrower, |
418 |
categorycode => $cat_borrower, |
419 |
itemtype => $parent_type, |
419 |
itemtype => $parent_type, |
420 |
branchcode => $branch, |
420 |
branchcode => $branch, |
|
|
421 |
onsite_checkout => $onsite_checkout, |
421 |
rule_name => 'maxissueqty', |
422 |
rule_name => 'maxissueqty', |
422 |
} |
423 |
} |
423 |
) if $parent_type; |
424 |
) if $parent_type; |
Lines 429-448
sub TooMany {
Link Here
|
429 |
categorycode => $cat_borrower, |
430 |
categorycode => $cat_borrower, |
430 |
itemtype => $type, |
431 |
itemtype => $type, |
431 |
branchcode => $branch, |
432 |
branchcode => $branch, |
|
|
433 |
onsite_checkout => $onsite_checkout, |
432 |
rule_name => 'maxissueqty', |
434 |
rule_name => 'maxissueqty', |
433 |
} |
435 |
} |
434 |
); |
436 |
); |
435 |
|
437 |
|
436 |
my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule( |
|
|
437 |
{ |
438 |
categorycode => $cat_borrower, |
439 |
itemtype => $type, |
440 |
branchcode => $branch, |
441 |
rule_name => 'maxonsiteissueqty', |
442 |
} |
443 |
); |
444 |
|
445 |
|
446 |
my $patron = Koha::Patrons->find($borrower->{borrowernumber}); |
438 |
my $patron = Koha::Patrons->find($borrower->{borrowernumber}); |
447 |
# if a rule is found and has a loan limit set, count |
439 |
# if a rule is found and has a loan limit set, count |
448 |
# how many loans the patron already has that meet that |
440 |
# how many loans the patron already has that meet that |
Lines 478-483
sub TooMany {
Link Here
|
478 |
branchcode => $maxissueqty_rule->branchcode, |
470 |
branchcode => $maxissueqty_rule->branchcode, |
479 |
categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ], |
471 |
categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ], |
480 |
itemtype => { '!=' => undef }, |
472 |
itemtype => { '!=' => undef }, |
|
|
473 |
onsite_checkout => $onsite_checkout, |
481 |
rule_name => 'maxissueqty' |
474 |
rule_name => 'maxissueqty' |
482 |
} |
475 |
} |
483 |
)->get_column('itemtype'); |
476 |
)->get_column('itemtype'); |
Lines 513-519
sub TooMany {
Link Here
|
513 |
onsite_checkout_count => $onsite_checkout_count, |
506 |
onsite_checkout_count => $onsite_checkout_count, |
514 |
onsite_checkout => $onsite_checkout, |
507 |
onsite_checkout => $onsite_checkout, |
515 |
max_checkouts_allowed => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef, |
508 |
max_checkouts_allowed => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef, |
516 |
max_onsite_checkouts_allowed => $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef, |
|
|
517 |
switch_onsite_checkout => $switch_onsite_checkout, |
509 |
switch_onsite_checkout => $switch_onsite_checkout, |
518 |
}; |
510 |
}; |
519 |
# If parent rules exists |
511 |
# If parent rules exists |
Lines 536-542
sub TooMany {
Link Here
|
536 |
} |
528 |
} |
537 |
|
529 |
|
538 |
# Now count total loans against the limit for the branch |
530 |
# Now count total loans against the limit for the branch |
539 |
my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower); |
531 |
my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower, $onsite_checkout ); |
540 |
if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') { |
532 |
if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') { |
541 |
my $checkouts; |
533 |
my $checkouts; |
542 |
if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { |
534 |
if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { |
Lines 553-559
sub TooMany {
Link Here
|
553 |
my $checkout_count = $checkouts->count; |
545 |
my $checkout_count = $checkouts->count; |
554 |
my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count; |
546 |
my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count; |
555 |
my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty}; |
547 |
my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty}; |
556 |
my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty} || undef; |
|
|
557 |
|
548 |
|
558 |
my $qty_over = _check_max_qty( |
549 |
my $qty_over = _check_max_qty( |
559 |
{ |
550 |
{ |
Lines 561-567
sub TooMany {
Link Here
|
561 |
onsite_checkout_count => $onsite_checkout_count, |
552 |
onsite_checkout_count => $onsite_checkout_count, |
562 |
onsite_checkout => $onsite_checkout, |
553 |
onsite_checkout => $onsite_checkout, |
563 |
max_checkouts_allowed => $max_checkouts_allowed, |
554 |
max_checkouts_allowed => $max_checkouts_allowed, |
564 |
max_onsite_checkouts_allowed => $max_onsite_checkouts_allowed, |
|
|
565 |
switch_onsite_checkout => $switch_onsite_checkout |
555 |
switch_onsite_checkout => $switch_onsite_checkout |
566 |
} |
556 |
} |
567 |
); |
557 |
); |
Lines 582-597
sub _check_max_qty {
Link Here
|
582 |
my $onsite_checkout_count = $params->{onsite_checkout_count}; |
572 |
my $onsite_checkout_count = $params->{onsite_checkout_count}; |
583 |
my $onsite_checkout = $params->{onsite_checkout}; |
573 |
my $onsite_checkout = $params->{onsite_checkout}; |
584 |
my $max_checkouts_allowed = $params->{max_checkouts_allowed}; |
574 |
my $max_checkouts_allowed = $params->{max_checkouts_allowed}; |
585 |
my $max_onsite_checkouts_allowed = $params->{max_onsite_checkouts_allowed}; |
|
|
586 |
my $switch_onsite_checkout = $params->{switch_onsite_checkout}; |
575 |
my $switch_onsite_checkout = $params->{switch_onsite_checkout}; |
587 |
|
576 |
|
588 |
if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) { |
577 |
if ( $onsite_checkout and defined $max_checkouts_allowed ) { |
589 |
if ( $max_onsite_checkouts_allowed eq '' ) { return; } |
578 |
if ( $max_checkouts_allowed eq '' ) { return; } |
590 |
if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) { |
579 |
if ( $onsite_checkout_count >= $max_checkouts_allowed ) { |
591 |
return { |
580 |
return { |
592 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
581 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
593 |
count => $onsite_checkout_count, |
582 |
count => $onsite_checkout_count, |
594 |
max_allowed => $max_onsite_checkouts_allowed, |
583 |
max_allowed => $max_checkouts_allowed, |
595 |
}; |
584 |
}; |
596 |
} |
585 |
} |
597 |
} |
586 |
} |
Lines 1731-1761
sub GetHardDueDate {
Link Here
|
1731 |
|
1720 |
|
1732 |
=head2 GetBranchBorrowerCircRule |
1721 |
=head2 GetBranchBorrowerCircRule |
1733 |
|
1722 |
|
1734 |
my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode); |
1723 |
my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode, $onsite_checkout); |
1735 |
|
1724 |
|
1736 |
Retrieves circulation rule attributes that apply to the given |
1725 |
Retrieves circulation rule attributes that apply to the given |
1737 |
branch and patron category, regardless of item type. |
1726 |
branch, patron category and checkout type, regardless of item type. |
1738 |
The return value is a hashref containing the following key: |
1727 |
The return value is a hashref containing the following key: |
1739 |
|
1728 |
|
1740 |
patron_maxissueqty - maximum number of loans that a |
1729 |
patron_maxissueqty - maximum number of loans that a |
1741 |
patron of the given category can have at the given |
1730 |
patron of the given category can have at the given |
1742 |
branch. If the value is undef, no limit. |
1731 |
branch. If the value is undef, no limit. |
1743 |
|
1732 |
|
1744 |
patron_maxonsiteissueqty - maximum of on-site checkouts that a |
1733 |
The order in which rules are searched is defined in |
1745 |
patron of the given category can have at the given |
1734 |
C<Koha::CirculationRules->get_effective_rule()> |
1746 |
branch. If the value is undef, no limit. |
|
|
1747 |
|
1748 |
This will check for different branch/category combinations in the following order: |
1749 |
branch and category |
1750 |
branch only |
1751 |
category only |
1752 |
default branch and category |
1753 |
|
1735 |
|
1754 |
If no rule has been found in the database, it will default to |
1736 |
If no rule has been found in the database, it will default to |
1755 |
the buillt in rule: |
1737 |
the buillt in rule: |
1756 |
|
1738 |
|
1757 |
patron_maxissueqty - undef |
1739 |
patron_maxissueqty - undef |
1758 |
patron_maxonsiteissueqty - undef |
|
|
1759 |
|
1740 |
|
1760 |
C<$branchcode> and C<$categorycode> should contain the |
1741 |
C<$branchcode> and C<$categorycode> should contain the |
1761 |
literal branch code and patron category code, respectively - no |
1742 |
literal branch code and patron category code, respectively - no |
Lines 1764-1784
wildcards.
Link Here
|
1764 |
=cut |
1745 |
=cut |
1765 |
|
1746 |
|
1766 |
sub GetBranchBorrowerCircRule { |
1747 |
sub GetBranchBorrowerCircRule { |
1767 |
my ( $branchcode, $categorycode ) = @_; |
1748 |
my ( $branchcode, $categorycode, $onsite_checkout ) = @_; |
1768 |
|
1749 |
|
1769 |
# Initialize default values |
1750 |
# Initialize default values |
1770 |
my $rules = { |
1751 |
my $rules = { |
1771 |
patron_maxissueqty => undef, |
1752 |
patron_maxissueqty => undef, |
1772 |
patron_maxonsiteissueqty => undef, |
|
|
1773 |
}; |
1753 |
}; |
1774 |
|
1754 |
|
1775 |
# Search for rules! |
1755 |
# Search for rules! |
1776 |
foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) { |
1756 |
foreach my $rule_name (qw( patron_maxissueqty )) { |
1777 |
my $rule = Koha::CirculationRules->get_effective_rule( |
1757 |
my $rule = Koha::CirculationRules->get_effective_rule( |
1778 |
{ |
1758 |
{ |
1779 |
categorycode => $categorycode, |
1759 |
categorycode => $categorycode, |
1780 |
itemtype => undef, |
1760 |
itemtype => undef, |
1781 |
branchcode => $branchcode, |
1761 |
branchcode => $branchcode, |
|
|
1762 |
onsite_checkout => $onsite_checkout, |
1782 |
rule_name => $rule_name, |
1763 |
rule_name => $rule_name, |
1783 |
} |
1764 |
} |
1784 |
); |
1765 |
); |