@@ -, +, @@ --- Koha/ItemType.pm | 14 ++++++++++++++ admin/itemtypes.pl | 9 ++------- 2 files changed, 16 insertions(+), 7 deletions(-) --- a/Koha/ItemType.pm +++ a/Koha/ItemType.pm @@ -89,6 +89,20 @@ sub translated_descriptions { } @translated_descriptions ]; } + +=head3 get_items_and_biblioitems + +=cut + +sub get_items_and_biblioitems { + my $itemtype_code = $_[1]; + my $schema = Koha::Database->new()->schema(); + my $itemtotal = $schema->resultset('Item')->search({ 'itype' => $itemtype_code})->count; + my $bibliototal = $schema->resultset('Biblioitem')->search({ 'itemtype' => $itemtype_code})->count; + my $overalltotal = $itemtotal + $bibliototal; + return $overalltotal; +} + =head3 type =cut --- a/admin/itemtypes.pl +++ a/admin/itemtypes.pl @@ -31,8 +31,8 @@ use C4::Koha; use C4::Context; use C4::Auth; use C4::Output; - use Koha::ItemTypes; +use Koha::ItemType; use Koha::Localizations; my $input = new CGI; @@ -140,12 +140,7 @@ if ( $op eq 'add_form' ) { } elsif ( $op eq 'delete_confirm' ) { - my $schema = Koha::Database->new()->schema(); - my $itemtotal = $schema->resultset('Item')->search({ 'itype' => $itemtype_code})->count; - my $bibliototal = $schema->resultset('Biblioitem')->search({ 'itemtype' => $itemtype_code})->count; - - my $overalltotal = $itemtotal + $bibliototal; - + my $overalltotal = Koha::ItemType->get_items_and_biblioitems($itemtype_code); if ($overalltotal) { push @messages, { type => 'error', code => 'cannot_be_deleted', total => $overalltotal }; $op = 'list'; --