Lines 388-394
sub TooMany {
Link Here
|
388 |
my ($type_object, $parent_type, $parent_maxissueqty_rule); |
388 |
my ($type_object, $parent_type, $parent_maxissueqty_rule); |
389 |
$type_object = Koha::ItemTypes->find( $type ); |
389 |
$type_object = Koha::ItemTypes->find( $type ); |
390 |
$parent_type = $type_object->parent_type if $type_object; |
390 |
$parent_type = $type_object->parent_type if $type_object; |
391 |
my $child_types = Koha::ItemTypes->search( parent_type => $type ); |
391 |
my $child_types = Koha::ItemTypes->search({ parent_type => $type }); |
392 |
# Find any children if we are a parent_type; |
392 |
# Find any children if we are a parent_type; |
393 |
|
393 |
|
394 |
# given branch, patron category, and item type, determine |
394 |
# given branch, patron category, and item type, determine |
Lines 403-409
sub TooMany {
Link Here
|
403 |
} |
403 |
} |
404 |
) if $parent_type; |
404 |
) if $parent_type; |
405 |
# If the parent rule is for default type we discount it |
405 |
# If the parent rule is for default type we discount it |
406 |
$parent_maxissueqty_rule = undef if $parent_maxissueqty_rule && $parent_maxissueqty_rule->itemtype eq '*'; |
406 |
$parent_maxissueqty_rule = undef if $parent_maxissueqty_rule && !defined $parent_maxissueqty_rule->itemtype ; |
407 |
|
407 |
|
408 |
my $maxissueqty_rule = Koha::CirculationRules->get_effective_rule( |
408 |
my $maxissueqty_rule = Koha::CirculationRules->get_effective_rule( |
409 |
{ |
409 |
{ |
Lines 449-469
sub TooMany {
Link Here
|
449 |
# matching rule has the default item type, so count only |
449 |
# matching rule has the default item type, so count only |
450 |
# those existing loans that don't fall under a more |
450 |
# those existing loans that don't fall under a more |
451 |
# specific rule |
451 |
# specific rule |
|
|
452 |
my $issuing_itemtypes_query = " SELECT itemtype FROM issuingrules |
453 |
WHERE branchcode = ? |
454 |
AND (categorycode = ? OR categorycode = ?) |
455 |
AND itemtype <> '*' "; |
452 |
if (C4::Context->preference('item-level_itypes')) { |
456 |
if (C4::Context->preference('item-level_itypes')) { |
453 |
$count_query .= " WHERE items.itype NOT IN ( |
457 |
$count_query .= " WHERE items.itype NOT IN ( $issuing_itemtypes_query )"; |
454 |
SELECT itemtype FROM issuingrules |
|
|
455 |
WHERE branchcode = ? |
456 |
AND (categorycode = ? OR categorycode = ?) |
457 |
AND itemtype <> '*' |
458 |
) "; |
459 |
} else { |
458 |
} else { |
460 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
459 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
461 |
WHERE biblioitems.itemtype NOT IN ( |
460 |
WHERE biblioitems.itemtype NOT IN ( $issuing_itemtypes_query )"; |
462 |
SELECT itemtype FROM issuingrules |
|
|
463 |
WHERE branchcode = ? |
464 |
AND (categorycode = ? OR categorycode = ?) |
465 |
AND itemtype <> '*' |
466 |
) "; |
467 |
} |
461 |
} |
468 |
push @bind_params, $maxissueqty_rule->branchcode; |
462 |
push @bind_params, $maxissueqty_rule->branchcode; |
469 |
push @bind_params, $maxissueqty_rule->categorycode; |
463 |
push @bind_params, $maxissueqty_rule->categorycode; |
Lines 473-488
sub TooMany {
Link Here
|
473 |
if ( $parent_maxissueqty_rule ) { |
467 |
if ( $parent_maxissueqty_rule ) { |
474 |
# if we have a parent item type then we count loans of the |
468 |
# if we have a parent item type then we count loans of the |
475 |
# specific item type or its siblings or parent |
469 |
# specific item type or its siblings or parent |
476 |
push @types, $parent_type; |
|
|
477 |
my $children = Koha::ItemTypes->search({ parent_type => $parent_type }); |
470 |
my $children = Koha::ItemTypes->search({ parent_type => $parent_type }); |
478 |
while ( my $child = $children->next ){ |
471 |
@types = $children->get_column('itemtype'); |
479 |
push @types, $child->itemtype; |
472 |
push @types, $parent_type; |
480 |
} |
|
|
481 |
} elsif ( $child_types ) { |
473 |
} elsif ( $child_types ) { |
482 |
# If we are a parent type, we need to count all child types and our own type |
474 |
# If we are a parent type, we need to count all child types and our own type |
483 |
while ( my $child = $child_types->next ){ |
475 |
@types = $child_types->get_column('itemtype'); |
484 |
push @types, $child->itemtype; |
|
|
485 |
} |
486 |
push @types, $type; # And don't forget to count our own types |
476 |
push @types, $type; # And don't forget to count our own types |
487 |
} else { push @types, $type; } # Otherwise only count the specific itemtype |
477 |
} else { push @types, $type; } # Otherwise only count the specific itemtype |
488 |
my $types_param = ( '?,' ) x @types; |
478 |
my $types_param = ( '?,' ) x @types; |