View | Details | Raw Unified | Return to bug 17944
Collapse All | Expand All

(-)a/Koha/ItemTypes.pm (+17 lines)
Lines 39-44 Koha::ItemTypes - Koha ItemType Object set class Link Here
39
39
40
=cut
40
=cut
41
41
42
sub check_items_and_biblioitems {
43
    my ($itemtype_code) = @_;
44
45
    my $dbh = C4::Context->dbh;
46
47
    # Check both items and biblioitems
48
    my ($total) = $dbh->selectrow_array( '
49
        SELECT COUNT(*) AS total FROM (
50
        SELECT itemtype AS t FROM biblioitems
51
            UNION ALL
52
           SELECT itype AS t FROM items
53
        ) AS tmp
54
        WHERE tmp.t=?
55
        ', {}, $itemtype_code );
56
    return $total;
57
}
58
42
sub _type {
59
sub _type {
43
    return 'Itemtype';
60
    return 'Itemtype';
44
}
61
}
(-)a/admin/itemtypes.pl (-10 / +1 lines)
Lines 139-153 if ( $op eq 'add_form' ) { Link Here
139
    $op          = 'list';
139
    $op          = 'list';
140
} elsif ( $op eq 'delete_confirm' ) {
140
} elsif ( $op eq 'delete_confirm' ) {
141
141
142
    # Check both items and biblioitems
142
    my $total = Koha::ItemTypes->check_items_and_biblioitems($itemtype_code);
143
    my ($total) = $dbh->selectrow_array( '
144
        SELECT COUNT(*) AS total FROM (
145
            SELECT itemtype AS t FROM biblioitems
146
            UNION ALL
147
            SELECT itype AS t FROM items
148
        ) AS tmp
149
        WHERE tmp.t=?
150
    ', {}, $itemtype_code );
151
143
152
    if ($total) {
144
    if ($total) {
153
        push @messages, { type => 'error', code => 'cannot_be_deleted', total => $total };
145
        push @messages, { type => 'error', code => 'cannot_be_deleted', total => $total };
154
- 

Return to bug 17944