|
Lines 417-422
sub TooMany {
Link Here
|
| 417 |
categorycode => $cat_borrower, |
417 |
categorycode => $cat_borrower, |
| 418 |
itemtype => $parent_type, |
418 |
itemtype => $parent_type, |
| 419 |
branchcode => $branch, |
419 |
branchcode => $branch, |
|
|
420 |
onsite_checkout => $onsite_checkout, |
| 420 |
rule_name => 'maxissueqty', |
421 |
rule_name => 'maxissueqty', |
| 421 |
} |
422 |
} |
| 422 |
) if $parent_type; |
423 |
) if $parent_type; |
|
Lines 428-447
sub TooMany {
Link Here
|
| 428 |
categorycode => $cat_borrower, |
429 |
categorycode => $cat_borrower, |
| 429 |
itemtype => $type, |
430 |
itemtype => $type, |
| 430 |
branchcode => $branch, |
431 |
branchcode => $branch, |
|
|
432 |
onsite_checkout => $onsite_checkout, |
| 431 |
rule_name => 'maxissueqty', |
433 |
rule_name => 'maxissueqty', |
| 432 |
} |
434 |
} |
| 433 |
); |
435 |
); |
| 434 |
|
436 |
|
| 435 |
my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule( |
|
|
| 436 |
{ |
| 437 |
categorycode => $cat_borrower, |
| 438 |
itemtype => $type, |
| 439 |
branchcode => $branch, |
| 440 |
rule_name => 'maxonsiteissueqty', |
| 441 |
} |
| 442 |
); |
| 443 |
|
| 444 |
|
| 445 |
my $patron = Koha::Patrons->find($borrower->{borrowernumber}); |
437 |
my $patron = Koha::Patrons->find($borrower->{borrowernumber}); |
| 446 |
# if a rule is found and has a loan limit set, count |
438 |
# if a rule is found and has a loan limit set, count |
| 447 |
# how many loans the patron already has that meet that |
439 |
# how many loans the patron already has that meet that |
|
Lines 477-482
sub TooMany {
Link Here
|
| 477 |
branchcode => $maxissueqty_rule->branchcode, |
469 |
branchcode => $maxissueqty_rule->branchcode, |
| 478 |
categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ], |
470 |
categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ], |
| 479 |
itemtype => { '!=' => undef }, |
471 |
itemtype => { '!=' => undef }, |
|
|
472 |
onsite_checkout => $onsite_checkout, |
| 480 |
rule_name => 'maxissueqty' |
473 |
rule_name => 'maxissueqty' |
| 481 |
} |
474 |
} |
| 482 |
)->get_column('itemtype'); |
475 |
)->get_column('itemtype'); |
|
Lines 512-518
sub TooMany {
Link Here
|
| 512 |
onsite_checkout_count => $onsite_checkout_count, |
505 |
onsite_checkout_count => $onsite_checkout_count, |
| 513 |
onsite_checkout => $onsite_checkout, |
506 |
onsite_checkout => $onsite_checkout, |
| 514 |
max_checkouts_allowed => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef, |
507 |
max_checkouts_allowed => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef, |
| 515 |
max_onsite_checkouts_allowed => $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef, |
|
|
| 516 |
switch_onsite_checkout => $switch_onsite_checkout, |
508 |
switch_onsite_checkout => $switch_onsite_checkout, |
| 517 |
}; |
509 |
}; |
| 518 |
# If parent rules exists |
510 |
# If parent rules exists |
|
Lines 535-541
sub TooMany {
Link Here
|
| 535 |
} |
527 |
} |
| 536 |
|
528 |
|
| 537 |
# Now count total loans against the limit for the branch |
529 |
# Now count total loans against the limit for the branch |
| 538 |
my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower); |
530 |
my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower, $onsite_checkout ); |
| 539 |
if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') { |
531 |
if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') { |
| 540 |
my $checkouts; |
532 |
my $checkouts; |
| 541 |
if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { |
533 |
if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { |
|
Lines 551-557
sub TooMany {
Link Here
|
| 551 |
my $checkout_count = $checkouts->count; |
543 |
my $checkout_count = $checkouts->count; |
| 552 |
my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count; |
544 |
my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count; |
| 553 |
my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty}; |
545 |
my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty}; |
| 554 |
my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty} || undef; |
|
|
| 555 |
|
546 |
|
| 556 |
my $qty_over = _check_max_qty( |
547 |
my $qty_over = _check_max_qty( |
| 557 |
{ |
548 |
{ |
|
Lines 559-565
sub TooMany {
Link Here
|
| 559 |
onsite_checkout_count => $onsite_checkout_count, |
550 |
onsite_checkout_count => $onsite_checkout_count, |
| 560 |
onsite_checkout => $onsite_checkout, |
551 |
onsite_checkout => $onsite_checkout, |
| 561 |
max_checkouts_allowed => $max_checkouts_allowed, |
552 |
max_checkouts_allowed => $max_checkouts_allowed, |
| 562 |
max_onsite_checkouts_allowed => $max_onsite_checkouts_allowed, |
|
|
| 563 |
switch_onsite_checkout => $switch_onsite_checkout |
553 |
switch_onsite_checkout => $switch_onsite_checkout |
| 564 |
} |
554 |
} |
| 565 |
); |
555 |
); |
|
Lines 580-595
sub _check_max_qty {
Link Here
|
| 580 |
my $onsite_checkout_count = $params->{onsite_checkout_count}; |
570 |
my $onsite_checkout_count = $params->{onsite_checkout_count}; |
| 581 |
my $onsite_checkout = $params->{onsite_checkout}; |
571 |
my $onsite_checkout = $params->{onsite_checkout}; |
| 582 |
my $max_checkouts_allowed = $params->{max_checkouts_allowed}; |
572 |
my $max_checkouts_allowed = $params->{max_checkouts_allowed}; |
| 583 |
my $max_onsite_checkouts_allowed = $params->{max_onsite_checkouts_allowed}; |
|
|
| 584 |
my $switch_onsite_checkout = $params->{switch_onsite_checkout}; |
573 |
my $switch_onsite_checkout = $params->{switch_onsite_checkout}; |
| 585 |
|
574 |
|
| 586 |
if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) { |
575 |
if ( $onsite_checkout and defined $max_checkouts_allowed ) { |
| 587 |
if ( $max_onsite_checkouts_allowed eq '' ) { return; } |
576 |
if ( $max_checkouts_allowed eq '' ) { return; } |
| 588 |
if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) { |
577 |
if ( $onsite_checkout_count >= $max_checkouts_allowed ) { |
| 589 |
return { |
578 |
return { |
| 590 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
579 |
reason => 'TOO_MANY_ONSITE_CHECKOUTS', |
| 591 |
count => $onsite_checkout_count, |
580 |
count => $onsite_checkout_count, |
| 592 |
max_allowed => $max_onsite_checkouts_allowed, |
581 |
max_allowed => $max_checkouts_allowed, |
| 593 |
}; |
582 |
}; |
| 594 |
} |
583 |
} |
| 595 |
} |
584 |
} |
|
Lines 1679-1709
sub GetHardDueDate {
Link Here
|
| 1679 |
|
1668 |
|
| 1680 |
=head2 GetBranchBorrowerCircRule |
1669 |
=head2 GetBranchBorrowerCircRule |
| 1681 |
|
1670 |
|
| 1682 |
my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode); |
1671 |
my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode, $onsite_checkout); |
| 1683 |
|
1672 |
|
| 1684 |
Retrieves circulation rule attributes that apply to the given |
1673 |
Retrieves circulation rule attributes that apply to the given |
| 1685 |
branch and patron category, regardless of item type. |
1674 |
branch, patron category and checkout type, regardless of item type. |
| 1686 |
The return value is a hashref containing the following key: |
1675 |
The return value is a hashref containing the following key: |
| 1687 |
|
1676 |
|
| 1688 |
patron_maxissueqty - maximum number of loans that a |
1677 |
patron_maxissueqty - maximum number of loans that a |
| 1689 |
patron of the given category can have at the given |
1678 |
patron of the given category can have at the given |
| 1690 |
branch. If the value is undef, no limit. |
1679 |
branch. If the value is undef, no limit. |
| 1691 |
|
1680 |
|
| 1692 |
patron_maxonsiteissueqty - maximum of on-site checkouts that a |
1681 |
The order in which rules are searched is defined in |
| 1693 |
patron of the given category can have at the given |
1682 |
C<Koha::CirculationRules->get_effective_rule()> |
| 1694 |
branch. If the value is undef, no limit. |
|
|
| 1695 |
|
| 1696 |
This will check for different branch/category combinations in the following order: |
| 1697 |
branch and category |
| 1698 |
branch only |
| 1699 |
category only |
| 1700 |
default branch and category |
| 1701 |
|
1683 |
|
| 1702 |
If no rule has been found in the database, it will default to |
1684 |
If no rule has been found in the database, it will default to |
| 1703 |
the buillt in rule: |
1685 |
the buillt in rule: |
| 1704 |
|
1686 |
|
| 1705 |
patron_maxissueqty - undef |
1687 |
patron_maxissueqty - undef |
| 1706 |
patron_maxonsiteissueqty - undef |
|
|
| 1707 |
|
1688 |
|
| 1708 |
C<$branchcode> and C<$categorycode> should contain the |
1689 |
C<$branchcode> and C<$categorycode> should contain the |
| 1709 |
literal branch code and patron category code, respectively - no |
1690 |
literal branch code and patron category code, respectively - no |
|
Lines 1712-1732
wildcards.
Link Here
|
| 1712 |
=cut |
1693 |
=cut |
| 1713 |
|
1694 |
|
| 1714 |
sub GetBranchBorrowerCircRule { |
1695 |
sub GetBranchBorrowerCircRule { |
| 1715 |
my ( $branchcode, $categorycode ) = @_; |
1696 |
my ( $branchcode, $categorycode, $onsite_checkout ) = @_; |
| 1716 |
|
1697 |
|
| 1717 |
# Initialize default values |
1698 |
# Initialize default values |
| 1718 |
my $rules = { |
1699 |
my $rules = { |
| 1719 |
patron_maxissueqty => undef, |
1700 |
patron_maxissueqty => undef, |
| 1720 |
patron_maxonsiteissueqty => undef, |
|
|
| 1721 |
}; |
1701 |
}; |
| 1722 |
|
1702 |
|
| 1723 |
# Search for rules! |
1703 |
# Search for rules! |
| 1724 |
foreach my $rule_name (qw( patron_maxissueqty patron_maxonsiteissueqty )) { |
1704 |
foreach my $rule_name (qw( patron_maxissueqty )) { |
| 1725 |
my $rule = Koha::CirculationRules->get_effective_rule( |
1705 |
my $rule = Koha::CirculationRules->get_effective_rule( |
| 1726 |
{ |
1706 |
{ |
| 1727 |
categorycode => $categorycode, |
1707 |
categorycode => $categorycode, |
| 1728 |
itemtype => undef, |
1708 |
itemtype => undef, |
| 1729 |
branchcode => $branchcode, |
1709 |
branchcode => $branchcode, |
|
|
1710 |
onsite_checkout => $onsite_checkout, |
| 1730 |
rule_name => $rule_name, |
1711 |
rule_name => $rule_name, |
| 1731 |
} |
1712 |
} |
| 1732 |
); |
1713 |
); |