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

(-)a/Koha/ItemTypes.pm (+17 lines)
Lines 62-67 sub search_with_localization { Link Here
62
62
63
=cut
63
=cut
64
64
65
sub check_items_and_biblioitems {
66
    my ($itemtype_code) = @_;
67
68
    my $dbh = C4::Context->dbh;
69
70
    # Check both items and biblioitems
71
    my ($total) = $dbh->selectrow_array( '
72
        SELECT COUNT(*) AS total FROM (
73
        SELECT itemtype AS t FROM biblioitems
74
            UNION ALL
75
           SELECT itype AS t FROM items
76
        ) AS tmp
77
        WHERE tmp.t=?
78
        ', {}, $itemtype_code );
79
    return $total;
80
}
81
65
sub _type {
82
sub _type {
66
    return 'Itemtype';
83
    return 'Itemtype';
67
}
84
}
(-)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