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