|
Lines 32-38
use C4::Context;
Link Here
|
| 32 |
use C4::Auth; |
32 |
use C4::Auth; |
| 33 |
use C4::Output; |
33 |
use C4::Output; |
| 34 |
|
34 |
|
| 35 |
use Koha::ItemTypes; |
35 |
use Koha::ItemType; |
| 36 |
use Koha::Localizations; |
36 |
use Koha::Localizations; |
| 37 |
|
37 |
|
| 38 |
my $input = new CGI; |
38 |
my $input = new CGI; |
|
Lines 140-151
if ( $op eq 'add_form' ) {
Link Here
|
| 140 |
|
140 |
|
| 141 |
} elsif ( $op eq 'delete_confirm' ) { |
141 |
} elsif ( $op eq 'delete_confirm' ) { |
| 142 |
|
142 |
|
| 143 |
my $schema = Koha::Database->new()->schema(); |
143 |
my $overalltotal = Koha::ItemType->get_items_and_biblioitems($itemtype_code); |
| 144 |
my $itemtotal = $schema->resultset('Item')->search({ 'itype' => $itemtype_code})->count; |
|
|
| 145 |
my $bibliototal = $schema->resultset('Biblioitem')->search({ 'itemtype' => $itemtype_code})->count; |
| 146 |
|
| 147 |
my $overalltotal = $itemtotal + $bibliototal; |
| 148 |
|
| 149 |
if ($overalltotal) { |
144 |
if ($overalltotal) { |
| 150 |
push @messages, { type => 'error', code => 'cannot_be_deleted', total => $overalltotal }; |
145 |
push @messages, { type => 'error', code => 'cannot_be_deleted', total => $overalltotal }; |
| 151 |
$op = 'list'; |
146 |
$op = 'list'; |
|
Lines 156-162
if ( $op eq 'add_form' ) {
Link Here
|
| 156 |
|
151 |
|
| 157 |
} elsif ( $op eq 'delete_confirmed' ) { |
152 |
} elsif ( $op eq 'delete_confirmed' ) { |
| 158 |
|
153 |
|
| 159 |
my $itemtype = Koha::ItemTypes->find($itemtype_code); |
154 |
my $itemtype = Koha::ItemType->get_items_and_biblioitems($itemtype_code); |
| 160 |
my $deleted = eval { $itemtype->delete }; |
155 |
my $deleted = eval { $itemtype->delete }; |
| 161 |
if ( $@ or not $deleted ) { |
156 |
if ( $@ or not $deleted ) { |
| 162 |
push @messages, { type => 'error', code => 'error_on_delete' }; |
157 |
push @messages, { type => 'error', code => 'error_on_delete' }; |
| 163 |
- |
|
|